Exemple #1
0
        private void LoadPlatformerObjects()
        {
            //Load in some sprites to the world that are not included in the imported Tiled map, but could be in future
            Turbine t  = new Turbine(this, Turbine, new Vector2(544, 768), new Vector2(32, 32), 1.5f, 100);
            Turbine t2 = new Turbine(this, Turbine, new Vector2(512, 768), new Vector2(32, 32), 1.5f, 100);
            Turbine t3 = new Turbine(this, Turbine, new Vector2(480, 768), new Vector2(32, 32), 1.5f, 100);

            Sprites.AddRange(new List <Turbine>()
            {
                t, t2, t3
            });
            Cannon c = new Cannon(this, Cannon, new Vector2(350, 160), new Vector2(48, 32));

            Sprites.Add(c);
            //MissileLauncher ml = new MissileLauncher(this, Cannon, new Vector2(571, 35), new Vector2(32, 32));
            //Sprites.Add(ml);
            Lever l = new Lever(this, SpriteSheet1, new Rectangle(576, 640, 64, 64), new Rectangle(704, 640, 64, 64), new Vector2(300, 176), new Vector2(32, 32), c);

            Sprites.Add(l);
            Box b  = new Box(this, BoxTex, new Vector2(384, 410), 16, new Vector2(0.2f), 0.2f);
            Box b2 = new Box(this, BoxTex, new Vector2(1120, 736), 16, new Vector2(0.2f), 0.2f);
            Box b3 = new Box(this, BoxTex, new Vector2(1056, 192), 16, new Vector2(0.2f), 0.2f);

            Sprites.Add(b);
            Portal p = new Portal(this, SpriteSheet1, new Rectangle(1216, 384, 64, 64), new Vector2(1216, 64), new Vector2(32, 32));

            Sprites.Add(p);
            //Platform pl = new Platform(this, new Vector2(768, 480), new Vector2(32 * 6, 32), 6, SpriteSheet1, new Vector2(900, 480));
            //Sprites.Add(pl);
        }
Exemple #2
0
        public World()
        {
            Console.CursorVisible = false;
            HasWon = false;

            CurrentRoom = new Room();
            Score      += 1000;

            // Players and enemies
            Player1 = new Player('@', new Coordinate(1, 1), ConsoleColor.Green);
            EnemyEntity enemy1 = new EnemyEntity('¶', new Coordinate(8, 17), ConsoleColor.DarkRed, 100);
            EnemyEntity enemy2 = new EnemyEntity('¶', new Coordinate(8, 4), ConsoleColor.DarkCyan, 200);

            // Add the walls of the level
            CurrentRoom.BuildWalls();

            // Draw them to the displaygrid
            CurrentRoom.DrawTraps();
            CurrentRoom.DrawWalls();


            Coin coin1     = new Coin(3, 15, ConsoleColor.Yellow, 'o', 100);
            Coin coin2     = new Coin(2, 6, ConsoleColor.Yellow, 'o', 100);
            Coin coin3     = new Coin(1, 13, ConsoleColor.Yellow, 'o', 100);
            Coin superCoin = new Coin(8, 1, ConsoleColor.Red, 'O', 250);

            Lever lever1 = new Lever(new Coordinate(4, 18), ConsoleColor.Magenta, CurrentRoom.RemoveWall, "Wall5");
            Lever lever3 = new Lever(new Coordinate(4, 1), ConsoleColor.Green, CurrentRoom.RemoveWall, "");
            Lever lever2 = new Lever(new Coordinate(8, 18), ConsoleColor.Green, CurrentRoom.RemoveWall, "Wall9");
            Lever trap1  = new Lever(new Coordinate(1, 10), ConsoleColor.Yellow, CurrentRoom.RemoveTrap, "Spike");

            ItemKey redKey    = new ItemKey(4, 8, ConsoleColor.Red, '¥');
            ItemKey yellowKey = new ItemKey(13, 8, ConsoleColor.Yellow, '¥');

            Door doorRed  = new Door(14, 5, ConsoleColor.Red, redKey);
            Exit doorGold = new Exit(10, 8, ConsoleColor.Yellow, yellowKey);

            do
            {
                Console.CursorLeft = 0;
                Console.CursorTop  = 0;

                // Update the players view range.
                Player1.UpdateVisible();

                // Draw the map and inventory to console.
                CurrentRoom.Draw();
                Player1.DrawInventory();

                // Get user input and move the player and update view range again.
                Player1.Move();
                Player1.UpdateVisible();

                enemy1.Move();
                enemy2.Move();

                // Checks if there are any items that can be picked up.
                Player1.CheckTile();
            } while (Player1.IsAlive && Score >= 0 && !HasWon);

            Console.Clear();
            if (!HasWon)
            {
                Console.WriteLine("Game Over!");
            }
            else
            {
                Console.WriteLine("You won!");
                Console.WriteLine($"Your score was: {Score}");
            }

            System.Threading.Thread.Sleep(1000);
            Console.ReadKey();
        }