Skip to content

Commit 1084527

Browse files
authored
修改下蹲执行逻辑
1. 按向下的方向键,提示已经在下蹲躲避状态中; 2. 按向上的方向键,回复站立状态;
1 parent 5aae3a3 commit 1084527

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Assets/Behavioral Patterns/State Pattern/Exmaple4/DuckingState.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ public void Update()
2222

2323
public void HandleInput()
2424
{
25-
if (Input.GetKeyUp(KeyCode.DownArrow))
25+
if (Input.GetKeyDown(KeyCode.DownArrow))
2626
{
27-
Debug.Log("get GetKeyUp.DownArrow!");
27+
Debug.Log("已经在下蹲躲避状态中!");
28+
return;
29+
}
30+
if (Input.GetKeyUp(KeyCode.UpArrow))
31+
{
32+
Debug.Log("get GetKeyUp.UpArrow!");
2833
_heroine.SetHeroineState(new StandingState(_heroine));
2934
}
3035
}

0 commit comments

Comments
 (0)