/// <summary> /// loads the item into a scene /// </summary> /// <param name="sceneName"></param> public void LoadItems(string sceneName) { List <Item> itemsToChange = new List <Item>(); if (sceneName.Equals("PreQuakeApartment")) { foreach (Item item in GlobalItemList.ItemList.Values) { if (item.scene.Equals("PreQuakeHouse")) { itemsToChange.Add(item); } } } foreach (Item item in itemsToChange) { GlobalItemList.UpdateItemList(item.name, "PreQuakeApartment", new Vector3(item.location.x - 2, item.location.y, item.location.z), item.containerName); } GameObject g = GameObject.FindWithTag("Inventory"); if (g) { inventory = g.GetComponent <Inventory>(); } foreach (Item item in GlobalItemList.ItemList.Values) { if (item.scene.Equals(sceneName) && item.containerName.Equals("")) { //poot item here GameObject prefab = (GameObject)Resources.Load(item.name, typeof(GameObject)); // prefab.transform.position = item.location; GameObject itemInScene = Instantiate(prefab, item.location, Quaternion.identity); itemInScene.transform.position = item.location; } else if (item.scene.Equals("Inventory") && item.containerName.Equals("Player") && inventory) { //populate inventory with many things GameObject prefab = (GameObject)Resources.Load(item.name, typeof(GameObject)); GameObject itemInInventory = Instantiate(prefab, item.location, Quaternion.identity); inventory.PickUpAtSlot((int)item.location.x, itemInInventory); } //case when we have an occupied container in the scene to be loaded else if (item.scene.Equals(sceneName) && !item.containerName.Equals("")) { GameObject itemInContainer = GameObject.Find(item.containerName); if (itemInContainer) { GameObject prefab = (GameObject)Resources.Load(item.name, typeof(GameObject)); // prefab.transform.position = item.location; GameObject itemInScene = Instantiate(prefab, item.location, Quaternion.identity); itemInScene.transform.position = item.location; //place this item into the storage container's contents itemInContainer.GetComponent <StorageContainer>().contents = itemInScene; } } } }
void FixedUpdate() { if (AllContainersFull()) { if (GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { foreach (StorageContainer container in containers) { GameObject item = container.contents; if (item) { GlobalItemList.UpdateItemList(item.name, "QuakeApartment", item.transform.position, container.name); } } SceneManager.LoadScene("QuakeApartment"); } else { foreach (StorageContainer container in containers) { GameObject item = container.contents; if (item) { GlobalItemList.UpdateItemList(item.name, "QuakeHouse", item.transform.position, container.name); } } SceneManager.LoadScene("QuakeHouse"); } } }
/// <summary> /// Takes the item in container (if there is one) or puts the selected item into container. /// </summary> void InteractWithStorageContainer(StorageContainer container) { int i = FirstEmptySlot(); if (i >= 0 && !SlotIsOccupied(i) && container.contents) { GameObject item = container.RemoveItem(); item.GetComponent <Collectible>().inStorageContainer = false; PickUp(item); } else { i = selectedSlotNumber; // Just to make the later expressions less hairy if (SlotIsOccupied(i) && !container.contents) { // Place item in the container container.contents = items[i]; items[i].SetActive(true); Transform t = player.transform; items[i].transform.position = player.destination.transform.position + player.transform.forward + Vector3.up; items[i].GetComponent <Collectible>().inStorageContainer = true; GlobalItemList.UpdateItemList(items[i].name, SceneManager.GetActiveScene().name, items[i].transform.position, container.name); // If these items are in a storage container, then the player doesn't have them // update globalControlsProperties accordingly. if (items[i].name.Equals("Water Bottle Clean(Clone)")) { GlobalControls.globalControlsProperties.Remove("playerHasCleanWater"); } if (items[i].name.Equals("Wrench(Clone)")) { GlobalControls.globalControlsProperties.Remove("playerHasWrench"); } if (items[i].name.Equals("First Aid Kit(Clone)")) { GlobalControls.globalControlsProperties.Remove("playerHasFirstAidKit"); } if (items[i].name.Equals("Epi Pen(Clone)")) { GlobalControls.globalControlsProperties.Remove("playerHasEpiPen"); } if (items[i].name.Equals("Wrench(Clone)")) { GlobalControls.globalControlsProperties.Remove("playerHasWrench"); } // Remove item from inventory items[i] = null; inventoryUI.RemoveFromSlot(i); } } }
void Awake() { if (GlobalItemList.instance == null) { GlobalItemList.instance = this; } else if (GlobalItemList.instance != this) { Destroy(this); } }
public void Restart() { GlobalControls.Reset(); GlobalItemList.Reset(); if (GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { ChangeScene("PreQuakeApartmentStylizedv3"); } else { ChangeScene("PreQuakeHouse"); } }
public void UpdateGlobalItemList(string npcName) { for (int i = 0; i < inventoryUIs[(int)InventoryE.NPC].slotContents.Length; i++) { if (inventoryUIs[(int)InventoryE.NPC].slotContents[i].activeSelf) { inventories[(int)InventoryE.NPC].items[i].name = inventories[(int)InventoryE.NPC].items[i].name.Replace("(Clone)", "").Trim(); //If new item for NPC and it's one of their needs increase satisfaction int indexInNPCNeeds = GlobalControls.npcList[npcName].needs .IndexOf(inventories[(int)InventoryE.NPC].items[i].name); if (indexInNPCNeeds >= 0 && !GlobalItemList.ItemList[inventories[(int)InventoryE.NPC].items[i].name] .containerName.Equals(npcName) && !GlobalControls.npcList[npcName].needsMet[indexInNPCNeeds]) { GlobalControls.npcList[npcName].satisfaction++; Debug.Log(npcName + " Satisfaction increased to " + GlobalControls.npcList[npcName].satisfaction); GlobalControls.npcList[npcName].needsMet[indexInNPCNeeds] = true; // adjust the NPC's description to be only what they still need List <string> neededItems = new List <string>(); for (int j = 0; j < GlobalControls.npcList[npcName].needsMet.Count; j++) { if (!GlobalControls.npcList[npcName].needsMet[j]) { neededItems.Add(GlobalControls.npcList[npcName].needs[j]); } } string description; if (neededItems.Count == 0) { description = GlobalControls.npcList[npcName].name + " is happy and needs nothing more"; } else if (neededItems.Count == 1) { description = GlobalControls.npcList[npcName].name + " needs a " + neededItems[0]; } else { description = GlobalControls.npcList[npcName].name + " needs a " + neededItems[0] + " and a " + neededItems[1]; } GlobalControls.npcList[npcName].description = description; } GlobalItemList.UpdateItemList(inventories[(int)InventoryE.NPC].items[i].name, "Inventory", new Vector3(i, 0, 0), npcName); } } }
public void PickUp(GameObject item) { int i = FirstEmptySlot(); if (i >= 0) { inventoryUI.AddToSlot(i, item.GetComponent <Collectible>().sprite); // Add item to the items array items[i] = item; //updates item list to add item to list GlobalItemList.UpdateItemList(item.name, "Inventory", new Vector3(i, 0, 0), "Player"); // Remove item from the world item.SetActive(false); // If you pick up these items, that means the player has them. // Update globalControlsProperties accordingly. if (item.name.Equals("Water Bottle Clean(Clone)")) { Debug.Log("Player Has Water!"); GlobalControls.globalControlsProperties.Add("playerHasCleanWater"); } if (item.name.Equals("Wrench(Clone)")) { Debug.Log("Player Has Wrench!"); GlobalControls.globalControlsProperties.Add("playerHasWrench"); } if (item.name.Equals("First Aid Kit(Clone)")) { Debug.Log("Player Has First Aid Kit!"); GlobalControls.globalControlsProperties.Add("playerHasFirstAidKit"); } if (item.name.Equals("Epi Pen(Clone)")) { Debug.Log("Player Has Epi Pen!"); GlobalControls.globalControlsProperties.Add("playerHasEpiPen"); } } //reselect slot to current slot number to update tooltip if necessary SelectSlotNumber(selectedSlotNumber); }
/// <summary> /// same as RemoveLatrineItem but for bucket (apartment condition) /// </summary> /// <param name="i"></param> void RemoveBucketItem(int i) { twoBucket.contents = items[i]; items[i].SetActive(true); items[i].transform.position = player.destination.transform.position + player.transform.forward + Vector3.up; items[i].GetComponent <Collectible>().inLatrine = true; GlobalItemList.UpdateItemList(items[i].name, "", new Vector3(0, 0, 0), ""); GameObject.Find(items[i].name).SetActive(false); // Remove item from inventory items[i] = null; inventoryUI.RemoveFromSlot(i); twoBucket.contents = null; }
public IEnumerator Setup() { GlobalControls.Reset(); GlobalItemList.Reset(); SceneManager.LoadScene("TitleScreen"); yield return(null); referenceManager = GameObject.Find("Managers").GetComponent <ReferenceManager>(); referenceManager.keyboardManager.GetComponent <CheatKeyboardController>().SetKeyDown(KeyCode.Z); yield return(new WaitForSeconds(1.5f)); referenceManager = GameObject.Find("Managers").GetComponent <ReferenceManager>(); playerKeyboard = referenceManager.keyboardManager.GetComponent <PlayerKeyboardManager>(); cheatKeyboard = referenceManager.keyboardManager.GetComponent <CheatKeyboardController>(); strategicMapKeyboard = referenceManager.keyboardManager.GetComponent <StrategicMapKeyboardController>(); playerKeyboard.virtualKeyboard = true; cheatKeyboard.virtualKeyboard = true; strategicMapKeyboard.virtualKeyboard = true; }
public void LeaveTrading() { for (int i = 0; i < inventoryUIs[(int)InventoryE.PlayerBin].slotContents.Length; i++) { if (inventoryUIs[(int)InventoryE.PlayerBin].slotContents[i].activeSelf) { tradeLogic.TransferItem(InventoryE.PlayerBin, InventoryE.Player, i); } } for (int i = 0; i < inventoryUIs[(int)InventoryE.NPCBin].slotContents.Length; i++) { if (inventoryUIs[(int)InventoryE.NPCBin].slotContents[i].activeSelf) { tradeLogic.TransferItem(InventoryE.NPCBin, InventoryE.NPC, i); } } tradeLogic.UpdateGlobalItemList(npcName); //update IOUs int counter = 0; foreach (GameObject go in inventoryUIs[(int)InventoryE.IOU].slotFrames) { if (go.activeSelf) { counter++; } } GlobalControls.npcList[npcName].owes = counter; referenceManager.inventoryCanvas.SetActive(true); if (referenceManager.inventoryCanvas) { //overwrite parent inventory with inventory here for (int i = 0; i < inventoryUIs[(int)InventoryE.Player].slotContents.Length; i++) { if (inventoryUIs[(int)InventoryE.Player].slotContents[i].activeSelf) { inventories[(int)InventoryE.Parent].items[i] = null; inventoryUIs[(int)InventoryE.Parent].slotContents[i].SetActive(false); tradeLogic.TransferItem(InventoryE.Player, InventoryE.Parent, i); } else if (inventoryUIs[(int)InventoryE.Parent].slotContents[i].activeSelf) { inventories[(int)InventoryE.Parent].items[i] = null; inventoryUIs[(int)InventoryE.Parent].slotContents[i].SetActive(false); } } for (int i = 0; i < inventoryUIs[(int)InventoryE.Parent].slotContents.Length; i++) { if (inventoryUIs[(int)InventoryE.Parent].slotContents[i].activeSelf) { inventories[(int)InventoryE.Parent].items[i].GetComponent <Collectible>().inventory = inventories[(int)InventoryE.Parent]; } } for (int i = 0; i < inventoryUIs[(int)InventoryE.Parent].slotContents.Length; i++) { if (inventoryUIs[(int)InventoryE.Parent].slotContents[i].activeSelf) { GlobalItemList.UpdateItemList(inventories[(int)InventoryE.Parent].items[i].name, "Inventory", new Vector3(i, 0, 0), "Player"); } } } gameStateManager.SetConversing(); }
void Update() { if (GlobalControls.globalControlsProperties.Contains("adminMode")) { if (!virtualKeyboard) { // Set keyDown to a specific cheat if (Input.GetKeyDown(preQuakeTeleport)) { keyDown = preQuakeTeleport; } else if (Input.GetKeyDown(quakeTeleport)) { keyDown = quakeTeleport; } else if (Input.GetKeyDown(strategicMapTeleport)) { keyDown = strategicMapTeleport; } else if (Input.GetKeyDown(completeWater)) { keyDown = completeWater; } else if (Input.GetKeyDown(completePoop)) { keyDown = completePoop; } else if (Input.GetKeyDown(restart)) { keyDown = restart; } else if (Input.GetKeyDown(loadPoopItems)) { keyDown = loadPoopItems; } else if (Input.GetKeyDown(loadWaterItems)) { keyDown = loadWaterItems; } else if (Input.GetKeyDown(loadPreQuakeItems)) { keyDown = loadPreQuakeItems; } else if (Input.GetKeyDown(changeCondition)) { keyDown = changeCondition; } else if (Input.GetKeyDown(angieItems)) { keyDown = angieItems; } else if (Input.GetKeyDown(carlosItems)) { keyDown = carlosItems; } else if (Input.GetKeyDown(demItems)) { keyDown = demItems; } else if (Input.GetKeyDown(annetteItems)) { keyDown = annetteItems; } else if (Input.GetKeyDown(safiItems)) { keyDown = safiItems; } else if (Input.GetKeyDown(rainerItems)) { keyDown = rainerItems; } } if (keyDown.Equals(preQuakeTeleport))//Load PreQuakeHouse { if (GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { sceneManagement.ChangeScene("PreQuakeApartment"); } else { sceneManagement.ChangeScene("PreQuakeHouse"); } } if (keyDown.Equals(quakeTeleport))//Load QuakeHouse { if (GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { sceneManagement.ChangeScene("QuakeApartment"); } else { sceneManagement.ChangeScene("QuakeHouse"); } } if (keyDown.Equals(strategicMapTeleport))//Load Strategic Map { sceneManagement.ChangeScene("StrategicMap"); } if (meters && keyDown.Equals(completeWater)) //Complete Water { meters.MarkTaskAsDone("water"); } if (meters && keyDown.Equals(completePoop)) //Complete Poop { meters.MarkTaskAsDone("poop"); } if (keyDown.Equals(restart)) //Restart Game { sceneManagement.Restart(); } if (keyDown.Equals(loadPoopItems)) //Load Yard with Latrine Items { if (GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Bucket", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Bucket 2", "Inventory", new Vector3(1, 0, 0), "Player"); GlobalItemList.UpdateItemList("Bag", "Inventory", new Vector3(2, 0, 0), "Player"); GlobalItemList.UpdateItemList("Toilet Paper", "Inventory", new Vector3(3, 0, 0), "Player"); GlobalItemList.UpdateItemList("Wood Chips", "Inventory", new Vector3(4, 0, 0), "Player"); sceneManagement.ChangeScene("Street"); } else { GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Shovel", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Plywood", "Inventory", new Vector3(1, 0, 0), "Player"); GlobalItemList.UpdateItemList("Rope", "Inventory", new Vector3(2, 0, 0), "Player"); GlobalItemList.UpdateItemList("Tarp", "Inventory", new Vector3(3, 0, 0), "Player"); GlobalItemList.UpdateItemList("Toilet Paper", "Inventory", new Vector3(4, 0, 0), "Player"); sceneManagement.ChangeScene("Yard"); } } if (keyDown.Equals(loadWaterItems)) //Load scene with water task items { GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Dirty Water Bottle", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Bleach", "Inventory", new Vector3(1, 0, 0), "Player"); sceneManagement.ChangeScene(SceneManager.GetActiveScene().name); } if (keyDown.Equals(loadPreQuakeItems)) //Load Yard with PreQuake Items { if (GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Bleach", "Street", new Vector3(4.5f, 1.5f, -8.5f), "Go Bag 1"); GlobalItemList.UpdateItemList("Book", "Street", new Vector3(4.5f, 1.5f, -7.5f), "Go Bag 2"); sceneManagement.ChangeScene("Street"); } else { GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Sunscreen", "Yard", new Vector3(6.5f, 0.5f, 0.5f), ""); GlobalItemList.UpdateItemList("Dirty Water Bottle", "Yard", new Vector3(-6.5f, 0.5f, 0.5f), ""); GlobalItemList.UpdateItemList("Flashlight", "Yard", new Vector3(3.5f, 0.5f, 3.5f), ""); GlobalItemList.UpdateItemList("Book", "Yard", new Vector3(-5.5f, 0.5f, -7.5f), ""); sceneManagement.ChangeScene("Yard"); } } if (keyDown.Equals(changeCondition)) { if (GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { Debug.Log("Changing Global Apartment condition flag from " + GlobalControls.globalControlsProperties.Contains("apartmentCondition") + " to " + !GlobalControls.globalControlsProperties.Contains("apartmentCondition")); GlobalControls.globalControlsProperties.Remove("apartmentCondition"); GlobalItemList.Reset(); } else if (!GlobalControls.globalControlsProperties.Contains("apartmentCondition")) { Debug.Log("Changing Global Apartment condition flag from " + GlobalControls.globalControlsProperties.Contains("apartmentCondition") + " to " + !GlobalControls.globalControlsProperties.Contains("apartmentCondition")); GlobalControls.globalControlsProperties.Add("apartmentCondition"); GlobalItemList.Reset(); } } if (keyDown.Equals(angieItems)) { Debug.Log("Giving Angie Required Items"); GlobalItemList.Reset(); GlobalItemList.UpdateItemList("First Aid Kit", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Epi Pen", "Inventory", new Vector3(1, 0, 0), "Player"); GlobalItemList.UpdateItemList("Water Bottle Clean", "Inventory", new Vector3(2, 0, 0), "Player"); sceneManagement.ChangeScene("PSU"); } else if (keyDown.Equals(carlosItems)) { Debug.Log("Giving Carlos Required Items"); GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Radio", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Batteries", "Inventory", new Vector3(1, 0, 0), "Player"); GlobalItemList.UpdateItemList("Water Bottle Clean", "Inventory", new Vector3(2, 0, 0), "Player"); sceneManagement.ChangeScene("PSU"); } else if (keyDown.Equals(demItems)) { Debug.Log("Giving Dem Required Items"); GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Canned Food", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Can Opener", "Inventory", new Vector3(1, 0, 0), "Player"); GlobalItemList.UpdateItemList("Water Bottle Clean", "Inventory", new Vector3(2, 0, 0), "Player"); sceneManagement.ChangeScene("WaterfrontPark"); } else if (keyDown.Equals(annetteItems)) { Debug.Log("Giving Annette Required Items"); GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Dog Crate", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Leash", "Inventory", new Vector3(1, 0, 0), "Player"); GlobalItemList.UpdateItemList("Water Bottle Clean", "Inventory", new Vector3(2, 0, 0), "Player"); sceneManagement.ChangeScene("PioneerCourthouseSquare"); } else if (keyDown.Equals(safiItems)) { Debug.Log("Giving Safi Required Items"); GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Wrench", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Water Bottle Clean", "Inventory", new Vector3(2, 0, 0), "Player"); sceneManagement.ChangeScene("WaterfrontPark"); } else if (keyDown.Equals(rainerItems)) { Debug.Log("Giving Rainer Required Items"); GlobalItemList.Reset(); GlobalItemList.UpdateItemList("Tent", "Inventory", new Vector3(0, 0, 0), "Player"); GlobalItemList.UpdateItemList("Blanket", "Inventory", new Vector3(1, 0, 0), "Player"); GlobalItemList.UpdateItemList("Water Bottle Clean", "Inventory", new Vector3(2, 0, 0), "Player"); sceneManagement.ChangeScene("PioneerCourthouseSquare"); } keyDown = KeyCode.JoystickButton0; } }
/// <summary> /// This handles All "end of scene" things we need to do /// </summary> /// <param name="sceneToLoad"></param> public void ChangeScene(string sceneToLoad) { // Set GlobalControls to current scene GlobalControls.currentScene = Array.IndexOf(previousScenes, SceneManager.GetActiveScene().name); if (sceneToLoad.Equals("StrategicMap")) { GlobalControls.globalControlsProperties.Add("isStrategicMap"); } else if (sceneToLoad.Equals("GameEnd")) { GlobalControls.globalControlsProperties.Remove("metersEnabled"); } else if (sceneToLoad.Contains("Quake")) { GlobalControls.globalControlsProperties.Remove("metersEnabled"); } else { GlobalControls.globalControlsProperties.Add("metersEnabled"); GlobalControls.globalControlsProperties.Remove("isStrategicMap"); if (!GlobalControls.globalControlsProperties.Contains("poopTaskCompleted")) { GlobalControls.poopTimeLeft--; } if (!GlobalControls.globalControlsProperties.Contains("waterTaskCompleted")) { GlobalControls.waterTimeLeft--; } } if (sceneToLoad.Equals("Yard") && SceneManager.GetActiveScene().name.Equals("QuakeHouse")) { bool noStoredWater = true; StorageContainer[] containers = new StorageContainer[] { GameObject.Find("Shed 1").GetComponent <StorageContainer>(), GameObject.Find("Shed 2").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 1").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 2").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 3").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 4").GetComponent <StorageContainer>(), }; foreach (StorageContainer container in containers) { GameObject item = container.contents; if (item) { GlobalItemList.UpdateItemList(item.name, "Yard", item.transform.position, container.name); } if (item && item.name.Equals("Dirty Water Bottle(Clone)") && (container.name.Equals("Shed 1") || container.name.Equals("Shed 2"))) { noStoredWater = false; } } if (noStoredWater) { GlobalControls.waterTimeLeft = GlobalControls.noStoredWaterTime; } } else if (sceneToLoad.Equals("QuakeHouse") && SceneManager.GetActiveScene().name.Equals("PreQuakeHouse")) { StorageContainer[] containers = new StorageContainer[] { GameObject.Find("Shed 1").GetComponent <StorageContainer>(), GameObject.Find("Shed 2").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 1").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 2").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 3").GetComponent <StorageContainer>(), GameObject.Find("Cabinet 4").GetComponent <StorageContainer>(), }; foreach (StorageContainer container in containers) { GameObject item = container.contents; if (item) { GlobalItemList.UpdateItemList(item.name, "QuakeHouse", item.transform.position, container.name); } } } else if (sceneToLoad.Equals("QuakeApartment") && SceneManager.GetActiveScene().name.Equals("PreQuakeApartmentStylizedv3")) { StorageContainer[] containers = new StorageContainer[] { GameObject.Find("Shelf 1").GetComponent <StorageContainer>(), GameObject.Find("Shelf 2").GetComponent <StorageContainer>(), GameObject.Find("Shelf 3").GetComponent <StorageContainer>(), GameObject.Find("Shelf 4").GetComponent <StorageContainer>(), GameObject.Find("Go Bag 1").GetComponent <StorageContainer>(), GameObject.Find("Go Bag 2").GetComponent <StorageContainer>(), }; foreach (StorageContainer container in containers) { GameObject item = container.contents; if (item) { GlobalItemList.UpdateItemList(item.name, "QuakeApartment", item.transform.position, container.name); } } } else if (sceneToLoad.Equals("Street") && SceneManager.GetActiveScene().name.Equals("QuakeApartment")) { bool noStoredWater = true; int inventoryCount = 0; foreach (Item item in GlobalItemList.ItemList.Values) { if (item.scene.Equals("Inventory") && item.containerName.Equals("Player")) { if (item.name.Equals("Bleach")) { noStoredWater = false; } inventoryCount++; } } if (noStoredWater || inventoryCount != 2) { GlobalControls.waterTimeLeft = GlobalControls.noStoredWaterTime; } } SceneManager.LoadSceneAsync(sceneToLoad); }
//=========================== SYNC SYSTEM ============================= /// <summary> /// Upload entire information item/order list from FTP/Cloud_Sync/FullSync directory /// </summary> public static void DownloadAllInformation() { string syncText = ""; string emailAddress = GetSettingsValue("SYNC_EMAIL"); try { if (Global.isOnWifi()) // only try on WiFi (most data will block this) { List <string> lines = new List <string>(); // Copy local repository to FTP Server if (Device.OS == TargetPlatform.Android || Device.OS == TargetPlatform.iOS) { // Read from FTP File //string[] lines = GetFileContent(emailAddress + SyncFileName) lines = AESGCM .SimpleDecryptWithPassword( DependencyService.Get <IFtpWebRequest>().FTPRead(emailAddress + FullSyncFileName), AESGCMKey) .Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList(); } // Load items and orders from downloaded file foreach (string line in lines) { // Load items if (line.Contains("||[IT_LO]=")) { Item New_Item = new Item(); New_Item.Name = Parse_Line_Information(line, "IT_DE_"); New_Item.Status = Parse_Line_Information(line, "IT_ST_") == "" ? "0" : Parse_Line_Information(line, "IT_ST_"); New_Item.RefundAlert = Parse_Line_Information(line, "IT_RE_") == "1" ? true : false; New_Item.consumedStatus = Convert.ToInt32(Parse_Line_Information(line, "IT_CO_", "||", "2")); New_Item.Location = Parse_Line_Information(line, "IT_LO"); New_Item.Payment_Type = Parse_Line_Information(line, "IT_PA_"); New_Item.Category = Parse_Line_Information(line, "IT_CA_"); New_Item.Discount_Amt = Convert.ToDouble(Parse_Line_Information(line, "IT_DI_", "||", "0")); New_Item.Price = Convert.ToDouble(Parse_Line_Information(line, "IT_PR_")); New_Item.Quantity = Convert.ToInt32(Parse_Line_Information(line, "IT_QU_")); New_Item.Date = Convert.ToDateTime(Parse_Line_Information(line, "IT_DA_")); New_Item.Refund_Date = Parse_Line_Information(line, "IT_RD_").Length > 0 ? Convert.ToDateTime(Parse_Line_Information(line, "IT_RD_")) : DateTime.Now; New_Item.Memo = Parse_Line_Information(line, "IT_ME_"); New_Item.OrderID = Parse_Line_Information(line, "IT_ID_"); GlobalItemList.Add(New_Item); } // Load orders else if (line.Contains("||[OR_QU_]=")) { Order New_Order = new Order(); New_Order.Location = Parse_Line_Information(line, "OR_LO_"); New_Order.OrderMemo = Parse_Line_Information(line, "OR_ME_"); New_Order.Payment = Parse_Line_Information(line, "OR_PA_"); New_Order.Tax_Overridden = (Parse_Line_Information(line, "OR_TO_") == "1"); New_Order.Order_Total_Pre_Tax = Convert.ToDouble(Parse_Line_Information(line, "OR_PP_")); New_Order.GC_Amount = Convert.ToDouble(Parse_Line_Information(line, "OR_GC_", "||", "0")); New_Order.Order_Taxes = Convert.ToDouble(Parse_Line_Information(line, "OR_TA_")); New_Order.Order_Discount_Amt = Convert.ToDouble(Parse_Line_Information(line, "OR_DI_", "||", "0")); New_Order.Order_Quantity = Convert.ToInt32(Parse_Line_Information(line, "OR_QU_")); New_Order.Date = Convert.ToDateTime(Parse_Line_Information(line, "OR_DA_")); New_Order.OrderID = Parse_Line_Information(line, "OR_ID_"); GlobalOrderList.Add(New_Order); } } foreach (Item item in GlobalItemList) { Debug.WriteLine(item.ToString()); } } } catch (Exception Ex) { Debug.WriteLine("No file found: " + Ex); } }
//=========================== LOAD FILES ============================== /// <summary> /// Load all local information from configuration file /// </summary> public static string LoadLocalInformation() { ResetParameters(); try { string[] lines = GetFileContent(ConfigFileName) .Split(new [] { Environment.NewLine }, StringSplitOptions.None); List <string> tempLocation = new List <string>(); List <string> tempPayment = new List <string>(); List <string> tempCategories = new List <string>(); foreach (string line in lines) { #region Load Local Settings if (line.Contains("[PE_SE]")) { SetSettingsValue("SYNC_EMAIL", Parse_Line_Information(line, "SYNC_EMAIL")); SetSettingsValue("EMAIL_VALIDATED", Parse_Line_Information(line, "EMAIL_VALIDATED")); } #endregion #region Load Locations if (line.Contains("[LO_NA_]=")) { tempLocation.Add(Parse_Line_Information(line, "LO_NA_")); } #endregion #region Load Payments if (line.Contains("[PA_NA_]=")) { tempPayment.Add(Parse_Line_Information(line, "PA_NA_")); } #endregion #region Load Categories if (line.Contains("[CA_NA_]=")) { tempCategories.Add(Parse_Line_Information(line, "CA_NA_")); } #endregion #region Load Items if (line.Contains("[LT_NA_]=")) { MasterItemList.Add(new Item( Parse_Line_Information(line, "LT_NA_"), Convert.ToDouble(Parse_Line_Information(line, "LT_PR_")), Convert.ToInt32(Parse_Line_Information(line, "LT_QU_")), Parse_Line_Information(line, "LT_CA_"), Parse_Line_Information(line, "LT_ID_") )); } #endregion #region Load Orders if (line.Contains("[LR_LO_]=")) { OrderList.Add(new Order( Parse_Line_Information(line, "LR_LO_"), //Convert.ToDouble(Parse_Line_Information(line, "PRETAX_PRICE")), Parse_Line_Information(line, "LR_PA_"), Convert.ToDateTime(Parse_Line_Information(line, "LR_DA_")), Parse_Line_Information(line, "LR_SY_") == "1", Parse_Line_Information(line, "LR_ID_") )); } #endregion #region Load ShopItem List if (line.Contains("[SI_NA_]=")) { ShoppingList.Add(new ShopItem(Parse_Line_Information(line, "SI_NA_"), Parse_Line_Information(line, "SI_CA_") )); } #endregion #region Load Global Items if (line.Contains("||[IT_LO]=")) { Item New_Item = new Item(); New_Item.Name = Parse_Line_Information(line, "IT_DE_"); New_Item.Status = Parse_Line_Information(line, "IT_ST_") == "" ? "0" : Parse_Line_Information(line, "IT_ST_"); New_Item.RefundAlert = Parse_Line_Information(line, "IT_RE_") == "1" ? true : false; New_Item.consumedStatus = Convert.ToInt32(Parse_Line_Information(line, "IT_CO_", "||", "2")); New_Item.Location = Parse_Line_Information(line, "IT_LO"); New_Item.Payment_Type = Parse_Line_Information(line, "IT_PA_"); New_Item.Category = Parse_Line_Information(line, "IT_CA_"); New_Item.Discount_Amt = Convert.ToDouble(Parse_Line_Information(line, "IT_DI_", "||", "0")); New_Item.Price = Convert.ToDouble(Parse_Line_Information(line, "IT_PR_")); New_Item.Quantity = Convert.ToInt32(Parse_Line_Information(line, "IT_QU_")); New_Item.Date = Convert.ToDateTime(Parse_Line_Information(line, "IT_DA_")); New_Item.Refund_Date = Parse_Line_Information(line, "IT_RD_").Length > 0 ? Convert.ToDateTime(Parse_Line_Information(line, "IT_RD_")) : DateTime.Now; New_Item.Memo = Parse_Line_Information(line, "IT_ME_"); New_Item.OrderID = Parse_Line_Information(line, "IT_ID_"); GlobalItemList.Add(New_Item); } #endregion #region Load Global Orders // Load orders else if (line.Contains("||[OR_QU_]=")) { Order New_Order = new Order(); New_Order.Location = Parse_Line_Information(line, "OR_LO_"); New_Order.OrderMemo = Parse_Line_Information(line, "OR_ME_"); New_Order.Payment = Parse_Line_Information(line, "OR_PA_"); New_Order.Tax_Overridden = (Parse_Line_Information(line, "OR_TO_") == "1"); New_Order.Order_Total_Pre_Tax = Convert.ToDouble(Parse_Line_Information(line, "OR_PP_")); New_Order.GC_Amount = Convert.ToDouble(Parse_Line_Information(line, "OR_GC_", "||", "0")); New_Order.Order_Taxes = Convert.ToDouble(Parse_Line_Information(line, "OR_TA_")); New_Order.Order_Discount_Amt = Convert.ToDouble(Parse_Line_Information(line, "OR_DI_", "||", "0")); New_Order.Order_Quantity = Convert.ToInt32(Parse_Line_Information(line, "OR_QU_")); New_Order.Date = Convert.ToDateTime(Parse_Line_Information(line, "OR_DA_")); New_Order.OrderID = Parse_Line_Information(line, "OR_ID_"); GlobalOrderList.Add(New_Order); } #endregion } // Load all synced orders LoadSyncFile(); // Sort locations LocationList = new ObservableCollection <string>(tempLocation.OrderBy(x => x)); PaymentList = new ObservableCollection <string>(tempPayment.OrderBy(x => x)); CategoryList = new ObservableCollection <string>(tempCategories.OrderBy(x => x)); // Remove synced orders from current orders return(RemoveSyncedOrders()); } catch (Exception ex) { Debug.WriteLine("Error with loading file: " + ex); } return(""); }
private void InteractWithWaterPurifyingTable(StorageContainer container) { if (!container.contents && SlotIsOccupied(selectedSlotNumber)) { if (items[selectedSlotNumber].name.Equals("Dirty Water Bottle(Clone)")) { Debug.Log("Dropping water bottle"); container.contents = items[selectedSlotNumber]; items[selectedSlotNumber].SetActive(true); Transform t = player.transform; items[selectedSlotNumber].transform.position = player.destination.transform.position + player.transform.forward + Vector3.up; items[selectedSlotNumber].GetComponent <Collectible>().inStorageContainer = true; GlobalItemList.UpdateItemList(items[selectedSlotNumber].name, SceneManager.GetActiveScene().name, items[selectedSlotNumber].transform.position, container.name); // Remove item from inventory items[selectedSlotNumber] = null; inventoryUI.RemoveFromSlot(selectedSlotNumber); } } else if (container.contents && SlotIsOccupied(selectedSlotNumber)) { if (items[selectedSlotNumber].name.Equals("Bleach(Clone)") && !GlobalControls.globalControlsProperties.Contains("waterPurified")) { Debug.Log("Using bleach"); meters = referenceManager.metersCanvas.GetComponent <Meters>(); meters.MarkTaskAsDone("water"); GlobalItemList.UpdateItemList("Dirty Water Bottle", "", new Vector3(0, 0, 0), ""); GameObject.Find("Dirty Water Bottle(Clone)").SetActive(false); GlobalItemList.UpdateItemList("Water Bottle Clean", SceneManager.GetActiveScene().name, player.destination.transform.position + player.transform.forward + Vector3.up, "Water Purifying Table"); GlobalControls.globalControlsProperties.Add("waterPurified"); GameObject prefab = (GameObject)Resources.Load("Water Bottle Clean", typeof(GameObject)); GameObject waterBottleClean = Instantiate(prefab, player.destination.transform.position + player.transform.forward + Vector3.up, Quaternion.identity); container.contents = waterBottleClean; } } else { int i = FirstEmptySlot(); if (i >= 0 && !SlotIsOccupied(i) && container.contents) { //picking up the item GameObject item = container.RemoveItem(); item.GetComponent <Collectible>().inStorageContainer = false; PickUp(item); } } }