public static void SaveChestData(ChestInteract chest) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/Chest.data"; FileStream stream = new FileStream(path, FileMode.Create); ChestData data = new ChestData(chest); formatter.Serialize(stream, data); stream.Close(); }
public ChestData(ChestInteract chest) { GoldCount = chest.gold; WoodCount = chest.wood; StoneCount = chest.stone; }
// Update is called once per frame void Update() { RaycastHit interactInfoRay; bool centerRay = Physics.Raycast(playerCam.transform.position, playerCam.transform.forward, out interactInfoRay, interactRange); if (centerRay) { if (interactInfoRay.transform.name.Contains("Lever")) { interactText.text = "Lever"; } else if (interactInfoRay.transform.name.Contains("FirePotionPickup")) { interactText.text = "Fire Potion"; } else if (interactInfoRay.transform.name.Contains("CheckpointTable")) { interactText.text = "Check Point Table"; } else if (interactInfoRay.transform.name.Contains("chest_epic_gems")) { interactText.text = "Treasure Chest"; } else if (interactInfoRay.transform.name.Contains("Big O' Bottle O' Spicy Sauce")) { interactText.text = "Big O' Bottle O' Spicy Sauce"; } else if (interactInfoRay.transform.name.Contains("Timmy")) { interactText.text = "Timmy"; } } else { interactText.text = ""; } if (Input.GetButtonDown("Fire2") && centerRay) { LeverActivate lever = interactInfoRay.collider.GetComponent <LeverActivate>(); if (lever) { lever.ActivateLever(); playerAnim.SetTrigger("ActivateObject"); } CheckPoint cp = interactInfoRay.collider.GetComponent <CheckPoint>(); if (cp) { cp.checkpoint(); playerAnim.SetTrigger("ActivateObject"); } PotionPickup potPickup = interactInfoRay.collider.GetComponent <PotionPickup>(); if (potPickup) { potPickup.pickupPotion(); playerAnim.SetTrigger("ActivateObject"); sounds[1].Play(); } ChestInteract treasureChest = interactInfoRay.collider.GetComponentInParent <ChestInteract>(); if (treasureChest) { treasureChest.openChest(); playerAnim.SetTrigger("ActivateObject"); } } }