void Awake() { health = maxHealth; rb = GetComponent <Rigidbody>(); fuelSlot = GetComponentInChildren <ModuleSlot>(); if (fuelSlot == null || fuelSlot.slotType != GameTypes.ModuleType.FuelPack) { Debug.LogError("Player: No fuel slot set as child"); } weaponSlot = GetComponentInChildren <WeaponSlot>(); if (weaponSlot == null) { Debug.LogError("Player: No weapon slot set as child"); } if (cameraRig == null) { Debug.LogError("Player: No camera rig set in inspector"); } PlayerControl.instance.TakeControl(this); StartCoroutine("WeaponTimer"); }
public void OnBuildModuleClick(int moduleId) // Set from editor { if (selectedTitan == null) { return; } if (selectedTitan.Titan.Faction.ID == 1) { return; } if (selectedTitan.Titan.ModuleSlots.Length <= moduleId || selectedTitan.Titan.ModuleSlots[moduleId] == null) { return; } selectedSlot = selectedTitan.Titan.ModuleSlots[moduleId]; var selectModule = UILayer.ShowModal <SelectModuleUI>(); selectModule.Init(modules[moduleId].RectTransform.anchoredPosition + new Vector2(0, 800), selectedSlot); // var module = new ModuleData("laser", 5, 2f); // selectedSlot.Attach(Model.ModulesFactory.CreateBuildModule(module, selectedSlot)); // UpdateModules(); // FullScreenHolder.gameObject.SetActive(true); // BuildContextMenu.gameObject.SetActive(true); // BuildContextMenu.position = modules[moduleId].transform.position; }
public void EquipFuelPack(ModuleSlot playerSlot) { if (heldObject != null) { if (heldObject.GetComponent <FuelPack>()) { if (playerSlot.connectedModule == null) { PlayerHUD.instance.EnableFuelPackHUD(heldObject.GetComponent <FuelPack>()); ConnectModule(playerSlot); } else { Debug.LogWarning("MatterManipulator: A different fuel pack is already equipped"); } } else { Debug.LogWarning("MatterManipulator: Not holding fuel pack"); } } else { if (playerSlot.connectedModule != null) { PlayerHUD.instance.DisableFuelPackHUD(); GrabObject(playerSlot.connectedModule.gameObject); assignedSlot = null; } } }
void ConnectModule(ModuleSlot slot) { Rigidbody rb = heldObject.GetComponent <Rigidbody>(); SceneManager.instance.RemoveGravityBody(rb); Destroy(rb); heldObject.transform.SetParent(slot.transform); ShipModule currentModule = heldObject.GetComponent <ShipModule>(); slot.connectedModule = currentModule; currentModule.connected = true; slot.GetComponent <MeshRenderer>().enabled = false; assignedSlot = null; Ship ship = slot.GetComponentInParent <Ship>(); if (ship) { ship.UpdateModuleStatus(currentModule, currentModule.moduleType, true); currentModule.shipRB = ship.GetComponent <Rigidbody>(); } FindObjectOfType <Ship>().ToggleModuleSlots(false); heldObject = null; PlayerHUD.instance.ToggleCrosshair(true); PlayerCamera.instance.checkForUsable = true; PlayerCamera.instance.checkForMaterializable = true; energyParticles.Stop(); }
public void Notify_ModulesChanges() { ChargeSpeed = 0.06f; EnergyBank = 0f; PowerLimit = 0f; for (int i = 0; i < Slots.Count; i++) { ModuleSlot <MKStationModule> slot = Slots[i]; if (slot.Module != null) { EnergyBank += slot.Module.def.EnergyBankCapacity; ChargeSpeed += slot.Module.def.AdditionalChargeSpeed; PowerLimit = Mathf.Clamp(PowerLimit + slot.Module.def.PowerLimit, 0, 9999); if (!CanOverDrive) { CanOverDrive = slot.Module.def.EnableOverDrive; } if (slot.Module.def.GainStationLevel > StationLevel) { StationLevel = slot.Module.def.GainStationLevel; } } } EnergyBankCharge = Mathf.Clamp(EnergyBankCharge, 0, EnergyBank); }
private void OnTriggerExit(Collider other) { var moduleCollider = other.GetComponent <ModuleInteractCollider>(); var airlock = other.GetComponent <Airlock>(); var validInteraction = false; if (moduleCollider != null) { validInteraction = true; nearbyModule = null; } else if (airlock != null && airlock == nearbyAirlock) { validInteraction = true; nearbyAirlock = null; } else { var slot = FindModuleSlot(other); if (slot == nearbySlot) { validInteraction = true; nearbySlot = null; } } if (validInteraction) { var events = other.GetComponent <EventsForToggle>(); if (events != null) { events.TriggerNegative(); } } }
private void UpdateModules() { for (int i = 0; i < modules.Length; i++) { if (modules[i] == null) { throw new NullReferenceException("Module slot dont set in interface"); } ModuleSlot slot = null; if (selectedTitan.Titan.ModuleSlots.Length > i) { slot = selectedTitan.Titan.ModuleSlots[i]; } modules[i].SetModule(slot); } // for (int i = 0; i < modules.Length; i++) { // bool needShow = false; // if (selectedTitan.SlotLevel.Length > i) // needShow = selectedTitan.SlotLevel[i] <= selectedTitan.Level; // if (modules[i] != null) { // modules[i].SetActive(needShow); // } // ITitanModule module = null; // if (selectedTitan.Modules.Length > i) // module = selectedTitan.Modules[i]; // if (modules[i] != null) { // modules[i].SetModule(module); // } // } // buildTitanModule.SetModule(selectedTitan.Modules[12]); // upgradeTitanModule.SetModule(selectedTitan.Modules[13]); // upgradeTitanModule.gameObject.SetActive(selectedTitan.Level < TitanViewOld.MaxLevel); // OnBuildRocketButton.SetModule(selectedTitan.Modules[14]); LayoutRebuilder.ForceRebuildLayoutImmediate(modules[0].transform.parent.GetComponent <RectTransform>()); }
//对拖动开始事件的响应 //读取信息并赋值给Image public void DragAndDrop_OnLeftBeginDrag(Transform tf) { //判断拖动的是什么格子 if (tf.transform.tag.Equals("ModuleSlot"))//如果是装备栏,则从装备中提取信息 { ModuleSlot ms = tf.GetComponent <ModuleSlot>(); if (PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex] != null) { Img.sprite = PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex].Icon; this.gameObject.SetActive(true); } else { return; } } else if (tf.transform.tag.Equals("ModuleSelection"))//如果是仓库,则从仓库中提取信息 { ModuleSelectUI ms = tf.GetComponent <ModuleSelectUI>(); if (PlayerManager.instance.ModuleList[ms.Index] != null) { Img.sprite = PlayerManager.instance.ModuleList[ms.Index].Icon; this.gameObject.SetActive(true); } else { return; } } else { return; } }
public void SetModule(ModuleSlot controlSlot) { if (module == controlSlot.Module) { return; } module = controlSlot.Module; UpdatePanel(); }
public Module RemoveModuleAtCollider(Collider c) { ModuleSlot moduleToRemove = m_ColliderToModuleDictionary[c]; Module m = null; if (moduleToRemove != null) { m = moduleToRemove.RemoveModule(); } m_ColliderToModuleDictionary[c] = null; return(m); }
void DisconnectModule(ModuleSlot slot) { Rigidbody rb = heldObject.AddComponent <Rigidbody>(); rb.mass = heldObject.GetComponent <ShipModule>().mass; SceneManager.instance.AddGravityBody(rb); slot.connectedModule = null; heldObject.GetComponent <ShipModule>().connected = false; assignedSlot = slot; slot.GetComponent <MeshRenderer>().enabled = true; }
public void LockIn(Crunk c, ModuleSlot slot) { m_CurrentCrunk = c; if (m_CurrentCrunk != null) { if (m_CurrentCrunk.parentShip == m_ParentShip) { m_CurrentCrunk.lockedSlot = slot; } } m_LockedIn = true; }
public void RemoveModule(MKStationModuleDef moduleDef) { for (int i = 0; i < Slots.Count; i++) { ModuleSlot <MKStationModule> slot = Slots[i]; if (slot.Module.def == moduleDef) { slot.Module = null; break; } } Notify_ModulesChanges(); }
private void OnTriggerEnter(Collider other) { var moduleCollider = other.GetComponent <ModuleInteractCollider>(); var airlock = other.GetComponent <Airlock>(); bool validInteraction = false; if (moduleCollider != null) { if (nearbyModule == null || (moduleCollider.targetModule.transform.position - transform.position).sqrMagnitude < (nearbyModule.transform.position - transform.position).sqrMagnitude) { validInteraction = true; nearbyModule = moduleCollider.targetModule; } } else if (airlock != null) { if (airlock.GetTeam() == GetTeam()) { validInteraction = true; nearbyAirlock = airlock; } } else { var slot = FindModuleSlot(other); if (slot != null) { if (nearbySlot != null && nearbySlot != slot) { allyShip.GetColliderFromModuleSlot(nearbySlot).GetComponent <EventsForToggle>().TriggerNegative(); } validInteraction = true; nearbySlot = slot; } } if (validInteraction) { var events = other.GetComponent <EventsForToggle>(); if (events != null) { events.TriggerPositive(); } } }
public void DragAndDrop_OnLeftBeginDrag(Transform tf) { //icon = new GameObject("Icon", typeof(Image)); if (tf.transform.tag.Equals("ModuleSlot")) { ModuleSlot ms = tf.GetComponent <ModuleSlot>(); if (PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex] != null) { icon = new GameObject("Icon", typeof(Image)); icon.GetComponent <Image>().sprite = PlayerManager.instance.ModuleMap[ms.rawIndex, ms.rolIndex].Icon; icon.transform.SetParent(GameObject.Find("Canvas").transform); icon.transform.SetAsLastSibling(); } else { return; } } else if (tf.transform.tag.Equals("ModuleSelection")) { ModuleSelectUI ms = tf.GetComponent <ModuleSelectUI>(); if (StorageManager.instance.ModuleList[ms.Index] != null) { icon = new GameObject("Icon", typeof(Image)); icon.GetComponent <Image>().sprite = StorageManager.instance.ModuleList[ms.Index].Icon; icon.transform.SetParent(GameObject.Find("Canvas").transform); icon.transform.SetAsLastSibling(); } else { return; } } else { return; } }
void Update() { if (!destroyed) { timeSinceDamage += Time.deltaTime; if (health < maxHealth && timeSinceDamage >= repairDelay) { repairing = true; } if (Input.GetButtonUp("WeaponSwap")) { wp[seats[curSeat].weaponSet].secondaryActive = !wp[seats[curSeat].weaponSet].secondaryActive; } if (Input.GetButtonUp("Module1")) { ModuleSlot mod = slots[seats[curSeat].moduleSlots[0]]; if (mod.cooldown <= 0) { mod.cooldown = mod.modules[0].cooldown * mod.modCooldown; mod.runtime = mod.modules[0].time * mod.modTime; } } if (Input.GetButtonUp("Module2")) { ModuleSlot mod = slots[seats[curSeat].moduleSlots[1]]; if (mod.cooldown <= 0) { mod.cooldown = mod.modules[0].cooldown * mod.modCooldown; mod.runtime = mod.modules[0].time * mod.modTime; } } if (Input.GetButtonUp("Module3")) { ModuleSlot mod = slots[seats[curSeat].moduleSlots[2]]; if (mod.cooldown <= 0) { mod.cooldown = mod.modules[0].cooldown * mod.modCooldown; mod.runtime = mod.modules[0].time * mod.modTime; } } if (Input.GetButtonUp("Module4")) { ModuleSlot mod = slots[seats[curSeat].moduleSlots[3]]; if (mod.cooldown <= 0) { mod.cooldown = mod.modules[0].cooldown * mod.modCooldown; mod.runtime = mod.modules[0].time * mod.modTime; } } foreach (ModuleSlot ms in slots) { ms.cooldown -= Time.deltaTime; if (ms.runtime > 0) { ms.runtime -= Time.deltaTime; if (ms.mtype == ModuleSlot.ModuleType.AutoRepair) { health += Time.deltaTime * ms.modules[0].power1 * ms.modPower; } else if (ms.mtype == ModuleSlot.ModuleType.JumpDrive) { if (ms.runtime <= 0) { transform.Translate(ms.modules[0].power1 * ms.modules[0].transform.forward, Space.World); } } else if (ms.mtype == ModuleSlot.ModuleType.Missile) { ms.runtime = -1; GameObject bullet = (GameObject)Instantiate(ms.modules[0].go, ms.modules[0].transform1.position, ms.modules[0].transform1.rotation); bullet.GetComponent <Rigidbody>().AddForce(bullet.transform.forward * ms.modules[0].time * ms.modTime); } } } int heals = injurySlots; foreach (Crew c in crewmembers) { if (c.j == Crew.Job.Engineer && c.injured == false && repairing) { health += repairSpeed * Time.deltaTime; } if (c.injured && heals > 0) { heals -= 1; c.recoveryTime += Time.deltaTime; if (c.recoveryTime > 30) { c.recoveryTime = 0; c.injured = false; } } } if (health < 0) { foreach (Block b in blocks) { b.OnShipDestroy(); b.transform.parent = null; b.transform.SetParent(null); } Cursor.lockState = CursorLockMode.None; Cursor.visible = true; destroyed = true; } if (health > maxHealth) { health = maxHealth; repairing = false; } foreach (PowerSystem ps in powerSys) { ps.energyStored += (ps.energyPerSec - ps.passive) * Time.deltaTime; if (ps.energyStored > ps.energyMax) { ps.energyStored = ps.energyMax; } if (ps.energyStored < 0) { ps.energyStored = 0; } } foreach (WeaponPair w in wp) { w.UpdateState(); } if (Input.GetButton("Fire1")) { wp[seats[curSeat].weaponSet].Fire(true); } if (Input.GetButtonUp("Fire1")) { wp[seats[curSeat].weaponSet].Fire(false); } if (Input.GetButtonUp("Reload")) { wp[seats[curSeat].weaponSet].Reload(); } if (Input.GetButton("Fire2")) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } if (Input.GetButtonUp("Pause")) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } WeaponPair wpp = wp[seats[curSeat].weaponSet]; if (wpp.secondaryActive) { foreach (Weapon w in wpp.weapons2) { w.LookAt(seats[curSeat].weaponTarget); w.active = true; } foreach (Weapon w in wpp.weapons1) { w.active = false; } } else { foreach (Weapon w in wpp.weapons1) { w.LookAt(seats[curSeat].weaponTarget); w.active = true; } foreach (Weapon w in wpp.weapons2) { w.active = false; } } } if (destroyed) { lifetime -= Time.deltaTime; if (lifetime <= 0) { Destroy(this.gameObject); } } }
public Collider GetColliderFromModuleSlot(ModuleSlot ms) { return(m_ColliderToModuleDictionary.FirstOrDefault(x => x.Value == ms).Key); }
public void AssignModuleSlot(ModuleSlot slot) { assignedSlot = slot; }
public void Init(Vector2 position, ModuleSlot controlSlot) { listPanel.anchoredPosition = new Vector2(position.x + 50, 0); cancelButtonRect.anchoredPosition = position; slot = controlSlot; }
private void Update() { if (Input.GetAxis($"Interact{crunk.playerNumber}") > Helper.Epsilon) { if (interactTime == 0) { if (crunk.nearbySlot != null) { var slotCollider = crunk.allyShip.GetColliderFromModuleSlot(crunk.nearbySlot); if (slotCollider != null) { if (crunk.nearbySlot.Module == null) { slotCollider.GetComponent <ModuleSlotAnimation>().BeginAttaching(); } else { slotCollider.GetComponent <ModuleSlotAnimation>().BeginDettaching(); } } } } interacting = !holdingDownButton; } else { interactTime = 0; canHoldButton = true; var slotCollider = crunk.allyShip.GetColliderFromModuleSlot(crunk.nearbySlot); if (slotCollider != null) { slotCollider.GetComponent <ModuleSlotAnimation>().StopTransitioning(); } ModuleSlot nearbySlot = crunk.lockedSlot ?? crunk.nearbySlot; if (interacting) { if (crunk.nearbyAirlock != null) { if (crunk.lockedSlot == null) { if (crunk.nearbyAirlock.GetTeam() == crunk.GetTeam()) { if (crunk.grabbedModule != null) { crunk.DropModule(true); } if (crunk.parentShip == null) { crunk.nearbyAirlock.EnterShip(crunk.Mover); } else { crunk.nearbyAirlock.LeaveShip(crunk.Mover); } } } } else if (crunk.grabbedModule != null) { crunk.DropModule(true); } else if (nearbySlot != null) { if (nearbySlot.GetShip().GetTeam() == crunk.GetTeam()) { var slottedModule = nearbySlot.Module; if (slottedModule != null) { if (slottedModule.IsLockedIn()) { slottedModule.LockOut(); // Turn off hinter on module slot. var hinter = slottedModule.GetComponentInParent <EventsForToggle>(); if (hinter != null) { hinter.TriggerPositive(); } } else { slottedModule.LockIn(crunk, nearbySlot); crunk.transform.LookAt(slottedModule.transform.position); // Turn off hinter on module slot. var hinter = slottedModule.GetComponentInParent <EventsForToggle>(); if (hinter != null) { hinter.TriggerNegative(); } } } } } else if (crunk.nearbyModule != null) { crunk.PickupModule(crunk.nearbyModule); } } interacting = false; holdingDownButton = false; } if (interacting) { if (interactTime >= holdThreshold) { interacting = false; holdingDownButton = canHoldButton; } interactTime += Time.deltaTime; } if (holdingDownButton && canHoldButton && crunk.lockedSlot == null) { if (crunk.nearbySlot != null && crunk.parentShip == null) { if (crunk.grabbedModule != null) { AttachModuleToShipFromHand(); } else if (crunk.nearbySlot.Module != null && crunk.parentShip == null) { var slotAnimation = crunk.nearbySlot.Module.GetComponentInParent <ModuleSlotAnimation>(); if (slotAnimation) { slotAnimation.FinishDettaching(); } Module detachingModule = crunk.nearbySlot.Module; crunk.nearbySlot.RemoveModule(); crunk.PickupModule(detachingModule); holdingDownButton = false; canHoldButton = false; } } } }
void SpawnShip(TextAsset file) { 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; shipBase.name = 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); ss.shipColorMain = 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); ss.shipColorPower = 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); ss.shipColorThrust = 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); ss.shipColorSpecial = cSpecial; string[] posOff = strings[offset].Split(','); offset += 1; Vector3 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; ss.seats = new BridgeSeat[numSeats]; for (int i = 0; i < numSeats; i++) { ss.seats[i] = new BridgeSeat(); ss.seats[i].name = strings[offset]; ss.seats[i].weaponTarget = targ; print(strings[offset]); offset += 1; ss.seats[i].availableThrusts = new List <int>(); int numThrustsSeat = int.Parse(strings[offset]); print(strings[offset]); offset += 1; for (int n = 0; n < numThrustsSeat; n++) { ss.seats[i].availableThrusts.Add(int.Parse(strings[offset])); print(strings[offset]); offset += 1; } ss.seats[i].weaponSet = int.Parse(strings[offset]); print("WEAPON SET: " + strings[offset]); offset += 1; ss.seats[i].powerSet = 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; ss.seats[i].moduleSlots = new int[numSeatModules]; for (int n = 0; n < numSeatModules; n++) { ss.seats[i].moduleSlots[n] = int.Parse(strings[offset]); print(strings[offset]); offset += 1; } } int numThrusts = int.Parse(strings[offset]); print(strings[offset]); offset += 1; ss.tgs = new List <ThrusterGroup>(); for (int i = 0; i < numThrusts; i++) { ThrusterGroup tg = new ThrusterGroup(); tg.name = strings[offset]; print(strings[offset]); offset += 1; tg.axis = strings[offset]; print(strings[offset]); offset += 1; tg.negThrust = new List <Thruster>(); tg.posThrust = new List <Thruster>(); ss.tgs.Add(tg); } int numWeps = int.Parse(strings[offset]); print(strings[offset]); offset += 1; ss.wp = new List <WeaponPair>(); for (int i = 0; i < numWeps; i++) { string wepSetName = 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; WeaponPreset wep1 = weapons[weaponPrimary]; WeaponPreset wep2 = weapons[weaponSecondary]; WeaponPair wp = new WeaponPair(); wp.weapons1 = new List <Weapon>(); wp.weapons2 = new List <Weapon>(); wp.ammo1 = wep1.ammo; wp.ammoMax1 = wep1.ammo; wp.ammo2 = wep2.ammo; wp.ammoMax2 = wep2.ammo; wp.firerate1 = wep1.firerate; wp.reloadSpeed1 = wep1.reloadSpeed; wp.firerate2 = wep2.firerate; wp.reloadSpeed2 = wep2.reloadSpeed; wp.name = wepSetName; ss.wp.Add(wp); } int numPowerSys = int.Parse(strings[offset]); print(strings[offset]); offset += 1; ss.powerSys = new List <PowerSystem>(); 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; PowerSystem ps = new PowerSystem(); 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); } ss.powerSys.Add(ps); } int numModulesReal = int.Parse(strings[offset]); print(strings[offset]); offset += 1; ss.slots = new List <ModuleSlot>(); 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; float power = 1 + (powerPower - 20) * 0.05f; float time = 1 + (timePower - 10) * 0.1f; float cool = 1 + (coolPower - 20) * -0.025f; ModuleSlot ms = new ModuleSlot(); ms.name = modName; ms.modPower = power; ms.modTime = time; ms.modCooldown = cool; ms.mtype = modules[modType]; ms.modules = new List <Module>(); ss.slots.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; shipBase.transform.GetChild(0).localPosition = new Vector3(offsetX, offsetY, offsetZ); float camrange = float.Parse(strings[offset]); print(strings[offset]); offset += 1; shipBase.transform.FindChild("CameraPos/CamObj/Main Camera").localPosition = new Vector3(0, 0, -camrange); float range = float.Parse(strings[offset]); print(strings[offset]); offset += 1; targ.localPosition = new Vector3(0, 0, range); int numBlocks = int.Parse(strings[offset]); print(strings[offset]); offset += 1; ss.blocks = new List <Block>(); 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(float.Parse(rotation[0]), float.Parse(rotation[1]), float.Parse(rotation[2])); Quaternion rot = new Quaternion(); rot.eulerAngles = ea; 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; } } sr.Close(); }