added bonus and side moving obstacle
This commit is contained in:
1 parent
08e050ffd3
commit
e039461a83
17 files changed
+1171
-11
No files matched your search
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using Code.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Gameplay.Player
|
||||
@@ -15,8 +17,11 @@ namespace Code.Gameplay.Player
|
||||
private CharacterController _controller;
|
||||
private Vector3 _direction;
|
||||
|
||||
public System.Action OnPlayerDeath;
|
||||
private bool _isDead = false;
|
||||
public Action OnPlayerDeath;
|
||||
private bool _isDead;
|
||||
|
||||
private bool _isDoubleCoins;
|
||||
private float _bonusTimer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -73,6 +78,7 @@ namespace Code.Gameplay.Player
|
||||
|
||||
_controller.Move(finalMove);
|
||||
CheckForDeath();
|
||||
HandleBonusTimer();
|
||||
}
|
||||
|
||||
public void IncreaseSpeed(float amount)
|
||||
@@ -86,12 +92,42 @@ namespace Code.Gameplay.Player
|
||||
|
||||
private void OnTriggerEnter(Collider foreign)
|
||||
{
|
||||
if (foreign.CompareTag("Obstacle"))
|
||||
{
|
||||
Die();
|
||||
}
|
||||
|
||||
if (foreign.CompareTag("Coin"))
|
||||
{
|
||||
UI.GameplayController.Instance.AddCoin();
|
||||
|
||||
var amount = _isDoubleCoins ? 2 : 1;
|
||||
for(var i = 0; i < amount; i++) GameplayController.Instance.AddCoin();
|
||||
|
||||
Destroy(foreign.gameObject);
|
||||
}
|
||||
|
||||
if (foreign.CompareTag("BonusX2"))
|
||||
{
|
||||
ActivateDoubleCoins(10f);
|
||||
Destroy(foreign.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActivateDoubleCoins(float duration)
|
||||
{
|
||||
_isDoubleCoins = true;
|
||||
_bonusTimer = duration;
|
||||
}
|
||||
|
||||
private void HandleBonusTimer()
|
||||
{
|
||||
if (_bonusTimer > 0)
|
||||
{
|
||||
_bonusTimer -= Time.deltaTime;
|
||||
if (_bonusTimer <= 0)
|
||||
{
|
||||
_isDoubleCoins = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckForDeath()
|
||||
|
||||
Reference in new issue
Block a user