Пример #1
0
 /// <summary>
 /// Updates the level state
 /// </summary>
 public void Update()
 {
     if (!timerStarted)
     {
         timeLeft.Reset();
         timeLeft.Start();
         timerStarted = true;
     }
     for (int index = 0; index < ObjectList.Count(); index++)
     {
         GameObject current = ObjectList.ElementAt <GameObject>(index);
         if (current.Dead())
         {
             ObjectList.RemoveAt(index);
             index--;
         }
         else
         {
             current.Update();
         }
     }
     Collision();
     timeLeft.Update();
     if (timeLeft.Ready())
     {
         Avatar.Instance().Kill();
     }
     if (Avatar.Instance().Dead())
     {
         timeLeft.Reset();
         LevelManager.Instance().GameOver();
         LevelManager.Instance().GenerateFirstLevel();
     }
 }
Пример #2
0
        /// <summary>
        /// Draws the current screen
        /// </summary>
        /// <param name="batch">Microsoft Sprite Batch</param>
        public override void Draw(SpriteBatch batch)
        {
            TreasureHunter.graphics.GraphicsDevice.SetRenderTarget(LevelManager.Instance().renderTarget);
            TreasureHunter.graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            LevelManager.Instance().Draw(batch);
        }
Пример #3
0
        /// <summary>
        /// Update the screen state
        /// </summary>
        public override void Update()
        {
            CameraManager.Instance().GetCamera().SetTarget(Avatar.Instance().kinetics.position);
            CameraManager.Instance().GetCamera().Update();

            LevelManager.Instance().Update();
        }
Пример #4
0
        /// <summary>
        /// Update the screen state
        /// </summary>
        public override void Update()
        {
            TreasureHunter.Cam.SetTarget(Avatar.Instance().kinetics.position);
            TreasureHunter.Cam.Update();

            LevelManager.Instance().Update();
        }
Пример #5
0
 /// <summary>
 /// Method for resolving collisions with given Item
 /// </summary>
 /// <param name="Item">Item that has collided with this</param>
 public override void CollisionResolution(GameObject Item)
 {
     if (Item.GetType() == typeof(Avatar))
     {
         dead = true;
         LevelManager.Instance().GenerateNextLevel();
     }
 }
Пример #6
0
 public void Draw(SpriteBatch batch, ref RenderTarget2D renderTarget)
 {
     TreasureHunter.graphics.GraphicsDevice.SetRenderTarget(renderTarget);
     graphics.Clear(Color.SteelBlue);
     batch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, CameraManager.Instance().GetCamera().View());
     LevelManager.Instance().getCurrentLevel().Draw(batch);
     batch.End();
     TreasureHunter.graphics.GraphicsDevice.SetRenderTarget(null);
 }
Пример #7
0
        /// <summary>
        /// Loads screen. Called when pushed onto the screen stack
        /// </summary>
        public override void Load()
        {
            LevelManager.Instance();

            LevelManager.Instance().GenerateFirstLevel();
            TreasureHunter.Cam = new Camera(new Vector2(0, 0), new Rectangle(0, 0,
                                                                             LevelManager.Instance().getCurrentLevel().ScaledWidth(),
                                                                             LevelManager.Instance().getCurrentLevel().ScaledHeight()));
        }
Пример #8
0
        /// <summary>
        /// Loads screen. Called when pushed onto the screen stack
        /// </summary>
        public override void Load()
        {
            LevelManager.Instance();

            LevelManager.Instance().GenerateFirstLevel();

            CameraManager.Instance().AddCamera(new Camera(new Vector2(0, 0), new Rectangle(0, 0,
                                                                                           LevelManager.Instance().getCurrentLevel().LevelWidth(),
                                                                                           LevelManager.Instance().getCurrentLevel().LevelHeight())));
        }
Пример #9
0
        /// <summary>
        /// Draws the level to the screen
        /// </summary>
        /// <param name="batch">Microsoft sprite batch</param>
        public void Draw(SpriteBatch batch)
        {
            foreach (GameObject Obj in ObjectList)
            {
                Obj.Draw(batch);
            }


            float minutes = (int)timeLeft.CurrentTime() / 60;
            float seconds = (int)(timeLeft.CurrentTime() % 60);

            Utilities.Instance().DrawString(batch, "Time Left!  " + minutes + ":" + seconds, new Vector2(10, 10));
            Utilities.Instance().DrawString(batch, "Level:      " + LevelManager.Instance().CurrentLevel(), new Vector2(10, 30));
        }
