예제 #1
0
    public void setTarget(GenericObject target)
    {
        if (this.target)
        {
            this.target.setAttacker(null);
        }
        this.target = target;
        roomNumber  = target.getRoom().getNumber();

        /*if (!this.target.getModel().Equals(GenericObject.Model.Live))
         *  GameManager.getCurrentLevel().alertObjectsQueue.Enqueue(this.target);*/

        Colony col = this.target.getAttacker();

        if (col)
        {
            addTermites(col.getTermites());
            foreach (Booster b in col.getBoosters())
            {
                applyBooster(b.getModel());
            }
            Destroy(col.gameObject);
        }

        this.target.setAttacker(this);
    }
예제 #2
0
    protected IEnumerator attackColony(int atkType)
    {
        while (true)
        {
            if (GameManager.getCurrentLevel().alertObjectsQueue.Count > 0 && !isAttacking)
            {
                isAttacking = true;
                switch (atkType)
                {
                case 1:
                    Debug.Log("Spray attack");
                    break;

                case 2:
                    Debug.Log("Gas attack");
                    break;

                case 3:
                    Debug.Log("Bomb attack");
                    break;

                case 4:
                    Debug.Log("Gun attack");
                    break;

                case 5:
                    Debug.Log("frog eating");
                    break;

                case 6:
                    Debug.Log("it's a spell");
                    break;

                default:
                    Debug.Log("Bug in LiveObject, not an attack");
                    break;
                }
                StopCoroutine(movementCoroutine);//pointer to movementCoroutine goes null
                setMovementCoroutine();
                targetObject = (GenericObject)GameManager.getCurrentLevel().alertObjectsQueue.Dequeue();
                int target             = GameManager.getCurrentLevel().getGraphLiveObjects().findNearestNode(targetObject.getRoom().number, targetObject.gameObject.transform.position);
                List <Graph.Node> path = GameManager.getCurrentLevel().getGraphLiveObjects().getPath(actualNodeNumber, target);
                path.RemoveAt(path.Count - 1);
                movementPath.Clear();
                foreach (Graph.Node n in path)
                {
                    movementPath.Enqueue(n);
                }
                StartCoroutine(movementCoroutine);
            }
            yield return(new WaitForSeconds(Costants.COLONY_ATTACK_FREQUENCY));
        }
    }
예제 #3
0
 protected IEnumerator attackColony(int atkType)
 {
     while (true)
     {
         if (GameManager.getCurrentLevel().alertObjectsQueue.Count > 0 && !isAttacking)
         {
             isAttacking = true;
             switch (atkType)
             {
                 case 1:
                     Debug.Log("Spray attack");
                     break;
                 case 2:
                     Debug.Log("Gas attack");
                     break;
                 case 3:
                     Debug.Log("Bomb attack");
                     break;
                 case 4:
                     Debug.Log("Gun attack");
                     break;
                 case 5:
                     Debug.Log("frog eating");
                     break;
                 case 6:
                     Debug.Log("it's a spell");
                     break;
                 default:
                     Debug.Log("Bug in LiveObject, not an attack");
                     break;
             }
             StopCoroutine(movementCoroutine);//pointer to movementCoroutine goes null
             setMovementCoroutine();
             targetObject = (GenericObject)GameManager.getCurrentLevel().alertObjectsQueue.Dequeue();
             int target = GameManager.getCurrentLevel().getGraphLiveObjects().findNearestNode(targetObject.getRoom().number, targetObject.gameObject.transform.position);
             List<Graph.Node> path = GameManager.getCurrentLevel().getGraphLiveObjects().getPath(actualNodeNumber, target);
             path.RemoveAt(path.Count - 1);
             movementPath.Clear();
             foreach (Graph.Node n in path)
                 movementPath.Enqueue(n);
             StartCoroutine(movementCoroutine);
         }
         yield return new WaitForSeconds(Costants.COLONY_ATTACK_FREQUENCY);
     }
 }
예제 #4
0
    public void setTarget(GenericObject target)
    {
        if (this.target)
            this.target.setAttacker(null);
        this.target = target;
        roomNumber = target.getRoom().getNumber();
        /*if (!this.target.getModel().Equals(GenericObject.Model.Live))
            GameManager.getCurrentLevel().alertObjectsQueue.Enqueue(this.target);*/

        Colony col = this.target.getAttacker();

        if (col)
        {
            addTermites(col.getTermites());
            foreach (Booster b in col.getBoosters())
                applyBooster(b.getModel());
            Destroy(col.gameObject);
        }

        this.target.setAttacker(this);
    }