Esempio n. 1
0
    // Let's say that when you're not throwing, you can limit the strength of a throw, by pressing shift.
    private void RUN_NotThrowing()
    {
        if (Input.GetMouseButton(0))
        {
            // mThrowMax.Val = IO_Settings.mSet.lPlayerData.mThrowSpd;
            TDC_EventManager.FBroadcast(TDC_GE.GE_QB_StartWindup);
            cAud.mThrowStart.Play();
            mThrowStartAngle = cCam.transform.forward;

            mThrowState = PC_THROW_STATE.S_CHARGING;

            // Start the throw at not zero.
            mThrowChrg.Val = 8f / IO_Settings.mSet.lPlayerData.mThrowSpd;
        }

        // Limit the power of a throw, or set it back. Actually, you can do this when charging as well.
        if (Input.GetKey(KeyCode.LeftShift))
        {
            mThrowMax.Val -= Time.deltaTime * 10f;
        }

        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            mThrowMax.Val = IO_Settings.mSet.lPlayerData.mThrowSpd;
        }
    }
Esempio n. 2
0
    protected virtual void KillYourself()
    {
        Instantiate(PF_Explode, transform.position, transform.rotation);
        Instantiate(PF_Gibs, transform.position, transform.rotation);

        // Randomly decide to spawn in ammo or health.
        {
            float random = Random.Range(0, 100f);
            if (random < _dropAmmoChance)
            {
                Instantiate(PF_AmmoBox, transform.position, transform.rotation);
            }
            else
            {
                random = Random.Range(0, 100f);
                if (random < _dropHealthChance)
                {
                    Instantiate(PF_HealthBox, transform.position, transform.rotation);
                }
            }
        }

        TDC_EventManager.FBroadcast(TDC_GE.GE_EDeath);

        Destroy(gameObject);
    }
Esempio n. 3
0
 private void CheckAndHandleDeath()
 {
     if (_health <= 0f)
     {
         TDC_EventManager.FBroadcast(TDC_GE.GE_PCDeath);
     }
 }
Esempio n. 4
0
 void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <PC_Controller>())
     {
         TDC_EventManager.FBroadcast(TDC_GE.GE_InPocket);
     }
 }
Esempio n. 5
0
    // ------------------------------------- Gamer info stuffs. Keep track of how often they pass, I guess?
    void Awake()
    {
        IO_Settings.FLOAD_SETTINGS();
        IO_GamerInfo.FLoadGamerData();

        TDC_EventManager.FRemoveAllHandlers();
    }
Esempio n. 6
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();
    }
Esempio n. 7
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);
        }
    }
Esempio n. 8
0
    void Start()
    {
        cScore = GetComponent <GM_Score>();
        TDC_EventManager.FAddHandler(TDC_GE.GE_PCDeath, E_PlayerDied);

        _lastSpawn = _spawnRate * -1f;
    }
Esempio n. 9
0
    private void ThrowBall()
    {
        cAud.FBallThrown(mThrowChrg.Val);

        PROJ_Football clone = Instantiate(PF_Football, mThrowPoint.transform.position, transform.rotation);

        // now we add in the innacuracy.
        // x inaccuracy feels better than y inaccuracy, which can look really stupid.
        float fXAcc = Random.Range(-GB_TotalInaccuracy.Val, GB_TotalInaccuracy.Val) / 100f;
        float fYAcc = Random.Range(-GB_TotalInaccuracy.Val, GB_TotalInaccuracy.Val) / 100f;

        fYAcc /= IO_Settings.mSet.lInaccuracyBias;
        Vector3 vThrowDir = cCam.transform.forward;

        vThrowDir.x += fXAcc; vThrowDir.y += fYAcc;
        vThrowDir    = Vector3.Normalize(vThrowDir);

        Debug.Log("Throw Dir: " + vThrowDir);
        Debug.Log("Throw Charge: " + mThrowChrg.Val);
        Debug.Log("Throw Speed Maximum: " + IO_Settings.mSet.lPlayerData.mThrowSpd);
        clone.GetComponent <Rigidbody>().velocity = vThrowDir * mThrowChrg.Val * IO_Settings.mSet.lPlayerData.mThrowSpd;
        mThrowChrg.Val = 0f;

        mThrowState = PC_THROW_STATE.S_RECOVERING;
        TDC_EventManager.FBroadcast(TDC_GE.GE_QB_ReleaseBall);

        SetInaccuraciesToZero();
        Invoke("CanThrowAgain", 1.0f);
    }
