示例#1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (isConfused)
            {
                switch (random.Next(0, 3))
                {
                case 0:
                    confusedWalkBehavior.Walk(playerSpeed, left, right, up, down, playerPictureBox);
                    break;

                case 1:
                    confusedWalkBehavior2.Walk(playerSpeed, left, right, up, down, playerPictureBox);
                    break;

                case 2:
                    confusedWalkBehavior3.Walk(playerSpeed, left, right, up, down, playerPictureBox);
                    break;

                default:
                    break;
                }

                if (!confusionChecked)
                {
                    confusionChecked = true;
                    Task.Delay(new TimeSpan(0, 0, 2)).ContinueWith(o => { isConfused = false; confusionChecked = false; });
                }
            }
            else
            {
                normalWalkBehavior.Walk(playerSpeed, left, right, up, down, playerPictureBox);
            }
        }
 public void Walk()
 {
     m_WalkBehavior.Walk();
 }