Example #1
0
        public static void Reset()
        {
            Logger.DBLog.InfoFormat("Funky Reseting Bot");
            //TownRunManager.townRunItemCache=new TownRunManager.TownRunCache();
            Hero = new ActiveHero();
            Equipment.RefreshEquippedItemsList();
            Backpack.ClearBackpackItemCache();

            Settings.PluginSettings.LoadSettings();
            Targeting  = new TargetingClass();
            Navigation = new Navigation.Navigation();
        }
Example #2
0
        /// <summary>
        /// Restores the activeHero to the starting point to try the level again.
        /// </summary>
        public void StartNewLife()
        {
            if (!activeHero.Equals(Heroes[0]) && Heroes[0].IsAlive)
            {
                Heroes[0].SwapIn();
                activeHero = (Hero)Heroes[0];
            }
            else if (!activeHero.Equals(Heroes[1]) && Heroes[1].IsAlive)
            {
                Heroes[1].SwapIn();
                activeHero = (Hero)Heroes[1];
            }
            else if (!activeHero.Equals(Heroes[2]) && Heroes[2].IsAlive)
            {
                Heroes[2].SwapIn();
                activeHero = (Hero)Heroes[2];
            }
            else
            {
                return;
            }

            ActiveHero.Reset(start);
        }
Example #3
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin(SpriteSortMode.Deferred,
                              BlendState.AlphaBlend,
                              null,
                              null,
                              null,
                              null,
                              Camera.GetViewMatrix(Vector2.One));

            map.Draw(spriteBatch, Camera, drawNavMesh);

            exitSprite.Draw(gameTime, spriteBatch, new Vector2(exit.X, exit.Y), SpriteEffects.None, Color.White);

            //draw each of the enemies in the enemies list
            foreach (Enemy enemy in enemies)
            {
                enemy.Draw(gameTime, spriteBatch);
                ((Gun)enemy.Weapon).DrawBullets(gameTime, spriteBatch);
                if (enemy.IsAlive)
                {
                    //XnaDebugDrawer.DebugDrawer.DrawRectangle(spriteBatch, enemy.BoundingRectangle, Color.Red, 1);
                    spriteBatch.DrawString(Hud.hudFont, enemy.Health.ToString(), new Vector2(enemy.BoundingRectangle.X, enemy.BoundingRectangle.Y - 20), Color.Black);

                    //if (enemy.lineIntersectDistance != null)
                    //{
                    //    Vector2 direction = enemy.Target - enemy.Center;
                    //    direction.Normalize();
                    //    XnaDebugDrawer.DebugDrawer.DrawLineSegment(spriteBatch, enemy.Center,
                    //        new Vector2(enemy.Center.X + direction.X * (float)enemy.lineIntersectDistance, enemy.Center.Y + direction.Y * (float)enemy.lineIntersectDistance), Color.Red, 3);
                    //}

                    //if (enemy.Path != null)
                    //{
                    //    foreach (GraphNode<Platform> gNode in enemy.Path)
                    //    {
                    //        Vector2 center = new Vector2((gNode.Value.RightEdgeX + gNode.Value.LeftEdgeX) / 2, gNode.Value.Y);
                    //        XnaDebugDrawer.DebugDrawer.DrawCircle(spriteBatch, center, 8, Color.Red, 5);

                    //        foreach (GraphNode<Platform> neighbor in gNode.Neighbors)
                    //        {
                    //            Vector2 neighborCenter = new Vector2((neighbor.Value.RightEdgeX + neighbor.Value.LeftEdgeX) / 2, neighbor.Value.Y);
                    //            XnaDebugDrawer.DebugDrawer.DrawCircle(spriteBatch, neighborCenter, 8, Color.Red, 5);
                    //            XnaDebugDrawer.DebugDrawer.DrawLineSegment(spriteBatch, center, neighborCenter, Color.Red, 5);
                    //        }

                    //    }
                    //}
                }
            }


            //draw each consumable in the consumables array
            foreach (Consumable consumable in consumables)
            {
                consumable.Draw(gameTime, spriteBatch);
            }

            //draw the active hero
            ActiveHero.Draw(gameTime, spriteBatch);

            if (ActiveHero is HeroStrength)
            {
                ((Gun)Heroes[1].Weapon).DrawBullets(gameTime, spriteBatch);
                ((Gun)Heroes[2].Weapon).DrawBullets(gameTime, spriteBatch);
            }
            else if (ActiveHero is HeroSpeed)
            {
                ((Gun)Heroes[0].Weapon).DrawBullets(gameTime, spriteBatch);
                ((Gun)Heroes[2].Weapon).DrawBullets(gameTime, spriteBatch);
            }
            else
            {
                ((Gun)Heroes[0].Weapon).DrawBullets(gameTime, spriteBatch);
                ((Gun)Heroes[1].Weapon).DrawBullets(gameTime, spriteBatch);
            }
            //XnaDebugDrawer.DebugDrawer.DrawRectangle(spriteBatch, ActiveHero.BoundingRectangle, Color.Red, 1);

            //Collision.Draw(spriteBatch);
            //if (rayIntersectDistance != null)
            //{
            //    Vector2 direction = playersTarget - ActiveHero.Center;
            //    direction.Normalize();
            //    XnaDebugDrawer.DebugDrawer.DrawLineSegment(spriteBatch, ActiveHero.Center,
            //        new Vector2(ActiveHero.Center.X + direction.X * (float)rayIntersectDistance, ActiveHero.Center.Y + direction.Y * (float)rayIntersectDistance), Color.Red, 3);
            //}


            spriteBatch.End();
        }//end Draw method
