public virtual void OnHealthChangedEvent() { LOGS.Add(String.Format("{0}'s HP changed", this.NameFull)); if (this.getCurrentHP <= 0) { Die(); } }
public void Die() { for (int i = 0; i < buffs.Count; i++) { buffs[i].Dissaply(); } OnDie(); LOGS.Add(String.Format("{0} died.", NameFull)); _isDead = true; }
public virtual bool SpendManaFor(int x) { if (_mp < x) { return(false); } _mp = _mp - x; LOGS.Add(String.Format("{0} spend {1} mana, {2}/{3} MP left", NameFull, x, getCurrentMP, getMaxMP)); return(true); }
public void LevelUp() { LOGS.Add(String.Format("{0} archieved {1} level", NameFull, Level)); _hp = _hpmax; _mp = _mpmax; _exp_mod = Math.Max(_exp_mod - .25f, 0.0f); // random stat gain // ... }
public virtual void HealFor(int x) { int _hpwas = _hp; _hp = Math.Min(_hpmax, _hp + x); if (_hp != _hpwas) { OnHealthChangedEvent(); LOGS.Add(String.Format("{0} was healed for {1} health up to {2}/{3}", NameFull, _hp - _hpwas, getCurrentHP, getMaxHP)); } }
public virtual void DamageFor(int x) { float defPercent = 1.0f - .01f * (_def + _def_mod); int wasHP = getCurrentHP; int recievedDamage = (int)Math.Max(1.0f, defPercent * x); OnHitRecievedEvent(x); _hp = Math.Max(0, _hp - recievedDamage); LOGS.Add(String.Format("{0} was damaged for {1} (blocked {2}), {5} -> {3}/{4} HP left", NameFull, x, x - recievedDamage, getCurrentHP, getMaxHP, wasHP)); OnHealthChangedEvent(); }
public void Attack(Abstraceunit who) { this.OnAttacking(who); LOGS.Add(String.Format("{0} attacks {1}", this.NameFull, who.NameFull)); who.OnAttacked(this); who.DamageFor(this.CurrentDamage); if (!who.isDead) { who.AfterAttacked(this); } }
public void RecieveExp(int exp) { _expirience += Math.Max(1, (int)(exp * _exp_mod)); LOGS.Add(String.Format("{0} gain {1} exp", NameFull, (int)(exp * _exp_mod))); int _level_prev = _level; _level = Math.Min(5, _expirience / 100 + 1); if (_level != _level_prev) { LevelUp(); } }
public void CalculateMovementForEachCharacter() { List <Point> currentUnitPoses = new List <Point>(); for (int i = 0; i < _units.Count; i++) { currentUnitPoses.Add(_units[i].GetPosition); } SORTUNITS(true); for (int i = 0; i < _units.Count; i++) { Abstraceunit unit = _units[i]; List <Point> unitCanGo = Calculator.deleteListFromList(Calculator.GetOblast(currentUnitPoses[i], unit.GetSpd, false, true), currentUnitPoses.ToArray()); unitCanGo.Add(_units[i].GetPosition); if (unitCanGo.Count == 0) { continue; } List <Prio> unitThinks = unit.CalculateSituation(this); Point decided = Calculator.CalculateMovement(unitCanGo, unitThinks); currentUnitPoses[i] = decided; _units[i].MoveTo(decided); } for (int i = 0; i < _units.Count; i++) { try { // attack for (int att = 0; att < _units[i].CurrentATP; att++) { if (i == _units.Count - 1) { Console.WriteLine(_units[i].NameFull); } Abstraceunit decideAttack = _units[i].CalculateAttack(getEnemyesInObl(_units[i].GetPosition, _units[i].CurrentAttackRange, true, _units[i].getTeamNumber)); if (decideAttack != null) { _units[i].Attack(decideAttack); if (decideAttack.isDead) { _units.Remove(decideAttack); } } } } catch (Exception e) { LOGS.Add("Unit can't do anything - he is dead. (" + e.Message + ")"); } } // end turn for (int i = 0; i < _units.Count; i++) { _units[i].OnTurnEnd(); } Console.Clear(); List <MapPicture> mp = new List <MapPicture>(); for (int i = 0; i < _units.Count; i++) { mp.Add(new MapPicture(_units[i].GetType().Name.ToString()[1], (_units[i].getTeamNumber == 0) ? ConsoleColor.Red : ConsoleColor.Green, _units[i].GetPosition)); } Calculator.TraceBattlefieldToConsole(mp); }
public void addUnit(Abstraceunit newUnit) { _units.Add(newUnit); LOGS.Add(String.Format("{0} joined the battle\t(for team {1})", newUnit.NameFull, newUnit.getTeamNumber)); }
public virtual void AfterAttacked(Iunit bywho) { LOGS.Add(String.Format("{0} was already attacked by {1}", this.NameFull, bywho.NameFull)); }
public virtual void OnDie() { LOGS.Add(String.Format("{0} will die", this.NameFull)); }
public virtual void OnKillUnit(Iunit who) { LOGS.Add(String.Format("{0} fragged {1}", this.NameFull, who.NameFull)); }
public virtual void OnAttacking(Iunit who) { LOGS.Add(String.Format("{0} will attack {1} in a second", this.NameFull, who.NameFull)); }
public virtual void OnHitRecievedEvent(int damage) { LOGS.Add(String.Format("{0} was hited", this.NameFull)); }
public virtual void FillManaFor(int x) { _mp = Math.Min(_mpmax, _mp + x); LOGS.Add(String.Format("{0} refilled mana for {1} up to {2}/{3}", NameFull, x, getCurrentMP, getMaxMP)); }
public void MoveTo(Point where) { LOGS.Add(String.Format("{0} moves ({1},{2}) -> ({3},{4})", NameFull, _pos.X, _pos.Y, where.X, where.Y)); _pos = where; }