Esempio n. 10
0
 void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <PC_Controller>())
     {
         TDC_EventManager.FBroadcast(TDC_GE.GE_PP_SackBallHit);
         Destroy(gameObject);
     }
 }
Esempio n. 11
0
 private void OnTriggerExit(Collider other)
 {
     if (other.GetComponent <PC_Controller>())
     {
         TDC_EventManager.FBroadcast(TDC_GE.GE_OutPocket);
         Debug.Log("Exited");
     }
 }
Esempio n. 12
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);
        }
    }
Esempio n. 13
0
    // Since we're displaying the scoreboard screen, this is still fine
    public void OnQuitPressed()
    {
        refUI.gameObject.SetActive(false);
        MN_PauseScreen.SetActive(false);
        refScoreboardUI.SetActive(false);
        refQuitUI.SetActive(true);

        TDC_EventManager.FRemoveAllHandlers();
    }
Esempio n. 14
0
    void Start()
    {
        TDC_EventManager.FAddHandler(TDC_GE.GE_EDeath, E_EnemyDies);
        TDC_EventManager.FAddHandler(TDC_GE.GE_PCK_HLT, E_HealthPickedUp);
        TDC_EventManager.FAddHandler(TDC_GE.GE_PCK_AM, E_AmmoPickedUp);

        _lastSec = 0;
        rUI.FSetScoreText(_score);
    }
Esempio n. 15
0
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        TDC_EventManager.FAddHandler(TDC_GE.GE_PCDeath, E_PlayerDied);

        _lastSpawnTime = _spawnInterval * -1f;
    }
Esempio n. 16
0
    private void ENTER_INTRO()
    {
        mState = STATE.S_INTRO_TEXT;

        mUI.rIntroCanvas.gameObject.SetActive(true);
        rPC.mState = PC_Controller.PC_STATE.SINACTIVE;

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

        // Destroy all receivers and rings who are still in the scene.
        RP_Receiver[] recs  = FindObjectsOfType <RP_Receiver>();
        RP_Hoop[]     hoops = FindObjectsOfType <RP_Hoop>();
        foreach (RP_Receiver rec in recs)
        {
            Destroy(rec.gameObject);
        }
        foreach (RP_Hoop h in hoops)
        {
            Destroy(h.gameObject);
        }

        // ------------------- Spawn in our receivers and hoops.
        rRecs  = new List <RP_Receiver>();
        rHoops = new List <RP_Hoop>();
        foreach (DT_RP_Rec r in mSet.mRecs)
        {
            // TODO: Change the starting position relative to the snap.
            Vector3 vPos = rSnap.transform.position;
            vPos += r.mStart; vPos.y = 1f;
            RP_Receiver clone = Instantiate(PF_Receiver, vPos, transform.rotation);
            clone.mTag = r.mTag;
            foreach (DATA_ORoute rt in mSet.mRoutes)
            {
                if (rt.mOwner == clone.mTag)
                {
                    clone.FSetUpRoute(rt);
                }
            }

            rRecs.Add(clone);
        }
        foreach (DT_RP_Hoop h in mSet.mHoops)
        {
            Vector3 vPos = rSnap.transform.position;
            vPos += h.mStart; vPos.y = 1f;
            RP_Hoop clone = Instantiate(PF_Ring, vPos, transform.rotation);
            clone.mWRTag = h.mTag;
            // TODO: Stuff about height and size.
            rHoops.Add(clone);
        }

        Debug.Log("Receivers Instantiated: " + rRecs.Count);
        Debug.Log("Hoops Instantiated: " + rHoops.Count);
    }
Esempio n. 17
0
    // Start is called before the first frame update
    void Start()
    {
        mState          = QB_UI_STATE.SNOTCHARGING;
        mBar.fillAmount = 0f;

        mLookStorer = new ForwardVecStorer(50);

        TDC_EventManager.FAddHandler(TDC_GE.GE_QB_StopThrow, E_StopCharging);
        TDC_EventManager.FAddHandler(TDC_GE.GE_QB_ReleaseBall, E_StopCharging);
        TDC_EventManager.FAddHandler(TDC_GE.GE_QB_StartWindup, E_StartCharging);
    }
