예제 #1
0
    public void OnSnap()
    {
        mActive = true;

        refRusher = FindObjectOfType <AI_Rusher>();
        refPlayer = FindObjectOfType <PC_Controller>();
    }
예제 #2
0
    public void RUN_Engage(OFF_BlockLog rBlocker, PC_Controller rPC)
    {
        cRigid.velocity = Vector3.zero;
        if (Time.time - mLastMoveTime > mMoveCooldown)
        {
            // alright now we try to beat the blocker.
            mLastMoveTime = Time.time;

            if (FuncCalcMoveSuccess(mMoveScore, rBlocker.mMoveDefMin, rBlocker.mMoveDefMax))
            {
                rBlocker.FGetFinessed();
                Vector3 vNewPos = transform.position;
                // here we want to know if we should go to our left, or our right.
                if (FuncGoRight(transform.right, transform.position, rPC.transform.position))
                {
                    vNewPos += transform.right * 1f;
                }
                else
                {
                    vNewPos += transform.right * -1f;
                }
                transform.position = vNewPos;
            }
        }

        transform.forward = Vector3.Normalize(rBlocker.transform.position - transform.position);
    }
예제 #3
0
    private void Start()
    {
        TDC_EventManager.FAddHandler(TDC_GE.GE_PP_SackBallHit, E_SackBallHitPlayer);
        TDC_EventManager.FAddHandler(TDC_GE.GE_QB_ReleaseBall, E_BallThrown);
        TDC_EventManager.FAddHandler(TDC_GE.GE_BallHitGround, E_BallHitGround);
        TDC_EventManager.FAddHandler(TDC_GE.GE_InPocket, E_StepIntoPocket);
        TDC_EventManager.FAddHandler(TDC_GE.GE_OutPocket, E_StepOutOfPocket);
        TDC_EventManager.FAddHandler(TDC_GE.GE_PP_TargetHit, E_TargetHit);

        cTurMan   = GetComponent <PP_Man_Tur>();
        cTargMan  = GetComponent <PP_Man_Targ>();
        cArrMan   = GetComponent <PP_Man_Arr>();
        cTrophMan = GetComponent <PP_Man_Trophy>();
        cAud      = GetComponent <AD_PP>();

        refPC = FindObjectOfType <PC_Controller>();

        ENTER_INSTRUCTIONS();

        // ------------------------------
        if (mSaveCurrent)
        {
            lDifData = IO_PP_Dif.FGetCurrent(lDifData.mName);
            IO_PP_Dif.FSaveCurrent(lDifData);
        }
        lDifData = IO_PP_Dif.FLoadDifficulty(IO_PP_Dif.mDif);
        SetUpDifficulty();
    }
예제 #4
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;
    }
예제 #5
0
    private void ENTER_GAMING()
    {
        Cursor.lockState = CursorLockMode.Locked;

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

        refUI.gameObject.SetActive(true);

        // testing this bug.
        Time.timeScale = 1f;

        // Activate all the turrets and the pc in the scene.
        cTurMan.FActivateTurrets();

        PC_Controller refPC = FindObjectOfType <PC_Controller>();

        refPC.mState = PC_Controller.PC_STATE.SACTIVE;
        Vector3 vPCPos = FindObjectOfType <PP_Pocket>().transform.position;

        vPCPos.y = 1f;
        refPC.transform.position = vPCPos;

        mScore = 0;
        ChangeScore(0);     // ah side effects, lovely aren't they?
        mStreak      = 0;
        mStreakBonus = 1;

        mTimeLeft = mGameTime;

        cTargMan.FDeactivateReceiver();
    }
예제 #6
0
 private void Start()
 {
     sprite     = transform.Find("Sprite").gameObject;
     controller = GetComponent <PC_Controller>();
     collider2D = GetComponent <BoxCollider2D>();
     rb         = GetComponent <Rigidbody2D>();
     isHide     = false;
 }
예제 #7
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
    }
예제 #8
0
    // Now rushing in an arc.
    public void RUN_FreeRun(PC_Controller rPC)
    {
        transform.forward = FuncAngleToSpot(transform.position, rPC.transform.position);
        Vector3 vDis = rPC.transform.position - transform.position;

        vDis            = Vector3.Normalize(vDis);
        cRigid.velocity = vDis;
    }
