Exemple #1
0
 public void OnStartedR(Personage uzer, Personage rand)
 {
     if (_startR != null)
     {
         _startR(this, new StartedFinishedRoundEventArgs(uzer, rand));
     }
 }
Exemple #2
0
 public void OnFinishedG(Personage uzer, Personage rand)
 {
     if (_finishG != null)
     {
         _finishG(this, new StartedFinishedGameEventArgs(uzer, rand));
     }
 }
Exemple #3
0
 public StartedFinishedRoundEventArgs(Personage uzer, Personage rand)
 {
     NameUzer = uzer.Name;
     NameRand = rand.Name;
     LiveUzer = uzer.Live;
     LiveRand = rand.Live;
 }
Exemple #4
0
        public static void GetNamePersonageForUser(Personage d)
        {
            Console.WriteLine();
            Console.WriteLine("Введите имя персонажа: ");
            string name = Console.ReadLine();

            d.Name = name;
        }
Exemple #5
0
        private Personage GetRandomPersonage()
        {
            Personage d   = null;
            int       num = rand.Next(1, 3);

            switch (num)
            {
            case 1:
                d = new Human();
                break;

            case 2:
                d = new Beast();
                break;

            case 3:
                d = new Magician();
                break;
            }
            int numW = rand.Next(1, 5);

            switch (numW)
            {
            case 1:
                d.WeaponsPersonage = new SwordAndShield();
                break;

            case 2:
                d.WeaponsPersonage = new StaffAndMantle();
                break;

            case 3:
                d.WeaponsPersonage = new ClawGlovesAndArmor();
                break;

            case 4:
                d.WeaponsPersonage = new BowArrowAndLightShoes();
                break;

            case 5:
                d.WeaponsPersonage = new SledgeHammerAndHelmet();
                break;
            }
            return(d);
        }
Exemple #6
0
        public StartedFinishedGameEventArgs(Personage uzer, Personage rand)
        {
            NameUzer       = uzer.Name;
            NameRand       = rand.Name;
            LiveUzer       = uzer.Live;
            LiveRand       = rand.Live;
            ForceUzer      = uzer.Force;
            ForceRand      = rand.Force;
            ProtectionUzer = uzer.Protection;
            ProtectionRand = rand.Protection;

            NameWUzer       = uzer.WeaponsPersonage.Name;
            NameWRand       = rand.WeaponsPersonage.Name;
            DamageWUzer     = uzer.WeaponsPersonage.Damage;
            DamageWRand     = rand.WeaponsPersonage.Damage;
            ProtectionWUzer = uzer.WeaponsPersonage.Protection;
            ProtectionWRand = rand.WeaponsPersonage.Protection;
        }
Exemple #7
0
        static void Main(string[] args)
        {
            Personage user = null;

            while (user == null)
            {
                try
                {
                    user = UI.GetPersonageForUser();
                }
                catch (InputUserPersonageException ex)
                {
                    Console.WriteLine("{0} {1}", ex.CreatedDate, ex.Message);
                }
            }

            UI.GetNamePersonageForUser(user);

            while (user.WeaponsPersonage == null)
            {
                try
                {
                    user.WeaponsPersonage = UI.GetWeaponsForUser();
                }
                catch (InputUserPersonageException ex)
                {
                    Console.WriteLine("{0} {1}", ex.CreatedDate, ex.Message);
                }
            }

            Console.Clear();

            GameLogic game       = new GameLogic();
            UI        eventsGame = new UI(game);

            game.Duel(user);

            Console.ReadKey();
        }
Exemple #8
0
        /// <summary>
        /// ход игры
        /// </summary>
        /// <param name="userPer">первый игрок</param>
        /// <param name="random">второй игрок</param>
        public void Duel(Personage userPer)
        {
            Personage randomPer = GetRandomPersonage();

            OnStartedG(userPer, randomPer);
            int damageForUzer;
            int damageForRandom;

            do
            {
                OnStartedR(userPer, randomPer);


                damageForUzer   = GetRezultDamage(userPer.GetProtectionValueForStep(), randomPer.GetHitValueForStep());
                damageForRandom = GetRezultDamage(randomPer.GetProtectionValueForStep(), userPer.GetHitValueForStep());
                userPer.SetLiveAfterDamage(damageForUzer);
                randomPer.SetLiveAfterDamage(damageForRandom);

                ToDamage(damageForUzer, damageForRandom);
                System.Threading.Thread.Sleep(1000);
            } while (userPer.Live > 0 && randomPer.Live > 0);
            OnFinishedG(userPer, randomPer);
        }