Ejemplo n.º 1
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (explosionDone)
        {
            return;
        }

        Target target = other.gameObject.GetComponent <Target> ();

        if (target == null || target.Allegiance == mSource.Allegiance)
        {
            return;
        }

        int damage = (int)WeaponStats.GetStat(WeaponType.IceWand, WeaponStat.Damage);

        if (target is Tower)
        {
            return;
        }

        if (!(target is Unit))
        {
            return;
        }

        // assuming that the target is a Unit

        IceBlock f = other.gameObject.GetComponent <IceBlock> ();

        // do not retarget frozen units
        if (f != null)
        {
            return;
        }

        Unit unit = (Unit)target;

        for (int i = unit.Squad.SquadMembers.Count - 1; i >= 0; --i)
        {
            Unit u = unit.Squad.SquadMembers[i];

            u.gameObject.AddComponent("IceBlock");
            f = u.gameObject.GetComponent <IceBlock> ();
            f.Freeze(u);

            u.Damage(damage);
            if (u.IsDead)
            {
                f.Unfreeze();
            }

            if (u.IsDead && mSource.Allegiance == Allegiance.Rodelle)
            {
                UnitStats.AddToExperience(mSource.UnitType, 1);
            }
        }
    }
Ejemplo n.º 2
0
    private void AssignNewTarget(Unit who)
    {
        if (this.mAllegiance == Allegiance.Rodelle)
        {
            UnitStats.AddToExperience(who.UnitType, 1);
        }

        List <Unit> mEnemies   = mTargetSquad.mSquadMembers;
        int         numEnemies = mEnemies.Count;

        if (numEnemies == 0)
        {
            Disengage();
        }
        else
        {
            who.Engage(mEnemies [Random.Range(0, numEnemies)]);   // engage random enemy
        }
    }