Skip to content

IAIBehaviour

Nick Stapleton edited this page Jun 11, 2019 · 3 revisions

IAIBehaviour- AI Behaviour Interface

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

Actions as of v0.1.0
  • Move
  • Shoot
  • Shield

How to make a new behaviour script

Example from ShooterDotBehaviour.cs

Inherit from SimpleDotBehaviour.cs

class ShooterDotBehaviour : SimpleDotBehaviour
{
    // Call base and set the type.
    new void Start()
    {
        base.Start();
        type = "Shooter Dot";
    }

    // Call base which Moves and Checkscore.
    // Then call any functions you define.
    new public void Update()
    {
        base.Update();
        Fire();
    }

    // Define any new functions.
    new public void Fire()
    {
        if (Random.Range(0, 100) <= owner.GetFireChance())
        {
            owner.Shoot();
        }
    }
}

Abstract

Code

namespace DotBehaviour.Command
{
    public interface IAIBehaviour
    {
        // Sets the parent.
        void init(IGeo geo);

        // Updates the parent's stats according to it's kill record.
        void CheckScore();

        // Move Logic for AI.
        void Move();

        // Returns the type of behaviour script.
        string GetType();

        // Shields Logic for AI.
        void Shields();

        // Shooting Logic for AI.
        void Fire();
    }
}