fixing fire system
This commit is contained in:
@@ -7,13 +7,13 @@ public class Player : Character
|
||||
[SerializeField]
|
||||
private GameObject _hammerPrefab;
|
||||
|
||||
private int _hammerSpeed=10;
|
||||
private int _hammerSpeed = 10;
|
||||
|
||||
private int _totalCoins = 0;
|
||||
private bool _hasKey = false;
|
||||
public static Player Instance { get; private set; }
|
||||
|
||||
|
||||
private GameObject _hammer;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -29,7 +29,6 @@ public class Player : Character
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
|
||||
public void AddCoin()
|
||||
{
|
||||
_totalCoins++;
|
||||
@@ -39,7 +38,7 @@ public class Player : Character
|
||||
public void SetKey()
|
||||
{
|
||||
print($"player have key");
|
||||
_hasKey =true;
|
||||
_hasKey = true;
|
||||
}
|
||||
|
||||
public void RemoveKey()
|
||||
@@ -54,10 +53,14 @@ public class Player : Character
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
if (Input.GetKeyDown(KeyCode.Space) && !_isFalling)
|
||||
{
|
||||
var hammer = Instantiate(_hammerPrefab, _hammerSpawnPoint.position, _hammerSpawnPoint.rotation);
|
||||
hammer.GetComponent<Rigidbody2D>().velocity = new Vector2(gameObject.transform.localScale.x * _hammerSpeed,0);
|
||||
if (_hammer == null)
|
||||
{
|
||||
_hammer = Instantiate(_hammerPrefab, _hammerSpawnPoint.position, _hammerSpawnPoint.rotation);
|
||||
_hammer.transform.localScale = new Vector2(_hammer.transform.localScale.x * (_facingRight ? 1 : -1), _hammer.transform.localScale.y);
|
||||
_hammer.GetComponent<Rigidbody2D>().velocity = new Vector2(gameObject.transform.localScale.x * _hammerSpeed, 0);
|
||||
}
|
||||
}
|
||||
base.MoveTo(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user