コード例 #1
0
ファイル: Stats.cs プロジェクト: kimch2/Winterfall
    /*
     * 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!"));
        }
    }
コード例 #2
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 //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!"));
     }
 }
コード例 #3
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
    //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!"));
        }
    }
コード例 #4
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 //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!"));
     }
 }
コード例 #5
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 //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!"));
     }
 }
コード例 #6
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 //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!"));
     }
 }
コード例 #7
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
    //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!"));
        }
    }
コード例 #8
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 //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!"));
     }
 }
コード例 #9
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 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!"));
     }
 }
コード例 #10
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 //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!"));
     }
 }
コード例 #11
0
ファイル: SaveLoad.cs プロジェクト: kimch2/Winterfall
    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."));
    }
コード例 #12
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 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!"));
     }
 }
コード例 #13
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 //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!"));
     }
 }
コード例 #14
0
ファイル: SaveLoad.cs プロジェクト: kimch2/Winterfall
    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."));
    }
コード例 #15
0
ファイル: Raycast.cs プロジェクト: kimch2/Winterfall
    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);
        }
    }
コード例 #16
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedPlanks()
 {
     inv.items[5].item++;
     inv.xp += 5;
     StartCoroutine(Notifications.Call("+2 Planks!"));
 }
コード例 #17
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedFoundation()
 {
     inv.items[18].item++;
     inv.xp += 25;
     StartCoroutine(Notifications.Call("+1 Foundation!"));
 }
コード例 #18
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void RoastedBerries()
 {
     inv.items[14].item++;
     inv.xp += 3;
     StartCoroutine(Notifications.Call("Roasted the Berries!"));
 }
コード例 #19
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedPillar()
 {
     inv.items[19].item += 2;
     inv.xp             += 20;
     StartCoroutine(Notifications.Call("+2 Pillars!"));
 }
コード例 #20
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void SmeltedIron()
 {
     inv.items[3].item += 5;
     inv.xp            += 15;
     StartCoroutine(Notifications.Call("+5 Metal!"));
 }
コード例 #21
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedWall()
 {
     inv.items[20].item++;
     inv.xp += 20;
     StartCoroutine(Notifications.Call("+1 Wall!"));
 }
コード例 #22
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void RefilledCanteen()
 {
     inv.items[12].item++;
     inv.xp += 15;
     StartCoroutine(Notifications.Call("+1 Canteen (Water)!"));
 }
コード例 #23
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedDoor()
 {
     inv.items[22].item++;
     inv.xp += 20;
     StartCoroutine(Notifications.Call("+1 Door!"));
 }
コード例 #24
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedRoof()
 {
     inv.items[28].item++;
     inv.xp += 25;
     StartCoroutine(Notifications.Call("+1 Bed!"));
 }
コード例 #25
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedStairs()
 {
     inv.items[23].item++;
     inv.xp += 20;
     StartCoroutine(Notifications.Call("+1 Stairs!"));
 }
コード例 #26
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedCeiling()
 {
     inv.items[24].item++;
     inv.xp += 20;
     StartCoroutine(Notifications.Call("+1 Ceiling!"));
 }
コード例 #27
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedWindow()
 {
     inv.items[25].item++;
     inv.xp += 20;
     StartCoroutine(Notifications.Call("+1 Window!"));
 }
コード例 #28
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedCraftingTable()
 {
     inv.items[27].item++;
     inv.xp += 35;
     StartCoroutine(Notifications.Call("+1 Crafting Table!"));
 }
コード例 #29
0
ファイル: Stats.cs プロジェクト: kimch2/Winterfall
    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();
            }
        }
    }
コード例 #30
0
ファイル: Crafting.cs プロジェクト: kimch2/Winterfall
 void CraftedCampfire()
 {
     inv.items[26].item++;
     inv.xp += 20;
     StartCoroutine(Notifications.Call("+1 Campfire!"));
 }