public void performAction(RobotAction action)
        {
            if (isOnLastMove)
            {
                Debug.Log("Robot is already at End");
                return;
            }
            m_playerIsMoving = true;
            m_currentAction = action;

            if (action.actionType == RobotActionType.StaggerLeft||action.actionType == RobotActionType.StaggerRight)
            {
                m_playerIsMoving = false;
                return;
            }

            if (m_stepPossible[m_currentStep])
            {
                // when the step is possible..
                if (action.actionType != RobotActionType.Jump)
                {
                    m_currentStep += 1;
                }
                else m_playerIsMoving = false;
            }
            else
            {
                // when the step is impossible..
                if (action.actionType == RobotActionType.Jump)
                {
                    m_currentStep += 1;
                }
                else m_playerIsMoving = false;
            }
        }
        public void Update()
        {
            if (m_currentAction != null)
            {
                m_currentAction.timeRemaining -= Time.deltaTime;
                if (m_currentAction.timeRemaining < 0)
                {
                    m_currentAction.timeRemaining = 0;
                }

                if (m_playerIsMoving)
                {
                    float t = 1 - (m_currentAction.timeLength - m_currentAction.timeRemaining)/m_currentAction.timeLength;
                    m_transform.position = Vector3.Lerp(m_steps[m_currentStep], m_steps[m_currentStep - 1], t);
                }

                if (m_currentAction.timeRemaining == 0)
                {
                    m_previousAction = m_currentAction;
                    m_currentAction = null;
                    OnMoveEnd();
                }
            }
        }
 public void PlayAnimation(RobotAction animation)
 {
     m_CurrentAnimation = animation;
         TriggerAnimation(m_CurrentAnimation.actionType);
 }
Beispiel #4
0
        private void Update()
        {
            distanceTraveled = distanceToTravel + Vector3.Distance(transform.position, m_endposition);

            // [TODO] Remove Action Preview
            if (m_nextAction != null)
            {
                m_previewAction = m_nextAction;
            }

            m_Timer = m_timeBeforeNextAction;
            if (m_nextAction != null)
            {
                m_timeBeforeNextAction -= Time.deltaTime;

                if (m_timeBeforeNextAction <= 0)
                {
                    m_isLeftButtonPressed = false;
                    m_isRightButtonPressed = false;

                    m_IsPlayingAnimation = true;
                    if (m_previousAction != null)
                    {
                        if (m_nextAction.actionType == m_previousAction.actionType)
                        {
                            if (m_previousAction.actionType == RobotActionType.StepLeft)
                            {
                                m_nextAction = new RobotAction(m_AnimationTimeStagger, RobotActionType.StaggerLeft);
                            }
                            else m_nextAction = new RobotAction(m_AnimationTimeStagger, RobotActionType.StaggerRight);
                        }
                    }
                    m_robotAnimation.PlayAnimation(m_nextAction);
                    m_robotMove.performAction(m_nextAction);
                    if (m_nextAction.actionType == RobotActionType.StepRight || m_nextAction.actionType == RobotActionType.StepLeft)
                    {
                        m_previousAction = m_nextAction;
                    }
                    m_previewAction = m_nextAction;
                    m_nextAction = null;
                    if (OnActionStart != null)
                    OnActionStart.Invoke();
                }
            }

            m_robotMove.Update();
            m_robotAnimation.Update();
        }
Beispiel #5
0
        private void AddAction(RobotAction action)
        {
            if (m_nextAction == null) ResetTimer();

            if (m_robotMove.nextMovePossible)
            {
                if (action.actionType == RobotActionType.StepLeft)
                {
                    if (m_isRightButtonPressed)
                    {
                        m_nextAction = new RobotAction(m_AnimationTimeJump, RobotActionType.Jump);
                    }
                    else
                    {
                        m_nextAction = new RobotAction(m_AnimationTimeStep, RobotActionType.StepLeft);
                    }
                }
                else
                {
                    if (m_isLeftButtonPressed)
                    {
                        m_nextAction = new RobotAction(m_AnimationTimeJump, RobotActionType.Jump);
                    }
                    else
                    {
                        m_nextAction = new RobotAction(m_AnimationTimeStep, RobotActionType.StepRight);
                    }
                }
            }
            else
            {
                if (action.actionType == RobotActionType.StepLeft)
                {
                    if (m_isRightButtonPressed)
                    {
                        m_nextAction = new RobotAction(m_AnimationTimeJump, RobotActionType.Jump);
                    }
                    else
                    {
                        m_nextAction = m_previousAction;
                    }
                }
                else
                {
                    if (m_isLeftButtonPressed)
                    {
                        m_nextAction = new RobotAction(m_AnimationTimeJump, RobotActionType.Jump);
                    }
                    else
                    {
                        m_nextAction = m_previousAction;
                    }
                }
            }
        }
Beispiel #6
0
 public void MoveRight()
 {
     if (m_IsPlayingAnimation) return;
     m_isRightButtonPressed = true;
     RobotAction input = new RobotAction(m_AnimationTimeStep, RobotActionType.StepRight);
     AddAction(input);
 }