void LoadShip() { /*GameObject shipBase = (GameObject)Instantiate(shipCorePrefab, transform.position, transform.rotation); * ShipScript ss = shipBase.GetComponent<ShipScript>(); * myShip=ss; * Transform targ = shipBase.transform.FindChild("CameraPos/CamObj/WeaponsTarget");*/ int offset = 0; //string[] sts = shipFilePlayer.text.Split('\n'); StreamReader sr = new StreamReader(Application.dataPath + "/" + shipPath); string[] sts = sr.ReadToEnd().Split('\n'); List <string> stringss = new List <string>(); foreach (string s in sts) { string result = Regex.Replace(s, @"\r\n?|\n", ""); stringss.Add(result); } string[] strings = stringss.ToArray(); string shipName = strings[offset]; print(strings[offset]); offset += 1; shipsName = shipName; string[] colorPrimary = strings[offset].Split(','); print(strings[offset]); offset += 1; Color cPrimary = new Color(float.Parse(colorPrimary[0]) / 255, float.Parse(colorPrimary[1]) / 255, float.Parse(colorPrimary[2]) / 255, 255); colMain = cPrimary; string[] colorPower = strings[offset].Split(','); print(strings[offset]); offset += 1; Color cPower = new Color(float.Parse(colorPower[0]) / 255, float.Parse(colorPower[1]) / 255, float.Parse(colorPower[2]) / 255, 255); colPower = cPower; string[] colorThrust = strings[offset].Split(','); print(strings[offset]); offset += 1; Color cThrust = new Color(float.Parse(colorThrust[0]) / 255, float.Parse(colorThrust[1]) / 255, float.Parse(colorThrust[2]) / 255, 255); colThrust = cThrust; string[] colorSpecial = strings[offset].Split(','); print(strings[offset]); offset += 1; Color cSpecial = new Color(float.Parse(colorSpecial[0]) / 255, float.Parse(colorSpecial[1]) / 255, float.Parse(colorSpecial[2]) / 255, 255); colSpecial = cSpecial; string[] posOff = strings[offset].Split(','); offset += 1; poff = new Vector3(float.Parse(posOff[0]), float.Parse(posOff[1]), float.Parse(posOff[2])); int numSeats = int.Parse(strings[offset]); print(strings[offset]); offset += 1; seats = new List <ProtoSeat>(); for (int i = 0; i < numSeats; i++) { ProtoSeat seatie = new ProtoSeat(); seatie.name = strings[offset]; print(strings[offset]); offset += 1; seatie.thrusts = new List <int>(); int numThrustsSeat = int.Parse(strings[offset]); print(strings[offset]); offset += 1; for (int n = 0; n < numThrustsSeat; n++) { seatie.thrusts.Add(int.Parse(strings[offset])); print(strings[offset]); offset += 1; } seatie.wepSet = int.Parse(strings[offset]); print("WEAPON SET: " + strings[offset]); offset += 1; seatie.powSet = int.Parse(strings[offset]); print("POWER SET: " + strings[offset]); offset += 1; int numSeatModules = int.Parse(strings[offset]); print("NUM SEAT MODULES: " + strings[offset]); offset += 1; seatie.modSlots = new int[numSeatModules]; for (int n = 0; n < numSeatModules; n++) { seatie.modSlots[n] = int.Parse(strings[offset]); print(strings[offset]); offset += 1; } seats.Add(seatie); } int numThrusts = int.Parse(strings[offset]); print(strings[offset]); offset += 1; thrust = new List <ProtoThrust>(); for (int i = 0; i < numThrusts; i++) { ProtoThrust tg = new ProtoThrust(); tg.name = strings[offset]; print(strings[offset]); offset += 1; tg.axis = strings[offset]; print(strings[offset]); offset += 1; thrust.Add(tg); } int numWeps = int.Parse(strings[offset]); print(strings[offset]); offset += 1; weps = new List <ProtoWep>(); for (int i = 0; i < numWeps; i++) { string weaponName = strings[offset]; print(strings[offset]); offset += 1; string weaponPrimary = strings[offset]; print(strings[offset]); offset += 1; string weaponSecondary = strings[offset]; print(strings[offset]); offset += 1; ProtoWep pw = new ProtoWep(); pw.name = weaponName; pw.primWep = weaponPrimary; pw.altWep = weaponSecondary; weps.Add(pw); } int numPowerSys = int.Parse(strings[offset]); print(strings[offset]); offset += 1; pows = new List <ProtoPowersys>(); for (int i = 0; i < numPowerSys; i++) { string powName = strings[offset]; print(strings[offset]); offset += 1; int numModules = int.Parse(strings[offset]); print(strings[offset]); offset += 1; ProtoPowersys ps = new ProtoPowersys(); ps.name = powName; ps.slots = new List <AuxPowerSlot>(); for (int n = 0; n < numModules; n++) { string modType = strings[offset]; print(strings[offset]); offset += 1; float mod = float.Parse(strings[offset]); print(strings[offset]); offset += 1; AuxPowerSlot aps = new AuxPowerSlot(); if (modType == "Shield") { aps.mtype = AuxPowerSlot.ModuleType.Shield; } else if (modType == "Thrust") { aps.mtype = AuxPowerSlot.ModuleType.Thrust; } else if (modType == "Weapon") { aps.mtype = AuxPowerSlot.ModuleType.Weapon; } aps.mod = mod; ps.slots.Add(aps); } pows.Add(ps); } int numModulesReal = int.Parse(strings[offset]); print(strings[offset]); offset += 1; mods = new List <ProtoModset>(); for (int i = 0; i < numModulesReal; i++) { string modName = strings[offset]; print(strings[offset]); offset += 1; string modType = strings[offset]; print(strings[offset]); offset += 1; int powerPower = int.Parse(strings[offset]); print(strings[offset]); offset += 1; int timePower = int.Parse(strings[offset]); print(strings[offset]); offset += 1; int coolPower = int.Parse(strings[offset]); print(strings[offset]); offset += 1; ProtoModset ms = new ProtoModset(); ms.name = modName; ms.pow = powerPower; ms.tim = timePower; ms.col = coolPower; ms.mtype = modules[modType]; mods.Add(ms); } float offsetX = float.Parse(strings[offset]); print(strings[offset]); offset += 1; float offsetY = float.Parse(strings[offset]); print(strings[offset]); offset += 1; float offsetZ = float.Parse(strings[offset]); print(strings[offset]); offset += 1; rotPivot.position = new Vector3(offsetX, offsetY, offsetZ); float camrange = float.Parse(strings[offset]); print(strings[offset]); offset += 1; camTemp.localPosition = new Vector3(0, 0, -camrange); float range = float.Parse(strings[offset]); print(strings[offset]); offset += 1; wepRange = range; int numBlocks = int.Parse(strings[offset]); print(strings[offset]); offset += 1; blocks = new List <BBlock>(); for (int i = 0; i < numBlocks; i++) { string[] bb = strings[offset].Split('/'); print(strings[offset]); offset += 1; string blockType = bb[0]; string[] position = bb[1].Split(','); string[] rotation = bb[2].Split(','); Vector3 pos = new Vector3(float.Parse(position[0]), float.Parse(position[1]), float.Parse(position[2])); Vector3 ea = new Vector3(Utilities.NearestRound(float.Parse(rotation[0]), 90), Utilities.NearestRound(float.Parse(rotation[1]), 90), Utilities.NearestRound(float.Parse(rotation[2]), 90)); /*GameObject blockObj = (GameObject)Instantiate(blocks[blockType], Vector3.zero, Quaternion.identity); * blockObj.transform.parent=shipBase.transform; * blockObj.transform.localPosition=pos+poff; * blockObj.transform.localRotation=rot; * Block b = blockObj.GetComponent<Block>(); * b.powerSys=int.Parse(bb[3]); * if(b is Weapon) * { * Weapon w = (Weapon)b; * w.weaponGroupID=int.Parse(bb[4]); * w.oneTwo=int.Parse(bb[5])==1; * } * if(b is Module) * { * Module m = (Module)b; * m.moduleSlot=int.Parse(bb[4]); * } * if(b is AuxModule) * { * AuxModule am = (AuxModule)b; * am.moduleSlot=int.Parse(bb[4]); * } * if(b is Thruster) * { * Thruster t = (Thruster)b; * t.thrustGroup=int.Parse(bb[4]); * t.posNeg=int.Parse(bb[5])==1; * }*/ AddBlock(blockType, pos, ea, int.Parse(bb[3]), int.Parse(bb[4]), int.Parse(bb[5])); } tempCMR = (int)(colMain.r * 255); tempCMG = (int)(colMain.g * 255); tempCMB = (int)(colMain.b * 255); tempCPR = (int)(colPower.r * 255); tempCPG = (int)(colPower.g * 255); tempCPB = (int)(colPower.b * 255); tempCTR = (int)(colThrust.r * 255); tempCTG = (int)(colThrust.g * 255); tempCTB = (int)(colThrust.b * 255); tempCSR = (int)(colSpecial.r * 255); tempCSG = (int)(colSpecial.g * 255); tempCSB = (int)(colSpecial.b * 255); sr.Close(); }
void DrawWindow(int id) { //GUI.DragWindow(); scrollP = GUILayout.BeginScrollView(scrollP, style); GUILayout.Space(25); GUILayout.Label("-=SHIP NAME=-", style, GUILayout.Width(220)); shipsName = GUILayout.TextField(shipsName, style, GUILayout.Width(220)); GUILayout.Label("-=PRIMARY SHIP COLOR (RGB 0-255)=-", style, GUILayout.Width(220)); tempCMR = int.Parse(GUILayout.TextField("" + tempCMR, style, GUILayout.Width(220))); tempCMG = int.Parse(GUILayout.TextField("" + tempCMG, style, GUILayout.Width(220))); tempCMB = int.Parse(GUILayout.TextField("" + tempCMB, style, GUILayout.Width(220))); GUILayout.Label("-=SHIP POWER COLOR (RGB 0-255)=-", style, GUILayout.Width(220)); tempCPR = int.Parse(GUILayout.TextField("" + tempCPR, style, GUILayout.Width(220))); tempCPG = int.Parse(GUILayout.TextField("" + tempCPG, style, GUILayout.Width(220))); tempCPB = int.Parse(GUILayout.TextField("" + tempCPB, style, GUILayout.Width(220))); GUILayout.Label("-=SHIP THRUST COLOR (RGB 0-255)=-", style, GUILayout.Width(220)); tempCTR = int.Parse(GUILayout.TextField("" + tempCTR, style, GUILayout.Width(220))); tempCTG = int.Parse(GUILayout.TextField("" + tempCTG, style, GUILayout.Width(220))); tempCTB = int.Parse(GUILayout.TextField("" + tempCTB, style, GUILayout.Width(220))); GUILayout.Label("-=SHIP SPECIAL COLOR (RGB 0-255)=-", style, GUILayout.Width(220)); tempCSR = int.Parse(GUILayout.TextField("" + tempCSR, style, GUILayout.Width(220))); tempCSG = int.Parse(GUILayout.TextField("" + tempCSG, style, GUILayout.Width(220))); tempCSB = int.Parse(GUILayout.TextField("" + tempCSB, style, GUILayout.Width(220))); //if(GUILayout.Button("APPLY COLOR", style, GUILayout.Width(220))) //{ colMain = new Color(tempCMR / 255f, tempCMG / 255f, tempCMB / 255f); colPower = new Color(tempCPR / 255f, tempCPG / 255f, tempCPB / 255f); colThrust = new Color(tempCTR / 255f, tempCTG / 255f, tempCTB / 255f); colSpecial = new Color(tempCSR / 255f, tempCSG / 255f, tempCSB / 255f); //} //if(GUILayout.Button("LOAD COLOR", style, GUILayout.Width(220))) //{ tempCMR = (int)(colMain.r * 255); tempCMG = (int)(colMain.g * 255); tempCMB = (int)(colMain.b * 255); tempCPR = (int)(colPower.r * 255); tempCPG = (int)(colPower.g * 255); tempCPB = (int)(colPower.b * 255); tempCTR = (int)(colThrust.r * 255); tempCTG = (int)(colThrust.g * 255); tempCTB = (int)(colThrust.b * 255); tempCSR = (int)(colSpecial.r * 255); tempCSG = (int)(colSpecial.g * 255); tempCSB = (int)(colSpecial.b * 255); //} GUILayout.Label("-=BRIDGE SEATING=-", style, GUILayout.Width(220)); if (GUILayout.Button("ADD SEAT", style, GUILayout.Width(220))) { ProtoSeat ps = new ProtoSeat(); ps.name = ""; ps.thrusts = new List <int>(); ps.powSet = 0; ps.wepSet = 0; ps.modSlots = new int[4]; seats.Add(ps); } for (int i = 0; i < seats.Count; i++) { GUILayout.Label("Seat: " + seats[i].name + "/#" + i, style, GUILayout.Width(220)); seats[i].name = GUILayout.TextField(seats[i].name, style, GUILayout.Width(220)); GUILayout.Label("Seat thruster group IDs", style, GUILayout.Width(220)); for (int j = 0; j < thrust.Count; j++) { if (GUILayout.Button("ADD GROUP " + thrust[j].name, style, GUILayout.Width(220))) { seats[i].thrusts.Add(j); } } for (int j = 0; j < seats[i].thrusts.Count; j++) { if (GUILayout.Button("REMOVE GROUP: " + thrust[seats[i].thrusts[j]].name, style, GUILayout.Width(220))) { seats[i].thrusts.RemoveAt(j); } } GUILayout.Label("Seat weapon group", style, GUILayout.Width(220)); for (int j = 0; j < weps.Count; j++) { if (seats[i].wepSet == j) { GUI.color = colSpecial; } else { GUI.color = Color.white; } if (GUILayout.Button("SET GROUP " + weps[j].name, style, GUILayout.Width(220))) { seats[i].wepSet = j; } GUI.color = Color.white; } GUILayout.Label("Seat power system", style, GUILayout.Width(220)); for (int j = 0; j < pows.Count; j++) { if (seats[i].powSet == j) { GUI.color = colPower; } else { GUI.color = Color.white; } if (GUILayout.Button("SET GROUP " + pows[j].name, style, GUILayout.Width(220))) { seats[i].wepSet = j; } GUI.color = Color.white; } for (int m = 0; m < seats[i].modSlots.Length; m++) { GUILayout.Label("Seat module slot #" + m, style, GUILayout.Width(220)); for (int j = 0; j < mods.Count; j++) { if (seats[i].modSlots[m] == j) { GUI.color = colPower; } else { GUI.color = Color.white; } if (GUILayout.Button("SET GROUP " + mods[j].name, style, GUILayout.Width(220))) { seats[i].modSlots[m] = j; } GUI.color = Color.white; } } if (GUILayout.Button("!!WARNING: REMOVE SEAT!!", style, GUILayout.Width(220))) { seats.RemoveAt(i); } } GUILayout.Label("-=THRUSTER GROUPS=-", style, GUILayout.Width(220)); if (GUILayout.Button("ADD GROUP", style, GUILayout.Width(220))) { ProtoThrust pt = new ProtoThrust(); pt.name = ""; pt.axis = ""; thrust.Add(pt); } for (int i = 0; i < thrust.Count; i++) { GUILayout.Label("Thruster Group: " + thrust[i].name + "/#" + i, style, GUILayout.Width(220)); thrust[i].name = GUILayout.TextField(thrust[i].name, style, GUILayout.Width(220)); GUILayout.Label("Thruster Axis: " + thrust[i].axis, style, GUILayout.Width(220)); thrust[i].axis = GUILayout.TextField(thrust[i].axis, style, GUILayout.Width(220)); GUILayout.Label("REMOVE ALL REFERENCES TO THRUSTERGROUP BEFORE USE!", style, GUILayout.Width(220)); if (GUILayout.Button("!!WARNING: REMOVE THRUSTER GROUP!!", style, GUILayout.Width(220))) { thrust.RemoveAt(i); } } GUILayout.Label("-=WEAPON GROUPS=-", style, GUILayout.Width(220)); GUILayout.Label("WEAPON TYPES AVAILABLE RIGHT NOW: LightGatling, LightBeam", style, GUILayout.Width(220)); GUILayout.Label("LightGatling: 240RPM 20-round-clip light gatling weapons. Mid damage, mid range.", style, GUILayout.Width(220)); GUILayout.Label("LightBeam: Constant DPS infinite ammo beam weapons. Mid damage, short range.", style, GUILayout.Width(220)); if (GUILayout.Button("ADD GROUP", style, GUILayout.Width(220))) { ProtoWep pw = new ProtoWep(); pw.name = ""; pw.primWep = ""; pw.altWep = ""; weps.Add(pw); } for (int i = 0; i < weps.Count; i++) { GUILayout.Label("Weapon Group: " + weps[i].name + "/#" + i, style, GUILayout.Width(220)); weps[i].name = GUILayout.TextField(weps[i].name, style, GUILayout.Width(220)); GUILayout.Label("Primary Weapon: " + weps[i].primWep, style, GUILayout.Width(220)); weps[i].primWep = GUILayout.TextField(weps[i].primWep, style, GUILayout.Width(220)); GUILayout.Label("Secondary Weapon: " + weps[i].altWep, style, GUILayout.Width(220)); weps[i].altWep = GUILayout.TextField(weps[i].altWep, style, GUILayout.Width(220)); GUILayout.Label("REMOVE ALL REFERENCES TO WEAPONGROUP BEFORE USE!", style, GUILayout.Width(220)); if (GUILayout.Button("!!WARNING: REMOVE WEAPON GROUP!!", style, GUILayout.Width(220))) { weps.RemoveAt(i); } } GUILayout.Label("-=POWER SYSTEMS=-", style, GUILayout.Width(220)); GUILayout.Label("APMS AVAILABLE RIGHT NOW: Shield, Thrust, Weapon", style, GUILayout.Width(220)); GUILayout.Label("Shield: Absorbs damage while active.", style, GUILayout.Width(220)); GUILayout.Label("Thrust: Boosts thruster strength.", style, GUILayout.Width(220)); GUILayout.Label("Weapon: Increases weapon damage, firerate, and reload speed.", style, GUILayout.Width(220)); if (GUILayout.Button("ADD GROUP", style, GUILayout.Width(220))) { ProtoPowersys pp = new ProtoPowersys(); pp.name = ""; pp.slots = new List <AuxPowerSlot>(); pows.Add(pp); } for (int i = 0; i < pows.Count; i++) { GUILayout.Label("Power System: " + pows[i].name + "/#" + i, style, GUILayout.Width(220)); pows[i].name = GUILayout.TextField(pows[i].name, style, GUILayout.Width(220)); GUILayout.Label("APMS: " + pows[i].slots.Count, style, GUILayout.Width(220)); if (GUILayout.Button("ADD SHIELD APM", style, GUILayout.Width(220))) { AuxPowerSlot aps = new AuxPowerSlot(); aps.mtype = AuxPowerSlot.ModuleType.Shield; pows[i].slots.Add(aps); } if (GUILayout.Button("ADD THRUST APM", style, GUILayout.Width(220))) { AuxPowerSlot aps = new AuxPowerSlot(); aps.mtype = AuxPowerSlot.ModuleType.Thrust; pows[i].slots.Add(aps); } if (GUILayout.Button("ADD WEAPON APM", style, GUILayout.Width(220))) { AuxPowerSlot aps = new AuxPowerSlot(); aps.mtype = AuxPowerSlot.ModuleType.Weapon; pows[i].slots.Add(aps); } for (int j = 0; j < pows[i].slots.Count; j++) { GUILayout.Label("APM #" + j + " TYPE: " + pows[i].slots[j].mtype.ToString() + ", MOD: " + pows[i].slots[j].mod.ToString("P2") + "%", style, GUILayout.Width(220)); pows[i].slots[j].mod = GUILayout.HorizontalSlider(pows[i].slots[j].mod, 0, 1, GUILayout.Width(220)); if (GUILayout.Button("!!WARNING: REMOVE APM!!", style, GUILayout.Width(220))) { pows[i].slots.RemoveAt(j); } } if (GUILayout.Button("!!WARNING: REMOVE POWER GROUP!!", style, GUILayout.Width(220))) { pows.RemoveAt(i); } } GUILayout.Label("-=MODULES=-", style, GUILayout.Width(220)); if (GUILayout.Button("ADD JUMP DRIVE MODULE", style, GUILayout.Width(220))) { ProtoModset pm = new ProtoModset(); pm.mtype = ModuleSlot.ModuleType.JumpDrive; pm.name = ""; pm.pow = 20; pm.tim = 10; pm.col = 20; mods.Add(pm); } if (GUILayout.Button("ADD MISSILE MODULE", style, GUILayout.Width(220))) { ProtoModset pm = new ProtoModset(); pm.mtype = ModuleSlot.ModuleType.Missile; pm.name = ""; pm.pow = 20; pm.tim = 10; pm.col = 20; mods.Add(pm); } if (GUILayout.Button("ADD AUTOREPAIR MODULE", style, GUILayout.Width(220))) { ProtoModset pm = new ProtoModset(); pm.mtype = ModuleSlot.ModuleType.AutoRepair; pm.name = ""; pm.pow = 20; pm.tim = 10; pm.col = 20; mods.Add(pm); } for (int i = 0; i < mods.Count; i++) { GUILayout.Label("Module Slot: " + mods[i].name + "/#" + i, style, GUILayout.Width(220)); mods[i].name = GUILayout.TextField(mods[i].name, style, GUILayout.Width(220)); int tempP = int.Parse(GUILayout.TextField("" + mods[i].pow, style, GUILayout.Width(220))); int tempT = int.Parse(GUILayout.TextField("" + mods[i].tim, style, GUILayout.Width(220))); int tempC = int.Parse(GUILayout.TextField("" + mods[i].col, style, GUILayout.Width(220))); if (tempP + tempT + tempC <= 50) { mods[i].pow = tempP; mods[i].tim = tempT; mods[i].col = tempC; } if (GUILayout.Button("!!WARNING: REMOVE MODSLOT!!", style, GUILayout.Width(220))) { pows.RemoveAt(i); } } GUILayout.Label("-=CAMERA SETUP (X/Y/Z/RANGE)=-", style, GUILayout.Width(220)); float tempX = float.Parse(GUILayout.TextField("" + rotPivot.transform.position.x, style, GUILayout.Width(220))); float tempY = float.Parse(GUILayout.TextField("" + rotPivot.transform.position.y, style, GUILayout.Width(220))); float tempZ = float.Parse(GUILayout.TextField("" + rotPivot.transform.position.z, style, GUILayout.Width(220))); float tempR = float.Parse(GUILayout.TextField("" + (-camTemp.transform.localPosition.z), style, GUILayout.Width(220))); rotPivot.transform.position = new Vector3(tempX, tempY, tempZ); camTemp.transform.localPosition = new Vector3(0, 0, -tempR); GUILayout.Label("-=OPTIMAL WEAPONS RANGE=-", style, GUILayout.Width(220)); wepRange = float.Parse(GUILayout.TextField("" + wepRange, style, GUILayout.Width(220))); GUILayout.EndScrollView(); GUI.DragWindow(); }