Example #4
0
 /// <summary>
 /// Called when the activeHero reaches the level's exit.
 /// </summary>
 private void OnExitReached()
 {
     ActiveHero.OnReachedExit();
     exitReachedSound.Play();
     reachedExit = true;
 }
Example #5
0
 /// <summary>
 /// Called when the activeHero is killed.
 /// </summary>
 /// <param name="killedBy">
 /// The enemy who killed the activeHero. This is null if the activeHero was not killed by an
 /// enemy, such as when a activeHero falls into a hole.
 /// </param>
 private void OnHeroKilled(Enemy killedBy)
 {
     ActiveHero.OnKilled(killedBy);
 }
Example #6
0
 /// <summary>
 /// Called when the activeHero is hit by an enemy.
 /// </summary>
 /// <param name="hitBy">
 /// The enemy who hit the activeHero. This is null if the activeHero was not hit by an
 /// enemy, such as when a activeHero hits or is hit by a hazard.
 /// </param>
 private void OnHeroHit(GameCharacter hitBy)
 {
     ActiveHero.OnHit(hitBy);
 }
Example #7
0
        /// <summary>
        /// Updates all objects in the world, performs collision between them,
        /// and handles the time limit.
        /// </summary>
        public void Update(GameTime gameTime, InputHandler gameInputs)
        {
            //switching characters in the air screws up the physics sometimes
            //This is a work around, but I would like to fix the bug
            if (activeHero.IsOnGround && activeHero.IsAlive)
            {
                SwapHeroes(gameInputs);
            }


            // Pause while the activeHero is dead or time is expired.
            if (!ActiveHero.IsAlive || TimeRemaining == TimeSpan.Zero)
            {
                // Still want to perform physics on the activeHero.
                ActiveHero.PhysicsEngine.ApplyPhysics(gameTime);

                ((Gun)Heroes[0].Weapon).UpdateBullets();
                ((Gun)Heroes[1].Weapon).UpdateBullets();
                ((Gun)Heroes[2].Weapon).UpdateBullets();
            }
            else if (ReachedExit)
            {
                // Animate the time being converted into points.
                int seconds = (int)Math.Round(gameTime.ElapsedGameTime.TotalSeconds * 100.0f);
                seconds        = Math.Min(seconds, (int)Math.Ceiling(TimeRemaining.TotalSeconds));
                timeRemaining -= TimeSpan.FromSeconds(seconds);
            }
            else
            {
                timeRemaining -= gameTime.ElapsedGameTime;
                ActiveHero.Update(gameTime, gameInputs);

                if (ActiveHero is HeroStrength)
                {
                    ((Gun)Heroes[1].Weapon).UpdateBullets();
                    ((Gun)Heroes[2].Weapon).UpdateBullets();
                }
                else if (ActiveHero is HeroSpeed)
                {
                    ((Gun)Heroes[0].Weapon).UpdateBullets();
                    ((Gun)Heroes[2].Weapon).UpdateBullets();
                }
                else
                {
                    ((Gun)Heroes[0].Weapon).UpdateBullets();
                    ((Gun)Heroes[1].Weapon).UpdateBullets();
                }

                UpdateConsumables(gameTime);

                //playersTarget = gameInputs.MouseInput.Position;
                //rayIntersectDistance = Collision.RayCastCollidesWithLevel(ActiveHero.Center, playersTarget);


                if (gameInputs.MouseState.ScrollWheelValue > gameInputs.PreviousMouseState.ScrollWheelValue)
                {
                    Camera.Zoom += 0.1f;
                }
                else if (gameInputs.MouseState.ScrollWheelValue < gameInputs.PreviousMouseState.ScrollWheelValue)
                {
                    Camera.Zoom -= 0.1f;
                }


                //follow the activeHero
                Camera.LookAt(ActiveHero.Position);



                // Falling off the bottom of the level kills the activeHero.
                if (ActiveHero.BoundingRectangle.Top >= Height * map.TileHeight && ActiveHero.IsAlive)
                {
                    OnHeroKilled(null);
                }

                UpdateEnemies(gameTime, gameInputs);


                // The activeHero has reached the exit if they are standing on the ground and
                // his bounding rectangle contains the center of the exit tile. They can only
                // exit when they have collected all of the gems.

                if (ActiveHero.IsAlive &&
                    ActiveHero.IsOnGround &&
                    ActiveHero.BoundingRectangle.Intersects(exitRectangle))
                {
                    OnExitReached();
                }
            }
            // Clamp the time remaining at zero.
            if (timeRemaining < TimeSpan.Zero)
            {
                timeRemaining = TimeSpan.Zero;
            }

            if (gameInputs.KeyboardState.IsKeyDown(Keys.N) && !gameInputs.PreviousKeyboardState.IsKeyDown(Keys.N))
            {
                if (drawNavMesh)
                {
                    drawNavMesh = false;
                }
                else
                {
                    drawNavMesh = true;
                }
            }

            //GOD MODE!!!
            //ActiveHero.Health = ActiveHero.MaxHealth;
        }