|
@@ -37,6 +37,7 @@ public class PlayerController : MoveCharacter
|
|
|
[HideInInspector]
|
|
[HideInInspector]
|
|
|
public float invincibleTime;
|
|
public float invincibleTime;
|
|
|
public float totalInvincibleTime = 2f;
|
|
public float totalInvincibleTime = 2f;
|
|
|
|
|
+ public float rushInvincibleTime = 0.2f;
|
|
|
[HideInInspector]
|
|
[HideInInspector]
|
|
|
public float canJumpTime; //离开平台后仍然可以跳跃的时间,用于提升手感
|
|
public float canJumpTime; //离开平台后仍然可以跳跃的时间,用于提升手感
|
|
|
public float leaveGroundCanJumpTime = 0.1f;
|
|
public float leaveGroundCanJumpTime = 0.1f;
|
|
@@ -76,11 +77,20 @@ public class PlayerController : MoveCharacter
|
|
|
{
|
|
{
|
|
|
get
|
|
get
|
|
|
{
|
|
{
|
|
|
- return Input.GetKey(KeyCode.LeftShift) || isClickBtnRush;
|
|
|
|
|
|
|
+ return Input.GetKeyDown(KeyCode.LeftShift) || isClickBtnRush;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
[HideInInspector]
|
|
[HideInInspector]
|
|
|
public bool isClickBtnRush;
|
|
public bool isClickBtnRush;
|
|
|
|
|
+ public bool btnRushKeep
|
|
|
|
|
+ {
|
|
|
|
|
+ get
|
|
|
|
|
+ {
|
|
|
|
|
+ return Input.GetKey(KeyCode.LeftShift) || isKeepBtnRush;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ [HideInInspector]
|
|
|
|
|
+ public bool isKeepBtnRush;
|
|
|
public bool btnSouthPress
|
|
public bool btnSouthPress
|
|
|
{
|
|
{
|
|
|
get
|
|
get
|
|
@@ -165,6 +175,10 @@ public class PlayerController : MoveCharacter
|
|
|
{
|
|
{
|
|
|
isClickBtnRush = true;
|
|
isClickBtnRush = true;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (Input.GetKey(KeyCode.LeftShift))
|
|
|
|
|
+ {
|
|
|
|
|
+ isKeepBtnRush = true;
|
|
|
|
|
+ }
|
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
|
{
|
|
{
|
|
|
isClickBtnJump = true;
|
|
isClickBtnJump = true;
|
|
@@ -208,20 +222,7 @@ public class PlayerController : MoveCharacter
|
|
|
{
|
|
{
|
|
|
ChangeState(CharacterState.Rise);
|
|
ChangeState(CharacterState.Rise);
|
|
|
Vector3 velocity = rb.velocity;
|
|
Vector3 velocity = rb.velocity;
|
|
|
- if (leftDir.x > 0.3f)
|
|
|
|
|
- {
|
|
|
|
|
- if (bodyTrans.localScale.x > 0)
|
|
|
|
|
- {
|
|
|
|
|
- Turn();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if (leftDir.x < -0.3f)
|
|
|
|
|
- {
|
|
|
|
|
- if (bodyTrans.localScale.x < 0)
|
|
|
|
|
- {
|
|
|
|
|
- Turn();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CheckTurn();
|
|
|
velocity.y = speed;
|
|
velocity.y = speed;
|
|
|
rb.velocity = velocity;
|
|
rb.velocity = velocity;
|
|
|
//animalAni.SetInteger("state", (int)PlayerState.Rise);
|
|
//animalAni.SetInteger("state", (int)PlayerState.Rise);
|
|
@@ -232,6 +233,14 @@ public class PlayerController : MoveCharacter
|
|
|
{
|
|
{
|
|
|
if (!foot.TrigGround)
|
|
if (!foot.TrigGround)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (btnRushPress || cacheRushTime > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != CharacterState.Rush)
|
|
|
|
|
+ {
|
|
|
|
|
+ ChangeState(CharacterState.Rush);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (rb.velocity.y > 0)
|
|
if (rb.velocity.y > 0)
|
|
|
{
|
|
{
|
|
|
if (excludeState != CharacterState.Rise)
|
|
if (excludeState != CharacterState.Rise)
|
|
@@ -399,31 +408,14 @@ public class PlayerController : MoveCharacter
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
canJumpTime = leaveGroundCanJumpTime;
|
|
canJumpTime = leaveGroundCanJumpTime;
|
|
|
|
|
+ CheckTurn();
|
|
|
if (leftDir.x > 0.3f)
|
|
if (leftDir.x > 0.3f)
|
|
|
{
|
|
{
|
|
|
- //rb.velocity += Vector3.right * moveAcc * Time.deltaTime;
|
|
|
|
|
rb.velocity = Vector3.right * maxMoveSpeed;
|
|
rb.velocity = Vector3.right * maxMoveSpeed;
|
|
|
- //if (rb.velocity.x > maxMoveSpeed)
|
|
|
|
|
- //{
|
|
|
|
|
- // rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
|
|
- //}
|
|
|
|
|
- if (bodyTrans.localScale.x > 0)
|
|
|
|
|
- {
|
|
|
|
|
- Turn();
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
else if (leftDir.x < -0.3f)
|
|
else if (leftDir.x < -0.3f)
|
|
|
{
|
|
{
|
|
|
- //rb.velocity -= Vector3.right * moveAcc * Time.deltaTime;
|
|
|
|
|
rb.velocity = Vector3.left * maxMoveSpeed;
|
|
rb.velocity = Vector3.left * maxMoveSpeed;
|
|
|
- //if (rb.velocity.x < -maxMoveSpeed)
|
|
|
|
|
- //{
|
|
|
|
|
- // rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
|
|
- //}
|
|
|
|
|
- if (bodyTrans.localScale.x < 0)
|
|
|
|
|
- {
|
|
|
|
|
- Turn();
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case CharacterState.Rise:
|
|
case CharacterState.Rise:
|
|
@@ -531,6 +523,11 @@ public class PlayerController : MoveCharacter
|
|
|
case CharacterState.Rush:
|
|
case CharacterState.Rush:
|
|
|
if (rushTime <= 0)
|
|
if (rushTime <= 0)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (btnRushKeep)
|
|
|
|
|
+ {
|
|
|
|
|
+ ChangeState(CharacterState.Sprint);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
if (CheckPlayerChangeState())
|
|
if (CheckPlayerChangeState())
|
|
|
{
|
|
{
|
|
|
break;
|
|
break;
|
|
@@ -546,6 +543,25 @@ public class PlayerController : MoveCharacter
|
|
|
rb.velocity = Vector3.right * rushSpeed;
|
|
rb.velocity = Vector3.right * rushSpeed;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case CharacterState.Sprint:
|
|
|
|
|
+ if (!btnRushKeep)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (CheckPlayerChangeState(CharacterState.Rush))
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ CachedPlayerInput();
|
|
|
|
|
+ CheckTurn();
|
|
|
|
|
+ if (bodyTrans.localScale.x > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ rb.velocity = Vector3.left * rushSpeed;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ rb.velocity = Vector3.right * rushSpeed;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
case CharacterState.Die:
|
|
case CharacterState.Die:
|
|
|
if (dieKeepTime <= 0)
|
|
if (dieKeepTime <= 0)
|
|
|
{
|
|
{
|
|
@@ -557,6 +573,7 @@ public class PlayerController : MoveCharacter
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
isClickBtnRush = false;
|
|
isClickBtnRush = false;
|
|
|
|
|
+ isKeepBtnRush = false;
|
|
|
isClickBtnJump = false;
|
|
isClickBtnJump = false;
|
|
|
isClickBtnSouth = false;
|
|
isClickBtnSouth = false;
|
|
|
isClickBtnEast = false;
|
|
isClickBtnEast = false;
|
|
@@ -566,6 +583,7 @@ public class PlayerController : MoveCharacter
|
|
|
|
|
|
|
|
public override void ChangeState(CharacterState newState)
|
|
public override void ChangeState(CharacterState newState)
|
|
|
{
|
|
{
|
|
|
|
|
+ //print("ChangeState:" + state + ";" + newState);
|
|
|
switch (state)
|
|
switch (state)
|
|
|
{
|
|
{
|
|
|
case CharacterState.Idle:
|
|
case CharacterState.Idle:
|
|
@@ -588,6 +606,9 @@ public class PlayerController : MoveCharacter
|
|
|
case CharacterState.Rush:
|
|
case CharacterState.Rush:
|
|
|
rb.velocity = Vector3.zero;
|
|
rb.velocity = Vector3.zero;
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case CharacterState.Sprint:
|
|
|
|
|
+ rb.velocity = Vector3.zero;
|
|
|
|
|
+ break;
|
|
|
case CharacterState.Die:
|
|
case CharacterState.Die:
|
|
|
isDie = false;
|
|
isDie = false;
|
|
|
break;
|
|
break;
|
|
@@ -644,6 +665,19 @@ public class PlayerController : MoveCharacter
|
|
|
aniCollider.Play("Rush", 0, 0);
|
|
aniCollider.Play("Rush", 0, 0);
|
|
|
ani.Play("rush_loop", 0, 0);
|
|
ani.Play("rush_loop", 0, 0);
|
|
|
rushTime = totalRushTime;
|
|
rushTime = totalRushTime;
|
|
|
|
|
+ invincibleTime = rushInvincibleTime;
|
|
|
|
|
+ if (bodyTrans.localScale.x > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ rb.velocity = Vector3.left * rushSpeed;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ rb.velocity = Vector3.right * rushSpeed;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case CharacterState.Sprint:
|
|
|
|
|
+ aniCollider.Play("Sprint", 0, 0);
|
|
|
|
|
+ ani.Play("rush_loop", 0, 0);
|
|
|
if (bodyTrans.localScale.x > 0)
|
|
if (bodyTrans.localScale.x > 0)
|
|
|
{
|
|
{
|
|
|
rb.velocity = Vector3.left * rushSpeed;
|
|
rb.velocity = Vector3.left * rushSpeed;
|
|
@@ -664,33 +698,28 @@ public class PlayerController : MoveCharacter
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void CheckTurn()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (leftDir.x > 0.3f && bodyTrans.localScale.x > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ Turn();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (leftDir.x < -0.3f && bodyTrans.localScale.x < 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ Turn();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void AirMove()
|
|
public void AirMove()
|
|
|
{
|
|
{
|
|
|
|
|
+ CheckTurn();
|
|
|
if (leftDir.x > 0.3f)
|
|
if (leftDir.x > 0.3f)
|
|
|
{
|
|
{
|
|
|
- //rb.velocity += Vector3.right * airMoveAcc * deltaTime;
|
|
|
|
|
- ////rb.velocity = Vector3.right * maxMoveSpeed;
|
|
|
|
|
- //if (rb.velocity.x > maxMoveSpeed)
|
|
|
|
|
- //{
|
|
|
|
|
- rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
|
|
- //}
|
|
|
|
|
- if (bodyTrans.localScale.x > 0)
|
|
|
|
|
- {
|
|
|
|
|
- Turn();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
}
|
|
}
|
|
|
else if (leftDir.x < -0.3f)
|
|
else if (leftDir.x < -0.3f)
|
|
|
{
|
|
{
|
|
|
- //rb.velocity -= Vector3.right * airMoveAcc * deltaTime;
|
|
|
|
|
- ////rb.velocity = Vector3.left * maxMoveSpeed;
|
|
|
|
|
- //if (rb.velocity.x < -maxMoveSpeed)
|
|
|
|
|
- //{
|
|
|
|
|
- rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
|
|
- //}
|
|
|
|
|
- if (bodyTrans.localScale.x < 0)
|
|
|
|
|
- {
|
|
|
|
|
- Turn();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -757,4 +786,13 @@ public class PlayerController : MoveCharacter
|
|
|
demonicDic[demonic.id][i].SetSortingOrder(demonic.id * 1000 + i);
|
|
demonicDic[demonic.id][i].SetSortingOrder(demonic.id * 1000 + i);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public override void BeHit(int damage, Vector3 force)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (invincibleTime > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ base.BeHit(damage, force);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|