示例#1
0
        public void AddXp(Character character, Beast beast)
        {
            if (beast == null)
            {
                throw new ArgumentNullException("beast");
            }

            if (character.Level - beast.Level > 10)
            {
                return;
            }

            if (character.Level - beast.Level > -10)
            {
                return;
            }

            if (character.Level > beast.Level)
            {
                character.Xp += beast.Xp * Math.Abs(character.Level - beast.Level) / 10;
            }

            if (character.Level < beast.Level)
            {
                character.Xp += beast.Xp * (Math.Abs(character.Level - beast.Level) / 10 + 1);
            }
        }
示例#2
0
文件: Game.cs 项目: Vaysman/Nightmare
        /// <summary>
        /// Бросок костей для монстра, в зависимости от уровня
        /// </summary>
        /// <param name="beast"></param>
        /// <returns></returns>
        public List<int> AiDice(Beast beast)
        {
            var ints = new List<int>();
            var random = new Random();

            var rolls = beast.Level;
            for (var i = 0; i < rolls; i++) {
                ints.Add(random.Next(6) + 1);
            }

            return ints;
        }
示例#3
0
文件: Game.cs 项目: Foile/dev-006
        public void Turn(Character character, Beast beast, List <int> charDices, List <int> beastDices)
        {
            if (CharStrengherThanBeast(character, beast))
            {
                for (var i = 0; i < charAttack.Count; i++)
                {
                    if (charAttack[i].Power > beastAttack[i].Defence)
                    {
                        if (charDices.Count(j => j == 6) >= 1)
                        {
                            beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.4m);
                        }
                        else
                        {
                            if (charDices.Count(j => j == 5) >= 2)
                            {
                                beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.6m);
                            }
                            if (charDices.Count(j => j == 5) >= 1)
                            {
                                beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.8m);
                            }
                        }
                    }

                    if (charAttack[i].Power < beastAttack[i].Defence)
                    {
                        if (charDices.Count(j => j == 6) >= 2)
                        {
                            beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.5m);
                        }
                        else
                        {
                            if (charDices.Count(j => j == 5) < 0)
                            {
                                character.Player.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.8m);
                            }
                            if (charDices.Count(j => j == 5) < 1)
                            {
                                beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.4m);
                            }
                        }
                    }
                }
            }


            if (beast.Life <= 0)
            {
                new ExpierenceService().AddXp(character, beast);
            }
        }
示例#4
0
文件: Game.cs 项目: Foile/dev-006
        public List <int> AiDice(Beast beast)
        {
            var ints   = new List <int>();
            var random = new Random();

            var rolls = beast.Level;

            for (var i = 0; i < rolls; i++)
            {
                ints.Add(random.Next(6) + 1);
            }

            return(ints);
        }
示例#5
0
        /// <summary>
        /// Рассчет количества опыта получаемого за врага. 
        /// опыт начисляется в зависимости от того, какая разница уровней
        /// есть между сражающимися. Если один из них слишком крут, то опыта
        /// не будет.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="beast"></param>
        public void AddXp(Character character, Beast beast)
        {
            if (beast == null) {
                throw new ArgumentNullException("beast");
            }

            if (character.Level - beast.Level > 10) {
                return;
            }

            if (character.Level - beast.Level > -10) {
                return;
            }

            if (character.Level > beast.Level) {
                character.Xp += beast.Xp*Math.Abs(character.Level - beast.Level)/10;
            }

            if (character.Level < beast.Level) {
                character.Xp += beast.Xp*(Math.Abs(character.Level - beast.Level)/10 + 1);
            }
        }
示例#6
0
文件: Game.cs 项目: Foile/dev-006
 private bool CharStrengherThanBeast(Character character, Beast beast)
 {
     return((character.Level > beast.Level) && (charAttack.Count >= beastAttack.Count));
 }
示例#7
0
文件: Game.cs 项目: Foile/dev-006
 public void Fight(Character character, Beast beast)
 {
     charAttack  = character.Attack();
     beastAttack = beast.Attack();
 }
示例#8
0
文件: Game.cs 项目: Vaysman/Nightmare
        /// <summary>
        /// Рассчет одного хода битвы 
        /// В зависимости от того, у кого круче уровень, будет по разному рассчитаны коэффициенты атаки и защиты,
        /// соответственно и урона. 
        /// Далее сравниваются атака и защита борющихся и в зависимости от этого опять же меняются коэффициенты. 
        /// </summary>
        /// <param name="character"></param>
        /// <param name="beast"></param>
        /// <param name="charDices"></param>
        /// <param name="beastDices"></param>
        public void Turn(Character character, Beast beast, List<int> charDices, List<int> beastDices)
        {
            if (character.Level > beast.Level) {
                if (charAttack.Count >= beastAttack.Count) {
                    for (var i = 0; i < charAttack.Count; i++) {
                        if (charAttack[i].Power > beastAttack[i].Defence) {
                            if (charDices.Count(j => j == 6) >= 1) {
                                beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.4m);
                            }
                            else {
                                if (charDices.Count(j => j == 5) >= 2) {
                                    beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.6m);
                                }
                                if (charDices.Count(j => j == 5) >= 1) {
                                    beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.8m);
                                }
                            }
                        }

                        if (charAttack[i].Power < beastAttack[i].Defence) {
                            if (charDices.Count(j => j == 6) >= 2) {
                                beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.5m);
                            }
                            else {
                                if (charDices.Count(j => j == 5) <= 0) {
                                    character.Player.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.8m);
                                }
                                if (charDices.Count(j => j == 5) < 2) {
                                    beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.4m);
                                }
                            }
                        }
                    }
                }
            }

            if (beast.Life <= 0) {
                new ExpierenceService().AddXp(character, beast);
            }
        }
示例#9
0
文件: Game.cs 项目: Vaysman/Nightmare
 /// <summary>
 /// Битва между персонажем и чудовищем
 /// </summary>
 /// <param name="character"></param>
 /// <param name="beast"></param>
 public void Fight(Character character, Beast beast)
 {
     charAttack = character.GetAttacks();
     beastAttack = beast.GetAttacks();
 }