Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        attack = GetComponent <Attack>();
        hp     = GetComponent <Hp>();


        target = null;
        mode   = TowerMode.DefaultAttack;
    }
Exemplo n.º 2
0
    public void EnemyReached(GameObject gameObject)
    {
        // If already attacking, ignore new enemy
        if (mode == TowerMode.Attack)
        {
            return;
        }

        mode       = TowerMode.Attack;
        target     = gameObject;
        hPBehavior = gameObject.GetComponent <HPBehaviour>();

        arrowAnimation();
        InvokeRepeating("AttackCycle", period, period);
    }
Exemplo n.º 3
0
    void AttackCycle()
    {
        // Enemy is dead
        if (hPBehavior == null)
        {
            CancelInvoke("AttackCycle");
            mode = TowerMode.Watch;

            // Check if we can keep attacking
            var closeEnemy = FindCloseEnemy();
            if (closeEnemy)
            {
                EnemyReached(closeEnemy);
            }
            return;

            // Enemy can be attacked
        }
        else
        {
            hPBehavior.decreaseHP(power);
        }
        arrowAnimation();
    }