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
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonsterController : UnitController
{
public override UnitType type { get { return UnitType.Monster; } }
protected override void Initialize()
{
base.Initialize();
unitState = GetOrAddUnitComponent<MonsterState>();
unitState.Initialize();
unitAnimation = GetOrAddUnitComponent<MonsterAnimation>();
unitAnimation.Initialize();
}
public override void Update()
{
base.Update();
}
public override void OnHit(CollisionInfo info)
{
}
public override void OnGetHit(CollisionInfo info)
{
ColliderBox hitbox = info.collider.colliderInfo.collider;
Debug.Assert(hitbox.type == ColliderBox.EColliderType.HitBox);
if(hitbox.hitResponse == ColliderBox.EHitResponse.Light)
{
monsterState.ChangeState(MonsterState.EUnitState.HitLight, new MonsterState.HitLightParam(), true);
}
else if (hitbox.hitResponse == ColliderBox.EHitResponse.HitAir)
{
monsterState.ChangeState(MonsterState.EUnitState.HitAir, new MonsterState.HitAirParam());
}
else if (hitbox.hitResponse == ColliderBox.EHitResponse.HitInAir)
{
monsterState.ChangeState(MonsterState.EUnitState.HitInAir, new MonsterState.HitInAirParam(), true);
}
string path = hitbox.sparkPath;
GameObject vfx = ResourceManager.Instance.LoadAsset<GameObject>(path);
if(vfx != null)
{
GameObject go = GameObject.Instantiate(vfx);
go.transform.position = center + hitbox.sparkOffset;
go.transform.localScale = hitbox.sparkScale;
}
}
public override void OnGetShot(CollisionInfo info)
{
monsterState.ChangeState(MonsterState.EUnitState.HitLight, new MonsterState.HitLightParam(), true);
}
public virtual bool IsFacePC()
{
PCController pc = PCController.instance;
float pcX = pc.transform.position.x;
float x = transform.position.x;
bool isface = pcX > x && isTowardRight || pcX <= x && !isTowardRight;
return isface;
}
// 朝向PC
public virtual void FacePC()
{
if (IsFacePC())
return;
PCController pc = PCController.instance;
float pcX = pc.transform.position.x;
float x = transform.position.x;
if (pcX > x)
{
transform.rotation = Quaternion.Euler(0, 0, 0);
}
else
{
transform.rotation = Quaternion.Euler(0, 180, 0);
}
}
public virtual void FaceToFacePC()
{
PCController pc = PCController.instance;
transform.rotation = Quaternion.Euler(0, 180, 0) * pc.transform.rotation;
}
}
|