// force player to die public void Kill() { // die ! m_life = 0; m_player.IsControlled = true; // prevent any more action from player // play animation if exists m_player.PlayAnim(m_animDie); // Request restart of level StartCoroutine("RestartLevel"); }
public void RefreshAnimations(APCharacterController character) { AttackContext ctx = GetCurrentContext(character); if (ctx != null && ctx.m_enabled) { // Handle aim sub context properly AttackContextAim ctxAim = ctx as AttackContextAim; if (ctxAim != null) { character.PlayAnim(character.IsRunning() && ctxAim.m_animRun.IsValid() ? ctxAim.m_animRun : ctxAim.m_anim); } else { // keep default set of animation if not overrided by each attack if (ctx.m_anim.IsValid()) { character.PlayAnim(ctx.m_anim); } } } }
void Update() { // Early exits if (!m_player || !m_player.enabled || m_player.IsControlled) { return; } // Check if player is in valid state if (m_player.GetState() != APCharacterController.State.Standard) { return; } // Check inputs and update animation according to this APAnimation anim = m_targetFront; bool bFront = Mathf.Abs(m_player.m_inputs.m_axisX.GetValue()) > 0f; bool bUp = m_player.m_inputs.m_axisY.GetValue() > 0f; bool bDown = m_player.m_inputs.m_axisY.GetValue() < 0f; if (bFront) { if (bUp) { anim = m_targetFrontUp; } else if (bDown) { anim = m_targetFrontDown; } } else if (bUp) { anim = m_targetUp; } else if (bDown) { anim = m_targetDown; } // Use front running animation if needed if ((anim == m_targetFront) && m_player.IsRunning() && (m_targetFrontRun.GetAnimHash() != 0)) { anim = m_targetFrontRun; } m_player.PlayAnim(anim); }
// force player to die public void Kill() { // die ! m_life = 0f; m_player.IsControlled = true; // prevent any more action from player m_refreshGui = true; // play animation if exists if (!string.IsNullOrEmpty(m_animDie)) { m_player.PlayAnim(m_animDie); } // Request restart of level StartCoroutine("RestartLevel"); }
void StartGrab(APCharacterController controlled, APAnimation anim, Vector2 grabHandle) { ClearRuntimeValues(); m_controlled = controlled; m_controlled.IsControlled = true; // Init handle to grab m_curGrabHandle = transform.TransformPoint(grabHandle); MatchGrabAnchor(); // start anim & reset velocity m_controlled.GetMotor().m_velocity = Vector2.zero; InitPhysAnimation(m_curGrabHandle); m_controlled.PlayAnim(anim); // launch events m_controlled.EventListeners.ForEach(e => e.OnEdgeGrabStart(this)); }
void FixedUpdate() { if (m_controlled) { // always stay on anchor every frame MatchGrabAnchor(); // check if currently exiting if (m_isClimbUpExit) { // wait for end of character animation float fClimbUpExitAnimTime = m_controlled.GetAnim().GetCurrentAnimatorStateInfo(0).normalizedTime; // raise exit power if needed if (m_exitClimbUp.m_maxExitPower > 0f && fClimbUpExitAnimTime >= m_exitClimbUp.m_maxExitPowerAnimTime) { float fClampedInput = GetClampedInput(); m_curExitPower += Time.deltaTime * Time.deltaTime * m_exitClimbUp.m_maxExitPower * fClampedInput; } if (fClimbUpExitAnimTime >= 1f) { // leave control m_isClimbUpExit = false; ReleaseControl(ExitType.ClimbExit); } return; } // do not exit too quickly (wait end of animation in all case) float fAnimTime = m_controlled.GetAnim().GetCurrentAnimatorStateInfo(0).normalizedTime; if ((Time.time - m_grabTime < m_minGrabTime) || fAnimTime < 1f) { return; } // snap to in air handle if grabbing from top and animation is ended (and stop physic animation) /*if (m_bIsGrabbingFromTop && m_controlled.GetAnim().GetCurrentAnimatorStateInfo(0).normalizedTime >= 1f) * { * m_bPhysicAnim = false; * m_bIsGrabbingFromTop = false; * m_curGrabHandle = transform.TransformPoint(m_grabInAir.m_handle); * }*/ // check input for leaving this state is pushed or script is disabled float xValue = m_controlled.m_inputs.m_axisX.GetValue(); float yValue = m_controlled.m_inputs.m_axisY.GetValue(); if (!enabled || (m_controlled.IsFacingRight() && xValue < -m_inputExitBack) || (m_controlled.IsFacingRight() && xValue > m_inputExitFront) || (!m_controlled.IsFacingRight() && xValue > m_inputExitBack) || (!m_controlled.IsFacingRight() && xValue < -m_inputExitFront) || (yValue < -m_inputExitDown)) { ReleaseControl(ExitType.Inputs); } // jump exit else if (m_jumpExit && m_controlled.m_jump.m_button.GetButtonDown()) { ReleaseControl(ExitType.Jump); } else { // handle climb up exit if (m_exitClimbUp.m_enabled && m_exitClimbUp.m_button.IsSpecified() && m_exitClimbUp.m_button.GetButton()) { m_isClimbUpExit = true; // launch player physic exit animation InitPhysAnimation(transform.TransformPoint(m_grabInAir.m_handle)); m_controlled.PlayAnim(m_exitClimbUp.m_anim); } } } }
void StartAnimation(string sAnim) { m_controlled.PlayAnim(sAnim, 0f); }