Skip to content

Enemy Movement

quocdat402 edited this page Oct 16, 2022 · 3 revisions

Overview

The enemy units roam freely within the city square. Roaming occurs where an enemy unit randomly selects a gridpoint within the city centre and moves towards the selected point. A timer is implemented to change the destination of the enemy unit at random intervals. A MovementTask object is created when a destination has been selected.

GridPoint Selection

    public GridPoint2 randomlySelectTileToMoveTo() {
        int height = this.mapGenerator.getHeight();
        ArrayList<int[]> legalMoves = this.mapGenerator.getLegalCoordinates();
        int size = legalMoves.size();
        int randomSeed = PseudoRandom.seedRandomInt(0, size);
        int[] coords = legalMoves.get(randomSeed);
        return new GridPoint2(coords[1], height - coords[0]);
    }

Timer

A timer is implemented that randomly selects an interval between 5 and 10 seconds. Once the timer has expired, a new grid point is chosen for the enemy unit to go to.

UML Diagram

Table of Contents

Home

Game

Game Home

Design Influences

Gameplay Features

Style

Story

Friendly Units
Map
City
Buildings
Unit Selections

Spell

Game User Testing: Theme of Unit Selection & Spell System

UI User Testing

Tutorial

Resource Stats Display

Loading Screen Bar

Health Bars
In Game menu
  • Feature
  • User Testing:In Game Menu

Landscape Tile Design

Landscape Tile Design Feedback

Weather Design

Weather Design Feedback

Camera Movement

Enemy design

Enemy Units

Enemy AI

How Animation Works

Map Flooding

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally