public void Execute(IGameObject gameObject1, IGameObject gameObject2) { Koopa2 koopa1 = (Koopa2)gameObject1; if (koopa1.State.GetType() == typeof(KoopaSideDeathState)) { return; } Koopa2 koopa2 = (Koopa2)gameObject2; if (koopa2.State.GetType() == typeof(KoopaSideDeathState)) { return; } if (koopa1.State.GetType() == typeof(KoopaDeadState) && koopa1.Velocity.X != GameUtilities.StationaryVelocity) { ScoringSystem.Player1Score.AddPointsForEnemyHitByShell(gameObject1); koopa2.Terminate("DOWN"); return; } if (koopa2.State.GetType() == typeof(KoopaDeadState) && koopa2.Velocity.X != GameUtilities.StationaryVelocity) { ScoringSystem.Player1Score.AddPointsForEnemyHitByShell(gameObject2); koopa1.Terminate("DOWN"); return; } koopa1.Location = new Vector2(koopa1.Location.X + GameUtilities.SinglePixel, koopa1.Location.Y); koopa1.ChangeDirection(); koopa2.ChangeDirection(); }
public void Execute(IGameObject gameObject1, IGameObject gameObject2) { IMario mario = (IMario)gameObject1; if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead || mario.IsProtected) { return; } Koopa2 koopa = (Koopa2)gameObject2; if (koopa.State.GetType() == typeof(KoopaSideDeathState)) { return; } int marioPreY = (int)(mario.Destination.Y - (mario.Velocity.Y - GameUtilities.SinglePixel)); if (marioPreY + mario.Destination.Height < gameObject2.Destination.Y) { ICollisionCommand TopCommand = new MarioKoopaCollisionTop(); TopCommand.Execute(gameObject1, gameObject2); return; } else if (marioPreY > gameObject2.Destination.Y + gameObject2.Destination.Height) { ICollisionCommand BottomCommand = new MarioKoopaCollisionBottom(); BottomCommand.Execute(gameObject1, gameObject2); return; } if (mario.State.IsStar == true) { ScoringSystem.PlayerScore(mario.Player).AddPointsForSpecialKoopaHit(gameObject2); koopa.Terminate("DOWN"); } else { if (koopa.State.GetType() == typeof(KoopaDeadState) && koopa.Velocity.X == GameUtilities.StationaryVelocity) { ScoringSystem.PlayerScore(mario.Player).AddPointsForInitiatingShell(gameObject2); koopa.Velocity = new Vector2(GameUtilities.KoopaShellVelocity, koopa.Velocity.Y); SoundManager.Instance.PlayKickSound(); return; } else if (koopa.State.GetType() == typeof(KoopaDeadState) && koopa.Velocity.X > 0) { return; } switch (mario.State.MarioShape) { case MarioState.MarioShapeEnums.Small: mario.State.Terminated(); break; case MarioState.MarioShapeEnums.Big: mario.IsProtected = true; GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.Small, mario); SoundManager.Instance.PlayPipeSound(); break; case MarioState.MarioShapeEnums.Fire: mario.IsProtected = true; SoundManager.Instance.PlayPipeSound(); GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.Small, mario); break; } mario.Location = new Vector2(mario.Location.X, mario.Location.Y); } }