private void UndoPower(PowerUpEffect power) { switch (power.PowerUpEffectAction) { case PowerUpEffectAction.Grow: ResetSize(); break; case PowerUpEffectAction.DecreaseSpeed: Speed *= 2; break; case PowerUpEffectAction.IncreaseSpeed: Speed /= 2; break; case PowerUpEffectAction.Ball_Split: GameObjectCollection.GetActive <Ball>(x => !x.IsMainBall).ForEach(x => x.IsActive = false); break; case PowerUpEffectAction.Ball_MultiBrickBreak: MultiBrickBreak = false; break; } this.PowerUpEffects.Remove(power); GameObjectCollection.ActivePowerUps.Remove(power.ToString()); }
public void CheckForCollisions(GameTime gameTime) { //prevent us from processing a collision multiple times if the object hasn't moved yet. if (AllowCollisionCheck) { foreach (var otherObject in GameObjectCollection.GetActive <InteractiveGameObject>(x => x != this)) { var points = Sprite.DrawMap.Select(x => x.Point).ToList(); var otherPoints = otherObject.Sprite.DrawMap.Select(x => x.Point).ToList(); var isCollision = points.Any(point => otherPoints.Any(otherPoint => otherPoint.X == point.X && otherPoint.Y == point.Y)); if (isCollision) { otherObject.AllowCollisionCheck = false; otherObject.ProcessCollisions(this, gameTime); ProcessCollisions(otherObject, gameTime); } } AllowCollisionCheck = false; } }
public override void ProcessCollisions(InteractiveGameObject CollidingObject, GameTime gameTime) { if (CollidingObject is Slider) { //Handover whatever power up effect we have to the objects impacted by it. var effectedObjects = GameObjectCollection.GetActive <T>(); foreach (var obj in effectedObjects) { foreach (var effect in this.PowerUpEffects) { if (obj.PowerUpEffects.All(x => x.PowerUpEffectAction != effect.PowerUpEffectAction)) { obj.PowerUpEffects.Add(effect); CurrentGame.Score += 25; } } } this.IsActive = false; } }