public void BT_SaveRoute() { if (rRtTl.rRouteNodes.Count < 2) { Debug.Log("ERROR. Must have at least 2 route nodes"); return; } Debug.Log("Owner should be: " + rRecs[ixRec].mTag); DATA_ORoute r = rRtTl.FReturnActiveRoute(rRecs[ixRec].mTag, rRecs[ixRec].mIxX, rRecs[ixRec].mIxY, 2); // ------------------------------- Now save that route in the play itself. // ------------------------------- Remove existing route if there is one. for (int i = 0; i < mSet.mRoutes.Count; i++) { if (mSet.mRoutes[i].mOwner == r.mOwner) { mSet.mRoutes.RemoveAt(i); Debug.Log("Removing existing route for: " + r.mOwner); break; } } mSet.mRoutes.Add(r); Debug.Log("Number of routes: " + mSet.mRoutes.Count); // clear the existing nodes. rRtTl.FClear(); cGfx.FRenderSet(mSet.mRoutes, rRecs, 2, rGrd); mState = STATE.S_NONE_SELECTED; }
public void FSetUpRoute(DATA_ORoute rt) { cRouteLog.mRouteSpots = new List <Vector3>(); for (int i = 0; i < rt.mSpots.Count; i++) { Vector3 rtSpot = UT_VecConversion.ConvertVec2(rt.mSpots[i]); rtSpot += transform.position; Debug.Log(rtSpot); cRouteLog.mRouteSpots.Add(rtSpot); } }
/*************************************************************************************** * The indices are the grid position of the receiver. This matters of course, because the route * is saved relative to them. * grdSqrSize is the conversion factor between grids and yards. I believe that each square is * currently 2x2 yards. ************************************************************************************** */ public DATA_ORoute FReturnActiveRoute(string owner, int ixRecX, int ixRecY, int grdSqrSize) { DATA_ORoute r = new DATA_ORoute(); r.mOwner = owner; // ------------------------------ Fill the positions according to the current list r.mSpots = new List <Vector2>(); r.mSpots.Add(new Vector2(0, 0)); for (int i = 1; i < rRouteNodes.Count; i++) { Vector2 v = new Vector2(); v.x = rRouteNodes[i].mIxX - ixRecX; v.y = rRouteNodes[i].mIxY - ixRecY; // v.x *= 2; // v.y *= 2; Debug.Log("Maybe convert here"); r.mSpots.Add(v); } return(r); }
/********************* * Should check that we don't already have a route for this receiver. If we do, just overwrite * that route. ******************************************************************************** */ public void BT_RouteUse() { if (rRouteNodes.Count < 2) { Debug.Log("ERROR. Must have at least 2 route nodes"); return; } DATA_ORoute r = new DATA_ORoute(); r.mOwner = mAths[ixPly].mTag; // ------------------------------- Remove existing route if their is one. for (int i = 0; i < mPlay.mRoutes.Count; i++) { if (mPlay.mRoutes[i].mOwner == r.mOwner) { mPlay.mRoutes.RemoveAt(i); Debug.Log("Removing existing route for: " + r.mOwner); break; } } // ------------------------------ Fill the positions according to the current list r.mSpots = new List <Vector2>(); r.mSpots.Add(new Vector2(0, 0)); for (int i = 1; i < rRouteNodes.Count; i++) { Vector2 v = new Vector2(); v.x = rRouteNodes[i].mIxX - mAths[ixPly].mIxX; v.y = rRouteNodes[i].mIxY - mAths[ixPly].mIxY; Debug.Log("Spot: " + v); r.mSpots.Add(v); } mPlay.mRoutes.Add(r); Debug.Log("Number of routes: " + mPlay.mRoutes.Count); RouteStopEdit(); }
public static DATA_OffPlay FLoadPlay(string name) { string path = Application.dataPath + "/FILE_IO/OffensivePlays/" + name + ".txt"; string[] sLines = System.IO.File.ReadAllLines(path); DATA_OffPlay p = new DATA_OffPlay(); for (int i = 0; i < sLines.Length; i++) { if (sLines[i].Contains("NUM PLAYERS")) { int numPlayers = int.Parse(sLines[i + 1]); p.mTags = new string[numPlayers]; p.mRoles = new string[numPlayers]; } } for (int i = 0; i < sLines.Length; i++) { if (sLines[i].Contains("NAME")) { p.mName = sLines[i + 1]; } if (sLines[i].Contains("FORMATION")) { p.mFormation = sLines[i + 1]; } if (sLines[i].Contains("NUM PLAYERS")) { int ix = i + 2; for (int j = 0; j < p.mTags.Length; j++) { p.mTags[j] = sLines[ix++]; p.mRoles[j] = sLines[ix++]; } } if (sLines[i].Contains("NUM RECEIVERS")) { int num = int.Parse(sLines[i + 1]); int ix = i + 3; for (int j = 0; j < num; j++) { DATA_ORoute r = new DATA_ORoute(); r.mOwner = sLines[ix++]; ix++; // skip over NUM SPOTS line int numSpots = int.Parse(sLines[ix++]); r.mSpots = new List <Vector2>(); for (int k = 0; k < numSpots; k++) { Vector2 v = UT_Strings.FGetVecFromString(sLines[ix++]); r.mSpots.Add(v); } p.mRoutes.Add(r); } } } return(p); }
public static DT_RP_Set FLoadSet(string name) { string path = Application.dataPath + "/FILE_IO/RoutePasser/" + name + ".txt"; string[] sLines = System.IO.File.ReadAllLines(path); DT_RP_Set set = new DT_RP_Set(); for (int i = 0; i < sLines.Length; i++) { if (sLines[i].Contains("NAME")) { set.mName = sLines[i + 1]; } if (sLines[i].Contains("Num Recs")) { int numRecs = int.Parse(sLines[i + 1]); int ix = i + 2; for (int j = 0; j < numRecs; j++) { DT_RP_Rec r = new DT_RP_Rec(); r.mStart = UT_Strings.FGetVec3FromString(sLines[ix++]); r.mTag = sLines[ix++]; set.mRecs.Add(r); } } if (sLines[i].Contains("Num Hoops")) { int numHoops = int.Parse(sLines[i + 1]); int ix = i + 2; for (int j = 0; j < numHoops; j++) { DT_RP_Hoop h = new DT_RP_Hoop(); h.mStart = UT_Strings.FGetVec3FromString(sLines[ix++]); h.mSize = float.Parse(sLines[ix++]); h.mTag = sLines[ix++]; set.mHoops.Add(h); } } if (sLines[i].Contains("Num Routes")) { int numRoutes = int.Parse(sLines[i + 1]); int ix = i + 2; for (int j = 0; j < numRoutes; j++) { DATA_ORoute r = new DATA_ORoute(); r.mOwner = sLines[ix++]; int numSpots = int.Parse(sLines[ix++]); r.mSpots = new List <Vector2>(); for (int k = 0; k < numSpots; k++) { Vector2 v = UT_Strings.FGetVecFromString(sLines[ix++]); r.mSpots.Add(v); } set.mRoutes.Add(r); } } } return(set); }