示例#1
0
    /// <summary>
    /// Changes the autoattack target.
    /// If atleast one tank is alive that is not currently the target, select one of the not selected tanks randomly as new target.
    /// If only the selected tank is alive, select him again.
    /// If no tank is alive, select one dd randomly, increase damage by 4 times.
    /// </summary>
    private void ChangeTarget()
    {
        targetDict = new List <Raider>(RaiderDB.GetInstance().GetAllTanks());
        int numberTargets = targetDict.Count;

        if (numberTargets <= 0) //no tank is alive, load all raider
        {
            targetDict    = new List <Raider>(RaiderDB.GetInstance().GetAllRaiders());
            numberTargets = targetDict.Count;
            dmg          *= 4;
        }

        if (numberTargets > 1) //more than one target, we can remove the current target and select a new target
        {
            targetDict.Remove(target);
            if (target != null)
            {
                target.SetBossTarget(false);
            }

            target = targetDict.First();
            if (target != null)
            {
                target.SetBossTarget(true);
            }
        }
        else if (numberTargets > 0) //only one target, select it
        {
            if (target != null)
            {
                target.SetBossTarget(false);
            }

            target = targetDict.First();
            if (target != null)
            {
                target.SetBossTarget(true);
            }
        }

        currentTargetTimer = 0f; //reset target and swing timer
        currentSwingTimer  = 0f;
    }
    /// <summary>
    /// Changes the current target, if 2 tanks are alive the other tank is selected, if only one tank is alive he satys the target, if no tank is alive a dd is selected.
    /// </summary>
    private void ChangeTarget()
    {
        List <Raider> targetDict    = new List <Raider>(RaiderDB.GetInstance().GetAllTanks());
        int           numberTargets = targetDict.Count;

        if (numberTargets <= 0)
        {
            targetDict     = new List <Raider>(RaiderDB.GetInstance().GetAllRaiders());
            numberTargets  = targetDict.Count;
            dmgAutoAttack *= 2f;
        }

        if (numberTargets > 1)
        {
            targetDict.Remove(target);
            numberTargets--;
            if (target != null)
            {
                target.SetBossTarget(false);
            }
            target = targetDict.First();
            if (target != null)
            {
                target.SetBossTarget(true);
            }
        }
        else if (numberTargets == 1)
        {
            if (target != null)
            {
                target.SetBossTarget(false);
            }
            target = targetDict.First();
            if (target != null)
            {
                target.SetBossTarget(true);
            }
        }
    }