Esempio n. 1
0
    IEnumerator attackTarget()
    {
        bool continueAttack = true;

        while (true)
        {
            if (target)
            {
                List <GenericObject.Model> eatableTypes = new List <GenericObject.Model>();
                eatableTypes.Add(GenericObject.Model.Soft);
                foreach (Booster b in boosters)
                {
                    eatableTypes = eatableTypes.Concat(b.getExtraEatableMaterials()).ToList();
                }

                if (eatableTypes.Contains(target.getModel()))
                {
                    continueAttack = target.attack(termites);
                    setAttackPossibility(true);
                }
                else
                {
                    continueAttack = true;
                    setAttackPossibility(false);
                }
                if (!continueAttack)
                {
                    GenericObject oldTarget = target;
                    target = findNewTarget(target);
                    oldTarget.destroy();
                }
            }
            yield return(new WaitForSeconds(Costants.COLONY_ATTACK_FREQUENCY));
        }
    }
 public void objectDestroyed(GenericObject obj)
 {
     if (targetModels.Contains(obj.getModel()) || targetModels == null)
         destroyed++;
     if (nTargets == destroyed)
         setStatus(Status.Completed);
 }
 public void objectDestroyed(GenericObject obj)
 {
     if (targetModels.Contains(obj.getModel()) || targetModels == null)
     {
         destroyed++;
     }
     if (nTargets == destroyed)
     {
         setStatus(Status.Completed);
     }
 }