コード例 #1
0
    private void Update()
    {
        if (gameManagerMaster.isGamePaused || gameManagerMaster.isGameOver)
        {
            return;
        }

        if (hydration.currentHydration <= 0 || cold._cold >= cold._maxCold)
        {
            life -= lifeDrainRate * Time.deltaTime;
            healthDrainOverlay.SetActive(true);

            if (life <= 0)
            {
                life = 0;
                gameManagerMaster.CallGameOverEvent();
            }
        }
        else
        {
            healthDrainOverlay.SetActive(false);
        }

        Vector3 scale = healthUI.transform.localScale;

        scale.x = life / 100f;
        healthUI.transform.localScale = scale;
    }
コード例 #2
0
    void OnCollisionEnter(Collision other)
    {
        if (other.transform.tag == "Orb")
        {
            Debug.Log("collision orb");
            Transform child = other.transform.GetChild(0);
            string    text  = child.GetComponent <TextMesh>().text;

            currentWord += text;

            var wordStartWithCurrentWordQueryResult = from word in wordArrayList
                                                      where word.StartsWith(currentWord)
                                                      select word;

            List <string> wordStartWithCurrentWordList = wordStartWithCurrentWordQueryResult.ToList();

            if (wordArrayList.Contains(currentWord.ToUpper()))
            {
                print("Correct word: " + currentWord);
                score += currentWord.Length;
            }
            else
            {
                print("!!! Wrong word: " + currentWord);

                if (wordStartWithCurrentWordList.Count == 0)
                {
                    //FindObjectOfType<GameManager>().EndGame();
                    gameManagerMaster.CallGameOverEvent();
                }
            }

            Destroy(other.gameObject);

            if (bodyParts.Count == 0)
            {
                //Debug.Log ("body parts count == 0");
                Vector3   currentPos  = transform.position;
                Transform newBodyPart = Instantiate(bodyObject, currentPos, Quaternion.identity) as Transform;

                newBodyPart.GetChild(0).GetComponent <TextMesh>().text = text;

                bodyParts.Add(newBodyPart);
                //Debug.Log (currentPos);
                //Debug.Log (newBodyPart.position);
            }
            else
            {
                //Debug.Log ("body parts count != 0");
                Vector3   currentPos  = bodyParts[bodyParts.Count - 1].position;
                Transform newBodyPart = Instantiate(bodyObject, currentPos, Quaternion.identity) as Transform;
                newBodyPart.GetChild(0).GetComponent <TextMesh>().text = text;
                bodyParts.Add(newBodyPart);
                //Debug.Log (currentPos);
                //Debug.Log (newBodyPart.position);
            }
        }
    }