public int GetHit(BodyPart part, FightPapams par)
        {
            int damage;

            if (part != blockedPart)
            {
                damage = CalculateDamage(par.straight);
                hp    -= damage;
                Wound.Invoke(this, part);
            }
            else
            {
                if (Dice.Throw() + (par.agility - agility) > 14)   // chanse of succesfull block is 70% - agility difference
                {
                    damage = CalculateDamage(par.straight);
                    hp    -= damage;
                    Wound.Invoke(this, part);
                }
                else
                {
                    damage = 0;
                    Block.Invoke(this, blockedPart);
                }
            }
            return(damage);
        }
示例#2
0
        public void GetHit(BodyPart bp)
        {
            logger.Debug("Игрока " + Name + " бьют.");
            int ResPoints;

            if (bp != Blocked)
            {
                logger.Info("Блокирование не помогло от удара.");
                if (HP - 10 > 0)
                {
                    if (bp == BodyPart.Head)
                    {
                        logger.Trace("Соперник бъет в голову.");
                        if (HP - 15 > 0)
                        {
                            ResPoints = 15;
                            HP       -= ResPoints;
                            Wound?.Invoke(this, new PlayerEventArgs(String.Format("Player {0} received minus {1} points, wounded {2}", Name, ResPoints, bp), Name, ResPoints, HP));
                            logger.Trace(Name + " получил минус 15 очков.");
                            logger.Trace("Оставшееся здоровье: " + HP);
                        }
                        else
                        {
                            logger.Info(Name + " проиграл.");
                            HP = 0;
                            Death?.Invoke(this, new PlayerEventArgs($"Player {Name} is dead.", Name, HP, HP));
                        }
                    }
                    else
                    {
                        if (bp == BodyPart.Body)
                        {
                            logger.Trace("Соперник бъет в корпус.");
                        }
                        else
                        {
                            logger.Trace("Соперник бъет в ноги.");
                        }
                        ResPoints = 10;
                        HP       -= ResPoints;
                        logger.Trace(Name + " получил минус 10 очков.");
                        logger.Trace("Оставшееся здоровье: " + HP);
                        Wound?.Invoke(this, new PlayerEventArgs(String.Format("Player {0} received minus {1} points, wounded {2}", Name, ResPoints, bp), Name, ResPoints, HP));
                    }
                }

                else
                {
                    logger.Info(Name + " проиграл.");
                    HP = 0;
                    Death?.Invoke(this, new PlayerEventArgs($"Player {Name} is dead.", Name, HP, HP));
                }
            }
            else
            {
                logger.Debug("Повезло! Блокирование спасло от удара.");
                logger.Trace("Оставшееся здоровье: " + HP);
                Block?.Invoke(this, new PlayerEventArgs($"Player {Name} was blocked succsessfully", Name, 0, HP));
            }
        }
        public ComputerAIPresenter(IComputerAIWindow computerAIWindow, IFighter fighter)
        {
            ComputerAIWindow = computerAIWindow;
            Fighter          = fighter;

            #region Подписка на события бойцa
            fighter.Block += (fighterName, hp) => Block?.Invoke(fighterName, hp);
            fighter.Wound += (fighterName, hp) => Wound?.Invoke(fighterName, hp);
            fighter.Death += (fighterName, hp) => Death?.Invoke(fighterName, hp);
            #endregion
        }
示例#4
0
        public FighterPresenter(IFighterWindow fighterWindow, IFighter fighter)
        {
            FighterWindow = fighterWindow;
            Fighter       = fighter;

            #region Подписка на события бойцa
            Fighter.Block += (fighterName, hp) => Block?.Invoke(fighterName, hp);
            Fighter.Wound += (fighterName, hp) => Wound?.Invoke(fighterName, hp);
            Fighter.Death += (fighterName, hp) => Death?.Invoke(fighterName, hp);
            #endregion

            #region Подписка на события страницы
            FighterWindow.Fight  += (sender, e) => Fight?.Invoke(sender, e);
            FighterWindow.Reload += (sender, e) => Reload?.Invoke(sender, e);
            #endregion
        }
