private void CheckAndHandleDeath() { if (_health <= 0f) { TDC_EventManager.FBroadcast(TDC_GE.GE_PCDeath); } }
void OnTriggerEnter(Collider other) { if (other.GetComponent <PC_Controller>()) { TDC_EventManager.FBroadcast(TDC_GE.GE_InPocket); } }
// 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; } }
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); } }
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); }
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); }
void OnTriggerEnter(Collider other) { if (other.GetComponent <PC_Controller>()) { TDC_EventManager.FBroadcast(TDC_GE.GE_PP_SackBallHit); Destroy(gameObject); } }
private void OnTriggerExit(Collider other) { if (other.GetComponent <PC_Controller>()) { TDC_EventManager.FBroadcast(TDC_GE.GE_OutPocket); Debug.Log("Exited"); } }
// 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); } }
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); }
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); } }
private void CheckDead() { if (_invinsible) { _health = 100f; return; } if (_health <= 0f) { TDC_EventManager.FBroadcast(TDC_GE.GE_PCDeath); } }
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); }
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; } }
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(); } }
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; } }
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); } } }
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); }
void OnTriggerEnter(Collider other) { PRAC_Off_Ply p = UT_FindComponent.FindComponent <PRAC_Off_Ply>(other.gameObject); if (p != null) { if (p.mState != PRAC_Ath.PRAC_ATH_STATE.STACKLED) { Debug.Log(p.mState); if (p == cAth.rMan.FGetBallCarrier()) { Debug.Log("Tackle the offensive player"); p.FENTER_Tackled(); TDC_EventManager.FBroadcast(TDC_GE.GE_Tackled); } else { Debug.Log("Wasn't the ball carrier"); } } } }
/****************************************************************************** * Alright, I'm sort of cheekily running two states in here. The first is after we get to the top, there's * a brief moment where nothing decays, then things decay really fast. * * If you've charged fully, then you just immediatley decay. However, if not, then you decay only after a while. ******************************************************************************/ private void RUN_FullyChargedThrow() { float fDampenEffects = mThrowMax.Val / IO_Settings.mSet.lPlayerData.mThrowSpd; fDampenEffects *= fDampenEffects * fDampenEffects * fDampenEffects; float fInaccuracyRate = 50f * fDampenEffects; float fPowerLossRate = 0.5f * fDampenEffects; // once the throw has decayed to half power, then it's just canceled. if (mThrowChrg.Val < 0.5f * mThrowMax.Val / IO_Settings.mSet.lPlayerData.mThrowSpd) { TDC_EventManager.FBroadcast(TDC_GE.GE_QB_StopThrow); return; } // RMB stops throw if (Input.GetMouseButton(1)) { TDC_EventManager.FBroadcast(TDC_GE.GE_QB_StopThrow); return; } GB_LookInaccuracy.Val += Time.deltaTime * fInaccuracyRate; // now here's where the throw "decays" mThrowChrg.Val -= Time.deltaTime * fPowerLossRate; // ---------- And now the same mThrowAngle.Val = cCam.transform.forward; HandleThrowModifiers(); if (Input.GetMouseButtonUp(0)) { ThrowBall(); } }
protected override void PickupEvent() { TDC_EventManager.FBroadcast(TDC_GE.GE_PCK_AM); }
// Run interception logic. public override void FCaughtBall() { TDC_EventManager.FBroadcast(TDC_GE.GE_BallCaught_Int); }
public override void FCaughtBall() { mState = PRAC_ATH_STATE.SRUN_WITH_BALL; cAud.mCatch.Play(); TDC_EventManager.FBroadcast(TDC_GE.GE_BallCaught_Rec); }