public void FinishContruction() { building_mode = false; is_overlap = false; selectable.enabled = true; foreach (Collider collide in colliders) { collide.isTrigger = false; } destruct = GetComponent <Destructible>(); if (destruct) { destruct.enabled = true; destruct.was_built = true; } SetModelColor(Color.white); BuiltConstructionData cdata = PlayerData.Get().AddConstruction(data.id, SceneNav.GetCurrentScene(), transform.position); unique_id.unique_id = cdata.uid; if (build_fx != null) { Instantiate(build_fx, transform.position, Quaternion.identity); } TheAudio.Get().PlaySFX("construction", build_audio); if (onBuild != null) { onBuild.Invoke(); } }
public void Save() { PlayerData.Get().current_scene = SceneNav.GetCurrentScene(); PlayerData.Get().current_pos = PlayerCharacter.Get().transform.position; PlayerData.Get().current_entry_index = -1; //Go to current_pos PlayerData.Get().Save(); }
private IEnumerator NewRoutine() { BlackPanel.Get().Show(); yield return(new WaitForSeconds(1f)); PlayerData.NewGame(); SceneNav.GoTo(PlayerData.Get().current_scene); }
private IEnumerator LoadRoutine() { BlackPanel.Get().Show(); yield return(new WaitForSeconds(1f)); PlayerData.Unload(); //Make sure to unload first, or it won't load if already loaded PlayerData.LoadLast(); SceneNav.GoTo(PlayerData.Get().current_scene); }
//Create a totally new one that will be added to save file public static Item Create(ItemData data, Vector3 pos, int quantity) { DroppedItemData ditem = PlayerData.Get().AddDroppedItem(data.id, SceneNav.GetCurrentScene(), pos, quantity); GameObject obj = Instantiate(data.item_prefab, pos, data.item_prefab.transform.rotation); Item item = obj.GetComponent <Item>(); item.data = data; item.was_dropped = true; item.unique_id.unique_id = ditem.uid; item.quantity = quantity; return(item); }
private void Start() { //Load game data PlayerData pdata = PlayerData.Get(); GameData gdata = GameData.Get(); if (!string.IsNullOrEmpty(pdata.current_scene)) { if (pdata.current_entry_index < 0 && pdata.current_scene == SceneNav.GetCurrentScene()) { PlayerCharacter.Get().transform.position = pdata.current_pos; TheCamera.Get().MoveToTarget(pdata.current_pos); } } pdata.current_scene = SceneNav.GetCurrentScene(); //Spawn dropped items foreach (KeyValuePair <string, DroppedItemData> elem in pdata.dropped_items) { if (elem.Value.scene == SceneNav.GetCurrentScene()) { Item.Spawn(elem.Key); } } //Spawn constructions foreach (KeyValuePair <string, BuiltConstructionData> elem in pdata.built_constructions) { if (elem.Value.scene == SceneNav.GetCurrentScene()) { Construction.Spawn(elem.Key); } } //Spawn plants foreach (KeyValuePair <string, SowedPlantData> elem in pdata.sowed_plants) { if (elem.Value.scene == SceneNav.GetCurrentScene()) { Plant.Spawn(elem.Key); } } BlackPanel.Get().Show(true); BlackPanel.Get().Hide(); }
//Create a totally new one that will be added to save file public static Plant Create(PlantData data, Vector3 pos, int stage) { SowedPlantData splant = PlayerData.Get().AddPlant(data.id, SceneNav.GetCurrentScene(), pos, stage); GameObject prefab = data.GetStagePrefab(stage); GameObject build = Instantiate(prefab, pos, prefab.transform.rotation); Plant plant = build.GetComponent <Plant>(); plant.data = data; plant.was_built = true; plant.unique_id.unique_id = splant.uid; Destructible destruct = plant.GetComponent <Destructible>(); if (destruct != null) { destruct.was_built = true; } return(plant); }
public void GrowPlant() { if (!IsFullyGrown()) { SowedPlantData sdata = PlayerData.Get().GetSowedPlant(GetUID()); if (sdata == null) { //Remove this plant and create a new one (this one probably was already in the scene) if (!was_built) { PlayerData.Get().RemoveObject(GetUID()); //Remove Unique id } sdata = PlayerData.Get().AddPlant(data.id, SceneNav.GetCurrentScene(), transform.position, growth_stage + 1); } else { //Grow current plant from data PlayerData.Get().GrowPlant(GetUID(), growth_stage + 1); } Plant plant = Spawn(sdata.uid); Destroy(gameObject); } }