Пример #1
0
        public HunterZombie(Pause pause) : base(pause)
        {
            Health         = 30;
            MaxHealth      = 30;
            WalkSpeed      = 250;
            AttackDamage   = 15;
            AttackSpeed    = 1000;
            Direction      = Direction.DOWN;
            JumpRange      = 10;
            IsPushable     = true;
            jumpThread     = null;
            ZombieModel    = new HunterZombieModel(GameData.HunterZombieModel);
            ZombiePosition = FindSpawnPosition();
            ZombieState    = new NormalState();
            GameData.AddZombieAtPosition(ZombiePosition, this);
            Thread zombieThread = new Thread(() => LiveTemplateMethod());

            GameData.AddThread(zombieThread);
            this.ZombieThread = zombieThread;
            zombieThread.Start();
        }
Пример #2
0
        public static void InitializeGame()
        {
            Console.Clear();

            IDifficulty difficulty;

            if (GameData.Difficulty == "Hard")
            {
                difficulty = new HardDifficulty();
            }
            else if (GameData.Difficulty == "Medium")
            {
                difficulty = new MediumDifficulty();
            }
            else
            {
                GameData.Difficulty = "Easy";
                difficulty          = new EasyDifficulty();
            }

            IInterfaceBuilder interfaceBuilder;

            if (GameData.InterfaceBuilder == "Mathemathics")
            {
                interfaceBuilder = new MathemathicsInterfaceBuilder();
            }
            else if (GameData.InterfaceBuilder == "Rainbow")
            {
                interfaceBuilder = new RainbowInterfaceBuilder();
            }
            else
            {
                interfaceBuilder = new DefaultInterfaceBuilder();
            }

            GameData.pause = new Pause();

            GameData.GameMechanics = new Mechanics(GameData.pause);

            PlayerStatusTracker playerStatusTracker = new PlayerStatusTracker(GameData.pause);

            GameData.SetGraphics(interfaceBuilder);
            Console.SetCursorPosition(105, 22);
            Console.Write("Difficulty: " + difficulty.ToString());
            Console.CursorVisible = false;

            GameData.gameMap = new char[50, 130];
            for (int i = 0; i < 50; i++)
            {
                for (int j = 0; j < 130; j++)
                {
                    GameData.gameMap[i, j] = ' ';
                }
            }

            GameData.TankZombieModel = new TankZombieModel(new char[4] {
                '¥', '¥', '¥', '¥'
            }, ConsoleColor.Green, GameData.BackgroundColor);
            GameData.NormalZombieModel = new NormalZombieModel(new char[4] {
                '@', '@', '@', '@'
            }, ConsoleColor.Green, GameData.BackgroundColor);
            GameData.HunterZombieModel = new HunterZombieModel(new char[4] {
                'x', 'x', 'x', 'x'
            }, ConsoleColor.Green, GameData.BackgroundColor);
            GameData.HealthPackModel = new HealthPackModel(new char[4] {
                '+', '+', '+', '+'
            }, ConsoleColor.Red, GameData.BackgroundColor);
            GameData.AmmoPackModel = new AmmoPackModel(new char[4] {
                '#', '#', '#', '#'
            }, ConsoleColor.Red, GameData.BackgroundColor);
            GameData.Ak47Model = new AK47Model(new char[4] {
                'A', 'A', 'A', 'A'
            }, ConsoleColor.Red, GameData.BackgroundColor);
            GameData.SniperRifleModel = new SniperRifleModel(new char[4] {
                'S', 'S', 'S', 'S'
            }, ConsoleColor.Red, GameData.BackgroundColor);
            GameData.PistolBulletModel = new PistolBulletModel(new char[4] {
                '.', '.', '.', '.'
            }, ConsoleColor.White, GameData.BackgroundColor);
            GameData.AK47BulletModel = new AK47BulletModel(new char[4] {
                '°', '°', '°', '°'
            }, ConsoleColor.White, GameData.BackgroundColor);
            GameData.SniperRifleBulletModel = new SniperRifleBulletModel(new char[4] {
                '│', '─', '│', '─'
            }, ConsoleColor.White, GameData.BackgroundColor);
            GameData.PlayerModel = new PlayerModel(new char[4] {
                '^', '>', 'v', '<'
            }, ConsoleColor.Green, GameData.BackgroundColor);

            GameData.ZombieAtPosition = new Dictionary <Position, Zombie>();
            GameData.DropAtPosition   = new Dictionary <Position, Drop>();

            GameData.Player = Player.GetPlayer();

            Player.Name        = GameData.PlayerName;
            Player.PlayerModel = new PlayerModel(new char[4] {
                '^', '>', 'v', '<'
            }, ConsoleColor.Green, GameData.BackgroundColor);
            Player.Score     = 0;
            Player.Position  = new Position(65, 25);
            Player.Health    = 100;
            Player.Direction = Direction.DOWN;
            Player.Weapons   = new List <Weapon>()
            {
                new Pistol()
            };
            Player.CurrentWeapon = Player.Weapons.ElementAt(0);
            GameData.DisplayModelAtPosition(Player.Position, Player.Position, Player.PlayerModel, Direction.DOWN, true);

            GameData.ReloadEvent                    = new ManualResetEvent(false);
            GameData.JumpWait                       = new ManualResetEvent(false);
            GameData.PauseGameEvent                 = new ManualResetEvent(false);
            GameData.PlayerHealthStatusEvent        = new ManualResetEvent(false);
            GameData.KeyInfoWaitEvent               = new ManualResetEvent(false);
            GameData.PlayerAmmoStatusEvent          = new ManualResetEvent(false);
            GameData.PlayerCurrentWeaponStatusEvent = new ManualResetEvent(false);
            GameData.PlayerScoreStatusEvent         = new ManualResetEvent(false);

            Player.IsReloaded   = true;
            GameData.threadList = new List <Thread>();

            Thread playerScoreStatusThread         = new Thread(() => playerStatusTracker.TrackPlayerScoreStatus());
            Thread playerCurrentWeaponStatusThread = new Thread(() => playerStatusTracker.TrackPlayerCurrentWeaponStatus());
            Thread playerAmmoStatusThread          = new Thread(() => playerStatusTracker.TrackPlayerAmmoStatus());
            Thread playerHealthStatusThread        = new Thread(() => playerStatusTracker.TrackPlayerHealthStatus());
            Thread reloadWeaponThread = new Thread(() => GameMechanics.ReloadWeapon());
            Thread zombieMaker        = new Thread(() => new ZombieMaker(difficulty, GameData.pause).MakeZombies());
            Thread start = new Thread(() => GameData.GameMechanics.StartGame());

            GameData.AddThread(playerScoreStatusThread);
            GameData.AddThread(playerCurrentWeaponStatusThread);
            GameData.AddThread(playerAmmoStatusThread);
            GameData.AddThread(playerHealthStatusThread);
            GameData.AddThread(reloadWeaponThread);
            GameData.AddThread(zombieMaker);

            playerScoreStatusThread.Start();
            playerCurrentWeaponStatusThread.Start();
            playerAmmoStatusThread.Start();
            playerHealthStatusThread.Start();
            reloadWeaponThread.Start();
            zombieMaker.Start();
            start.Start();
        }