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(); } } }
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(); }
/// <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); }
/// <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); }
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); } } }
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; } }
public abstract void SufferAttack(TAttackInfo info);