예제 #9
0
    // We just straight up run to the quarterback.
    public void FRunRush()
    {
        // -------------------- We always need references to all the blockers, as well as the PC.
        PC_Controller rPC = FindObjectOfType <PC_Controller>();

        if (rPC == null)
        {
            cRigid.velocity = Vector3.zero;
            return;
        }

        // ------------------ Tackle the QB. Shouldn't work if the ball has not been thrown yet.
        Vector3 vDis = rPC.transform.position - transform.position;

        // Debug.DrawLine(rPC.transform.position, transform.position, Color.green);
        if (vDis.magnitude < 1f)
        {
            TDC_EventManager.FBroadcast(TDC_GE.GE_Sack);
            return;
        }

        PRAC_Off_Ply[]      athlets  = FindObjectsOfType <PRAC_Off_Ply>();
        List <OFF_BlockLog> blockers = new List <OFF_BlockLog>();

        foreach (PRAC_Off_Ply a in athlets)
        {
            if (a.mRole == "BLOCK")
            {
                blockers.Add(a.GetComponent <OFF_BlockLog>());
            }
        }
        if (blockers.Count == 0)
        {
            RUN_FreeRun(rPC);
            return;
        }


        // ---------------- Okay, now we see if there is a guy blocking us.
        // For now just pick the closest one to us.
        OFF_BlockLog closestBlocker = FuncClosestBlocker(blockers, transform.position);
        float        fDisToBlocker  = Vector3.Distance(transform.position, closestBlocker.transform.position);
        bool         blockerInFront = FuncBlockerInFront(transform.position, closestBlocker.transform.position, transform.forward);

        if (fDisToBlocker < mEngageDis && closestBlocker.mState != OFF_BlockLog.STATE.S_Stunned && blockerInFront)
        {
            RUN_Engage(closestBlocker, rPC);
        }
        else if (blockerInFront)
        {
            RUN_RushLane(rPC);
        }
        else
        {
            RUN_FreeRun(rPC);
        }
    }
예제 #10
0
    void OnTriggerEnter(Collider col)
    {
        //Find the class of the Playable Character when colliding with it
        PC_Controller Pc = col.gameObject.GetComponent <PC_Controller>();

        if (Pc)
        {
            Won = true;
        }
    }
예제 #11
0
    private void Start()
    {
        mCam = GetComponent <Camera>();
        if (!mCam)
        {
            Debug.Log("No Cam Found");
        }

        mCont = GetComponentInParent <PC_Controller>();
    }
예제 #12
0
    private void RUN_RushLane(PC_Controller rPC)
    {
        Vector3 vDirToSnap   = FuncAngleToSpot(transform.position, rSnapSpot); vDirToSnap.y = 0f;
        Vector3 vDirToQB     = FuncAngleToSpot(transform.position, rPC.transform.position); vDirToQB.y = 0f;
        Vector3 vSnapQbCross = Vector3.Cross(vDirToSnap, vDirToQB);     // will be either straight up or straight down.
        Vector3 vRushDir     = Vector3.Cross(vDirToSnap, vSnapQbCross) * -1f;

        // cRigid.velocity = vDirToSnap.normalized;
        cRigid.velocity = vRushDir.normalized * 2f;
        Debug.DrawLine(transform.position, (transform.position + vRushDir), Color.red);
    }
예제 #13
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;
    }
예제 #14
0
    void Start()
    {
        mPoints = new Vector3[10];
        for (int i = 0; i < 20; i++)
        {
            Instantiate(PF_PointSphere, transform.position, transform.rotation);
        }
        mSpheres = FindObjectsOfType <GFX_UI_Traj>();
        Debug.Log("Length: " + mSpheres.Length);

        rQB = FindObjectOfType <PC_Controller>();
    }
예제 #15
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;
    }
예제 #16
0
    void OnTriggerEnter(Collider col)
    {
        #region get PC reference
        //Find the class of the Playable Character when colliding with it
        PC_Controller PC = col.gameObject.GetComponent <PC_Controller>();

        #endregion get PC reference

        #region if the Dragon catches the Playable Character, transition to the Lose screen
        if (PC)
        {
            levelManager.changeScene("Lose");
        }
        #endregion if the Dragon catches the Playable Character, transition to the Lose screen
    }
