예제 #1
0
        public override void UpdateState()
        {
            float horizontalInput = Input.GetAxis("Horizontal");
            float verticalInput = Input.GetAxis("Vertical");
            int   x, y;

            if (horizontalInput < -0.0f)
            {
                x = -1;
            }
            else if (horizontalInput > 0.0f)
            {
                x = 1;
            }
            else
            {
                x = 0;
            }
            if (verticalInput < -0.0f)
            {
                y = -1;
            }
            else if (verticalInput > 0.0f)
            {
                y = 1;
            }
            else
            {
                y = 0;
            }
            batter.SetAim(x, y);
        }
예제 #2
0
        public override void MakeDecisions()
        {
            int  horizontal = ((Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) ? 1 : 0) - ((Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) ? 1 : 0);
            int  vertical   = ((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) ? 1 : 0) - ((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) ? 1 : 0);
            bool swing      = Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.LeftShift);

            batter.SetAim(horizontal, vertical);
            if (swing)
            {
                batter.Swing(horizontal, vertical);
            }
        }