|
@@ -24,8 +24,6 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
public Vector3 targetPos;
|
|
public Vector3 targetPos;
|
|
|
public float back;
|
|
public float back;
|
|
|
[HideInInspector]
|
|
[HideInInspector]
|
|
|
- public int hp;
|
|
|
|
|
- [HideInInspector]
|
|
|
|
|
public float posx;
|
|
public float posx;
|
|
|
[HideInInspector]
|
|
[HideInInspector]
|
|
|
public Soul targetSoul;
|
|
public Soul targetSoul;
|
|
@@ -34,6 +32,10 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
public int haveSoulNumber;
|
|
public int haveSoulNumber;
|
|
|
public SoulFollowEffect followEffect;
|
|
public SoulFollowEffect followEffect;
|
|
|
public float backSoulX;
|
|
public float backSoulX;
|
|
|
|
|
+ public float stayTime;
|
|
|
|
|
+ [HideInInspector]
|
|
|
|
|
+ public float time;
|
|
|
|
|
+ public float getSoulDistance;
|
|
|
// Start is called before the first frame update
|
|
// Start is called before the first frame update
|
|
|
void Start()
|
|
void Start()
|
|
|
{
|
|
{
|
|
@@ -42,16 +44,17 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
gameObject.SetActive(false);
|
|
gameObject.SetActive(false);
|
|
|
}
|
|
}
|
|
|
demonic.isNonAttack = true;
|
|
demonic.isNonAttack = true;
|
|
|
- hp = demonic.hp;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
// Update is called once per frame
|
|
|
void Update()
|
|
void Update()
|
|
|
{
|
|
{
|
|
|
Onstate();
|
|
Onstate();
|
|
|
- if (demonic.hp <= 0)
|
|
|
|
|
|
|
+ time += Time.deltaTime;
|
|
|
|
|
+ if (time >= stayTime)
|
|
|
{
|
|
{
|
|
|
- ChangeState(InvisibleState.Die);
|
|
|
|
|
|
|
+ followEffect.DropSoul(haveSoulNumber,false);
|
|
|
|
|
+ gameObject.SetActive(false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
void Onstate()
|
|
void Onstate()
|
|
@@ -64,18 +67,18 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
|
|
|
|
|
if (haveSoulNumber != followNumber && SoulInMap.souls.Count != 0)
|
|
if (haveSoulNumber != followNumber && SoulInMap.souls.Count != 0)
|
|
|
{
|
|
{
|
|
|
- ChangeState(InvisibleState.FindSoul);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (hp != demonic.hp)
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(InvisibleState.Hurt);
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ FindSoul();
|
|
|
|
|
+ if(targetSoul != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ ChangeState(InvisibleState.FindSoul);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
posx = PlayersInput.instance[demonic.playerID].transform.position.x;
|
|
posx = PlayersInput.instance[demonic.playerID].transform.position.x;
|
|
|
targetPos = new Vector3(posx + offsetX, altitude + offsetY, transform.position.z);
|
|
targetPos = new Vector3(posx + offsetX, altitude + offsetY, transform.position.z);
|
|
|
Goto(targetPos, moveSpeed);
|
|
Goto(targetPos, moveSpeed);
|
|
|
- if (Vector3.Distance(targetPos, transform.position) < 0.5f)
|
|
|
|
|
|
|
+ if (Vector3.Distance(targetPos, transform.position) < 1)
|
|
|
{
|
|
{
|
|
|
offsetY = Random.Range(-randomRageY, randomRageY);
|
|
offsetY = Random.Range(-randomRageY, randomRageY);
|
|
|
offsetX = Random.Range(-randomRageX, randomRageX);
|
|
offsetX = Random.Range(-randomRageX, randomRageX);
|
|
@@ -88,7 +91,7 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
ChangeState(InvisibleState.FindSoul);
|
|
ChangeState(InvisibleState.FindSoul);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (Vector3.Distance(targetPos, transform.position) < 0.5f)
|
|
|
|
|
|
|
+ if (Vector3.Distance(targetPos, transform.position) < 1)
|
|
|
{
|
|
{
|
|
|
ChangeState(InvisibleState.Normal);
|
|
ChangeState(InvisibleState.Normal);
|
|
|
return;
|
|
return;
|
|
@@ -116,7 +119,7 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
pos1 = new Vector3(transform.position.x, transform.position.y, 0);
|
|
pos1 = new Vector3(transform.position.x, transform.position.y, 0);
|
|
|
pos2 = new Vector3(targetSoul.transform.position.x,
|
|
pos2 = new Vector3(targetSoul.transform.position.x,
|
|
|
targetSoul.transform.position.y, 0);
|
|
targetSoul.transform.position.y, 0);
|
|
|
- if (Vector3.Distance(pos1, pos2) <= 0.5f)
|
|
|
|
|
|
|
+ if (Vector3.Distance(pos1, pos2) <= 1)
|
|
|
{
|
|
{
|
|
|
SoulInMap.souls.Remove(targetSoul);
|
|
SoulInMap.souls.Remove(targetSoul);
|
|
|
targetSoul.gameObject.SetActive(false);
|
|
targetSoul.gameObject.SetActive(false);
|
|
@@ -145,15 +148,13 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
break;
|
|
break;
|
|
|
case InvisibleState.FindPlayer:
|
|
case InvisibleState.FindPlayer:
|
|
|
pos1 = new Vector3(transform.position.x, transform.position.y, 0);
|
|
pos1 = new Vector3(transform.position.x, transform.position.y, 0);
|
|
|
- pos2 = new Vector3(PlayersInput.instance[demonic.playerID].transform.position.x + backSoulX,
|
|
|
|
|
- PlayersInput.instance[demonic.playerID].transform.position.y + 1, 0);
|
|
|
|
|
- if (Vector3.Distance(pos1, pos2) <= 0.5f)
|
|
|
|
|
|
|
+ if (Vector3.Distance(pos1, targetPos) <= 1)
|
|
|
{
|
|
{
|
|
|
ChangeState(InvisibleState.Boom);
|
|
ChangeState(InvisibleState.Boom);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
boomSpeed += Time.deltaTime * upSpeed;
|
|
boomSpeed += Time.deltaTime * upSpeed;
|
|
|
- Goto(pos2, boomSpeed);
|
|
|
|
|
|
|
+ Goto(targetPos, boomSpeed);
|
|
|
break;
|
|
break;
|
|
|
case InvisibleState.Boom:
|
|
case InvisibleState.Boom:
|
|
|
ChangeState(InvisibleState.Normal);
|
|
ChangeState(InvisibleState.Normal);
|
|
@@ -182,7 +183,6 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
switch (newState)
|
|
switch (newState)
|
|
|
{
|
|
{
|
|
|
case InvisibleState.Normal:
|
|
case InvisibleState.Normal:
|
|
|
- hp = demonic.hp;
|
|
|
|
|
offsetY = Random.Range(-randomRageY, randomRageY);
|
|
offsetY = Random.Range(-randomRageY, randomRageY);
|
|
|
offsetX = Random.Range(-randomRageX, randomRageX);
|
|
offsetX = Random.Range(-randomRageX, randomRageX);
|
|
|
break;
|
|
break;
|
|
@@ -195,7 +195,22 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
FindSoul();
|
|
FindSoul();
|
|
|
break;
|
|
break;
|
|
|
case InvisibleState.FindPlayer:
|
|
case InvisibleState.FindPlayer:
|
|
|
|
|
+
|
|
|
boomSpeed = minSpeed;
|
|
boomSpeed = minSpeed;
|
|
|
|
|
+ PlayerController playerController = PlayersInput.instance[demonic.playerID];
|
|
|
|
|
+ if (playerController.transform.GetChild(0).localScale.x < 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ targetPos =
|
|
|
|
|
+ new Vector3(playerController.transform.position.x - backSoulX,
|
|
|
|
|
+ playerController.transform.position.y + 1, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ targetPos =
|
|
|
|
|
+ new Vector3(playerController.transform.position.x + backSoulX,
|
|
|
|
|
+ playerController.transform.position.y + 1, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
break;
|
|
break;
|
|
|
case InvisibleState.Boom:
|
|
case InvisibleState.Boom:
|
|
|
rb.velocity = Vector3.zero;
|
|
rb.velocity = Vector3.zero;
|
|
@@ -223,32 +238,30 @@ public class Spirits_Invisible : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
Vector3 pos1;
|
|
Vector3 pos1;
|
|
|
Vector3 pos2;
|
|
Vector3 pos2;
|
|
|
|
|
+ Vector3 pos3;
|
|
|
List<Soul> souls = SoulInMap.souls;
|
|
List<Soul> souls = SoulInMap.souls;
|
|
|
if (souls.Count == 0)
|
|
if (souls.Count == 0)
|
|
|
{
|
|
{
|
|
|
targetSoul = null;
|
|
targetSoul = null;
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- pos1 = new Vector3(souls[0].transform.position.x, souls[0].transform.position.y, 0);
|
|
|
|
|
- pos2 = new Vector3(transform.position.x, transform.position.y, 0);
|
|
|
|
|
- float minDistance = Vector3.Distance(pos1, pos2);
|
|
|
|
|
- int targetSoulId = 0;
|
|
|
|
|
- for (int i = 1; i < souls.Count; i++)
|
|
|
|
|
|
|
+ float minDistance = Mathf.Infinity;
|
|
|
|
|
+ int targetSoulId = -1;
|
|
|
|
|
+ for (int i = 0; i < souls.Count; i++)
|
|
|
{
|
|
{
|
|
|
- if (souls[i].Spirits_Invisible_NotFind)
|
|
|
|
|
- {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
pos1 = new Vector3(souls[i].transform.position.x, souls[i].transform.position.y, 0);
|
|
pos1 = new Vector3(souls[i].transform.position.x, souls[i].transform.position.y, 0);
|
|
|
pos2 = new Vector3(transform.position.x, transform.position.y, 0);
|
|
pos2 = new Vector3(transform.position.x, transform.position.y, 0);
|
|
|
|
|
+ pos3 = new Vector3(PlayersInput.instance[demonic.playerID].transform.position.x,
|
|
|
|
|
+ PlayersInput.instance[demonic.playerID].transform.position.y, 0);
|
|
|
float distance = Vector3.Distance(pos1, pos2);
|
|
float distance = Vector3.Distance(pos1, pos2);
|
|
|
- if (souls[targetSoulId].Spirits_Invisible_NotFind || distance < minDistance)
|
|
|
|
|
|
|
+ float distance1 = Vector3.Distance(pos1, pos3);
|
|
|
|
|
+ if (distance1 > getSoulDistance && distance<minDistance)
|
|
|
{
|
|
{
|
|
|
minDistance = distance;
|
|
minDistance = distance;
|
|
|
targetSoulId = i;
|
|
targetSoulId = i;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (souls[targetSoulId].Spirits_Invisible_NotFind)
|
|
|
|
|
|
|
+ if (targetSoulId == -1)
|
|
|
{
|
|
{
|
|
|
targetSoul = null;
|
|
targetSoul = null;
|
|
|
return;
|
|
return;
|