protected override bool HandleCollision(GameTime gameTime) { var player = Collides.Find(item => item is Player) as Player; if (player == null) { return(false); } AddPowerup(gameTime, player); return(true); }
protected override bool HandleCollision() { var player = Collides.Find(item => item is Player) as Player; if (player == null) { return(false); } player.TakeDamage(1); return(true); }
protected override bool HandleCollision() { var target = Collides.Find(item => item is IDamageable) as IDamageable; if (target == null || Owner == target) { return(false); } target.TakeDamage(1); Active = false; return(true); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } // TODO: Add your update logic here player.Update(gameTime); obstacle.Update(gameTime); if (Collides.IsColliding(player.bounds, obstacle.bounds)) { score = 0; obstacle.Reset(); } base.Update(gameTime); }
public BankTower(float x, float y, bool buy = false) : base(x, y, new RectangleShape(new Vector2f(25, 25)), _cost, "Bank", $"Creates ${Program.MoneyRate} every 3 seconds", 0f, Program.MoneyRate, 3_000f) { if (buy) { Program.Money -= Cost; } shape.Texture = new Texture("./Resources/BankTower.png"); Upgrade item = new Upgrade(new Modifier(ModifierType.Value, 1), 20, "More Money", "Increases money gain by 1", UpdateType.Amount) { Unlocks = { new Upgrade(new Modifier(ModifierType.Value, 1), 30, "More Money II", "Increases money gain by 1", UpdateType.Amount), new Upgrade(new Modifier(ModifierType.Percentage, -20), 15, "Print quicker", "Decreases time between funds by 20%", UpdateType.Speed) } }; base.AvailableUpgrades.Add(item); Collides.Add(typeof(Enemy)); }