public void FSetUpPlayers(string sDefName, PLY_SnapSpot rSnapSpot) { DATA_Play p = IO_DefPlays.FLOAD_PLAY_BY_NAME(sDefName); Debug.Log("About to run: " + p.mName); List <PRAC_Def_Ply> plys = new List <PRAC_Def_Ply>(); // ------------------------- Old style still has the starting position in there already. DATA_Play defPlay = IO_DefPlays.FLOAD_PLAY_BY_NAME(sDefName); // PRAC_UI ui = FindObjectOfType<PRAC_UI>(); // ui.mDefensivePlayName.text = defPlay.mName; for (int i = 0; i < defPlay.mPlayerRoles.Length; i++) { Vector3 vPlayerSpot = new Vector3(); vPlayerSpot.x = defPlay.mPlayerRoles[i].mStart.x; vPlayerSpot.z = defPlay.mPlayerRoles[i].mStart.y; vPlayerSpot += rSnapSpot.transform.position; var clone = Instantiate(PF_DefPlayer, vPlayerSpot, transform.rotation); clone.mJob.mTag = defPlay.mPlayerRoles[i].mTag; clone.mJob.mRole = defPlay.mPlayerRoles[i].mRole; clone.mJob.mDetail = defPlay.mPlayerRoles[i].mDetail; } // ----------------------- Figure out who's covering who. return; }
public void BT_SavePlay() { if (rPlayInputText.text == string.Empty) { Debug.Log("Please enter a play name"); return; } // gather up all the defenders in the scene. PE_Role[] roles = FindObjectsOfType <PE_Role>(); DATA_Play ply = new DATA_Play(); ply.mName = rPlayInputText.text; ply.mPlayerRoles = new DT_PlayerRole[roles.Length]; // Should always be 11. Debug.Log("Should be 11: " + ply.mPlayerRoles.Length); for (int i = 0; i < ply.mPlayerRoles.Length; i++) { DT_PlayerRole dtRole = new DT_PlayerRole(); dtRole.mTag = roles[i].mTag; dtRole.mRole = roles[i].mRole; dtRole.mDetail = roles[i].mDetails; dtRole.mStart = roles[i].mStartPos; ply.mPlayerRoles[i] = dtRole; } IO_DefPlays.FWRITE_PLAY(ply); }
void Start() { IO_DefPlays.FLOAD_PLAYS(); IO_PlayList.FLOAD_PLAYS(); IO_RouteList.FLOAD_ROUTES(); IO_Settings.FLOAD_SETTINGS(); IO_ZoneList.FLOAD_ZONES(); mDebugText.text = "Loading in stuffs"; // IO_RouteList.FWRITE_ALL_ROUTES_AS_TEXT(); DeleteOldFilesFromPlayArtDirectories(); TransferCurrentFormationsAndPlaysIntoPlayArtDirectories(); mDebugText.text = "Should have transfered text files with formation and plays"; mState = SplashState.SLOGO; mAudioMixer.SetFloat("MASTER_VOLUME", IO_Settings.mSet.lMasterVolume); ENTER_Logo(); }
void Start() { cPlaySetter = GetComponent <PRAC_SetUpPlay>(); cShowDefence = GetComponent <PRAC_ShowDefense>(); mState = PRAC_STATE.SPOST_PLAY; mPreSnapState = PRESNAP_STATE.SREADYTOSNAP; mPickPlayState = PICKPLAY_STATE.SOFFENSE; IO_PlayList.FLOAD_PLAYS(); IO_DefPlays.FLOAD_PLAYS(); IO_ZoneList.FLOAD_ZONES(); IO_RouteList.FLOAD_ROUTES(); PRS_AssignMan.FLOAD_PRIORITIES(); // Won't affect the build, but will affect the editor. IO_Settings.FLOAD_SETTINGS(); // IO_RouteList.FCONVERT_TO_TEXT_FILES(); // IO_PlayList.FCONVERT_TO_TEXT_FILES(); // IO_DefPlays.FCONVERT_TO_TEXT_FILES(); // IO_ZoneList.FCONVERT_TO_TEXT_FILES(); MN_PauseScreen.SetActive(false); }
void Awake() { IO_Settings.FLOAD_SETTINGS(); IO_DefPlays.FLOAD_PLAYS(); IO_ZoneList.FLOAD_ZONES(); }
// ----------------------------- PRESNAP STATES private void RUN_SnapReady() { if (Input.GetKeyDown(KeyCode.Space)) { FindObjectOfType <PC_Controller>().mState = PC_Controller.PC_STATE.SACTIVE; PRAC_Ath[] athletes = FindObjectsOfType <PRAC_Ath>(); for (int i = 0; i < athletes.Length; i++) { athletes[i].mState = PRAC_Ath.PRAC_ATH_STATE.SDOING_JOB; } // For now so it's not there when we run. Going to change this soon. cShowDefence.FStopShowingPlayArt(); mState = PRAC_STATE.SPLAY_RUNNING; } // We also need the camera to go to the higher perspective. if (Input.GetKeyDown(KeyCode.T)) { cShowDefence.FStopShowingPlayArt(); cShowDefence.FShowAllPlayRoles(IO_PlayList.FLOAD_PLAY_BY_NAME(rPracUI.mOffensivePlayName.text), IO_DefPlays.FLOAD_PLAY_BY_NAME(rPracUI.mDefensivePlayName.text), rSnapSpot); FindObjectOfType <CAM_PlayShowing>().FActivate(); mPreSnapState = PRESNAP_STATE.SHIGHCAM; } }
// For now we are ignoring the defensive play name. public void FSetUpPlay(string sOffName, string sDefName, PLY_SnapSpot rSnapSpot) { // ------------------------------- LOAD IN PLAYERS DATA_Play playToRun = IO_PlayList.FLOAD_PLAY_BY_NAME(sOffName); if (playToRun == null) { Debug.Log("No play of that name"); } // Now we just pretend there were no issues, so we put our players in their spots. for (int i = 0; i < playToRun.mPlayerRoles.Length; i++) { Vector3 vPlayerSpot = new Vector3(); vPlayerSpot.x = playToRun.mPlayerRoles[i].mStart.x; vPlayerSpot.z = playToRun.mPlayerRoles[i].mStart.y; vPlayerSpot += rSnapSpot.transform.position; var clone = Instantiate(PF_OffensivePlayer, vPlayerSpot, transform.rotation); clone.mJob.mTag = playToRun.mPlayerRoles[i].mTag; clone.mJob.mRole = playToRun.mPlayerRoles[i].mRole; clone.mJob.mDetail = playToRun.mPlayerRoles[i].mDetail; } int randomDefPlay = Random.Range(0, IO_DefPlays.mPlays.Length); // DATA_Play defPlay = IO_DefPlays.mPlays[randomDefPlay]; DATA_Play defPlay = IO_DefPlays.FLOAD_PLAY_BY_NAME(sDefName); PRAC_UI ui = FindObjectOfType <PRAC_UI>(); ui.mDefensivePlayName.text = defPlay.mName; // spawn a defensive player according to the play. for (int i = 0; i < defPlay.mPlayerRoles.Length; i++) { Vector3 vPlayerSpot = new Vector3(); vPlayerSpot.x = defPlay.mPlayerRoles[i].mStart.x; vPlayerSpot.z = defPlay.mPlayerRoles[i].mStart.y; vPlayerSpot += rSnapSpot.transform.position; var clone = Instantiate(PF_DefensivePlayer, vPlayerSpot, transform.rotation); clone.mJob.mTag = defPlay.mPlayerRoles[i].mTag; clone.mJob.mRole = defPlay.mPlayerRoles[i].mRole; clone.mJob.mDetail = defPlay.mPlayerRoles[i].mDetail; } // --------------------------------------------- Set all athletes to waiting for snap. PRAC_Ath[] athletes = FindObjectsOfType <PRAC_Ath>(); foreach (PRAC_Ath athlete in athletes) { athlete.mState = PRAC_Ath.PRAC_ATH_STATE.SPRE_SNAP; } // --------------------------------------------- Re-arrange offensive and defensive player pointers left->right. PRAC_Off[] offenders = FindObjectsOfType <PRAC_Off>(); PRAC_Def[] defenders = FindObjectsOfType <PRAC_Def>(); SortPlayersLeftToRight(offenders); SortPlayersLeftToRight(defenders); // -------------------------------------- For route runners, load in their routes. IO_RouteList.FLOAD_ROUTES(); for (int i = 0; i < offenders.Length; i++) { if (offenders[i].mJob.mRole == "Route") { // Yep, memory not allocated error if we don't do this here. offenders[i].GetComponent <OFF_RouteLog>().mRouteSpots = new List <Vector3>(); DATA_Route rt = IO_RouteList.FLOAD_ROUTE_BY_NAME(offenders[i].mJob.mDetail); foreach (Vector2 routeSpot in rt.mSpots) { Vector3 vSpot = offenders[i].transform.position; vSpot.x += routeSpot.x; vSpot.z += routeSpot.y; // Also, shove the spot into the receiver, just for now. offenders[i].GetComponent <OFF_RouteLog>().mRouteSpots.Add(vSpot); // Instantiate(PF_RouteNode, vSpot, transform.rotation); } } } // ---------------------------------------------------------- Shove the player "into" the QB character. for (int i = 0; i < offenders.Length; i++) { if (offenders[i].mJob.mTag == "QB") { Vector3 vSpot = offenders[i].transform.position; vSpot.y = 1f; FindObjectOfType <PC_Controller>().transform.position = vSpot; } } // ------------------------------------------ Now we're assigning the man for man coverage. // An offense has 5 eligible receivers on every play, so we actually SHOULD go by that, not their routes. // Update, we've added PRS_AssignMan which globally stores the order that tags should be covered, and the same for defense. List <PRAC_Off> elibibleRecs = new List <PRAC_Off>(); foreach (PRAC_Off off in offenders) { if (PRS_AssignMan.FELIGIBLE_RECEIVER(off.mJob.mTag)) { elibibleRecs.Add(off); } } elibibleRecs = PRS_AssignMan.FSORT_RECEIVER_IMPORTANCE(elibibleRecs); List <PRAC_Def> defsInMan = new List <PRAC_Def>(); foreach (PRAC_Def def in defenders) { if (def.mJob.mRole == "Man") { Debug.Log("Added"); defsInMan.Add(def); } } defsInMan = PRS_AssignMan.FSORT_DEFENDER_IMPORTANCE(defsInMan); // Now we finally start assigning man coverage responsibility. for (int i = 0; i < defsInMan.Count; i++) { if (elibibleRecs.Count <= 0) { break; } defsInMan[i].GetComponent <DEF_ManLog>().rMan = elibibleRecs[0]; elibibleRecs.RemoveAt(0); } // ---------- ALIGN MAN DEFENDERS TO THE GUY THEY'RE COVERING for (int i = 0; i < defsInMan.Count; i++) { Vector3 vManPos = defsInMan[i].GetComponent <DEF_ManLog>().rMan.transform.position; vManPos.z += 7f; defsInMan[i].transform.position = vManPos; } }