예제 #1
0
        public void Move()
        {
            var world = GameService.GetService <World>();

            if (stepCount > maxSteps)
            {
                Stop();
            }

            if (currentState == State.MOVING)
            {
                Vector2 stepPosition = getStep();
                stepCount += 1;

                if (world.Contains(stepPosition))
                {
                    moveable.ChangePosition(stepPosition);
                }
                else
                {
                    Stop();
                }
            }

            if (currentState == State.IDLE || currentState == State.STOPPED)
            {
                targetPosition = getTarget();
                currentState   = State.MOVING;
            }
        }