|
|
|
@@ -10,7 +10,6 @@ public class Teo : MonoBehaviour
|
|
|
|
public float swingDistance = 10;
|
|
|
|
public float swingDistance = 10;
|
|
|
|
public float damageStrength = 10;
|
|
|
|
public float damageStrength = 10;
|
|
|
|
public float attackCooldownSeconds = 10;
|
|
|
|
public float attackCooldownSeconds = 10;
|
|
|
|
public float spamPunishMultiplier = 0.5F;
|
|
|
|
|
|
|
|
public float dashDistance = 5F;
|
|
|
|
public float dashDistance = 5F;
|
|
|
|
public float dashCooldownSeconds = 5;
|
|
|
|
public float dashCooldownSeconds = 5;
|
|
|
|
public float lastAttackTime = 0;
|
|
|
|
public float lastAttackTime = 0;
|
|
|
|
@@ -68,13 +67,15 @@ public class Teo : MonoBehaviour
|
|
|
|
Input.mousePosition.x - Screen.width/2
|
|
|
|
Input.mousePosition.x - Screen.width/2
|
|
|
|
)) > swingRangeDeg * Mathf.Deg2Rad
|
|
|
|
)) > swingRangeDeg * Mathf.Deg2Rad
|
|
|
|
) continue;
|
|
|
|
) continue;
|
|
|
|
// Apply a multiplier to damageStrength based on attack cooldown.
|
|
|
|
// Apply x^2 multiplier to damage if not fully charged
|
|
|
|
// If multiplier > 1, just do damageStrength
|
|
|
|
// Just use damageStrength if fully charged
|
|
|
|
float damageAmount = damageStrength * (Time.fixedTime - lastAttackTime)/attackCooldownSeconds;
|
|
|
|
float timeWaited = Time.fixedTime - lastAttackTime;
|
|
|
|
ratbot.Damage(
|
|
|
|
ratbot.Damage(
|
|
|
|
(damageAmount > damageStrength)
|
|
|
|
(timeWaited < attackCooldownSeconds)
|
|
|
|
? damageStrength
|
|
|
|
? Mathf.Pow(timeWaited, 2) *
|
|
|
|
: damageAmount * spamPunishMultiplier
|
|
|
|
damageStrength /
|
|
|
|
|
|
|
|
Mathf.Pow(attackCooldownSeconds, 2)
|
|
|
|
|
|
|
|
: damageStrength
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -93,9 +94,21 @@ public class Teo : MonoBehaviour
|
|
|
|
).normalized * dashDistance);
|
|
|
|
).normalized * dashDistance);
|
|
|
|
// Wait 0.2 seconds before ending the dash
|
|
|
|
// Wait 0.2 seconds before ending the dash
|
|
|
|
yield return new WaitForSeconds(0.2F);
|
|
|
|
yield return new WaitForSeconds(0.2F);
|
|
|
|
// Re enable collision and linearDamping after dash complete
|
|
|
|
// Re enable collision and linearDamping after dash
|
|
|
|
dashing = false;
|
|
|
|
dashing = false;
|
|
|
|
collider.enabled = true;
|
|
|
|
|
|
|
|
controller.linearDamping = 15;
|
|
|
|
controller.linearDamping = 15;
|
|
|
|
|
|
|
|
// Push enemies away at end of dash
|
|
|
|
|
|
|
|
foreach (Collider2D hit in Physics2D.OverlapCircleAll(
|
|
|
|
|
|
|
|
transform.position, 3
|
|
|
|
|
|
|
|
)) {
|
|
|
|
|
|
|
|
if (hit.tag != "Ratbot") continue;
|
|
|
|
|
|
|
|
hit.GetComponent<Rigidbody2D>().AddRelativeForce(
|
|
|
|
|
|
|
|
(hit.transform.position - transform.position)
|
|
|
|
|
|
|
|
.normalized * dashDistance
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't take damage at end of dash
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(0.2F);
|
|
|
|
|
|
|
|
collider.enabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|