Beispiel #1
0
        // DEBUG CODE
        private void Update()
        {
#if UNITY_EDITOR
            if (Input.GetMouseButtonDown(0))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                GameObject ps = Instantiate(particleSystemOnTap);
                ps.transform.position = ray.origin + new Vector3(0, 0, 0.05f);

                if (Physics.SphereCast(ray, tapRadius, out RaycastHit hit))
                {
                    Mole target = hit.transform.GetComponentInParent <Mole>();
                    if (target != null)
                    {
                        if (target.behaviour.HitMole(damage))
                        {
                            OnMoleHit?.Invoke(target.behaviour.scoreOnKill);
                        }
                    }
                    else
                    {
                        OnMoleMiss?.Invoke(moleMissScore);
                    }
                }
                else
                {
                    OnMoleMiss?.Invoke(moleMissScore);
                }
            }
#endif
        }
Beispiel #2
0
        private void TouchStart(Touch touch, Vector2 pos)
        {
            Ray ray = Camera.main.ScreenPointToRay(touch.position);

            GameObject ps = Instantiate(particleSystemOnTap);

            ps.transform.position = ray.origin + new Vector3(0, 0, 0.05f);

            if (Physics.SphereCast(ray, tapRadius, out RaycastHit hit))
            {
                Mole target = hit.transform.GetComponentInParent <Mole>();
                if (target != null)
                {
                    target.behaviour.HitMole(damage);
                    OnMoleHit?.Invoke(target.behaviour.scoreOnKill);
                }
                else
                {
                    OnMoleMiss?.Invoke(moleMissScore);
                }
            }
            else
            {
                OnMoleMiss?.Invoke(moleMissScore);
            }
        }
Beispiel #3
0
 void Hit()
 {
     onHit?.Invoke(points, this);
     Hide();
 }