示例#1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         th = GameObject.Find("Tank").GetComponent <TankHealth>();
         th.AddHP(reward);
         Destroy(gameObject);
         GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity);
         Destroy(effect, 0.5f);
         AudioSource.PlayClipAtPoint(getSound, transform.position);
     }
 }
示例#2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         th = other.gameObject.GetComponent <TankHealth>();
         th.AddHP(50);
         th.SetHealthUI();
         Destroy(gameObject);
         GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity);
         Destroy(effect, 0.7f);
     }
 }
示例#3
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Player")
        {
            th = GameObject.Find("Tank").GetComponent <TankHealth> ();

            //AddHp()メソッドを呼び出して引数にrewardを与えている
            th.AddHP(reward);

            Destroy(gameObject);
            GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity);
            Destroy(effect, 0.5f);
            AudioSource.PlayClipAtPoint(getSound, transform.position);
        }
    }
示例#4
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            // Find()メソッドの使い方をマスターすること
            th = GameObject.Find("Tank").GetComponent <TankHealth>();

            // AddHP()メソッドを呼び出して「引数」にrewardを与えている。
            th.AddHP(reward);

            Destroy(gameObject);
            GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity);
            Destroy(effect, 0.5f);
            AudioSource.PlayClipAtPoint(getSound, Camera.main.transform.position);
        }
    }