public Boolean attack(Unit attacker_, Unit defender_) { attacker_._canMove = false; if (!isHit(defender_)) { return false; } defender_._currentHealPoint -= attacker_._stats._damage; //xp kiszámítása Int32 xpEarnd=Convert.ToInt32((attacker_._stats._damage + defender_._stats._maxHealPoint) * (1 - 0.7)); attacker_._xp+=xpEarnd; //ha megöli az egységet Int32 nextPalyerIndex = (_currentPlayerIndex + 1) % _players.Length; if(defender_._currentHealPoint <= 0) { _players[nextPalyerIndex]._units.Remove(defender_); //mapról is leszedi, map.removeUnit(defender_); _players[nextPalyerIndex]._income = calculateIncome(_players[nextPalyerIndex]); } _gameOver=isEndGame(_players[nextPalyerIndex]); return true; }
public void buyUnit(UnitType unitType_) { Unit newUnit = new Unit(unitType_, _players[_currentPlayerIndex]._race); //map.placeNewUnit(_players[currentPlayerIndex],newUnit); //beállítja a pozíciót a unitnál-is!!!!! _players[_currentPlayerIndex]._units.Add(newUnit); _players[_currentPlayerIndex]._money -= newUnit._stats._price; }
//private helper functions private Boolean isHit(Unit defender_) { Int32 randomNum = _randomGenerator.Next(1,100); Int32 defPercentage = 0;// lekérni a fieldtől ami a vádő áll map.getDefPercente(defender_) if (randomNum >= defPercentage) { return true; } return false; }
public void heal(Unit source_, Unit target_) { source_._canMove = false; target_._currentHealPoint += source_._stats._healingPoint; if (target_._currentHealPoint > target_._stats._movementPoint) { target_._currentHealPoint = target_._stats._maxHealPoint; } }