Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (notification.text != "" && woodAmount != 5 && ropeAmount != 2)
        {
            StartCoroutine(DelayNotification());
        }

        woodText.text = "Wooden logs: " + woodAmount.ToString();

        if (woodAmount == 5)
        {
            woodText.color = Color.green;
        }

        ropeText.text = "Ropes: " + ropeAmount.ToString();

        if (ropeAmount == 2)
        {
            ropeText.color = Color.green;
        }

        if (woodAmount == 5 && ropeAmount == 2)
        {
            notification.text = "You can build a raft now! Go near water and press F!";
        }

        if (woodAmount == 5 && ropeAmount == 2 && fpc.IsNearWater())
        {
            notification.text = "Press F to build a raft!";

            if (Input.GetKey(KeyCode.F))
            {
                sound      = GetComponent <AudioSource> ();
                sound.clip = scratchingSound;
                sound.Play();

                if (!(raftIsCreated))
                {
                    Instantiate(woodenRaft, woodenRaftPlace.transform.position, woodenRaftPlace.transform.rotation);
                    raftIsCreated     = true;
                    ropeAmount        = 0;
                    woodAmount        = 0;
                    notification.text = "";
                    notification.text = "You have made it! You will survive!";
                    StartCoroutine(PlaySoundAndFinish());
                }
            }
        }
    }