コード例 #1
0
        public static void LevelOne()
        {
            BattleGroundInitialize();
            Walls             walls     = new Walls(WidthOfBattleGround, HeightOfBattleGround, '#');
            MainHero          Hero      = new MainHero(1, 1, '&');
            List <NPC>        NPC       = new List <NPC>();
            List <MapObjects> MapObject = new List <MapObjects>();

            LogicMethods.AddOfGameName(ref MapObject);
            NPC.Add(new Zombie(10, 10, '@'));
            NPC.Add(new Zombie(6, 11, '@'));
            NPC.Add(new Zombie(12, 18, '@'));
            NPC.Add(new Zombie(14, 5, '@'));
            NPC.Add(new Zombie(6, 8, '@'));
            NPC.Add(new Zombie(20, 20, '@'));
            NPC.Add(new Necromant(15, 15, 'N'));

            MapObject.Add(new Keys(22, 1, 'K'));
            MapObject.Add(new Keys(15, 8, 'K'));
            MapObject.Add(new Keys(1, 24, 'K'));

            MapObject.Add(new Column(1, 10, 'O'));
            MapObject.Add(new Column(1, 11, 'O'));
            MapObject.Add(new Column(2, 10, 'O'));
            MapObject.Add(new Column(1, 11, 'O'));

            MapObject.Add(new Column(20, 18, 'O'));
            MapObject.Add(new Column(18, 1, 'O'));
            MapObject.Add(new Column(13, 13, 'O'));



            GameLaunch(walls, Hero, NPC, MapObject);
        }
コード例 #2
0
        public override Point GetNextPoint(List <MapObjects> list)
        {
            Point p = new Point(GetMove().x, GetMove().y, GetMove().ch);

            switch (direction)
            {
            case Direction.LEFT:
                p.x -= step;
                if (p.x == 0)
                {
                    p.x = 1;
                }
                if (LogicMethods.IsHitColumns(p, list))
                {
                    p.x += step;
                }
                break;

            case Direction.RIGHT:
                p.x += step;
                if (p.x == Game.WidthOfBattleGround - 1)
                {
                    p.x = Game.WidthOfBattleGround - 2;
                }
                if (LogicMethods.IsHitColumns(p, list))
                {
                    p.x -= step;
                }
                break;

            case Direction.UP:
                p.y -= step;
                if (p.y == 0)
                {
                    p.y = 1;
                }
                if (LogicMethods.IsHitColumns(p, list))
                {
                    p.y += step;
                }
                break;

            case Direction.DOWN:
                p.y += step;
                if (p.y == Game.HeightOfBattleGround)
                {
                    p.y = Game.HeightOfBattleGround - 1;
                }
                if (LogicMethods.IsHitColumns(p, list))
                {
                    p.y -= step;
                }
                break;
            }
            return(p);
        }
コード例 #3
0
        public static int GameLaunch(Walls walls, MainHero Hero, List <NPC> NPC, List <MapObjects> MapObject)
        {
            int timer = 0;
            int i     = 1;
            int keys  = 0;

            while (true)
            {
                timer++;
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    Hero.Rotation(key.Key);
                    {
                        Hero.Move(MapObject);
                        if (LogicMethods.IsHitListZombies(Hero.body, NPC))
                        {
                            Lose(); return(0);
                        }
                        if (LogicMethods.IsHitKeys(Hero.body, MapObject))
                        {
                            keys++;
                            if (keys == 3)
                            {
                                Win();
                                break;
                            }
                        }
                    }
                }
                if (LogicMethods.IsHitListZombies(Hero.body, NPC))
                {
                    Lose(); return(0);
                }
                if (timer == 20000)
                {
                    foreach (NPC z in NPC)
                    {
                        z.Rotation((DateTime.Now.Millisecond));
                        z.Move(MapObject);
                        Thread.Sleep(1);
                        if (LogicMethods.IsHit(z.body, Hero.body))
                        {
                            Lose(); return(0);
                        }
                    }
                    timer = 0;
                    i++;
                    if (i == 10)
                    {
                        int countOfSpawnedZombie = 0;
                        foreach (NPC N in NPC)
                        {
                            if (N.NPCType == TypesOfNPC.Necromant)
                            {
                                countOfSpawnedZombie++;
                            }
                        }
                        while (countOfSpawnedZombie > 0)
                        {
                            Necromant.SpawnZombie(NPC, 15, 15);
                            countOfSpawnedZombie--;
                        }
                        i = 0;
                    }
                }
            }
            return(0);
        }