Esempio n. 18
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <PROJ_Football>())
        {
            mLastTimeHit = Time.time;

            Instantiate(PF_Particles, transform.position, transform.rotation);

            TDC_EventManager.FBroadcast(TDC_GE.GE_PP_TargetHit);
        }
    }
Esempio n. 19
0
 private void CheckDead()
 {
     if (_invinsible)
     {
         _health = 100f;
         return;
     }
     if (_health <= 0f)
     {
         TDC_EventManager.FBroadcast(TDC_GE.GE_PCDeath);
     }
 }
Esempio n. 20
0
    public void FENTER_Controlling()
    {
        mBallHitHandsTime = Time.time;
        mState            = STATE.S_CONTROLLING;

        cAth.mHasBall = true;
        TDC_EventManager.FBroadcast(TDC_GE.GE_BallHitFingers);

        // testing, make them drop it every time.
        // cAth.mHasBall = false;
        // TDC_EventManager.FBroadcast(TDC_GE.GE_BallDropped);
    }
Esempio n. 21
0
    void Start()
    {
        TDC_EventManager.FAddHandler(TDC_GE.GE_EDeath, E_EnemyDied);

        DT_Wave w = IO_Wave.FLoadWave(IO_Prog._curLevel.ToString());

        IO_Prog._numLevels = 2;
        _numWaves          = w._numWaves;

        _state         = STATE.S_Spawning;
        rSpawners      = FindObjectsOfType <LVL_Spawner>();
        _lastSpawnTime = _spawnInterval * -1;
    }
Esempio n. 22
0
 public override void Start()
 {
     base.Start();
     TDC_EventManager.FAddHandler(TDC_GE.GE_QB_ReleaseBall, E_BallThrown);
     TDC_EventManager.FAddHandler(TDC_GE.GE_Sack, E_Sack);
     TDC_EventManager.FAddHandler(TDC_GE.GE_BallHitFingers, E_BallHitsFingerTips);
     TDC_EventManager.FAddHandler(TDC_GE.GE_BallChangesHands, E_BallChangesHands);
     TDC_EventManager.FAddHandler(TDC_GE.GE_BallDropped, E_BallDropped);
     TDC_EventManager.FAddHandler(TDC_GE.GE_BallCaught_Rec, E_ReceiverCatchesBall);
     TDC_EventManager.FAddHandler(TDC_GE.GE_BallHitGround, E_BallHitsGround);
     TDC_EventManager.FAddHandler(TDC_GE.GE_BallCaught_Int, E_DefenderCatchesBall);
     TDC_EventManager.FAddHandler(TDC_GE.GE_Tackled, E_RunnerTackled);
 }
Esempio n. 23
0
    void Awake()
    {
        TDC_EventManager.FRemoveAllHandlers();

        DT_Wave w = new DT_Wave(1, 1, 4);

        IO_Wave.FSaveWave(w);
        // w = IO_Wave.FLoadWave(1.ToString());
        for (int i = 2; i < 5; i++)
        {
            w._id       = i;
            w._numWaves = i;
            IO_Wave.FSaveWave(w);
        }
    }
Esempio n. 24
0
    private void RUN_ChargingThrow()
    {
        // RMB stops throw
        if (Input.GetMouseButton(1))
        {
            TDC_EventManager.FBroadcast(TDC_GE.GE_QB_StopThrow);
            cAud.mThrowCancel.Play();
            return;
        }

        // Alright, this is what needs to be changed. Throw power should not charge linearly, it should charge logarithmically.
        float fChrgPct   = IO_Settings.mSet.lPlayerData.mThrowSpd * mThrowChrg.Val / mThrowMax.Val;
        float fChargeAmt = Time.deltaTime / IO_Settings.mSet.lPlayerData.mReleaseTime;

        fChargeAmt *= (mThrowMax.Val) / IO_Settings.mSet.lPlayerData.mThrowSpd; // the slower they want to throw, the slower it charges.
        // float fChargeAmt = Time.deltaTime / 5f;
        fChargeAmt -= fChargeAmt * (fChrgPct * fChrgPct);                       // gives us right side of bell curve.
        // but now we also have to factor in that we charge faster when closer to 0.
        // fChargeAmt *= (1-mThrowChrg.Val) * 2f;              // so when at 0, x as fast. When at 1, 0 charge speed.
        mThrowChrg.Val += fChargeAmt;
        if ((mThrowChrg.Val * IO_Settings.mSet.lPlayerData.mThrowSpd) > (mThrowMax.Val * 0.98f))
        {
            mThrowState       = PC_THROW_STATE.S_FULLYCHARGED;
            mTimeThrowCharged = Time.time;
        }

        // Now handle the look inaccuracy
        mThrowAngle.Val = cCam.transform.forward;

        HandleThrowModifiers();

        if (Input.GetMouseButtonUp(0))
        {
            ThrowBall();
        }

        // Limit the power of a throw, or set it back. Actually, you can do this when charging as well.
        if (Input.GetKey(KeyCode.LeftShift))
        {
            mThrowMax.Val -= Time.deltaTime * 10f;
        }

        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            mThrowMax.Val = IO_Settings.mSet.lPlayerData.mThrowSpd;
        }
    }
