private void UpdateTraction(PlayerPickupsModule pPickupsModule) { float fHookingTime = (float)(pPickupsModule.GetVariable(c_sVariableName_fGrapplingHookCurrentStepStartTime, 0.0f)); if (Time.time - fHookingTime < m_fTimeBetweenHookingAndTractionInSeconds) { return; // TODO: Add recoil here before traction } Transform pPlayerTransform = pPickupsModule.m_pMaster.transform; Vector3 tMoveThisFrame = pPlayerTransform.forward * (m_fTractionSpeed * Time.deltaTime); Vector3 tHookHeadPos = (Vector3)(pPickupsModule.GetVariable(c_sVariableName_tGrapplingHookTractionDestination)); Vector3 tHookToPlayer = pPlayerTransform.position - tHookHeadPos; if (tHookToPlayer.sqrMagnitude <= tMoveThisFrame.sqrMagnitude) { pPlayerTransform.position = tHookHeadPos; EffectEnd(pPickupsModule); } else { pPlayerTransform.position += tMoveThisFrame; } }
override public void UpdateEffect(PlayerPickupsModule pPickupsModule) { EGrapplingHookEffectStep eCurrentStep = (EGrapplingHookEffectStep)(pPickupsModule.GetVariable(c_sVariableName_eGrapplingHookCurrentStep, EGrapplingHookEffectStep.AWAITING_INPUT)); switch (eCurrentStep) { case EGrapplingHookEffectStep.AWAITING_INPUT: { if (Input.GetButtonDown(m_sShootInputName)) { InitAnticipation(pPickupsModule); } } break; case EGrapplingHookEffectStep.ANTICIPATION: { UpdateAnticipation(pPickupsModule); } break; case EGrapplingHookEffectStep.TRACTION: { UpdateTraction(pPickupsModule); } break; case EGrapplingHookEffectStep.ABORTED: { ResetVariablesAfterAbort(pPickupsModule); } break; } }
private void UpdateAnticipation(PlayerPickupsModule pPickupsModule) { Vector3 tShootDirection = Toolkit.QueryMoveDirectionInput(); if (tShootDirection != Vector3.zero) { pPickupsModule.m_pMaster.transform.forward = Toolkit.FlattenDirectionOnOneAxis(tShootDirection); } else { tShootDirection = pPickupsModule.m_pMaster.transform.forward; } float fInputPressTime = (float)(pPickupsModule.GetVariable(c_sVariableName_fGrapplingHookCurrentStepStartTime, 0.0f)); if (Time.time - fInputPressTime < m_fAnticipationDurationInSeconds) { return; // TODO: Add hand animation } Vector3 tHookDestination; bool bSuccess = ShootHookInDirection(pPickupsModule, tShootDirection, out tHookDestination); if (bSuccess) { InitTraction(pPickupsModule, tHookDestination); } else { AbortShot(pPickupsModule, tHookDestination); } }
private void InitAnticipation(PlayerPickupsModule pPickupsModule) { pPickupsModule.SetVariable(c_sVariableName_fGrapplingHookCurrentStepStartTime, Time.time); pPickupsModule.m_pMaster.SetBehaviourFrozen(true); GrapplingHook pHook = (GrapplingHook)(pPickupsModule.GetVariable(c_sVariableName_pGrapplingHookObject)); pPickupsModule.m_pMaster.m_pInventorySlotsModule.EquipItemInSlot(pHook.transform, EInventorySlot.HAND, false); pPickupsModule.SetVariable(c_sVariableName_eGrapplingHookCurrentStep, EGrapplingHookEffectStep.ANTICIPATION); }
override public void UpdateEffect(PlayerPickupsModule pPickupsModule) { float fStartTime = (float)(pPickupsModule.GetVariable(c_sVariableName_fSuperPelletStartTime, 0.0f)); float fElapsedTime = Time.time - fStartTime; GameManager.Instance.SuperPelletEffectAboutToWearOut = fElapsedTime >= (m_fEffectDurationInSeconds - m_fEffectEndWarningStartTimeFromEnd); if (fElapsedTime >= m_fEffectDurationInSeconds) { EffectEnd(pPickupsModule); } }
private void ResetVariablesAfterAbort(PlayerPickupsModule pPickupsModule) { GrapplingHook pHook = (GrapplingHook)(pPickupsModule.GetVariable(c_sVariableName_pGrapplingHookObject)); PutHookBackInBelt(pHook, pPickupsModule.m_pMaster); ResetVariables(pPickupsModule); pPickupsModule.SetVariable(c_sVariableName_pGrapplingHookObject, pHook); pPickupsModule.m_pMaster.SetBehaviourFrozen(false); pPickupsModule.SetVariable(c_sVariableName_eGrapplingHookCurrentStep, EGrapplingHookEffectStep.AWAITING_INPUT); }
override public void EffectEnd(PlayerPickupsModule pPickupsModule) { GrapplingHook pHook = (GrapplingHook)(pPickupsModule.GetVariable(c_sVariableName_pGrapplingHookObject)); Destroy(pHook.gameObject); ResetVariables(pPickupsModule); m_pSuperGhostKillEffect.DetachEffect(pPickupsModule.m_pMaster); pPickupsModule.RemoveActiveEffect(this); pPickupsModule.m_pMaster.SetBehaviourFrozen(false); pPickupsModule.m_pMaster.CanKillGhosts = false; }