|
|
@@ -11,6 +11,8 @@ public class Demonic : MoveCharacter
|
|
|
public SearchState searchState;
|
|
|
public float attackDistance;
|
|
|
public bool canFly = false;
|
|
|
+ public float flyHeight;
|
|
|
+ public float flyUpSpeed = 10;
|
|
|
public int sortingOrder = 0;
|
|
|
|
|
|
public int playerID;
|
|
|
@@ -185,6 +187,25 @@ public class Demonic : MoveCharacter
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public void AdjustHeight()
|
|
|
+ {
|
|
|
+ if (canFly)
|
|
|
+ {
|
|
|
+ if (transform.position.y - flyHeight > 0.1f)
|
|
|
+ {
|
|
|
+ Vector3 pos = transform.position;
|
|
|
+ pos.y -= flyUpSpeed * Time.deltaTime;
|
|
|
+ transform.position = pos;
|
|
|
+ }
|
|
|
+ else if (transform.position.y - flyHeight < -0.1f)
|
|
|
+ {
|
|
|
+ Vector3 pos = transform.position;
|
|
|
+ pos.y += flyUpSpeed * Time.deltaTime;
|
|
|
+ transform.position = pos;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public override void OnState()
|
|
|
{
|
|
|
base.OnState();
|
|
|
@@ -195,6 +216,7 @@ public class Demonic : MoveCharacter
|
|
|
weakTime -= Time.deltaTime;
|
|
|
Vector3 leftDir = GetMoveDir();
|
|
|
bool isAttack = GetAttack();
|
|
|
+
|
|
|
switch (state)
|
|
|
{
|
|
|
case CharacterState.Idle:
|
|
|
@@ -221,6 +243,7 @@ public class Demonic : MoveCharacter
|
|
|
ChangeState(CharacterState.Run);
|
|
|
break;
|
|
|
}
|
|
|
+ AdjustHeight();
|
|
|
//rb.velocity = Vector3.zero;
|
|
|
break;
|
|
|
case CharacterState.Run:
|
|
|
@@ -273,6 +296,7 @@ public class Demonic : MoveCharacter
|
|
|
Turn();
|
|
|
}
|
|
|
}
|
|
|
+ AdjustHeight();
|
|
|
break;
|
|
|
case CharacterState.Rise:
|
|
|
if (rb.velocity.y <= 0)
|
|
|
@@ -390,6 +414,10 @@ public class Demonic : MoveCharacter
|
|
|
isDie = false;
|
|
|
break;
|
|
|
case CharacterState.Weak:
|
|
|
+ if (canFly)
|
|
|
+ {
|
|
|
+ rb.constraints += 4; //RigidbodyConstraints.FreezePositionY = 4£¬²»ÄÜÖ±½Ó¼Ó
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -443,6 +471,10 @@ public class Demonic : MoveCharacter
|
|
|
velocity.y = weakUpSpeed;
|
|
|
rb.velocity = velocity;
|
|
|
weakTime = totalWeakTime;
|
|
|
+ if (canFly)
|
|
|
+ {
|
|
|
+ rb.constraints -= RigidbodyConstraints.FreezePositionY;
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|