示例#1
0
 public void follow(Transform t = null)
 {
     if (craft is Drone && (craft as Drone).type == DroneType.Worker)
     {
         (module as TractorAI).Follow(t);
     }
     else
     {
         setMode(AIMode.Follow);
         (module as FollowAI).followTarget = t;
         module.Init();
     }
 }
示例#2
0
    //public static List<Entity> entities = new List<Entity>();

    public void setMode(AIMode mode)
    {
        // Debug.Log("Mode (" + mode + ") set! (try to reduce these, the AI is initialized each time)");
        if (mode == this.mode)
        {
            return;
        }

        this.mode = mode;

        switch (mode)
        {
        case AIMode.Follow:
            module = new FollowAI();
            break;

        case AIMode.Path:
            module = new PathAI();
            break;

        case AIMode.Battle:
            module = new BattleAI();
            break;

        case AIMode.Inactive:
            if (module is TractorAI tractorAI)
            {
                tractorAI.StopFollowing();
                movement.StopMoving();
            }

            module = null;
            break;

        case AIMode.Tractor:
            module = new TractorAI();
            break;

        default:
            break;
        }

        if (module != null)
        {
            module.craft = craft;
            module.owner = owner;
            module.ai    = this;
            module.Init();
        }
    }