示例#5
0
        public void GetHit(BodyParts part)
        {
            if (part != Blocked)
            {
                hp -= power;
                Wound?.Invoke(this, new PlayerEventArgs(Name, hp, power));

                if (hp <= 0)
                {
                    hp = 0;
                    Death?.Invoke(this, new PlayerEventArgs(Name, hp, 0));
                }
            }
            else
            {
                Block?.Invoke(this, new PlayerEventArgs(Name, hp, 0));
            }
        }
示例#6
0
 public void GetHit(BodyParts bodyParts)
 {
     if (bodyParts != Bloked)
     {
         if (HP > 0)
         {
             HP -= 10;
             Wound?.Invoke(this, new FightEventArgs(Name, HP));
         }
         else
         {
             Death?.Invoke(this, new FightEventArgs(Name, HP));
         }
     }
     else
     {
         Block?.Invoke(this, new FightEventArgs(Name, HP));
     }
 }
示例#7
0
        public void GetHit(PartOfTheBody hit)
        {
            if (Blocked == hit)
            {
                Block?.Invoke(FighterName, Hp);
            }
            else
            {
                Hp -= 20;

                if (Hp <= 0)
                {
                    Death?.Invoke(FighterName, 0);
                }
                else
                {
                    Wound?.Invoke(FighterName, Hp);
                }
            }
        }
示例#8
0
 virtual public void getHit(BodyParts attacked, BattleEventArgs e)
 {
     if (attacked == body)
     {
         Block?.Invoke(this, e);
     }
     else
     {
         Hp  -= (int)attacked;
         e.hp = Hp;
         if (Hp > 0)
         {
             Wound?.Invoke(this, e);
         }
         else
         {
             Death?.Invoke(this, e);
         }
     }
 }
示例#9
0
 public void TryBlock(BodyComponents attackedPart, CombatEventArgs e)
 {
     if (!GetHit(attackedPart))
     {
         Block?.Invoke(this, e);
     }
     else
     {
         int damage = e.randomGenerator.Next(2, 20);
         e.currentHP = HP - damage;
         HP          = e.currentHP;
         if (HP > 0)
         {
             Wound?.Invoke(this, e);
         }
         else
         {
             Death?.Invoke(this, e);
         }
     }
 }
示例#10
0
        public void GetHit(BodyPart attackedPart, int damage = 20)
        {
            if (attackedPart != Blocked)
            {
                if (damage < Hp)
                {
                    Hp -= damage;

                    Wound?.Invoke(this, new PlayerEventArgs(Name, Hp, "Received 20 damage"));
                }
                else
                {
                    Hp = 0;
                    Death?.Invoke(this, new PlayerEventArgs(Name, Hp, "Died"));
                }
            }
            else
            {
                Block?.Invoke(this, new PlayerEventArgs(Name, Hp, String.Format("Hit to {0} was blocked", attackedPart)));
            }
        }
示例#11
0
        public void GetHit(BodyParts target)
        {
            if (target == TargetBlock)
            {
                Block?.Invoke(this, new FightEventArgs($"{Name} заблокировал удар.", Name, HP));
            }
            else
            {
                HP -= Dice.Roll("3d6+5");

                if (HP <= 0)
                {
                    HP = 0;
                    Death?.Invoke(this, new FightEventArgs($"Победил {Name}", Name, HP));
                }
                else
                {
                    Wound?.Invoke(this, new FightEventArgs($"{Name} получил ранение. У него осталось всего {HP} HP.", Name, HP));
                }
            }
        }
示例#12
0
 public void OnWound(FightCourseEventArgs args)
 {
     Wound?.Invoke(this, args);
 }
示例#13
0
 private void OnWound()
 {
     Wound?.Invoke(this, new PlayerEventArgs(Name, Id, healthPoints));
 }