|
|
@@ -35,7 +35,6 @@ public class Enemy : MoveCharacter
|
|
|
|
|
|
public float attackRatio;
|
|
|
public float maxMoveSpeed, minMoveSpeed;
|
|
|
- public float runSpeed;
|
|
|
|
|
|
public int dropSoul = 1;
|
|
|
public GameObject soulPrefab;
|
|
|
@@ -71,7 +70,7 @@ public class Enemy : MoveCharacter
|
|
|
|
|
|
private void Awake()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void OnDisable()
|
|
|
@@ -91,7 +90,7 @@ public class Enemy : MoveCharacter
|
|
|
if (!noOnSearchState)
|
|
|
{
|
|
|
OnSearchState();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
OnState();
|
|
|
|
|
|
@@ -197,7 +196,7 @@ public class Enemy : MoveCharacter
|
|
|
weakTime -= Time.deltaTime;
|
|
|
Vector3 leftDir = GetMoveDir();
|
|
|
bool isAttack = GetAttack();
|
|
|
-
|
|
|
+
|
|
|
switch (state)
|
|
|
{
|
|
|
case CharacterState.Idle:
|
|
|
@@ -306,7 +305,7 @@ public class Enemy : MoveCharacter
|
|
|
if (leftDir.x > 0.3f)
|
|
|
{
|
|
|
//rb.velocity += Vector3.right * moveAcc * Time.deltaTime;
|
|
|
- rb.velocity = Vector3.right * runSpeed;
|
|
|
+ rb.velocity = Vector3.right * rushSpeed;
|
|
|
//if (rb.velocity.x > maxMoveSpeed)
|
|
|
//{
|
|
|
// rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
@@ -319,7 +318,7 @@ public class Enemy : MoveCharacter
|
|
|
else if (leftDir.x < -0.3f)
|
|
|
{
|
|
|
//rb.velocity -= Vector3.right * moveAcc * Time.deltaTime;
|
|
|
- rb.velocity = Vector3.left * runSpeed;
|
|
|
+ rb.velocity = Vector3.left * rushSpeed;
|
|
|
//if (rb.velocity.x < -maxMoveSpeed)
|
|
|
//{
|
|
|
// rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
@@ -346,7 +345,7 @@ public class Enemy : MoveCharacter
|
|
|
// break;
|
|
|
// }
|
|
|
//}
|
|
|
-
|
|
|
+
|
|
|
rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
|
|
|
break;
|
|
|
case CharacterState.Fall:
|
|
|
@@ -360,7 +359,7 @@ public class Enemy : MoveCharacter
|
|
|
{
|
|
|
ChangeState(CharacterState.Idle);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
//if (foot.canStepPlayers.Count > 0)
|
|
|
@@ -442,7 +441,7 @@ public class Enemy : MoveCharacter
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (Vector3.Distance(transform.position, targetCharacter.transform.position)
|
|
|
+ if (Vector3.Distance(transform.position, targetCharacter.transform.position)
|
|
|
< hateDistance)
|
|
|
{
|
|
|
rushEndPos = targetCharacter.transform.position;
|
|
|
@@ -456,7 +455,7 @@ public class Enemy : MoveCharacter
|
|
|
Turn();
|
|
|
}
|
|
|
}
|
|
|
- if(targetCharacter.transform.position.x < transform.position.x)
|
|
|
+ if (targetCharacter.transform.position.x < transform.position.x)
|
|
|
{
|
|
|
rb.velocity = Vector3.left * moveSpeed;
|
|
|
if (bodyTrans.localScale.x < 0)
|
|
|
@@ -467,7 +466,7 @@ public class Enemy : MoveCharacter
|
|
|
break;
|
|
|
case CharacterState.ReadyToRush:
|
|
|
time += Time.deltaTime;
|
|
|
-
|
|
|
+
|
|
|
if (time >= readyCD)
|
|
|
{
|
|
|
time = 0;
|
|
|
@@ -479,7 +478,7 @@ public class Enemy : MoveCharacter
|
|
|
{
|
|
|
ChangeState(CharacterState.Rush);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
break;
|
|
|
case CharacterState.RushAttack:
|
|
|
@@ -576,8 +575,8 @@ public class Enemy : MoveCharacter
|
|
|
case CharacterState.ReadyToRush:
|
|
|
aimEffect.SetActive(false);
|
|
|
aimEffect.transform.localScale = Vector3.zero;
|
|
|
- rb.constraints =
|
|
|
- RigidbodyConstraints.FreezePositionZ|RigidbodyConstraints.FreezeRotation;
|
|
|
+ rb.constraints =
|
|
|
+ RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
|
|
|
break;
|
|
|
case CharacterState.RushAttack:
|
|
|
dashEffect.canHit = false;
|
|
|
@@ -586,12 +585,12 @@ public class Enemy : MoveCharacter
|
|
|
|
|
|
break;
|
|
|
case CharacterState.ReadyToDownRush:
|
|
|
- rb.constraints =
|
|
|
- RigidbodyConstraints.FreezePositionZ|RigidbodyConstraints.FreezeRotation;
|
|
|
-
|
|
|
+ rb.constraints =
|
|
|
+ RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
|
|
|
+
|
|
|
break;
|
|
|
case CharacterState.DownRush:
|
|
|
-
|
|
|
+
|
|
|
dashEffect.canHit = false;
|
|
|
rb.velocity = Vector3.zero;
|
|
|
bodyTrans.rotation = Quaternion.Euler(Vector3.zero);
|
|
|
@@ -769,6 +768,14 @@ public class Enemy : MoveCharacter
|
|
|
switch (searchState)
|
|
|
{
|
|
|
case SearchState.NoTarget:
|
|
|
+ if (targetCharacter == PlayersInput.instance[0])
|
|
|
+ {
|
|
|
+ PlayersInput.instance[0].beTargetCharacter.Remove(this);
|
|
|
+ }
|
|
|
+ if (targetCharacter == PlayersInput.instance[1])
|
|
|
+ {
|
|
|
+ PlayersInput.instance[1].beTargetCharacter.Remove(this);
|
|
|
+ }
|
|
|
targetCharacter = null;
|
|
|
break;
|
|
|
case SearchState.InSearchScope:
|
|
|
@@ -783,8 +790,17 @@ public class Enemy : MoveCharacter
|
|
|
public bool SearchTarget()
|
|
|
{
|
|
|
targetCharacter = searchTrigger.GetMinDisTarget(targetTypes, canHitFly);
|
|
|
+
|
|
|
if (targetCharacter != null)
|
|
|
{
|
|
|
+ if (targetCharacter == PlayersInput.instance[0])
|
|
|
+ {
|
|
|
+ PlayersInput.instance[0].beTargetCharacter.Add(this);
|
|
|
+ }
|
|
|
+ if (targetCharacter == PlayersInput.instance[1])
|
|
|
+ {
|
|
|
+ PlayersInput.instance[1].beTargetCharacter.Add(this);
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
@@ -821,7 +837,7 @@ public class Enemy : MoveCharacter
|
|
|
case SearchState.InAttackScope:
|
|
|
if (targetCharacter != null)
|
|
|
{
|
|
|
- if (!targetCharacter.gameObject.activeInHierarchy || targetCharacter.isDie
|
|
|
+ if (!targetCharacter.gameObject.activeInHierarchy || targetCharacter.isDie
|
|
|
|| Mathf.Abs(targetCharacter.transform.position.x - transform.position.x) > attackDistance)
|
|
|
{
|
|
|
ChangeSearchState(SearchState.NoTarget);
|
|
|
@@ -865,12 +881,14 @@ public class Enemy : MoveCharacter
|
|
|
if (distance0 <= distance1)
|
|
|
{
|
|
|
targetCharacter = PlayersInput.instance[0];
|
|
|
+ PlayersInput.instance[0].beTargetCharacter.Add(this);
|
|
|
distance = distance0;
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
targetCharacter = PlayersInput.instance[1];
|
|
|
+ PlayersInput.instance[1].beTargetCharacter.Add(this);
|
|
|
distance = distance1;
|
|
|
}
|
|
|
}
|