/* * void Temperature() * { * // TEMPERATURE CONTROL SECTION * if (sky.Cycle.Hour >= 7) * { * temperature = Random.Range(-5, 5); * } * } */ public void Sleep() { if (sky.Cycle.Hour >= 21 || sky.Cycle.Hour <= 7) { sky.Cycle.Hour = 7; sky.Cycle.Day++; StartCoroutine(Notifications.Call("Good morning.")); } else { StartCoroutine(Notifications.Call("You can only sleep at night!")); } }
//Bed public void CraftBed() { if (inv.items[5].item >= 30 && inv.xp >= 250 && crafting == false) { inv.items[5].item -= 30; StartCoroutine(Time(5, "CraftedBed")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Tier 1 Crafting //Planks public void CraftPlanks() { if (inv.items[0].item >= 1 && crafting == false) { inv.items[0].item -= 1; StartCoroutine(Time(3, "CraftedPlanks")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Crafting Table public void CraftCraftingTable() { if (inv.items[0].item >= 20 && inv.items[4].item >= 1 && crafting == false) { inv.items[0].item -= 20; inv.items[4].item--; StartCoroutine(Time(3, "CraftedCraftingTable")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Ceiling public void CraftCeiling() { if (inv.items[5].item >= 12 && inv.items[4].item >= 1 && inv.xp >= 500 && crafting == false) { inv.items[5].item -= 12; inv.items[4].item--; StartCoroutine(Time(3, "CraftedCeiling")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Roof public void CraftRoof() { if (inv.items[5].item >= 10 && inv.items[4].item >= 1 && inv.xp >= 250 && crafting == false) { inv.items[5].item -= 10; inv.items[4].item--; StartCoroutine(Time(5, "CraftedRoof")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Smelting\\ //Iron public void SmeltIron() { if (inv.items[0].item >= 2 && inv.items[8].item >= 1 && crafting == false) { inv.items[0].item -= 2; inv.items[8].item--; StartCoroutine(Time(5, "SmeltedIron")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Berries public void RoastBerries() { if (inv.items[0].item >= 1 && inv.items[13].item >= 1 && crafting == false) { inv.items[0].item--; inv.items[13].item--; StartCoroutine(Time(1, "RoastedBerries")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
public void CraftHatchet() { if (inv.items[5].item >= 5 && inv.items[3].item >= 10 && inv.items[4].item >= 1 && crafting == false) { inv.items[5].item -= 5; inv.items[3].item -= 10; inv.items[4].item--; StartCoroutine(Time(3, "CraftedHatchet")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Campfire public void CraftCampfire() { if (inv.items[0].item >= 10 && inv.items[2].item >= 1 && inv.items[1].item >= 10 && inv.xp >= 250 && crafting == false) { inv.items[0].item -= 10; inv.items[2].item -= 10; inv.items[1].item--; StartCoroutine(Time(3, "CraftedCampfire")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
public void Save() { if (!Directory.Exists(Application.persistentDataPath + "/Saves")) { Directory.CreateDirectory(Application.persistentDataPath + "/Saves"); } /* Player */ PlayerPrefsX.SetVector3("PlayerPosition", transform.position); //PlayerPrefsX.SetVector3("PlayerRotation", transform.eulerAngles); /* Items */ foreach (Inventory.ItemsClass item in invScript.items) { PlayerPrefs.SetInt("Item-" + item.name, item.item); } StartCoroutine(Notifications.Call("Saved.")); }
public void CraftStairs() { if (inv.items[5].item >= 15 && inv.items[4].item >= 1 && inv.xp >= 500 && crafting == false) { inv.items[5].item -= 15; inv.items[4].item--; StartCoroutine(Time(3, "CraftedStairs")); } else if (inv.xp <= 300) { StartCoroutine(Notifications.Call("Not Enough XP!")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
//Window public void CraftWindow() { if (inv.items[5].item >= 7 && inv.items[4].item >= 1 && inv.items[3].item >= 1 && inv.xp >= 250 && crafting == false) { inv.items[5].item -= 3; inv.items[4].item--; inv.items[3].item--; StartCoroutine(Time(3, "CraftedWindow")); } else if (inv.xp <= 500) { StartCoroutine(Notifications.Call("Not Enough XP!")); } else if (crafting) { StartCoroutine(Notifications.Call("Crafting queue is full!")); } else { StartCoroutine(Notifications.Call("Not enough materials!")); } }
public void Load() { //Player transform.position = PlayerPrefsX.GetVector3("PlayerPosition"); //transform.eulerAngles = PlayerPrefsX.GetVector3("PlayerRotation"); //Inventory /* * invScript.logs = PlayerPrefs.GetInt("Logs"); * invScript.logs = PlayerPrefs.GetInt("Stone"); * invScript.logs = PlayerPrefs.GetInt("Flint"); * invScript.logs = PlayerPrefs.GetInt("Metal"); */ foreach (Inventory.ItemsClass item in invScript.items) { PlayerPrefs.GetInt("Item-" + item.name); Debug.Log("Load Item-" + item.name + " - " + item.item); } StartCoroutine(Notifications.Call("Loaded.")); }
void Update() { RaycastHit hit; Vector3 fwd = transform.TransformDirection(Vector3.forward); if (Physics.Raycast(transform.position, fwd, out hit, range, myLayerMask)) { //TREE RAYCAST if (hit.collider.gameObject.tag == "Tree") { GameObject tree = (hit.collider.gameObject); if (Input.GetButtonDown("Fire1") && inv.items[15].item >= 1 && inv.equipables[0].activeSelf && timeStamp <= Time.time) { inv.items[15].item--; timeStamp = Time.time + 1f; audioSrc.clip = otherClip[0]; audioSrc.Play(); axeAnim.Play(); tree.GetComponent <TreeController>().health--; inv.xp++; } } //STONE RAYCAST if (hit.collider.gameObject.tag == "Stone") { GameObject stone = (hit.collider.gameObject); if (Input.GetButtonDown("Fire1") && inv.items[16].item >= 1 && inv.equipables[1].activeSelf && timeStamp <= Time.time) { //Object eff = Instantiate(effect, hit.point, Quaternion.LookRotation(hit.normal)); //Destroy(eff, 0.25f); inv.items[16].item--; timeStamp = Time.time + 1f; audioSrc.clip = otherClip[0]; audioSrc.Play(); pickaxeAnim.Play(); stone.GetComponent <StoneController>().health--; inv.xp++; } } /* * //BUILDING RAYCAST * else if (hit.collider.gameObject.tag == "Building") * { * * if (Input.GetButtonDown("Fire1") && currentMiningLevel >= 1) * { * //building.GetComponent<BuildingController>().health--; * } * } */ //CAMPFIRE RAYCAST else if (hit.collider.gameObject.tag == "Campfire") { infoText.gameObject.SetActive(true); infoText.text = "Open/Close Campfire"; if (Input.GetKeyDown(KeyCode.E)) { inv.OpenCampfire(); } } //SLEEP RAYCAST else if (hit.collider.gameObject.tag == "Sleep") { infoText.gameObject.SetActive(true); infoText.text = "Sleep"; if (Input.GetButtonDown("Open")) { statsScript.Sleep(); } } //CRAFTING TABLE RAYCAST else if (hit.collider.gameObject.tag == "CraftingTable") { infoText.gameObject.SetActive(true); infoText.text = "Open/Close Crafting Table"; if (Input.GetButtonDown("Open")) { inv.OpenCraftingTable(); } } //BUSH RAYCAST else if (hit.collider.gameObject.tag == "Berry") { GameObject bush = (hit.collider.gameObject); BushController bushScript = bush.GetComponent <BushController>(); if (bushScript.isMature) { infoText.gameObject.SetActive(true); infoText.text = "Pick Berries"; } if (Input.GetButtonDown("Open")) { bushScript.Pick(); } } //ITEM RAYCAST else if (hit.collider.gameObject.tag == "Item") { GameObject item = (hit.collider.gameObject); infoText.gameObject.SetActive(true); infoText.text = "Pick Up <i>" + item.name + "</i>"; if (Input.GetButtonDown("Pickup")) { ItemController itemScript = item.GetComponent <ItemController>(); itemScript.PickUp(); StartCoroutine(Notifications.Call("Picked Up <i>" + item.name + "</i>!")); audioSrc.clip = otherClip[1]; audioSrc.Play(); } } /* * //CHEST RAYCAST * else if (hit.collider.gameObject.tag == "Chest") * { * GameObject item = (hit.collider.gameObject); * infoText.gameObject.SetActive(true); * infoText.text = "Open/Close Chest"; * * if (Input.GetButtonDown("Open")) * { * //inv.OpenChest(); * } * } */ else { infoText.gameObject.SetActive(false); } } else { infoText.gameObject.SetActive(false); } }
void CraftedPlanks() { inv.items[5].item++; inv.xp += 5; StartCoroutine(Notifications.Call("+2 Planks!")); }
void CraftedFoundation() { inv.items[18].item++; inv.xp += 25; StartCoroutine(Notifications.Call("+1 Foundation!")); }
void RoastedBerries() { inv.items[14].item++; inv.xp += 3; StartCoroutine(Notifications.Call("Roasted the Berries!")); }
void CraftedPillar() { inv.items[19].item += 2; inv.xp += 20; StartCoroutine(Notifications.Call("+2 Pillars!")); }
void SmeltedIron() { inv.items[3].item += 5; inv.xp += 15; StartCoroutine(Notifications.Call("+5 Metal!")); }
void CraftedWall() { inv.items[20].item++; inv.xp += 20; StartCoroutine(Notifications.Call("+1 Wall!")); }
void RefilledCanteen() { inv.items[12].item++; inv.xp += 15; StartCoroutine(Notifications.Call("+1 Canteen (Water)!")); }
void CraftedDoor() { inv.items[22].item++; inv.xp += 20; StartCoroutine(Notifications.Call("+1 Door!")); }
void CraftedRoof() { inv.items[28].item++; inv.xp += 25; StartCoroutine(Notifications.Call("+1 Bed!")); }
void CraftedStairs() { inv.items[23].item++; inv.xp += 20; StartCoroutine(Notifications.Call("+1 Stairs!")); }
void CraftedCeiling() { inv.items[24].item++; inv.xp += 20; StartCoroutine(Notifications.Call("+1 Ceiling!")); }
void CraftedWindow() { inv.items[25].item++; inv.xp += 20; StartCoroutine(Notifications.Call("+1 Window!")); }
void CraftedCraftingTable() { inv.items[27].item++; inv.xp += 35; StartCoroutine(Notifications.Call("+1 Crafting Table!")); }
void Update() { healthSlider.value = health; energySlider.value = energy; hungerSlider.value = hunger; thirstSlider.value = thirst; moneyText.text = (int)money + "€"; /* MONEY CONTROL SECTION */ if (money >= maxMoney) { money = maxMoney; StartCoroutine(Notifications.Call("You can't have more money!")); } /* ENERGY CONTROL SECTION */ if (energy > 0) { energy -= Time.deltaTime / 10; } if (energy >= 100) { energy = 100; } /* THIRST CONTROL SECTION*/ if (thirst > 0 && thirstSaturation <= 0) { thirst -= Time.deltaTime / 7; } if (thirst >= 100) { thirst = 100; } /* AIR CONTROL SECTION*/ if (transform.position.y <= waterLevel) { if (air > 0) { air -= Time.deltaTime; } } else { if (air > 0) { air = 70; } } /* SATURATION CONTROL SECTION */ if (hungerSaturation > 0) { hungerSaturation -= Time.deltaTime; } if (thirstSaturation > 0) { thirstSaturation -= Time.deltaTime; } /* HUNGER CONTROL SECTION */ if (hunger > 0 && hungerSaturation <= 0) { hunger -= Time.deltaTime / 9; } if (hunger >= 100) { hunger = 100; } /* DAMAGE CONTROL SECTION*/ if (health >= 100) { health = 100; } if (damagePanel.activeSelf) { damagePanel.SetActive(false); } if (hunger <= 0 && (thirst <= 0)) { health -= Time.deltaTime * 3; if (damagePanel.activeSelf == false) { damagePanel.SetActive(true); } } else { if (hunger <= 0 || thirst <= 0 || energy <= 0) { health -= Time.deltaTime * 1.5f; if (damagePanel.activeSelf == false) { damagePanel.SetActive(true); } } } if (air <= 0) { health -= Time.deltaTime * 2; } /* DEATH CONTROL SECTION*/ if (health <= 0) { if (deathPanel.activeSelf == false) { deathPanel.SetActive(true); CursorControll.UnlockCursor(); } } }
void CraftedCampfire() { inv.items[26].item++; inv.xp += 20; StartCoroutine(Notifications.Call("+1 Campfire!")); }