public void CloseUI(bool val) { foreach (ShipBuilderPart part in cursorScript.parts) { Destroy(part.gameObject); } cursorScript.parts.Clear(); if (partDict != null) { foreach (DWInventoryButton but in partDict.Keys) { Destroy(but.gameObject); } partDict = null; } if (builderPartDict != null) { foreach (ShipBuilderInventoryScript inv in builderPartDict.Values) { Destroy(inv.gameObject); } builderPartDict = null; } player.SetIsInteracting(false); base.CloseUI(); player.Rebuild(); }
public void OnPointerClick(PointerEventData eventData) { if (Input.GetKey(KeyCode.LeftShift)) { ClearPreset(); return; } if (!valid) { return; // allow user to left shift out blueprint so return after that } // TODO: check if adding a part back into your inventory validates the preset if (!blueprint && (builder.reconstructStatus == ShipBuilder.ReconstructButtonStatus.Valid)) { blueprint = ScriptableObject.CreateInstance <EntityBlueprint>(); blueprint.coreShellSpriteID = player.blueprint.coreShellSpriteID; blueprint.coreSpriteID = player.blueprint.coreSpriteID; blueprint.parts = new List <EntityBlueprint.PartInfo>(); foreach (ShipBuilderPart part in cursorScript.parts) { if (!part.isInChain || !part.validPos) { blueprint = null; return; } blueprint.parts.Add(part.info); } if (player.cursave.presetBlueprints == null || (player.cursave.presetBlueprints != null && player.cursave.presetBlueprints.Length < 5)) { player.cursave.presetBlueprints = new string[5]; } player.cursave.presetBlueprints[number - 1] = JsonUtility.ToJson(blueprint); } else if (blueprint) { cursorScript.ClearAllParts(); foreach (EntityBlueprint.PartInfo info in blueprint.parts) { if (!builder.DecrementPartButton(ShipBuilder.CullSpatialValues(info))) { // cursorScript.ClearAllParts(); builder.CloseUI(false); return; } } var x = new EntityBlueprint.PartInfo[blueprint.parts.Count]; blueprint.parts.CopyTo(x); player.blueprint.parts = new List <EntityBlueprint.PartInfo>(x); builder.CloseUI(true); OnPointerExit(null); player.Rebuild(); } }
public void CloseUI(bool val) { // try adding parts in the player's inventory and on their ship into the part index obtained list. if (val && builderPartDict != null) { var spawnParts = player.cursave.partInventory.FindAll(p => p.abilityID == 10); player.cursave.partInventory = spawnParts; foreach (EntityBlueprint.PartInfo info in builderPartDict.Keys) { if (builderPartDict[info].GetCount() > 0) { for (int i = 0; i < builderPartDict[info].GetCount(); i++) { player.cursave.partInventory.Add(info); PartIndexScript.AttemptAddToPartsObtained(info); } } } } if (builderPartDict != null) { foreach (ShipBuilderInventoryScript inv in builderPartDict.Values) { Destroy(inv.gameObject); } builderPartDict = null; } foreach (ShipBuilderPart part in cursorScript.parts) { Destroy(part.gameObject); } cursorScript.parts.Clear(); if (partDict != null) { foreach (DWInventoryButton but in partDict.Keys) { Destroy(but.gameObject); } partDict = null; } player.SetIsInteracting(false); base.CloseUI(); player.Rebuild(); }
public void OnPointerClick(PointerEventData eventData) { if (player.reputation >= repCost) { player.blueprint.coreShellSpriteID = coreID; player.blueprint.baseRegen = CoreUpgraderScript.GetRegens(coreID); player.Rebuild(); CoreUpgraderScript.DrawScreen(); NodeEditorFramework.Standard.UpgradeCoreCondition.OnCoreUpgrade.Invoke(); } else { Debug.Log("Not enough reputation!" + player.reputation + " " + repCost); } }
public void Initialize() { string currentPath; if (!File.Exists(Application.persistentDataPath + "\\CurrentSavePath")) { currentPath = Application.persistentDataPath + "\\TestSave"; } else { currentPath = File.ReadAllLines(Application.persistentDataPath + "\\CurrentSavePath")[0]; } if (File.Exists(currentPath)) { // Load string json = File.ReadAllText(currentPath); save = JsonUtility.FromJson <PlayerSave>(json); if (save.timePlayed != 0) { player.spawnPoint = save.position; } if (SectorManager.testJsonPath != null) { save.resourcePath = SectorManager.testJsonPath; } else if (save.resourcePath == "") { save.resourcePath = SectorManager.jsonPath; } player.cursave = save; SectorManager.instance.LoadSectorFile(save.resourcePath); taskManager.Initialize(true); // Re-init DialogueSystem.InitCanvases(); player.blueprint = ScriptableObject.CreateInstance <EntityBlueprint>(); player.blueprint.name = "Player Save Blueprint"; if (save.currentPlayerBlueprint != null && save.currentPlayerBlueprint != "") { JsonUtility.FromJsonOverwrite(save.currentPlayerBlueprint, player.blueprint); } else { Debug.LogWarning("Save should have been given a currentPlayerBlueprint by now."); player.blueprint.parts = new List <EntityBlueprint.PartInfo>(); player.blueprint.baseRegen = new float[] { 60, 0, 60 }; player.blueprint.shellHealth = new float[] { 1000, 250, 500 }; player.blueprint.coreSpriteID = "core1_light"; player.blueprint.coreShellSpriteID = "core1_shell"; } player.abilityCaps = save.abilityCaps; player.shards = save.shards; player.credits = save.credits; player.reputation = save.reputation; if (save.presetBlueprints.Length != 5) { save.presetBlueprints = new string[5]; } player.Rebuild(); Camera.main.GetComponent <CameraScript>().Initialize(player); GameObject.Find("AbilityUI").GetComponent <AbilityHandler>().Initialize(player); taskManager.taskVariables.Clear(); for (int i = 0; i < save.taskVariableNames.Length; i++) { taskManager.taskVariables.Add(save.taskVariableNames[i], save.taskVariableValues[i]); } } else { Debug.LogWarning("There was not a save or test save that was ready on load."); save = new PlayerSave(); save.presetBlueprints = new string[5]; save.currentHealths = new float[] { 1000, 250, 500 }; save.partInventory = new List <EntityBlueprint.PartInfo>(); player.blueprint = ScriptableObject.CreateInstance <EntityBlueprint>(); player.blueprint.name = "Player Save Blueprint"; player.blueprint.baseRegen = new float[] { 60, 0, 60 }; player.blueprint.shellHealth = new float[] { 1000, 250, 500 }; player.blueprint.parts = new List <EntityBlueprint.PartInfo>(); player.blueprint.coreSpriteID = "core1_light"; player.blueprint.coreShellSpriteID = "core1_shell"; player.cursave = save; player.abilityCaps = new int[] { 10, 10, 10, 10 }; } }