コード例 #1
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);
            }
        }
コード例 #2
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
        }
コード例 #3
0
        public override void OnLevelEnd()
        {
            foreach (ScoreManager.ScoreAddHandler d in OnMoleHit.GetInvocationList())
            {
                OnMoleHit -= (ScoreManager.ScoreAddHandler)d;
            }
            foreach (ScoreManager.ScoreAddHandler d in OnMoleMiss.GetInvocationList())
            {
                OnMoleMiss -= (ScoreManager.ScoreAddHandler)d;
            }

            this.enabled = false;
        }