예제 #1
0
 // Update is called once per frame
 void Update()
 {
     if (GameObject.FindGameObjectWithTag("Enemy") && avoidcount == 0)
     {
         Avoidfollow = GameObject.FindGameObjectWithTag("Enemy");
         avoidcount++;
         Avoid.SetActive(true);
         avoidname = Avoidfollow.scene.name;
     }
     if (avoidcount == 1)
     {
         if (Avoidfollow == null)
         {
             Avoid.SetActive(false);
             avoidcount++;
         }
         Avoid.transform.position = Camera.main.WorldToScreenPoint(new Vector2(Avoidfollow.transform.position.x, Avoidfollow.transform.position.y + 0.8f));
     }
     if (GameObject.FindGameObjectWithTag("Money") && catchcount == 0)
     {
         Catchfollow = GameObject.FindGameObjectWithTag("Money");
         catchcount++;
         Catch.SetActive(true);
         catchname = Catchfollow.name;
     }
     if (catchcount == 1)
     {
         if (Catchfollow == null)
         {
             Catch.SetActive(false);
             catchcount++;
             if (PlayerPrefs.HasKey("tutval"))
             {
                 PlayerPrefs.SetInt("tutval", PlayerPrefs.GetInt("tutval") + 1);
             }
             else
             {
                 PlayerPrefs.SetInt("tutval", 1);
             }
         }
         Catch.transform.position = Camera.main.WorldToScreenPoint(new Vector2(Catchfollow.transform.position.x, Catchfollow.transform.position.y + 0.6f));
     }
 }