예제 #1
0
 public virtual void OnHealthChangedEvent()
 {
     LOGS.Add(String.Format("{0}'s HP changed", this.NameFull));
     if (this.getCurrentHP <= 0)
     {
         Die();
     }
 }
예제 #2
0
 public string TraceBar(bool health)
 {
     if (health)
     {
         return(String.Format("{0}  {1}/{2}", LOGS.TraceBar(_hp + _hp_shield, _hpmax + _hp_shield), _hp + _hp_shield, _hpmax + _hp_shield));
     }
     return(String.Format("{0}  {1}/{2}", LOGS.TraceBar(_mp, _mpmax), _mp, _mpmax));
 }
예제 #3
0
 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);
 }
예제 #4
0
 public void Die()
 {
     for (int i = 0; i < buffs.Count; i++)
     {
         buffs[i].Dissaply();
     }
     OnDie();
     LOGS.Add(String.Format("{0} died.", NameFull));
     _isDead = true;
 }
예제 #5
0
        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
            // ...
        }
예제 #6
0
        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));
            }
        }
예제 #7
0
        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();
        }
예제 #8
0
 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);
     }
 }
예제 #9
0
        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();
            }
        }
예제 #10
0
        public virtual string TraceMoveStats()
        {
            string s = String.Format("\n{0} (lvl.{1})\n{8}\nHP: {15}  {2} / {3}\t +{4}\nMP: {16}  {5} / {6}\t +{7}\nATT: {9}x{10} at range {11}\nMV: {12}\tDEF: {13}\tACC: {14}\n"
                                     , NameFull, Level, StrPlus(_hp, _hp_shield), _hpmax, StrPlus(_hp_regen_per_turn, _hp_regen_mod),
                                     _mp, _mpmax, StrPlus(_mp_regen_per_turn, _mp_regen_mod), description, StrPlus(_atpmax, _atp_mod),
                                     StrPlus(_att_dmg, _att_dmg_mod), _att_dist, StrPlus(_mvpmax, _mvp_mod), StrPlus(_def, _def_mod), (_acc == -1) ? "no"
                 : StrPlus(_acc, _acc_mod), LOGS.TraceBar(_hp + _hp_shield, _hpmax + _hp_shield), LOGS.TraceBar(_mp, _mpmax));

            for (int i = 0; i < buffs.Count; i++)
            {
                s += buffs[i].NameFull + "\n";
            }
            return(s);
        }
예제 #11
0
 public virtual void AfterAttacked(Iunit bywho)
 {
     LOGS.Add(String.Format("{0} was already attacked by {1}", this.NameFull, bywho.NameFull));
 }
예제 #12
0
 public virtual void OnKillUnit(Iunit who)
 {
     LOGS.Add(String.Format("{0} fragged {1}", this.NameFull, who.NameFull));
 }
예제 #13
0
 public virtual void OnDie()
 {
     LOGS.Add(String.Format("{0} will die", this.NameFull));
 }
예제 #14
0
 public virtual void OnAttacking(Iunit who)
 {
     LOGS.Add(String.Format("{0} will attack {1} in a second", this.NameFull, who.NameFull));
 }
예제 #15
0
 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));
 }
예제 #16
0
 public virtual void OnHitRecievedEvent(int damage)
 {
     LOGS.Add(String.Format("{0} was hited", this.NameFull));
 }
예제 #17
0
 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;
 }
예제 #18
0
 public void addUnit(Abstraceunit newUnit)
 {
     _units.Add(newUnit); LOGS.Add(String.Format("{0} joined the battle\t(for team {1})", newUnit.NameFull, newUnit.getTeamNumber));
 }
예제 #19
0
        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);
        }
예제 #20
0
 public virtual string TraceBars()
 {
     return(String.Format("\n  {0}:\n  HP:{1}\n  MP:{2}", NameFull, LOGS.TraceBar(_hp + _hp_shield, _hpmax + _hp_shield), LOGS.TraceBar(_mp, _mpmax)));
 }