예제 #1
0
 private void Start()
 {
     mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
     popUp      = FindObjectOfType <PopUpManager>();
     guiLogic   = FindObjectOfType <GUILogic>();
     StartCoroutine(Timer(timerMax));
     score = 0;
     guiLogic.ShowScore(score);
 }
예제 #2
0
    void Click()
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);

        if (Input.GetButton("Fire1"))
        {
            if (hit.collider != null)
            {
                if (hit.collider.tag == "Block")
                {
                    return;
                }
                else
                {
                    if (hit.collider.tag != "Block")
                    {
                        if (hit.collider.tag == "Shape" && !hit.collider.gameObject.GetComponent <ShapeScripts>().isEnemy)
                        {
                            Vector3 pos = hit.collider.gameObject.GetComponent <Transform>().position;
                            IncrementScore();
                            guiLogic.ShowScore(score);
                            Destroy(hit.collider.gameObject);
                            popUp.SpawnPopUpScore("+1", pos);
                        }
                        if (hit.collider.tag == "Shape" && hit.collider.gameObject.GetComponent <ShapeScripts>().isEnemy)
                        {
                            Vector3 pos = hit.collider.gameObject.GetComponent <Transform>().position;
                            DecrementScore();
                            GameOver();
                            guiLogic.ShowScore(score);
                            Destroy(hit.collider.gameObject);
                            popUp.SpawnPopUpScore("-1", pos);
                        }
                    }
                }
            }
        }
    }