예제 #1
0
    public void FActivate()
    {
        PC_Controller pc   = FindObjectOfType <PC_Controller>();
        PLY_SnapSpot  snap = FindObjectOfType <PLY_SnapSpot>();

        mPosToSnapTo    = pc.transform.position;
        mPosToSnapTo.y += 20f;
        if (pc.transform.position.z > snap.transform.position.z)
        {
            mPosToSnapTo.z += 15f;
        }
        else
        {
            mPosToSnapTo.z -= 15f;
        }
        transform.position = pc.GetComponentInChildren <PC_Camera>().transform.position;

        pc.GetComponentInChildren <Camera>().enabled        = false;
        pc.GetComponentInChildren <AudioListener>().enabled = false;
        cCam.enabled = true;
        GetComponent <AudioListener>().enabled = true;

        pc.mState = PC_Controller.PC_STATE.SINACTIVE;
        mState    = CAM_STATE.SACTIVE;
    }
예제 #2
0
    // This should be called ~0.5 seconds after FDeactivate, every time.
    private void TrueDeactivate()
    {
        cCam.enabled = false;
        GetComponent <AudioListener>().enabled = false;
        PC_Controller pc = FindObjectOfType <PC_Controller>();

        pc.GetComponentInChildren <Camera>().enabled        = true;
        pc.GetComponentInChildren <AudioListener>().enabled = true;

        mState = CAM_STATE.SINACTIVE;
    }
예제 #3
0
    void OnDestroy()
    {
        Instantiate(PF_PartAndSFX, transform.position, transform.rotation);
        PC_Controller refPC = FindObjectOfType <PC_Controller>();

        if (refPC == null)
        {
            return;
        }
        refPC.GetComponentInChildren <Camera>().enabled        = true;
        refPC.GetComponentInChildren <AudioListener>().enabled = true;
    }
예제 #4
0
    private void ENTER_INSTRUCTIONS()
    {
        Cursor.lockState = CursorLockMode.Locked;

        MN_PauseScreen.SetActive(false);
        refUI.gameObject.SetActive(false);
        refInstrUI.SetActive(true);
        refScoreboardUI.SetActive(false);

        mGameState = PP_GAME_STATE.CHILLING;
        mState     = PP_State.DISPLAY_INSTRUCTIONS;

        // Note, this needs to be polished, the rotations can get wonky.
        refPC.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
        refPC.GetComponentInChildren <PC_Camera>().transform.rotation = Quaternion.Euler(0f, 0f, 0f);
        refPC.mState = PC_Controller.PC_STATE.SINACTIVE;
        refPC.GetComponent <Rigidbody>().velocity = Vector3.zero;

        // this is kind of to solve a bug with respect to throwing.
        TDC_EventManager.FBroadcast(TDC_GE.GE_QB_StopThrow);

        DestroyExistingProjectilesArrowsAndDeactivateTurrets();
        // Also destroy all footballs
        PROJ_Football[] refFootballs = FindObjectsOfType <PROJ_Football>();
        for (int i = 0; i < refFootballs.Length; i++)
        {
            Destroy(refFootballs[i].gameObject);
        }
    }
예제 #5
0
    private void ENTER_OUTRO()
    {
        mState = STATE.S_OUTRO;

        mUI.rOutroCanvas.gameObject.SetActive(true);
        mUI.FSetOutroText(mScore, mNumThrows);
        rPC.GetComponentInChildren <Camera>().enabled        = false;
        rPC.GetComponentInChildren <AudioListener>().enabled = false;
        rPC.mState = PC_Controller.PC_STATE.SINACTIVE;
        FindObjectOfType <CAM_Outro>().FActivate();

        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        FindObjectOfType <QB_UI>().gameObject.SetActive(false);
    }
예제 #6
0
    public void FDeactivate()
    {
        PC_Controller pc = FindObjectOfType <PC_Controller>();

        mPosToSnapTo = pc.GetComponentInChildren <PC_Camera>().transform.position;
        pc.mState    = PC_Controller.PC_STATE.SPRE_SNAP;
        mState       = CAM_STATE.S_DEACTIVATING;     // maybe not the best name
    }
예제 #7
0
    private void RUN_ReadQBEyes()
    {
        PC_Controller rPC        = FindObjectOfType <PC_Controller>();
        Vector3       vPlayerDir = rPC.GetComponentInChildren <PC_Camera>().transform.forward;

        // now we stay relatively close to our zone spot, but we "cheat" a little towards where the player is looking.
        // I can just assume that the depth should stay the same, for now.
        // also, if they aren't even looking close to us, don't do anything.
        Vector3 vDisPlayerToZone = mZoneSpot - rPC.transform.position;
        float   fDot             = Vector3.Dot(Vector3.Normalize(vDisPlayerToZone), vPlayerDir);

        if (fDot < 0.8f)
        {
            Vector3 dis = mZoneSpot - transform.position;
            dis.y = 0f;
            Vector3 disNorm = Vector3.Normalize(dis);

            Vector3 vAcc = cAcc.FCalcAccFunc(disNorm, cAcc.mSpd);
            cRigid            = cAth.FApplyAccelerationToRigidbody(cRigid, vAcc, cAcc.mSpd);
            transform.forward = cRigid.velocity.normalized;
        }
        else
        {
            Vector3 vCheatSpot = rPC.transform.position + vDisPlayerToZone.magnitude * vPlayerDir;
            // can't cheat too much here.
            float fCheatDis = (vDisPlayerToZone.magnitude / 10f) * 2f;      // every 10 yards, you can cheat x more yards.
            if (Vector3.Distance(vCheatSpot, mZoneSpot) > fCheatDis)
            {
                Vector3 vDisToCheatSpot = vCheatSpot - mZoneSpot;
                vCheatSpot = mZoneSpot + vDisToCheatSpot.normalized * 2f;
            }
            Vector3 dis     = vCheatSpot - transform.position; dis.y = 0f;
            Vector3 disNorm = Vector3.Normalize(dis);

            // ------- need to, just like catching, prematurely slow down if going too fast.
            // ------- Turns out, we need to know how quickly we can decelerate, or we can't calc this.
            // ------- Update. Just pretend that they need to be there in 0.2 seconds.
            Vector3 vAcc    = new Vector3();
            float   fDotVel = Vector3.Dot(cRigid.velocity, dis);
            if (fDotVel > 0f)        // otherwise time is infinite.
            {
                float   fTime     = 0.2f;
                Vector3 vIdealVel = dis / fTime;
                Vector3 vAccDir   = vIdealVel - cRigid.velocity;
                vAccDir = Vector3.Normalize(vAccDir);
                vAcc    = cAcc.FCalcAccFunc(vAccDir, cAcc.mSpd / 2f);
            }
            else
            {
                vAcc = cAcc.FCalcAccFunc(disNorm, cAcc.mSpd / 2f);
            }
            // pretend that strafing speed is a lot lower.
            cRigid            = cAth.FApplyAccelerationToRigidbody(cRigid, vAcc, cAcc.mSpd / 2f);
            transform.forward = vDisPlayerToZone.normalized;
        }

        float fDepth = vDisPlayerToZone.magnitude;

        if (cAth.FCheckIfBallThrown())
        {
            ENTER_TryCatchBall();
        }
    }