示例#1
0
 void checkTaskFailed()
 {
     if (LifeBarScript.getHealth() <= threshold)
     {
         gameObject.SetActive(!gameObject.activeSelf);
     }
 }
 void Start()
 {
     player        = GameObject.FindGameObjectWithTag("Player").transform;
     offset        = new Vector3(0, 1f, 0);
     rb            = this.GetComponent <Rigidbody>();
     lifeBarScript = GameObject.Find("Canvas").transform.Find("LifeBar Parent").GetChild(0).GetComponent <LifeBarScript>();
 }
 // Update is called once per frame
 void Update()
 {
     checkTaskFailed();
     if (LifeBarScript.getHealth() == 0)
     {
         gameOver();
     }
 }
示例#4
0
    void Start()
    {
        if (GameObject.FindGameObjectWithTag("GController"))
        {
            gController = GameObject.FindGameObjectWithTag("GController").transform.GetComponent <GameController>();
            if (gController == null)
            {
                Debug.Log("Отсутствует GameController объект в PC");
            }
        }
        else
        {
            Debug.Log("Отсутствует GameController в сцене");
        }

        if (GameObject.FindGameObjectWithTag("UIC"))
        {
            uiControl = GameObject.FindGameObjectWithTag("UIC").transform.GetComponent <UIController>();
            if (uiControl == null)
            {
                Debug.Log("Отсутствует uiC in PC");
            }
        }
        else
        {
            Debug.Log("Отсутствует родительский объект UIController");
        }

        //joistick = GameObject.FindGameObjectWithTag("Joistick").GetComponent<Joistick>();
        joistick = uiControl.GetJoistick();
        if (joistick == null)
        {
            Debug.Log("Отсутствует скрипт управления Джойстиком");
        }

        lifeBar = GameObject.Find("LifeBar").transform.GetComponent <LifeBarScript>();
        if (lifeBar == null)
        {
            Debug.Log("Отсутствует скрипт объекта LifeBarScript. PC.");
        }
    }
 // Use this for initialization
 void Start()
 {
     CurrentHealth   = MaxHealth;
     _playerRenderer = gameObject.GetComponent <Renderer>();
     _lifeBarScript  = LifeBar.GetComponent <LifeBarScript>();
 }