Esempio n. 1
0
 /// <summary>
 /// Fires a projectile at the target.
 /// </summary>
 public void fire(Texture2D sprite, Vector2 targetPosition)
 {
     if (this.LastFired >= 5.5f)
     {
         ProjectileManager.AddProjectile(this, sprite, targetPosition);
     }
 }
Esempio n. 2
0
 protected void HandleTowerLoop()
 {
     foreach (Tower t in towers.Values)
     {
         t.Update();
         Creep target;
         if (t.CanFire && Calculator.BestShootableCreep(creeps, t.Position, t.GetTowerStats().Range, out target))
         {
             var proj = TowerFactory.GetTowerProjectile(t, target);
             target.DeathForecast += proj.Stats.Damage;
             projectileManager.AddProjectile(proj);
         }
     }
 }
Esempio n. 3
0
        private void HandleMouseInput(GameTime gameTime)
        {
            int x        = newMouseState.X;
            int y        = newMouseState.Y;
            int PressedX = 0;
            int PressedY = 0;

            // Mouse left button has been pressed
            if (newMouseState.LeftButton == ButtonState.Pressed)
            {
                if (oldMouseState.LeftButton != ButtonState.Pressed)
                {
                    PressedX = newMouseState.X;
                    PressedY = newMouseState.Y;
                }
            }
            if (Settings.IsGamePaused)
            {
                // Resume Hover
                if (x >= 564 && x <= 715 && y >= 225 && y <= 296)
                {
                    DrawResumeHover = true;
                }
                else
                {
                    DrawResumeHover = false;
                }

                // Options Hover
                if (x >= 564 && x <= 715 && y >= 329 && y <= 370)
                {
                    DrawOptionsHover = true;
                }
                else
                {
                    DrawOptionsHover = false;
                }

                // Exit Hover
                if (x >= 564 && x <= 715 && y >= 404 && y <= 497)
                {
                    DrawExitHover = true;
                }
                else
                {
                    DrawExitHover = false;
                }

                // Resume the game
                if (PressedX >= 564 && PressedX <= 715 && PressedY >= 225 && PressedY <= 296)
                {
                    Settings.IsGamePaused = false;
                }

                // Options
                if (PressedX >= 564 && PressedX <= 715 && PressedY >= 329 && PressedY <= 370)
                {
                }

                // Exit to main menu
                if (PressedX >= 564 && PressedX <= 715 && PressedY >= 404 && PressedY <= 497)
                {
                    MyPlayer.SaveProfile();
                    StateManager.EnterState((int)StateManager.GameStates.MENU_SCREEN);
                }
            }
            // Mouse left button has been pressed
            if (newMouseState.LeftButton == ButtonState.Pressed)
            {
                if (ElapsedTime >= Settings.ShotThrottleLimit)
                {
                    if (!Boosts[Settings.DAMAGE_BOOST])
                    {
                        ProjectileManager.AddProjectile(MyPlayer, ProjectileManager.projectileSprites[0], new Vector2(newMouseState.X, newMouseState.Y));
                    }
                    else if (Boosts[Settings.DAMAGE_BOOST])
                    {
                        ProjectileManager.AddProjectile(MyPlayer, ProjectileManager.projectileSprites[1], new Vector2(newMouseState.X, newMouseState.Y));
                    }
                    ElapsedTime = 0f;
                }
            }
        }
Esempio n. 4
0
 public override void Use(Entity entity)
 {
     ProjectileManager.AddProjectile(new Grenade(MathHelper.Vec2ToEntitySpace(firePoint, position, rotation), MathHelper.RotationToVector2(rotation), 100f));
     base.Use(this);
 }