Beispiel #1
0
    private void attackFromSelf(TAttackInfo info)
    {
        if (currentHealth < MaxHealth)
        {
            if (info.Units < MaxHealth - currentHealth)
            {
                currentHealth += info.Units;
            }
            else
            {
                info.Units   -= MaxHealth - currentHealth;
                currentHealth = MaxHealth;
                attackFromSelf(info);
            }
        }

        else if (currentLevel >= maxLevel)
        {
            currentUnits += info.Units;
        }
        else
        {
            if (info.Units < ExpForNextLevel - CurrentExp)
            {
                currentExp += info.Units;
            }
            else
            {
                info.Units   -= ExpForNextLevel - CurrentExp;
                currentExp    = 0;
                currentUnits += info.Units;
                levelUp();
            }
        }
    }
Beispiel #2
0
 public void AddAttack(TAttackInfo att)
 {
     Debug.Log("Jugador " + att.Player + " añade ataque para planeta " + att.Destiny + " con " + att.Units + " que tardara " + att.remainingTurns);
     GameMutex.WaitOne();
     pendingAttacks.Add(att);
     GameMutex.ReleaseMutex();
 }
Beispiel #3
0
 /// <summary>
 /// Checks if it has enough units and if not, corrects the attack
 ///
 /// </summary>
 /// <param name="info"></param>
 public void UseUnits(TAttackInfo info)
 {
     if (info.Units > currentUnits)
     {
         info.Units = currentUnits;
     }
     currentUnits -= info.Units;
     OLD_M_FlowController.Instance.CurrentGame.AddAttack(info);
 }
Beispiel #4
0
 /// <summary>
 /// Checks if it has enough units and if not, corrects the attack
 ///
 /// </summary>
 /// <param name="info"></param>
 public void UseUnits(TAttackInfo info)
 {
     if (info.Units > currentUnits)
     {
         info.Units = currentUnits;
     }
     currentUnits -= info.Units;
     currentGame.AddAttack(info);
 }
Beispiel #5
0
    public override void SufferAttack(TAttackInfo info)
    {
        //if the planet is neutral
        if (CurrentPlayerOwner == GlobalData.NO_PLAYER)
        {
            //if the contestant is the same player
            if (CurrentContestantId == info.Player)
            {
                //if the planet is conquered
                if (info.Units >= currentHealth)
                {
                    /*if (currentPlayerOwner != GlobalData.NO_PLAYER)
                     *  M_FlowController.Instance.Players[currentPlayerOwner].Planets.Remove(this);*/

                    currentUnits       += info.Units - currentHealth;
                    currentPlayerOwner  = info.Player;
                    currentHealth       = maxHealth;
                    currentContestantId = -1;
                    OLD_M_FlowController.Instance.CurrentGame.Players[currentPlayerOwner].Planets.Add(this);
                }
                else
                {
                    currentHealth -= info.Units;
                }
            }

            else
            {
                //if the contestant is anoher player
                //if the attack surpases the other player attakc, becmoes the contestant (MaxHealth - curretn healt = oponent damage)
                if (info.Units > MaxHealth - currentHealth)
                {
                    info.Units         -= MaxHealth - currentHealth;
                    currentHealth       = MaxHealth;
                    currentContestantId = info.Player;
                    SufferAttack(info);
                }
                else
                {
                    currentHealth += info.Units;
                }
            }
        }

        else
        {
            if (info.Player == currentPlayerOwner)
            {
                attackFromSelf(info);
            }
            else
            {
                attackFromOther(info);
            }
        }
    }
Beispiel #6
0
    private void attackFromOther(TAttackInfo info)
    {
        //if the planet is conquered
        if (info.Units >= CurrentUnits + currentHealth + CurrentExp)
        {
            info.Units   -= CurrentUnits + currentHealth + CurrentExp;
            currentUnits  = 0;
            currentUnits += info.Units;
            OLD_M_FlowController.Instance.CurrentGame.Players[currentPlayerOwner].Planets.Remove(this);
            currentPlayerOwner = info.Player;
            OLD_M_FlowController.Instance.CurrentGame.Players[currentPlayerOwner].Planets.Add(this);
            currentHealth = maxHealth;
            currentExp    = 0;
            levelDown();
        }
        //if its health or exp is reduced
        else if (info.Units > CurrentUnits)
        {
            info.Units  -= CurrentUnits;
            currentUnits = 0;

            if (currentExp > 0)
            {
                if (info.Units > CurrentExp)
                {
                    info.Units -= CurrentExp;
                    currentExp  = 0;
                    attackFromOther(info);
                }
                else
                {
                    currentExp -= info.Units;
                }
            }
            else
            {
                currentHealth -= info.Units;
            }
        }
        else //if no damage to the planet
        {
            currentUnits -= info.Units;
        }
    }
Beispiel #7
0
 public abstract void SufferAttack(TAttackInfo info);