public bool SubtractBonusFromUnit(BattleBonus BB) { int chkInd = -1; int minVol = 0; for (int i = 0; i < bu.getFullBonuses.Count; ++i) { if (bu.getFullBonuses[i].unitBonus == BB) { chkInd = i; break; } } if (chkInd == -1) { return(false); } minVol = currBonuses[chkInd].currnetCount - 1; if (minVol > 0) { myBonuse mb = new myBonuse(); mb.unitBonus = BB; mb.currnetCount = minVol; currBonuses[chkInd] = mb; } else { currBonuses.RemoveAt(chkInd); } return(true); }
public bool AddBonusToUnit(BattleBonus BB, int bonusNum) { // Check if we can add this bonus to unit int chkInd = -1; int maxVol = 0; for (int i = 0; i < bu.getFullBonuses.Count; ++i) { if (bu.getFullBonuses[i].unitBonus == BB) { chkInd = i; maxVol = bu.getFullBonuses[i].bonusMaxCount; break; } } if (chkInd == -1) { return(false); } int ind = -1; for (int i = 0; i < currBonuses.Count; ++i) { if (currBonuses[i].unitBonus == BB) { ind = i; break; } } if (ind != -1) { myBonuse mb = new myBonuse(); mb.unitBonus = BB; mb.currnetCount = Mathf.Max(currBonuses[ind].currnetCount + bonusNum, maxVol); currBonuses[ind] = mb; } else { myBonuse mb = new myBonuse(); mb.unitBonus = BB; mb.currnetCount = Mathf.Max(bonusNum, maxVol);; currBonuses.Add(mb); } return(true); }