Пример #1
0
    private void Update()
    {
        if (PlayerPrefs.GetInt(Prefstype.Item1Use, 1) == 1)// 포탈담는 버튼 눌렀는지 체크
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                RaycastHit2D hit      = Physics2D.Raycast(ray.origin, ray.direction, 100f);
                Vector3      mousepos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                mousepos.z = 0;

                if (hit)
                {
                    if (hit.transform.CompareTag("TeleportExit") && !ingameButtonManager.IshaveWhite && HavingWhite == null)
                    {
                        HavingWhite = hit.transform.gameObject;
                        HavingWhite.SetActive(false);
                        ingameButtonManager.IshaveWhite = true;
                        PlayerPrefs.SetInt(Prefstype.Item1Use, 0);
                        ingameButtonManager.ItemUsed();
                    }
                    else if (hit.transform.CompareTag("Crack") && ingameButtonManager.IshaveWhite && candeletecrash)
                    {
                        HavingWhite = null;
                        NowCrash.SetActive(false);
                        ingameButtonManager.IshaveWhite = false;
                        ingameButtonManager.crashnum++;
                        PlayerPrefs.SetInt(Prefstype.Item1Use, 0);
                        ingameButtonManager.ItemUsed();
                    }
                    else if (hit.transform.CompareTag("Ground") && ingameButtonManager.IshaveWhite)
                    {
                        PlayerPrefs.SetInt(Prefstype.Item1Use, 0);
                        ingameButtonManager.ItemUsed();
                    }
                }
                else if (ingameButtonManager.IshaveWhite)
                {
                    HavingWhite.transform.position = mousepos;
                    HavingWhite.SetActive(true);
                    HavingWhite = null;
                    ingameButtonManager.IshaveWhite = false;
                    PlayerPrefs.SetInt(Prefstype.Item1Use, 0);
                    ingameButtonManager.ItemUsed();
                }
            }
        }
    }