fea: add bonus boost (#50)

Co-authored-by: Djelal BOUDJI <djelal@gmail.com>
This commit is contained in:
djelalb
2025-03-31 11:47:33 +02:00
committed by GitHub
parent 0c2ac9639f
commit 4723b8fab5
14 changed files with 744 additions and 3 deletions

View File

@ -9,7 +9,7 @@ public class NormalGameMode : IGameMode
public void Update(Player player)
{
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed, player.RigidBody.linearVelocity.y);
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed * player.SpeedMultiplier, player.RigidBody.linearVelocity.y);
if (player.HasStarted && player.IsColliding && Input.GetKey(JumpKey) && player.CanJump)
{

View File

@ -12,7 +12,7 @@ public class ShipGameMode : IGameMode
public void Update(Player player)
{
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed, player.RigidBody.linearVelocity.y);
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed * player.SpeedMultiplier, player.RigidBody.linearVelocity.y);
bool jumpPressed = Input.GetKey(JumpKey);

View File

@ -13,6 +13,7 @@ public class Player : MonoBehaviour
public bool CanJump { get; set; } = true;
public IGameMode CurrentGameMode { get; set; }
public float SpeedMultiplier = 1f;
public void Awake()
{
@ -67,6 +68,16 @@ public class Player : MonoBehaviour
SpriteRenderer.sprite = Resources.Load<Sprite>("Shapes/BaseSquare");
ChangeGameMode(new NormalGameMode());
}
else if (collision.CompareTag("BonusBoostSpeed"))
{
SpeedMultiplier *= 1.5f;
Destroy(collision.gameObject);
}
else if (collision.CompareTag("BonusSlowSpeed"))
{
SpeedMultiplier /= 1.5f;
Destroy(collision.gameObject);
}
}
public void ChangeGameMode(IGameMode newMode)