// Make sure that we gather up the play and then save it public void BT_SaveSet() { // Let me go ahead and try to add up all the things in the scene. mSet.mRecs.Clear(); mSet.mHoops.Clear(); ED_RP_Hp[] hoops = FindObjectsOfType <ED_RP_Hp>(); foreach (ED_RP_Hp h in hoops) { DT_RP_Hoop dh = new DT_RP_Hoop(); dh.mTag = h.mTag; dh.mSize = 1f; Vector3 vStart = new Vector3(); vStart.y = 1f; vStart.x = h.mIxX - rSnap.mIxX; vStart.z = h.mIxY - rSnap.mIxY; // convert grid coordinates to starting position... dh.mStart = vStart; mSet.mHoops.Add(dh); } ED_RP_Rec[] recs = FindObjectsOfType <ED_RP_Rec>(); foreach (ED_RP_Rec r in recs) { DT_RP_Rec dr = new DT_RP_Rec(); dr.mTag = r.mTag; Vector3 vStart = new Vector3(); vStart.y = 1f; vStart.x = r.mIxX - rSnap.mIxX; vStart.z = r.mIxY - rSnap.mIxY; // convert grid coordinates to starting position... dr.mStart = vStart; mSet.mRecs.Add(dr); } Debug.Log("Num Recs: " + mSet.mRecs.Count + ", Num Hoops: " + mSet.mHoops.Count + ", Num Routes: " + mSet.mRoutes.Count); IO_RP.FWriteSet(mSet); }
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); }