Exemple #1
0
 protected override void DetectionReaction(GameObject[] target)
 {
     foreach (GameObject potentialEnemy in target)
     {
         Destructible enemy = potentialEnemy.GetComponent <Destructible>();
         if (enemy != null)
         {
             if (!enemy.IsDead())
             {
                 // TODO: properly detect if enemy is dead?
                 if (CurrentInstruction == null)
                 {
                     Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                     //Instructions.Push(new Goto(this.transform.position, 0,  this));
                     TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                     break;
                 }
                 else if (CurrentInstruction.GetType() == typeof(Chase))
                 {
                     Instructions.Pop();
                     Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                     TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                     break;
                 }
                 else if (CurrentInstruction.GetType() != typeof(Attack))
                 {
                     Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                     TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                     break;
                 }
             }
         }
     }
 }
Exemple #2
0
    protected override void DetectionReaction(GameObject[] target)
    {
        foreach (GameObject potentialEnemy in target)
        {
            Destructible enemy = potentialEnemy.GetComponent <Destructible>();

            if (enemy != null)
            {
                if (!enemy.IsDead())
                {
                    if (CurrentInstruction == null)
                    {
                        Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                        TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                        break;
                    }
                    else if (CurrentInstruction.GetType() != typeof(Attack))
                    {
                        Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                        TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                        break;
                    }
                }
            }
        }
    }
Exemple #3
0
    public override void TakeDamage(int damage, Vector3 origin = default(Vector3))
    {
        base.TakeDamage(damage);

        if (!IsDead() && origin != default && (CurrentInstruction.GetType() != typeof(Attack) &&
                                               CurrentInstruction.GetType() != typeof(Chase)))
        {
            Instructions.Push(CurrentInstruction);
            if (origin != default)
            {
                CurrentInstruction = new Goto(origin, 2, this);
            }
        }
    }
Exemple #4
0
    protected override void DetectionReaction(GameObject[] target)
    {
        GameObject threat = Array.Find(target, potentialTarget => potentialTarget.GetComponent <Destructible>().CurrentGrowth == (int)Destructible.Sizes.Large);

        if (threat != null && this.SpookLevel != ReportState.Attacking)
        {
            canAttack = false;
            NumberOfSoldiersToSend = largeResponse;
            Instructions.Clear();
            Instructions.Push(new Interact(barracks, this));
            CurrentInstruction = new Goto(barracks.transform.position, 0, this);
            reportPosition     = threat.transform.position;
            return;
        }
        foreach (GameObject potentialEnemy in target)
        {
            Destructible enemy = potentialEnemy.GetComponent <Destructible>();
            if (enemy != null)
            {
                if (!enemy.IsDead())
                {
                    if (CurrentInstruction == null)
                    {
                        // Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                        //Instructions.Push(new Goto(this.transform.position, 0,  this));
                        TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                        break;
                    }
                    else if (CurrentInstruction.GetType() == typeof(Chase))
                    {
                        Instructions.Pop();
                        // Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                        TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                        break;
                    }
                    else if (CurrentInstruction.GetType() != typeof(Attack))
                    {
                        //Debug.Log(enemy + " has a tag " + target[0].gameObject.layer);
                        TargetAcquired(target[0].gameObject.GetComponent <Destructible>());
                        break;
                    }
                }
            }
        }
    }
Exemple #5
0
    protected void Update()
    {
        if (CurrentInstruction != null)
        {
            CurrentInstruction.Execute();
        }
        else
        {
            GetNextInstruction();
        }

        if (CurrentInstruction == null)
        {
            return;
        }
        else if ((CurrentInstruction.GetType() != typeof(Attack) && CurrentInstruction.GetType() != typeof(FixBreaker) && CurrentInstruction.GetType() != typeof(CreateNest) && CurrentInstruction.GetType() != typeof(CreateQueen)) && isWalking == true)
        {
            isWalking = false;
            StartCoroutine(walkingLoop());
        }
    }
Exemple #6
0
    public override void TakeDamage(int damage, Vector3 origin = default(Vector3))
    {
        base.TakeDamage(damage);

        if (!IsDead() && origin != default && (CurrentInstruction.GetType() != typeof(Attack) && CurrentInstruction.GetType() != typeof(Chase)))
        {
            callSmallAliens(origin);
        }
    }
Exemple #7
0
    public override void TakeDamage(int damage, Vector3 origin = default(Vector3))
    {
        base.TakeDamage(damage);

        if (!IsDead() && origin != default && (CurrentInstruction.GetType() != typeof(Attack) && CurrentInstruction.GetType() != typeof(Chase)))
        {
            Instructions.Push(CurrentInstruction);
            if (origin != default)
            {
                CurrentInstruction = new Goto(origin, 2, this);
            }
        }

        if (CurrentHealth < 10)
        {
            canAttack = false;
            Instructions.Clear();
            Instructions.Push(new Interact(barracks, this));
            CurrentInstruction = new Goto(barracks.transform.position, 0, this);
            reportPosition     = origin;
        }
    }