Weapons
This commit is contained in:
1 parent
18f513af38
commit
ac91ce5ca7
36 files changed
+2114
-25
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
|
||||
public enum BodyPart
|
||||
{
|
||||
Head,
|
||||
Body,
|
||||
Leg
|
||||
}
|
||||
|
||||
// 掛在機器人骨頭上的命中框 (Collider 要勾 Is Trigger)
|
||||
public class Hitbox : MonoBehaviour
|
||||
{
|
||||
[Header("部位")]
|
||||
public BodyPart part = BodyPart.Body;
|
||||
|
||||
private BotHealth owner;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
owner = GetComponentInParent<BotHealth>();
|
||||
}
|
||||
|
||||
// 部位傷害倍率 : 頭 ×1.5、身體 ×1、腿 ×0.7
|
||||
public static float GetMultiplier(BodyPart part)
|
||||
{
|
||||
switch (part)
|
||||
{
|
||||
case BodyPart.Head: return 1.5f;
|
||||
case BodyPart.Leg: return 0.7f;
|
||||
default: return 1f;
|
||||
}
|
||||
}
|
||||
|
||||
// 回傳實際造成的傷害 (機器人已經倒下就回傳 0)
|
||||
public float Hit(float baseDamage)
|
||||
{
|
||||
if (owner == null || owner.IsDead) return 0f;
|
||||
|
||||
float damage = baseDamage * GetMultiplier(part);
|
||||
owner.TakeDamage(damage, part);
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user