Пример #10
0
        /// <summary>
        /// Updates the level state
        /// </summary>
        public void Update()
        {
            Avatar.Instance().speed = Avatar.Instance().standardSpeed + Avatar.Instance().standardSpeed *(combo / 50.0f);
            Avatar.Instance().speed = MathHelper.Clamp(Avatar.Instance().speed, 0, Avatar.Instance().kinetics.maxSpeed);

            comboTimer.Update();
            if (!timerStarted)
            {
                timeLeft.Reset();
                timeLeft.Start();
                timerStarted = true;
            }
            for (int index = 0; index < UpdateList.Count(); index++)
            {
                GameObject current = UpdateList.ElementAt <GameObject>(index);
                if (current.Dead())
                {
                    UpdateList.RemoveAt(index);
                    index--;
                }
                else
                {
                    current.Update();
                    if (current != Avatar.Instance())
                    {
                        Collision(current, Avatar.Instance());
                    }
                }
            }
            Collision();
            timeLeft.Update();
            if (timeLeft.Ready())
            {
                Avatar.Instance().Kill();
            }
            if (Avatar.Instance().Dead())
            {
                timeLeft.Reset();
                LevelManager.Instance().GameOver();
                LevelManager.Instance().GenerateFirstLevel();
            }
            if (comboTimer.Ready())
            {
                combo = 0;
            }
        }
Пример #11
0
        public void Draw(SpriteBatch batch, ref RenderTarget2D renderTarget, Vector2 ObjectPositionONE, Vector2 ObjectPositionTWO)
        {
            graphics.SetRenderTarget(renderTarget);
            graphics.Clear(Color.Transparent);

            radarShader.CurrentTechnique = radarShader.Techniques["Technique1"];

            graphics.Textures[0] = GraphicsManager.BlankTarget;
            graphics.Textures[1] = radarMap;

            ObjectPositionONE = LevelManager.Instance().getCurrentLevel().NormalizedCoorindates(ObjectPositionONE);
            ObjectPositionTWO = LevelManager.Instance().getCurrentLevel().NormalizedCoorindates(ObjectPositionTWO);

            radarShader.Parameters["AvatarPosition"].SetValue(ObjectPositionONE);
            radarShader.Parameters["TreasurePosition"].SetValue(ObjectPositionTWO);
            radarShader.Parameters["GemColor"].SetValue(new Vector4(LevelManager.Instance().getCurrentLevel().treasure.color.ToVector3(), (float)Math.Sin(radiate)));

            batch.Begin(SpriteSortMode.Immediate, null, null, null, null, radarShader);
            batch.Draw(GraphicsManager.BlankTarget, Vector2.Zero, Color.White);
            batch.End();
            graphics.SetRenderTarget(null);
            graphics.Textures[0] = null;
            graphics.Textures[1] = null;
        }
Пример #12
0
        /// <summary>
        /// Method for resolving collisions with given Item
        /// </summary>
        /// <param name="Item">Item that has collided with this</param>
        public override void CollisionResolution(GameObject Item)
        {
            if (Item.GetType() == typeof(MazeBlock))
            {
                return;
            }
            if (Item.GetType() == typeof(Avatar))
            {
                if (!Walkable)
                {
                    if (Item.kinetics.boundingBox.Bottom >= kinetics.boundingBox.Top && Item.kinetics.boundingBox.Bottom <= kinetics.boundingBox.Top + 5.0f)
                    {
                        float offset = Item.kinetics.boundingBox.Top - Item.kinetics.position.Y;
                        Item.kinetics.position.Y    = kinetics.boundingBox.Top - Item.kinetics.boundingBox.Height - offset;
                        Item.kinetics.boundingBox.Y = (int)(Item.kinetics.position.Y + offset);
                        return;
                    }

                    if (Item.kinetics.boundingBox.Right >= kinetics.boundingBox.Left && Item.kinetics.boundingBox.Right <= kinetics.boundingBox.Left + 5.0f)
                    {
                        Item.kinetics.position.X    = kinetics.boundingBox.Left - Item.kinetics.boundingBox.Width - 29;
                        Item.kinetics.boundingBox.X = (int)(Item.kinetics.position.X + 29);
                        return;
                    }

                    if (Item.kinetics.boundingBox.Left <= kinetics.boundingBox.Right && Item.kinetics.boundingBox.Left >= kinetics.boundingBox.Right - 5.0f)
                    {
                        if (Item.kinetics.boundingBox.Top <= kinetics.boundingBox.Bottom && Item.kinetics.boundingBox.Top >= kinetics.boundingBox.Bottom - 5.0f)
                        {
                            if (Right != null)
                            {
                                if (!Right.Walkable)
                                {
                                    float offset = Item.kinetics.boundingBox.Top - Item.kinetics.position.Y;
                                    Item.kinetics.position.Y    = kinetics.boundingBox.Bottom - offset;
                                    Item.kinetics.boundingBox.Y = (int)(Item.kinetics.position.Y + offset);
                                    Item.kinetics.velocity.Y    = 0;
                                    return;
                                }
                            }
                        }
                        Item.kinetics.position.X    = kinetics.boundingBox.Right - 29;
                        Item.kinetics.boundingBox.X = (int)(Item.kinetics.position.X + 29);
                        return;
                    }

                    if (Item.kinetics.boundingBox.Top <= kinetics.boundingBox.Bottom && Item.kinetics.boundingBox.Top >= kinetics.boundingBox.Bottom - 5.0f)
                    {
                        float offset = Item.kinetics.boundingBox.Top - Item.kinetics.position.Y;
                        Item.kinetics.position.Y    = kinetics.boundingBox.Bottom - offset;
                        Item.kinetics.boundingBox.Y = (int)(Item.kinetics.position.Y + offset);
                        Item.kinetics.velocity.Y    = 0;
                        return;
                    }
                }
                else
                {
                    if (!discovered)
                    {
                        LevelManager.Instance().Discovered();
                        color = Color.White;
                    }
                    discovered = true;
                }
            }
        }
