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); }
// 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); } }
void Start() { base.Start(); cRouteLog = GetComponent <OFF_RouteLog>(); cBlockLog = GetComponent <OFF_BlockLog>(); cCatchRadius = GetComponentInChildren <TRG_Catch>(); cRunLog = GetComponent <OFF_RunLog>(); cCatchRadius.gameObject.SetActive(false); SetupRouteSpots(); }
void Start() { cRouteLog = GetComponent <OFF_RouteLog>(); cBlockLog = GetComponent <OFF_BlockLog>(); }