Implemented forced fight, updated attack range to be closer to player.
This commit is contained in:
@@ -19,9 +19,7 @@ namespace Assets.Scripts.InteractableObjects
|
||||
bool isJumping;
|
||||
Stopwatch jumpTimer;
|
||||
bool followsPlayer;
|
||||
bool isAttacking;
|
||||
bool isAttackOnCooldown;
|
||||
Stopwatch attackTimer;
|
||||
Fight fight;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -30,33 +28,14 @@ namespace Assets.Scripts.InteractableObjects
|
||||
jumpTimer = new Stopwatch();
|
||||
jumpTimer.Start();
|
||||
followsPlayer = false;
|
||||
isAttacking = false;
|
||||
isAttackOnCooldown = false;
|
||||
attackTimer = new Stopwatch();
|
||||
fight = GameObject.Find("Fight").GetComponent<Fight>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(fight.isFightActive) return;
|
||||
Jump();
|
||||
if (isAttacking)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
}
|
||||
|
||||
void Attack()
|
||||
{
|
||||
if (!isAttackOnCooldown)
|
||||
{
|
||||
attackTimer.Start();
|
||||
isAttackOnCooldown = true;
|
||||
}
|
||||
if (attackTimer.ElapsedMilliseconds >= 2000)
|
||||
{
|
||||
attackTimer.Reset();
|
||||
isAttackOnCooldown = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Jump()
|
||||
@@ -95,16 +74,12 @@ namespace Assets.Scripts.InteractableObjects
|
||||
|
||||
public void HandleAttack()
|
||||
{
|
||||
isAttacking = true;
|
||||
//Create attack logic here
|
||||
//TODO: Force Fight start
|
||||
}
|
||||
|
||||
public void handleFollow(bool isFollowing)
|
||||
{
|
||||
followsPlayer = isFollowing;
|
||||
isAttacking = false;
|
||||
attackTimer.Reset();
|
||||
isAttackOnCooldown = false;
|
||||
}
|
||||
|
||||
public void HandleDetection()
|
||||
|
||||
Reference in New Issue
Block a user