|
@@ -10,6 +10,7 @@ using Unity.VisualScripting;
|
|
|
|
|
|
|
|
public enum PlayerState
|
|
public enum PlayerState
|
|
|
{
|
|
{
|
|
|
|
|
+ None = 0,
|
|
|
Idle = 1,
|
|
Idle = 1,
|
|
|
Run = 2,
|
|
Run = 2,
|
|
|
Rise = 3,//空中上升
|
|
Rise = 3,//空中上升
|
|
@@ -88,6 +89,7 @@ public class PlayerController : MonoBehaviour
|
|
|
return Input.GetKeyDown(KeyCode.Space) || isClickBtnJump;
|
|
return Input.GetKeyDown(KeyCode.Space) || isClickBtnJump;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ [HideInInspector]
|
|
|
public bool isClickBtnJump;
|
|
public bool isClickBtnJump;
|
|
|
public bool btnRushPress
|
|
public bool btnRushPress
|
|
|
{
|
|
{
|
|
@@ -96,6 +98,7 @@ public class PlayerController : MonoBehaviour
|
|
|
return Input.GetKeyDown(KeyCode.LeftShift) || isClickBtnRush;
|
|
return Input.GetKeyDown(KeyCode.LeftShift) || isClickBtnRush;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ [HideInInspector]
|
|
|
public bool isClickBtnRush;
|
|
public bool isClickBtnRush;
|
|
|
public bool btnSouthPress
|
|
public bool btnSouthPress
|
|
|
{
|
|
{
|
|
@@ -104,6 +107,7 @@ public class PlayerController : MonoBehaviour
|
|
|
return Input.GetKeyDown(KeyCode.K) || isClickBtnSouth;
|
|
return Input.GetKeyDown(KeyCode.K) || isClickBtnSouth;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ [HideInInspector]
|
|
|
public bool isClickBtnSouth;
|
|
public bool isClickBtnSouth;
|
|
|
public bool btnEastPress
|
|
public bool btnEastPress
|
|
|
{
|
|
{
|
|
@@ -112,6 +116,7 @@ public class PlayerController : MonoBehaviour
|
|
|
return Input.GetKeyDown(KeyCode.L) || isClickBtnEast;
|
|
return Input.GetKeyDown(KeyCode.L) || isClickBtnEast;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ [HideInInspector]
|
|
|
public bool isClickBtnEast;
|
|
public bool isClickBtnEast;
|
|
|
public bool btnWestPress
|
|
public bool btnWestPress
|
|
|
{
|
|
{
|
|
@@ -120,6 +125,7 @@ public class PlayerController : MonoBehaviour
|
|
|
return Input.GetKeyDown(KeyCode.J) || isClickBtnWest;
|
|
return Input.GetKeyDown(KeyCode.J) || isClickBtnWest;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ [HideInInspector]
|
|
|
public bool isClickBtnWest;
|
|
public bool isClickBtnWest;
|
|
|
public bool btnNorthPress
|
|
public bool btnNorthPress
|
|
|
{
|
|
{
|
|
@@ -128,6 +134,7 @@ public class PlayerController : MonoBehaviour
|
|
|
return Input.GetKeyDown(KeyCode.I) || isClickBtnNorth;
|
|
return Input.GetKeyDown(KeyCode.I) || isClickBtnNorth;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ [HideInInspector]
|
|
|
public bool isClickBtnNorth;
|
|
public bool isClickBtnNorth;
|
|
|
|
|
|
|
|
public Vector2 leftDir
|
|
public Vector2 leftDir
|
|
@@ -237,130 +244,168 @@ public class PlayerController : MonoBehaviour
|
|
|
transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
|
|
transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void OnState()
|
|
|
|
|
|
|
+ //角色处于可自由活动状态时的通用切换状态逻辑,如Idle、Run状态,以及别的状态结束时准备回到Idle状态前
|
|
|
|
|
+ public bool CheckPlayerChangeState(PlayerState excludeState)
|
|
|
{
|
|
{
|
|
|
- cacheJumpTime -= Time.deltaTime;
|
|
|
|
|
- cacheAttackTime -= Time.deltaTime;
|
|
|
|
|
- cacheSummonTime -= Time.deltaTime;
|
|
|
|
|
- canJumpTime -= Time.deltaTime;
|
|
|
|
|
- invincibleTime -= Time.deltaTime;
|
|
|
|
|
- hurtKeepTime -= Time.deltaTime;
|
|
|
|
|
- attackTime -= Time.deltaTime;
|
|
|
|
|
- summonTime -= Time.deltaTime;
|
|
|
|
|
- rushTime -= Time.deltaTime;
|
|
|
|
|
- cacheRushTime -= Time.deltaTime;
|
|
|
|
|
- switch (state)
|
|
|
|
|
|
|
+ if (!foot.TrigGround)
|
|
|
{
|
|
{
|
|
|
- case PlayerState.Idle:
|
|
|
|
|
- if (btnWestPress || cacheAttackTime > 0)
|
|
|
|
|
|
|
+ if (rb.velocity.y > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Rise)
|
|
|
|
|
+ {
|
|
|
|
|
+ ChangeState(PlayerState.Rise);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Fall)
|
|
|
|
|
+ {
|
|
|
|
|
+ ChangeState(PlayerState.Fall);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ airJumped = false;
|
|
|
|
|
+ if (btnWestPress || cacheAttackTime > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Attack)
|
|
|
{
|
|
{
|
|
|
ChangeState(PlayerState.Attack);
|
|
ChangeState(PlayerState.Attack);
|
|
|
- break;
|
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- if (btnNorthPress)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (cacheSummonTime > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Summon)
|
|
|
|
|
+ {
|
|
|
|
|
+ Summon(cacheSummonId);
|
|
|
|
|
+ ChangeState(PlayerState.Summon);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnNorthPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Summon)
|
|
|
{
|
|
{
|
|
|
Summon(0);
|
|
Summon(0);
|
|
|
- break;
|
|
|
|
|
|
|
+ ChangeState(PlayerState.Summon);
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- if (btnSouthPress)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnSouthPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Summon)
|
|
|
{
|
|
{
|
|
|
Summon(1);
|
|
Summon(1);
|
|
|
- break;
|
|
|
|
|
|
|
+ ChangeState(PlayerState.Summon);
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- if (btnEastPress)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnEastPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Summon)
|
|
|
{
|
|
{
|
|
|
Summon(2);
|
|
Summon(2);
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (cacheSummonTime > 0)
|
|
|
|
|
- {
|
|
|
|
|
- Summon(cacheSummonId);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ ChangeState(PlayerState.Summon);
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- if (btnRushPress || cacheRushTime > 0)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnRushPress || cacheRushTime > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Rush)
|
|
|
{
|
|
{
|
|
|
ChangeState(PlayerState.Rush);
|
|
ChangeState(PlayerState.Rush);
|
|
|
- break;
|
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- if (btnJumpPress || cacheJumpTime > 0)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnJumpPress || cacheJumpTime > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Rise)
|
|
|
{
|
|
{
|
|
|
Jump();
|
|
Jump();
|
|
|
ChangeState(PlayerState.Rise);
|
|
ChangeState(PlayerState.Rise);
|
|
|
- break;
|
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- if (!foot.TrigGround)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (leftDir.x > 0.3f || leftDir.x < -0.3f)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Run)
|
|
|
{
|
|
{
|
|
|
- if (rb.velocity.y > 0)
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(PlayerState.Rise);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(PlayerState.Fall);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ChangeState(PlayerState.Run);
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- if (leftDir.x > 0.3f || leftDir.x < -0.3f)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (excludeState != PlayerState.Idle)
|
|
|
|
|
+ {
|
|
|
|
|
+ ChangeState(PlayerState.Idle);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void CachedPlayerInput()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (btnRushPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheRushTime = totalCacheRushTime;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnJumpPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheJumpTime = totalCacheJumpTime;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnWestPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheAttackTime = totalCacheAttackTime;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnNorthPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
+ cacheSummonId = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnSouthPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
+ cacheSummonId = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (btnEastPress)
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
+ cacheSummonId = 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void OnState()
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheJumpTime -= Time.deltaTime;
|
|
|
|
|
+ cacheAttackTime -= Time.deltaTime;
|
|
|
|
|
+ cacheSummonTime -= Time.deltaTime;
|
|
|
|
|
+ canJumpTime -= Time.deltaTime;
|
|
|
|
|
+ invincibleTime -= Time.deltaTime;
|
|
|
|
|
+ hurtKeepTime -= Time.deltaTime;
|
|
|
|
|
+ attackTime -= Time.deltaTime;
|
|
|
|
|
+ summonTime -= Time.deltaTime;
|
|
|
|
|
+ rushTime -= Time.deltaTime;
|
|
|
|
|
+ cacheRushTime -= Time.deltaTime;
|
|
|
|
|
+ switch (state)
|
|
|
|
|
+ {
|
|
|
|
|
+ case PlayerState.Idle:
|
|
|
|
|
+ if (CheckPlayerChangeState(state))
|
|
|
{
|
|
{
|
|
|
- ChangeState(PlayerState.Run);
|
|
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
canJumpTime = leaveGroundCanJumpTime;
|
|
canJumpTime = leaveGroundCanJumpTime;
|
|
|
//rb.velocity = Vector3.zero;
|
|
//rb.velocity = Vector3.zero;
|
|
|
break;
|
|
break;
|
|
|
case PlayerState.Run:
|
|
case PlayerState.Run:
|
|
|
- if (btnWestPress || cacheAttackTime > 0)
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(PlayerState.Attack);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnNorthPress)
|
|
|
|
|
|
|
+ if (CheckPlayerChangeState(state))
|
|
|
{
|
|
{
|
|
|
- Summon(0);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnSouthPress)
|
|
|
|
|
- {
|
|
|
|
|
- Summon(1);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnEastPress)
|
|
|
|
|
- {
|
|
|
|
|
- Summon(2);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (cacheSummonTime > 0)
|
|
|
|
|
- {
|
|
|
|
|
- Summon(cacheSummonId);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnRushPress || cacheRushTime > 0)
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(PlayerState.Rush);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnJumpPress || cacheJumpTime > 0)
|
|
|
|
|
- {
|
|
|
|
|
- Jump();
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (!foot.TrigGround)
|
|
|
|
|
- {
|
|
|
|
|
- if (rb.velocity.y > 0)
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(PlayerState.Rise);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(PlayerState.Fall);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (leftDir.x < 0.3f && leftDir.x > -0.3f)
|
|
|
|
|
- {
|
|
|
|
|
- ChangeState(PlayerState.Idle);
|
|
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
canJumpTime = leaveGroundCanJumpTime;
|
|
canJumpTime = leaveGroundCanJumpTime;
|
|
@@ -411,33 +456,7 @@ public class PlayerController : MonoBehaviour
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (btnRushPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheRushTime = totalCacheRushTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnJumpPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheJumpTime = totalCacheJumpTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnWestPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheAttackTime = totalCacheAttackTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnNorthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnSouthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnEastPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 2;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CachedPlayerInput();
|
|
|
rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
|
|
rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
|
|
|
AirMove();
|
|
AirMove();
|
|
|
break;
|
|
break;
|
|
@@ -449,8 +468,10 @@ public class PlayerController : MonoBehaviour
|
|
|
}
|
|
}
|
|
|
if (foot.TrigGround)
|
|
if (foot.TrigGround)
|
|
|
{
|
|
{
|
|
|
- ChangeState(PlayerState.Idle);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if (CheckPlayerChangeState(state))
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//if (foot.canStepPlayers.Count > 0)
|
|
//if (foot.canStepPlayers.Count > 0)
|
|
|
//{
|
|
//{
|
|
@@ -472,75 +493,25 @@ public class PlayerController : MonoBehaviour
|
|
|
AirJump();
|
|
AirJump();
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- else if (cacheJumpTime > 0)
|
|
|
|
|
|
|
+ else if (canJumpTime > 0)
|
|
|
{
|
|
{
|
|
|
Jump();
|
|
Jump();
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (btnRushPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheRushTime = totalCacheRushTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnJumpPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheJumpTime = totalCacheJumpTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnWestPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheAttackTime = totalCacheAttackTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnNorthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnSouthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnEastPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 2;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CachedPlayerInput();
|
|
|
rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
|
|
rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
|
|
|
AirMove();
|
|
AirMove();
|
|
|
break;
|
|
break;
|
|
|
case PlayerState.Hurt:
|
|
case PlayerState.Hurt:
|
|
|
if (hurtKeepTime <= 0)
|
|
if (hurtKeepTime <= 0)
|
|
|
{
|
|
{
|
|
|
- ChangeState(PlayerState.Idle);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnRushPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheRushTime = totalCacheRushTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnJumpPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheJumpTime = totalCacheJumpTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnWestPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheAttackTime = totalCacheAttackTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnNorthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnSouthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnEastPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 2;
|
|
|
|
|
|
|
+ if (CheckPlayerChangeState(state))
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ CachedPlayerInput();
|
|
|
if (!foot.TrigGround)
|
|
if (!foot.TrigGround)
|
|
|
{
|
|
{
|
|
|
rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
|
|
rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
|
|
@@ -550,77 +521,32 @@ public class PlayerController : MonoBehaviour
|
|
|
case PlayerState.Attack:
|
|
case PlayerState.Attack:
|
|
|
if (attackTime <= 0)
|
|
if (attackTime <= 0)
|
|
|
{
|
|
{
|
|
|
- ChangeState(PlayerState.Idle);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnRushPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheRushTime = totalCacheRushTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnJumpPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheJumpTime = totalCacheJumpTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnWestPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheAttackTime = totalCacheAttackTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnNorthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnSouthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnEastPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 2;
|
|
|
|
|
|
|
+ if (CheckPlayerChangeState(state))
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ CachedPlayerInput();
|
|
|
break;
|
|
break;
|
|
|
case PlayerState.Summon:
|
|
case PlayerState.Summon:
|
|
|
if (summonTime <= 0)
|
|
if (summonTime <= 0)
|
|
|
{
|
|
{
|
|
|
- ChangeState(PlayerState.Idle);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnRushPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheRushTime = totalCacheRushTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnJumpPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheJumpTime = totalCacheJumpTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnWestPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheAttackTime = totalCacheAttackTime;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnNorthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnSouthPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (btnEastPress)
|
|
|
|
|
- {
|
|
|
|
|
- cacheSummonTime = totalCacheSummonTime;
|
|
|
|
|
- cacheSummonId = 2;
|
|
|
|
|
|
|
+ if (CheckPlayerChangeState(state))
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
break;
|
|
break;
|
|
|
case PlayerState.Rush:
|
|
case PlayerState.Rush:
|
|
|
if (rushTime <= 0)
|
|
if (rushTime <= 0)
|
|
|
{
|
|
{
|
|
|
- ChangeState(PlayerState.Idle);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if (CheckPlayerChangeState(state))
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ CachedPlayerInput();
|
|
|
if (transform.localScale.x > 0)
|
|
if (transform.localScale.x > 0)
|
|
|
{
|
|
{
|
|
|
rb.velocity = Vector3.left * rushSpeed;
|
|
rb.velocity = Vector3.left * rushSpeed;
|
|
@@ -672,6 +598,7 @@ public class PlayerController : MonoBehaviour
|
|
|
switch (newState)
|
|
switch (newState)
|
|
|
{
|
|
{
|
|
|
case PlayerState.Idle:
|
|
case PlayerState.Idle:
|
|
|
|
|
+ airJumped = false;
|
|
|
bodyCollider.enabled = true;
|
|
bodyCollider.enabled = true;
|
|
|
jumpBodyCollider.enabled = false;
|
|
jumpBodyCollider.enabled = false;
|
|
|
if (oldState == PlayerState.Fall)
|
|
if (oldState == PlayerState.Fall)
|
|
@@ -776,7 +703,6 @@ public class PlayerController : MonoBehaviour
|
|
|
public void Summon(int id)
|
|
public void Summon(int id)
|
|
|
{
|
|
{
|
|
|
print("Summon:" + id);
|
|
print("Summon:" + id);
|
|
|
- ChangeState(PlayerState.Summon);
|
|
|
|
|
if (id >= demonicPrefabs.Count)
|
|
if (id >= demonicPrefabs.Count)
|
|
|
{
|
|
{
|
|
|
Debug.LogError("未配置" + id + "号使魔");
|
|
Debug.LogError("未配置" + id + "号使魔");
|