Beispiel #1
0
        //Generates a map based on the rawMap multidimensional array.
        private static string[,] GenerateBoard()
        {
            Wall           wall  = new Wall();
            Floor          floor = new Floor();
            Door           door  = new Door();
            HorisontalDoor hdoor = new HorisontalDoor();
            Exit           exit  = new Exit();

            string[,] rawMap = new string[, ] {
                { wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, wall.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, wall.Tile, floor.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, door.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, wall.Tile, wall.Tile, hdoor.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, exit.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, door.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, floor.Tile, wall.Tile },
                { wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, wall.Tile, },
            };
            return(rawMap);
        }
Beispiel #2
0
        //All types of collision will go here. Returns a bool and uses it in the UpdatePlayerPosition function to see if the move is
        //a valid move or not.
        public static bool Collision(int x, int y)
        {
            Wall           wall  = new Wall();
            Door           door  = new Door();
            Floor          floor = new Floor();
            Exit           exit  = new Exit();
            HorisontalDoor hdoor = new HorisontalDoor();

            bool collision = true;

            if (GameBoard[y, x].Equals(wall.Tile))
            {
                collision = false;
            }
            if (GameBoard[y, x].Equals(door.Tile) && player.GetPlayerKeys() == 0)
            {
                collision = false;
            }
            else if (GameBoard[y, x].Equals(door.Tile))
            {
                player.RemovePlayerKey();
            }
            if (GameBoard[y, x].Equals(hdoor.Tile) && player.GetPlayerKeys() == 0)
            {
                collision = false;
            }
            else if (GameBoard[y, x].Equals(hdoor.Tile))
            {
                player.RemovePlayerKey();
            }

            if (GameBoard[y, x].Equals(monster1.Tile))
            {
                //player.Steps += 20;
                collision = false;
            }
            if (GameBoard[y, x].Equals(exit.Tile))
            {
                EndGame(player);
                GameLoop  = false;
                collision = true;
            }
            return(collision);
        }
Beispiel #3
0
        //Checks the tile of the given coordinate.
        public static bool MonsterCollision(int x, int y)
        {
            Wall           wall          = new Wall();
            Door           door          = new Door();
            HorisontalDoor hdoor         = new HorisontalDoor();
            Key            hiddenKey     = new Key(0, 0);
            Monster        hiddenMonster = new Monster(0, 0);
            Player         player        = new Player();

            if (GameBoard[y, x].Equals(wall.Tile))
            {
                return(false);
            }
            if (GameBoard[y, x].Equals(door.Tile))
            {
                return(false);
            }
            if (GameBoard[y, x].Equals(hdoor.Tile))
            {
                return(false);
            }
            if (GameBoard[y, x].Equals(hiddenKey.Tile))
            {
                return(false);
            }
            if (GameBoard[y, x].Equals(player.Tile))
            {
                return(true);
            }
            if (GameBoard[y, x].Equals(hiddenMonster.Tile))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }