Пример #1
0
        /*
         * void Update()
         * {
         *      red1 = GameObject.FindGameObjectWithTag ("red1");
         *      red2 = GameObject.FindGameObjectWithTag ("red2");
         *      red3 = GameObject.FindGameObjectWithTag ("red3");
         * }*/


        void OnTriggerEnter(Collider other)
        {
            if (isHandled)
            {
                return;
            }

            var splitLineCollider = GetComponent <SplitLinerCollider>();

            Debug.Log($"trigger enter with collider type => {splitLineCollider.colliderType}");

            switch (splitLineCollider.colliderType)
            {
            case SplitLinerColliderType.yellow: {
                gm.DecrementTemp();
                gameObject.SetActive(false);
                aud.Play();
                SplitLinerGameManager.OnYellowBlockHitted();
            }
            break;

            case SplitLinerColliderType.green: {
                gm.DecrementTemp();
                gameObject.SetActive(false);
                aud.Play();
                SplitLinerGameManager.OnGreenBlockHitted();
            }
            break;

            case SplitLinerColliderType.red1:
            case SplitLinerColliderType.red2:
            case SplitLinerColliderType.red3: {
                motor.OnDeath();
            }
            break;

            case SplitLinerColliderType.blue1: {
                motor.needBounce = true;
                tempPos          = transform.position;
                StartCoroutine(SwapOnOtherCollider(0.2f, red1));
            }
            break;

            case SplitLinerColliderType.blue2: {
                motor.needBounce = true;
                tempPos          = transform.position;
                StartCoroutine(SwapOnOtherCollider(0.2f, red2));
            }
            break;

            case SplitLinerColliderType.blue3: {
                motor.needBounce = true;
                tempPos          = transform.position;
                StartCoroutine(SwapOnOtherCollider(0.2f, red3));
            }
            break;
            }

            isHandled = true;
        }
Пример #2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         motor.OnDeath();
     }
     if (other.tag == "red1")
     {
         Destroy(other.gameObject);
     }
 }