private void RefreshPlaysDropdown() { mDropPlays.options = new List <Dropdown.OptionData>(); string[] offPlayNames = IO_OffensivePlays.FReturnPlayNames(); foreach (string s in offPlayNames) { mDropPlays.options.Add(new Dropdown.OptionData(s)); } }
public void BT_PlaysUpdate() { string text = mDropPlays.captionText.text; Debug.Log("They want to see this play shown: " + text); DATA_OffPlay p = IO_OffensivePlays.FLoadPlay(text); p.mName = "NO NAME"; SetUpNewFormation(p.mFormation); SetPlayerRolesFromPlayData(p); mPlay = p; RenderJobs(); }
public virtual void FSetUpPlaybookImagery() { int ind = mPlayArts.Length * mPage; string[] offPlayNames = IO_OffensivePlays.FReturnPlayNames(); // If we have 14 plays, we should have 3 pages. Can't show a fourth page, obviously. if (ind > offPlayNames.Length) { Debug.Log("Past the end of the playbook"); mPage = 0; } for (int i = ind; i < mPlayArts.Length + ind; i++) { // Here we put in a blank sprite if there's no play to go into there. if (i + 1 > offPlayNames.Length) { Debug.Log("Can't show past the end of the PB"); break; } // We also want to put some text on them to show the play name. string path = Application.dataPath + "/FILE_IO/PlayArt/Offense/" + offPlayNames[i] + ".png"; Debug.Log("Play: " + path); int el = i - (mPlayArts.Length * mPage); // old // Texture2D tex = Resources.Load<Texture2D>(path); // Rect r = new Rect(0, 0, 256, 256); // Sprite spr = Sprite.Create(tex, r, new Vector2(1f, 1f)); // mPlayArts[el].GetComponent<Image>().sprite = spr; // mPlayArts[el].mName = offPlayNames[i]; // mPlayArts[el].GetComponentInChildren<Text>().text = offPlayNames[i]; // new byte[] fileData; Texture2D tex = null; fileData = File.ReadAllBytes(path); tex = new Texture2D(256, 256); tex.LoadImage(fileData); Rect r = new Rect(0, 0, 256, 256); Sprite spr = Sprite.Create(tex, r, new Vector2(1f, 1f)); mPlayArts[el].GetComponent <Image>().sprite = spr; mPlayArts[el].mName = offPlayNames[i]; mPlayArts[el].GetComponentInChildren <Text>().text = offPlayNames[i]; } }
public void BT_SavePlay() { if (mPlay.mName == "NAME ME") { Debug.Log("No name for this play"); return; } // Course, only gets us some of the play. Sigh. GetPlayFromSceneData(); foreach (string s in mPlay.mRoles) { if (s == "NO_ROLE") { Debug.Log("One or more player does not have a role"); return; } } for (int i = 0; i < mAths.Count; i++) { mPlay.mTags[i] = mAths[i].mTag; mPlay.mRoles[i] = mAths[i].mRole; } // ---------------- give it a name corresponding to personnel, RB->TE int numRB = 0; int numTE = 0; foreach (string s in mPlay.mTags) { if (s.Contains("TE")) { numTE++; } else if (s.Contains("RB")) { numRB++; } } string sOldName = mPlay.mName; string sPlayName = numRB + "-" + numTE + "_" + mPlay.mName; mPlay.mName = sPlayName; Debug.Log("Saving as: " + sPlayName); IO_OffensivePlays.FWritePlay(mPlay); mPlay.mName = sOldName; RefreshPlaysDropdown(); mSaved.FSetVisible(); }
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; } }
void Start() { IO_Formations.FLoadAllFormations(); RefreshFormationDropdown(); RefreshPlaysDropdown(); mAths = new List <ED_OP_Ply>(); rRouteNodes = new List <ED_OP_GFX_RT_ND>(); mPlay = IO_OffensivePlays.FLoadPlay("Default"); mPlay.mName = "NO NAME"; mSnapSpot.x = rGrid.mAxLth / 2; mSnapSpot.y = rGrid.mAxLth - 5; LoadValidRoles(); ENTER_BEGIN(); // DATA_OffPlay oPlay = IO_OffensivePlays.FLoadPlay("Default"); // oPlay.mName = "TestWrite"; // oPlay.mFormation = "Default"; // IO_OffensivePlays.FWritePlay(oPlay); }
private void HandlePageTurned() { string[] offPlayNames = IO_OffensivePlays.FReturnPlayNames(); int numPages = offPlayNames.Length / mPlayArts.Length; if (offPlayNames.Length % mPlayArts.Length > 0) { numPages++; } if (mPage < 0) { // calc the maximum number of pages we can have, then minus one mPage = numPages - 1; } else if (mPage > numPages - 1) { mPage = 0; } mTXTPage.text = ("Page: " + (mPage + 1) + "/" + numPages); FSetUpPlaybookImagery(); }
public void FSetUpPlayers(string sOffName, PLY_SnapSpot rSnapSpot) { DATA_OffPlay p = IO_OffensivePlays.FLoadPlay(sOffName); Debug.Log("About to run: " + p.mName); DATA_Formation f = IO_Formations.FLOAD_FORMATION(p.mFormation); Debug.Log("From this formation: " + f.mName); List <PRAC_Off_Ply> plys = new List <PRAC_Off_Ply>(); // --------------- Set up the players according to the formation. for (int i = 0; i < f.mTags.Length; i++) { Vector3 vSpot = new Vector3(); vSpot.x = f.mSpots[i].x; vSpot.z = f.mSpots[i].y * -1f; vSpot.y = 0f; vSpot += rSnapSpot.transform.position; var clone = Instantiate(PF_OffPlayer, vSpot, transform.rotation); clone.mTag = f.mTags[i]; plys.Add(clone); } // ---------------- Now give the players their roles. for (int i = 0; i < p.mTags.Length; i++) { for (int j = 0; j < plys.Count; j++) { if (plys[j].mTag == p.mTags[i]) { plys[j].mRole = p.mRoles[i]; } } } // --------------- Assign all the routes to the proper receivers. for (int i = 0; i < p.mRoutes.Count; i++) { for (int j = 0; j < plys.Count; j++) { if (plys[j].mTag == p.mRoutes[i].mOwner) { plys[j].mSpots = p.mRoutes[i].mSpots; for (int k = 0; k < plys[j].mSpots.Count; k++) { Vector2 v = plys[j].mSpots[k]; v.y *= -1f; plys[j].mSpots[k] = v; } } } } // --------------------------- Shove the player "into" the QB position. for (int i = 0; i < plys.Count; i++) { if (plys[i].mTag == "QB") { FindObjectOfType <PC_Controller>().transform.position = plys[i].transform.position; } } return; }