Пример #13
0
 /// <summary>
 /// Draws the current screen
 /// </summary>
 /// <param name="batch">Microsoft Sprite Batch</param>
 public override void Draw(SpriteBatch batch)
 {
     TreasureHunter.graphics.GraphicsDevice.Clear(Color.Transparent);
     LevelManager.Instance().Draw(batch);
 }
Пример #14
0
        /// <summary>
        /// Method for resolving collisions with given Item
        /// </summary>
        /// <param name="Item">Item that has collided with this</param>
        public override void CollisionResolution(GameObject Item)
        {
            if (Item.GetType() == typeof(MazeBlock))
            {
                return;
            }
            if (Item.GetType() == typeof(Avatar))
            {
                if (!Walkable)
                {
                    float margin = (float)Math.Ceiling(Avatar.Instance().speed) + 1;
                    //Down
                    if (Item.kinetics.boundingBox.Bottom >= kinetics.boundingBox.Top && Item.kinetics.boundingBox.Bottom <= kinetics.boundingBox.Top + margin)
                    {
                        if (ControllerInput.Instance().GetKey(Microsoft.Xna.Framework.Input.Keys.Space).Pressed)
                        {
                            MazeBlock target = Down;
                            if (target.Walkable == true)
                            {
                                Item.kinetics.position.X = target.kinetics.position.X + 10;
                                Item.kinetics.position.Y = target.kinetics.position.Y - 25;

                                Item.kinetics.boundingBox.X = (int)target.kinetics.position.X + Item.kinetics.BoundingBoxOffset.X;
                                Item.kinetics.boundingBox.Y = (int)target.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y;
                                Avatar.Instance().Teleported();
                            }
                        }
                        else
                        {
                            float offset = Item.kinetics.boundingBox.Top - Item.kinetics.position.Y;
                            Item.kinetics.position.Y    = kinetics.boundingBox.Top - Item.kinetics.boundingBox.Height - Item.kinetics.BoundingBoxOffset.Y;
                            Item.kinetics.boundingBox.Y = (int)(Item.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y);
                        }
                        return;
                    }

                    //Left
                    if (Item.kinetics.boundingBox.Right >= kinetics.boundingBox.Left && Item.kinetics.boundingBox.Right <= kinetics.boundingBox.Left + margin)
                    {
                        if (ControllerInput.Instance().GetKey(Microsoft.Xna.Framework.Input.Keys.Space).Pressed)
                        {
                            MazeBlock target = Right;
                            if (target.Walkable == true)
                            {
                                Item.kinetics.position.X = target.kinetics.position.X + 10;
                                Item.kinetics.position.Y = target.kinetics.position.Y - 25;

                                Item.kinetics.boundingBox.X = (int)target.kinetics.position.X + Item.kinetics.BoundingBoxOffset.X;
                                Item.kinetics.boundingBox.Y = (int)target.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y;
                                Avatar.Instance().Teleported();
                            }
                        }
                        else
                        {
                            Item.kinetics.position.X    = kinetics.boundingBox.Left - Item.kinetics.boundingBox.Width - Item.kinetics.BoundingBoxOffset.X;
                            Item.kinetics.boundingBox.X = (int)(Item.kinetics.position.X + Item.kinetics.BoundingBoxOffset.X);
                            return;
                        }
                    }

                    if (Item.kinetics.boundingBox.Left <= kinetics.boundingBox.Right && Item.kinetics.boundingBox.Left >= kinetics.boundingBox.Right - margin)
                    {
                        if (Item.kinetics.boundingBox.Top <= kinetics.boundingBox.Bottom && Item.kinetics.boundingBox.Top >= kinetics.boundingBox.Bottom - margin)
                        {
                            if (Right != null)
                            {
                                if (!Right.Walkable)
                                {
                                    if (ControllerInput.Instance().GetKey(Microsoft.Xna.Framework.Input.Keys.Space).Pressed)
                                    {
                                        MazeBlock target = Up;
                                        if (target.Walkable == true)
                                        {
                                            Item.kinetics.position.X = target.kinetics.position.X + 10;
                                            Item.kinetics.position.Y = target.kinetics.position.Y - 25;

                                            Item.kinetics.boundingBox.X = (int)target.kinetics.position.X + Item.kinetics.BoundingBoxOffset.X;
                                            Item.kinetics.boundingBox.Y = (int)target.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y;
                                            Avatar.Instance().Teleported();
                                        }
                                    }
                                    else
                                    {
                                        float offset = Item.kinetics.boundingBox.Top - Item.kinetics.position.Y;
                                        Item.kinetics.position.Y    = kinetics.boundingBox.Bottom - Item.kinetics.BoundingBoxOffset.Y;
                                        Item.kinetics.boundingBox.Y = (int)(Item.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y);
                                        Item.kinetics.velocity.Y    = 0;
                                        return;
                                    }
                                }
                            }
                        }

                        if (ControllerInput.Instance().GetKey(Microsoft.Xna.Framework.Input.Keys.Space).Pressed)
                        {
                            MazeBlock target = Left;
                            if (target.Walkable == true)
                            {
                                Item.kinetics.position.X = target.kinetics.position.X + 10;
                                Item.kinetics.position.Y = target.kinetics.position.Y - 25;

                                Item.kinetics.boundingBox.X = (int)target.kinetics.position.X + Item.kinetics.BoundingBoxOffset.X;
                                Item.kinetics.boundingBox.Y = (int)target.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y;
                                Avatar.Instance().Teleported();
                            }
                        }
                        else
                        {
                            Item.kinetics.position.X    = kinetics.boundingBox.Right - Item.kinetics.BoundingBoxOffset.X;
                            Item.kinetics.boundingBox.X = (int)(Item.kinetics.position.X + Item.kinetics.BoundingBoxOffset.X);
                        }
                        return;
                    }

                    if (Item.kinetics.boundingBox.Top <= kinetics.boundingBox.Bottom && Item.kinetics.boundingBox.Top >= kinetics.boundingBox.Bottom - margin)
                    {
                        if (ControllerInput.Instance().GetKey(Microsoft.Xna.Framework.Input.Keys.Space).Pressed)
                        {
                            MazeBlock target = Up;
                            if (target.Walkable == true)
                            {
                                Item.kinetics.position.X = target.kinetics.position.X + 10;
                                Item.kinetics.position.Y = target.kinetics.position.Y - 25;

                                Item.kinetics.boundingBox.X = (int)target.kinetics.position.X + Item.kinetics.BoundingBoxOffset.X;
                                Item.kinetics.boundingBox.Y = (int)target.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y;
                                Avatar.Instance().Teleported();
                            }
                        }
                        else
                        {
                            float offset = Item.kinetics.boundingBox.Top - Item.kinetics.position.Y;
                            Item.kinetics.position.Y    = kinetics.boundingBox.Bottom - Item.kinetics.BoundingBoxOffset.Y;
                            Item.kinetics.boundingBox.Y = (int)(Item.kinetics.position.Y + Item.kinetics.BoundingBoxOffset.Y);
                            Item.kinetics.velocity.Y    = 0;
                        }
                        return;
                    }
                }
                else
                {
                    if (!discovered)
                    {
                        LevelManager.Instance().Discovered();
                        color = Color.White;
                    }
                    discovered = true;
                }
            }
        }