Up to date with main

This commit is contained in:
2024-10-21 21:38:32 -07:00
parent e36ef7cffa
commit bc0e3cd2dc
2 changed files with 158 additions and 1 deletions

View File

@@ -9,9 +9,10 @@ public class Teo : MonoBehaviour
public float swingDistance = 10;
public float damageStrength = 10;
public float attackCooldownSeconds = 10;
public float dashDistance = 5;
public float dashDistance = 0.5F;
public float dashCooldownSeconds = 5;
public float lastAttackTime = 0;
public float lastDashTime = 0;
Rigidbody2D controller;
GameState gameState;
// Start is called once before the first execution of Update after the MonoBehaviour is created
@@ -32,6 +33,9 @@ public class Teo : MonoBehaviour
Attack();
lastAttackTime = Time.fixedTime;
}
if (Input.GetMouseButtonDown(1)) {
StartCoroutine("Dash");
}
}
void Attack() {
if (Time.fixedTime-lastAttackTime < attackCooldownSeconds) {
@@ -53,4 +57,14 @@ public class Teo : MonoBehaviour
ratbot.Damage(damageStrength);
}
}
void Dash() {
if (Time.fixedTime-lastDashTime < dashCooldownSeconds) return;
GetComponent<Rigidbody2D>().simulated = false;
controller.linearVelocity = new Vector2(
Screen.width/2 - Input.mousePosition.x,
Screen.height/2 - Input.mousePosition.y
) * dashDistance;
new WaitForSeconds (0.5F);
GetComponent<Rigidbody2D>().simulated = true;
}
}