예제 #17
0
    void Start()
    {
        mUI          = GetComponent <RP_UI>();
        cRouteDrawer = GetComponent <RP_DrawRoutes>();

        mSet = IO_RP.FLoadSet("Slants");

        // Unfortunately, the destroyed receivers and hoops are still around, so we can't get references this frame.
        // Instead, do this on exitIntro.
        rPC     = FindObjectOfType <PC_Controller>();
        rPocket = FindObjectOfType <RP_ThrowSpot>();

        TDC_EventManager.FAddHandler(TDC_GE.GE_BallHitGround, E_BallHitGround);
        TDC_EventManager.FAddHandler(TDC_GE.GE_InPocket, E_PocketEntered);
        TDC_EventManager.FAddHandler(TDC_GE.GE_OutPocket, E_PocketExited);
        TDC_EventManager.FAddHandler(TDC_GE.GE_QB_ReleaseBall, E_BallThrown);
        TDC_EventManager.FAddHandler(TDC_GE.GE_BallCaught_Rec, E_BallCaught_Rec);

        mCompletions = new List <string>();
        ENTER_INTRO();
    }
예제 #18
0
    void OnTriggerEnter(Collider col)
    {
        #region get the Playable Character
        PC_Controller PC = col.gameObject.GetComponent <PC_Controller>();

        #endregion get PC reference

        #region if the Playable Character is there when the powerup gets hit, boost its speed
        if (PC)
        {
            //call the boostSpeed function from the Playable Character
            PC.BoostSpeed();

            //play sound
            AudioSource.PlayClipAtPoint(boostSound, transform.position);

            //destroy the boost powerup
            Destroy(gameObject);
        }
        #endregion if the Playable Character is there when the powerup gets hit, boost its speed
    }
    void OnTriggerEnter(Collider col)
    {
        #region get PC reference
        //Find the class of the Playable Character when colliding with it
        PC_Controller PC = col.gameObject.GetComponent <PC_Controller>();

        #endregion get PC reference

        #region if the Playable Character is there when the coin gets hit, the score is increased and the coin is destroyed
        if (PC)
        {
            //call the increaseScore function from the score manager to add to the score
            scoreManager.increaseScore(points);

            //play coin sound
            AudioSource.PlayClipAtPoint(coinSound, transform.position);

            //destroy coin gameObject
            Destroy(gameObject);
        }
        #endregion if the Playable Character is there when the coin gets hit, the score is increased and the coin is destroyed
    }
예제 #20
0
 // Use this for initialization
 void Start()
 {
     CC_Controller = GetComponent <PC_Controller>();
 }
예제 #21
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();
        }
    }
예제 #22
0
    private void ENTER_SCORESCREEN()
    {
        bool bNewHighScore = false;

        if (lDifData.mName == "EASY")
        {
            if (IO_GamerInfo.mInfo.mPPHighScores.mEasyScore < mScore)
            {
                IO_GamerInfo.mInfo.mPPHighScores.mEasyScore = mScore;
                bNewHighScore = true;
            }
        }
        else if (lDifData.mName == "NORMAL")
        {
            if (IO_GamerInfo.mInfo.mPPHighScores.mNormalScore < mScore)
            {
                IO_GamerInfo.mInfo.mPPHighScores.mNormalScore = mScore;
                bNewHighScore = true;
            }
        }
        else if (lDifData.mName == "HARD")
        {
            if (IO_GamerInfo.mInfo.mPPHighScores.mHardScore < mScore)
            {
                IO_GamerInfo.mInfo.mPPHighScores.mHardScore = mScore;
                bNewHighScore = true;
            }
        }
        else if (lDifData.mName == "PETERMAN")
        {
            if (IO_GamerInfo.mInfo.mPPHighScores.mPetermanScore < mScore)
            {
                IO_GamerInfo.mInfo.mPPHighScores.mPetermanScore = mScore;
                bNewHighScore = true;
            }
        }
        if (bNewHighScore)
        {
            IO_GamerInfo.FWriteGamerData(IO_GamerInfo.mInfo);
        }


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

        mState = PP_State.SCORE_SCREEN;

        refUI.gameObject.SetActive(false);
        refInstrUI.gameObject.SetActive(false);
        refScoreboardUI.SetActive(true);
        if (bNewHighScore)
        {
            refScoreboardUI.GetComponent <PP_Scoreboard>().mNewHighScoreTXT.text = "NEW HIGH SCORE!";
        }
        else
        {
            refScoreboardUI.GetComponent <PP_Scoreboard>().mNewHighScoreTXT.text = "Good Game";
        }

        DestroyExistingProjectilesArrowsAndDeactivateTurrets();

        PC_Controller refPC = FindObjectOfType <PC_Controller>();

        refPC.mState = PC_Controller.PC_STATE.SINACTIVE;
        refPC.GetComponent <Rigidbody>().velocity = Vector3.zero;
    }
예제 #23
0
 public void OnSnap()
 {
     refPlayer  = FindObjectOfType <PC_Controller>();
     refBlocker = FindObjectOfType <AI_Blocker>();
     mActive    = true;
 }