Esempio n. 25
0
    void OnCollisionEnter(Collision collision)
    {
        if (mGrounded)
        {
            return;
        }

        EN_FieldGround field = UT_FindComponent.FindComponent <EN_FieldGround>(collision.gameObject);

        if (field != null)
        {
            TDC_EventManager.FBroadcast(TDC_GE.GE_BallHitGround);
            mGrounded = true;
            FX_Football s = Instantiate(PF_PartAndSFX, transform.position, transform.rotation);
            s.mClunk.Play();
        }
    }
Esempio n. 26
0
    void RUN_SnapReady()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            FExit();
            TDC_EventManager.FBroadcast(TDC_GE.GE_BallSnapped);
            cLive.FEnter();
        }

        // We also need the camera to go to the higher perspective.
        if (Input.GetKeyDown(KeyCode.T))
        {
            cShowPreSnapGFX.FStopShowingPlayArt();
            cShowPreSnapGFX.FShowOffensivePlay(IO_OffensivePlays.FLoadPlay(cMan.mPlay), cMan.rSnapSpot);
            FindObjectOfType <CAM_PlayShowing>().FActivate();
            mPreSnapState = PRESNAP_STATE.SHIGHCAM;
        }
    }
Esempio n. 27
0
    public void FENTER_Tackled()
    {
        mState             = PRAC_ATH_STATE.STACKLED;
        cRigid.constraints = RigidbodyConstraints.None;
        cRigid.velocity    = Vector3.up * 10f;

        // if we have the ball, then we drop the ball.
        if (mHasBall)
        {
            if (cCatcher.mState != AI_CatchHandling.STATE.S_CONTROLLED)
            {
                Debug.Log("They jarred the ball loose from me");
                mHasBall        = false;
                cCatcher.mState = AI_CatchHandling.STATE.S_NOCATCH;
                TDC_EventManager.FBroadcast(TDC_GE.GE_BallDropped);
            }
        }
    }
Esempio n. 28
0
    // Start is called before the first frame update
    void Start()
    {
        cRigid = GetComponent <Rigidbody>();
        cCam   = GetComponentInChildren <PC_Camera>();
        cAud   = GetComponentInChildren <AD_Player>();

        mState         = PC_STATE.SINACTIVE;
        mThrowState    = PC_THROW_STATE.SNOT_THROWING;
        mThrowChrg.Val = 0f;
        mThrowMax.Val  = IO_Settings.mSet.lPlayerData.mThrowSpd;
        Debug.Log("Charge now: " + mThrowChrg.Val);

        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;

        TDC_EventManager.FAddHandler(TDC_GE.GE_QB_StopThrow, E_ThrowStopped);

        SetInaccuraciesToZero();
    }
Esempio n. 29
0
    public void E_BallHitsFingerTips()
    {
        PROJ_Football[] footballs = FindObjectsOfType <PROJ_Football>();
        foreach (PROJ_Football f in footballs)
        {
            Destroy(f.gameObject);
        }

        // make all the defenders try to tackle now
        PRAC_Def_Ply[] defenders = FindObjectsOfType <PRAC_Def_Ply>();
        foreach (PRAC_Def_Ply d in defenders)
        {
            // shit, even I don't know who the ball carrier is.
            d.GetComponent <DEF_TackLog>().FEnter();
            d.mTimeToTackle = true;
        }

        cMan.cAud.FPlayPunch();

        TDC_EventManager.FBroadcast(TDC_GE.GE_BallChangesHands);
    }
Esempio n. 30
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();
    }