Skip to content
Nick Stapleton edited this page Jun 11, 2019 · 33 revisions

Game States

Start Menu

TODO DAVID

Sub Menus

TODO DAVID

Main Game Loop

NOTE: excerpts are not representative of final code, which has boundary checking, error checking, etc.

Death & Respawn

All geo objects have a health variable that gets checked in the update loop. If it's less than 0 than it call the spawner's kill method.

public void Update()
{
    // ...
    if (health <= 0)
    {
        GameObject spawner = GameObject.FindWithTag("Spawner");
        spawner.GetComponent<DotSpawner>().Kill(this.gameObject, lastHitBy);
    }
    // ...
}

AI Spawn

The spawner keeps track of how many AI are alive in a list. If that amount is less than a certain amount it spawns another variable.

void Update()
{
    // ...
    if(Alive.Count < NumDots)
    {
        Spawn();
    }
    // ...
}

Kill Tracking

The geos have a hash table that maps the string of the type of AI they kill to the amount of kills that they have. Each time an AI is kill the geo that last hit it has it's killHistory<string, int> updated.

public void Kill(GameObject dead, GameObject killer = null)
{
    // ...
    IGeo geo = killer.gameObject.GetComponent<DotController>();
    geo.AddKill("Dot");
    // ...
}
Dictionary<string, int> killHistory;

public void AddKill(string name)
{
    // ...
    if (killHistory.ContainsKey(name))
    {
        killHistory[name]++;
    }
    // ...
}

Controllers

The player controller script that handles user input and stuff.

This is a basic AI controller for a Dot object.

The abstact interface that handles all AI logic. More functions should be added here if we ant the AI to do more special things.

This interface controls all behaviour for AI. To make an AI, define it's Action functions and call them successively in Update().

This is the base interface for all geometric objects in the game, ie all AI and the player.

This bad boy is attached to a GameObject, sits there, and waits to be called in DotSpawner.Kill() when an AI dies.

This acts as a programatic spawner for all Projectiles.

This interface handles the spawning for all AI

Each piece of geometry has a weapon, think of player in Call of Duty has a gun.

Location: Scripts/Geos/Shield.cs

Location: Scripts/Terrain/planeCollision.cs

Clone this wiki locally