blob: c44af96c5147a377e7e9fbd4ec970676ab1b6154 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 角色,包括player和opponents
/// </summary>
public partial class Avatar : MonoBehaviour, IInteractable
{
public string Name;
// 一个角色包括一个身体的collider和若干hitbox和hurtbox
public PhysicsBody m_Body;
public PhysicsBox m_BodyCollider;
public Hitbox[] m_Hitbox;
public Hurtbox[] m_Hurtbox;
protected AbilitySystem m_AbilitySystem = new AbilitySystem();
public PhysicsBody Body
{
get
{
return m_Body;
}
}
public PhysicsPrimitive[] GetAllPrimitive()
{
throw new System.NotImplementedException();
}
protected void Init()
{
AvatarManager.Instance.AddAvatar(this);
}
public PhysicsBox GetHitbox()
{
throw new System.NotImplementedException();
}
public PhysicsBox GetHurtbox()
{
throw new System.NotImplementedException();
}
public PhysicsPrimitive[] GetAllHit()
{
throw new System.NotImplementedException();
}
public bool IsHit()
{
for (int i = 0; i < m_Hitbox.Length; ++i)
{
if (PhysicsWorld.Instance.HasCollision(m_Hitbox[i].Collider))
{
return true;
}
}
return false;
}
public bool IsHurt()
{
for (int i = 0; i < m_Hitbox.Length; ++i)
{
if (PhysicsWorld.Instance.HasCollision(m_Hurtbox[i].Collider))
{
return true;
}
}
return false;
}
public void OnUpdate()
{
m_AbilitySystem.OnUpdate();
}
// 在物理模拟之后调用
public void OnPhysicsUpdate()
{
m_AbilitySystem.OnPhysicsUpdate();
}
public virtual Vector3 GetEffectPosition()
{
return Vector3.zero;
}
// 获得当前击打如果有的话
public Hit GetHit()
{
return m_AbilitySystem.GetHit();
}
public virtual void OnHit(HitInfo hitInfo)
{
//Debug.Log("Hit");
m_AbilitySystem.OnHit(hitInfo);
}
public virtual void OnHurt(HurtInfo hurtInfo)
{
//Debug.Log("Hurt");
HitDefination hitDef = hurtInfo.hitDef;
if (hitDef != null)
ApplyHit(hitDef);
m_AbilitySystem.OnHurt(hurtInfo);
}
}
|