private void ResetVariables(PlayerPickupsModule pPickupsModule)
 {
     pPickupsModule.ResetVariable(c_sVariableName_eGrapplingHookCurrentStep);
     pPickupsModule.ResetVariable(c_sVariableName_fGrapplingHookCurrentStepStartTime);
     pPickupsModule.ResetVariable(c_sVariableName_pGrapplingHookObject);
     pPickupsModule.ResetVariable(c_sVariableName_tGrapplingHookTractionDestination);
 }
    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);
        }
    }
    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 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;
        }
    }
    private void InitHookObject(PlayerPickupsModule pPickupsModule)
    {
        GrapplingHook pHook = Instantiate(m_pHookPrefab);

        pPickupsModule.m_pMaster.m_pInventorySlotsModule.EquipItemInSlot(pHook.transform, EInventorySlot.BELT, false);

        pPickupsModule.SetVariable(c_sVariableName_pGrapplingHookObject, pHook);
    }
Esempio n. 6
0
    override public void EffectEnd(PlayerPickupsModule pPickupsModule)
    {
        GhostsManager.Instance.ResetGhostsToNormalBehaviour();
        pPickupsModule.RemoveActiveEffect(this);
        PlayerCharacter.Instance.CanKillGhosts = false;
        PlayerCharacter.Instance.m_pNavMeshObstacle.carving = false;

        GameManager.Instance.SuperPelletEffectAboutToWearOut = false;
    }
    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);
    }
Esempio n. 8
0
    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 InitTraction(PlayerPickupsModule pPickupsModule, Vector3 tHookDestination)
    {
        PlayerCharacter pPlayer = pPickupsModule.m_pMaster;

        pPlayer.CanKillGhosts = true;
        m_pSuperGhostKillEffect.HookEffect(pPickupsModule.m_pMaster);

        pPickupsModule.SetVariable(c_sVariableName_tGrapplingHookTractionDestination, tHookDestination);
        pPickupsModule.SetVariable(c_sVariableName_fGrapplingHookCurrentStepStartTime, Time.time);

        pPickupsModule.SetVariable(c_sVariableName_eGrapplingHookCurrentStep, EGrapplingHookEffectStep.TRACTION);
    }
    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);
    }
Esempio n. 11
0
    override public void GiveEffectToPlayer(PlayerPickupsModule pPickupsModule)
    {
        pPickupsModule.RegisterPelletCollect();
        pPickupsModule.SetVariable(c_sVariableName_fSuperPelletStartTime, Time.time);
        GhostsManager.Instance.GiveFleeBehaviourToGhosts();

        if (!pPickupsModule.HasActiveEffect(this))
        {
            pPickupsModule.GiveActiveEffect(this);
            PlayerCharacter.Instance.CanKillGhosts = true;
            PlayerCharacter.Instance.m_pNavMeshObstacle.carving = true;                         // So ghosts won't try to get through the player when trying to go away from him
        }
    }
    override public void GiveEffectToPlayer(PlayerPickupsModule pPickupsModule)
    {
        if (pPickupsModule.HasActiveEffect(this))
        {
            return;
        }

        pPickupsModule.GiveActiveEffect(this);

        ResetVariables(pPickupsModule);
        InitHookObject(pPickupsModule);

        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;
    }
    private bool ShootHookInDirection(PlayerPickupsModule pPickupsModule, Vector3 tDirection, out Vector3 tHitPos)
    {
        /*		Abort player's movement		*/
        PlayerCharacter pPlayer = pPickupsModule.m_pMaster;

        pPlayer.SetCurrentTileTarget(null);
        pPlayer.ClearInputsTileTarget();


        RaycastHit tHit;

        if (!Physics.Raycast(pPickupsModule.m_pMaster.transform.position + (Vector3.up * 0.5f), tDirection, out tHit, m_fMaxShootDistance, LayerMask.GetMask("Wall", "Ghost"), QueryTriggerInteraction.Collide))
        {
            tHitPos = pPickupsModule.m_pMaster.transform.position + (tDirection * m_fMaxShootDistance);
            return(false);
        }

        tHitPos = tHit.point - (Vector3.up * 0.5f);

        if (tHit.collider.gameObject.layer == LayerMask.NameToLayer("Wall"))
        {
            Tile pActualTileDestination = MapManager.Instance.GetTileFromPosition(tHitPos - (tDirection * 0.1f));
            Tile pCurrentTile           = MapManager.Instance.GetTileFromPosition(pPickupsModule.m_pMaster.transform.position);

            if (pActualTileDestination == pCurrentTile)
            {
                return(false);
            }

            tHitPos = pActualTileDestination.transform.position;
        }
        else
        {
            Ghost pHitGhost = tHit.collider.GetComponent <Ghost>();
            Assert.IsTrue(pHitGhost != null, "The grappling hook hit something (" + tHit.collider.name + ") that is not a wall but not a ghost either? Something's wrong!");

            pHitGhost.SetBehaviourFrozen(true);

            tHitPos += (tDirection * 0.6f);             // To make sure we get through without dying first
        }

        PinHookToDestination(pPickupsModule.m_pMaster, tHitPos);

        return(true);
    }
Esempio n. 15
0
 abstract public void GiveEffectToPlayer(PlayerPickupsModule pPickupsModule);
Esempio n. 16
0
 public void GivePointsToPlayer(PlayerPickupsModule pPickupsModule)
 {
     pPickupsModule.GivePoints(m_iPointsWorth);
 }
    private void AbortShot(PlayerPickupsModule pPickupsModule, Vector3 tHookDestination)
    {
        pPickupsModule.SetVariable(c_sVariableName_eGrapplingHookCurrentStep, EGrapplingHookEffectStep.ABORTED);

        PinHookToDestination(pPickupsModule.m_pMaster, tHookDestination);               // Just show the hook for a frame, for visual feedback on why it's got aborted
    }
Esempio n. 18
0
 /// <summary>
 /// Empty by default
 /// </summary>
 virtual public void UpdateEffect(PlayerPickupsModule pPickupsModule)
 {
 }
Esempio n. 19
0
 /// <summary>
 /// Has to be called by children!
 /// </summary>
 virtual public void EffectEnd(PlayerPickupsModule pPickupsModule)
 {
     pPickupsModule.RemoveActiveEffect(this);
 }
Esempio n. 20
0
 override public void GiveEffectToPlayer(PlayerPickupsModule pPickupsModule)
 {
     pPickupsModule.RegisterPelletCollect();
     // Doesn't do anything else, shouldn't give itself to the module for update or anything
 }