Ejemplo n.º 1
0
 public void LoadLevel(Enums.Levels levelType)
 {
     if (Levels.Any(x => x.LevelType == levelType))
     {
         var level = Levels.FirstOrDefault(x => x.LevelType == levelType);
         SceneManager.LoadScene(level.LevelID);
     }
     else
     {
         Debug.LogWarning("Level could not be found" + levelType.ToString());
     }
 }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);


            currentLevel = Enums.Levels.One;


            if (currentLevel == Enums.Levels.EasterEgg)
            {
                for (int i = 0; i < minotaurs.Length; i++)
                {
                    minotaurs[i].Speed = new Vector2(0, 0);
                }
            }
            minotaurs = new Minotaur[5];
            for (int i = 0; i < minotaurs.Length; i++)
            {
                Color tint = new Color(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));

                minotaurs[i] = new Minotaur(Content.Load <Texture2D>("MinotaurSpriteShet"),
                                            new Vector2(550 + offset, 410 + offset), tint, 1f, TimeSpan.FromMilliseconds(100), SpriteEffects.None, 0, 22);
                minotaurs[i].Speed     = new Vector2(10, 10);
                minotaurs[i].direction = Enums.Direction.Left;
            }



            pacboy = new Pacman(Content.Load <Texture2D>("PacManSpriteSheet"), Content.Load <Texture2D>("labbyField"),
                                new Vector2(250 + offset, 350 + offset), Color.White, 0.56f, frames, TimeSpan.FromMilliseconds(100), SpriteEffects.None, 0, 22);
            pacboy.fog = false;

            wall       = new Sprite(Content.Load <Texture2D>("MossyStone"), new Vector2(0, 0), Color.White, 1f);
            inviswall  = new Sprite(Content.Load <Texture2D>("MossyStone"), new Vector2(0, 0), Color.Black, 1f);
            EscapeTile = new Minotaur(Content.Load <Texture2D>("ESCAPEROOPEE"), new Vector2(540 + offset, 505 + offset), Color.White, 1f, TimeSpan.FromMilliseconds(100), SpriteEffects.None, 0, 0);
            addLevels();

            for (int i = 0; i < 18; i++)
            {
                for (int k = 0; k < 18; k++)
                {
                    if (levels[currentLevel][k, i] == 1)
                    {
                        obstacleGrid[i, k] = new Tile(i * 50, k * 50, wall);
                    }
                    else if (levels[currentLevel][k, i] == 2)
                    {
                        obstacleGrid[i, k] = new MinotaurCheckTile(i * 50, k * 50, inviswall);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            ks = Keyboard.GetState();
            pacboy.Update(gameTime, ks, blockPosX, blockPosY, GraphicsDevice.Viewport);
            for (int i = 0; i < minotaurs.Length; i++)
            {
                minotaurs[i].Update(gameTime, ks, GraphicsDevice.Viewport);
            }

            if (EscapeTile.Hitbox.Intersects(pacboy.Hitbox) && currentLevel == Enums.Levels.One)
            {
                currentLevel = Enums.Levels.Two;
            }

            for (int i = 0; i < minotaurs.Length; i++)
            {
                if (minotaurs[i].Hitbox.Intersects(pacboy.Hitbox))
                {
                    Exit();
                }
            }


            if (EscapeTile.Hitbox.Intersects(pacboy.Hitbox))
            {
                Exit();
            }



            for (int i = 0; i < minotaurs.Length; i++)
            {
                if (minotaurs[i].direction == Enums.Direction.Right)
                {
                    if (minotaurs[i].Speed.X != 0)
                    {
                        minotaurs[i].Speed = new Vector2(Math.Abs(minotaurs[i].Speed.X), 0);
                    }
                }
                else if (minotaurs[i].direction == Enums.Direction.Left)
                {
                    if (minotaurs[i].Speed.X != 0)
                    {
                        minotaurs[i].Speed = new Vector2(-Math.Abs(minotaurs[i].Speed.X), 0);
                    }
                }
                else if (minotaurs[i].direction == Enums.Direction.Down)
                {
                    if (minotaurs[i].Speed.Y != 0)
                    {
                        minotaurs[i].Speed = new Vector2(0, Math.Abs(minotaurs[i].Speed.Y));
                    }
                }
                else if (minotaurs[i].direction == Enums.Direction.Up)
                {
                    if (minotaurs[i].Speed.Y != 0)
                    {
                        minotaurs[i].Speed = new Vector2(0, -Math.Abs(minotaurs[i].Speed.Y));
                    }
                }
            }

            foreach (Tile tile in obstacleGrid)
            {
                if (tile == null)
                {
                    continue;
                }
                if (tile.Hitbox().Intersects(pacboy.Hitbox))
                {
                    pacboy.HitWall();
                }

                for (int i = 0; i < minotaurs.Length; i++)
                {
                    if (minotaurs[i].Hitbox.Intersects(tile.Hitbox()))
                    {
                        minotaurs[i].HitWall();
                    }
                }
            }
        }