예제 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.CompareTag("Player"))
        {
            Weapon weapon = other.transform.GetComponentInParent <Weapon>();
            if (weapon.canSlice)
            {
                if (weapon.SwordVelocity > 3f || particleTyp == particleType.Explosion)
                {
                    gameController.Slice(gameObject, weapon);
                }
            }
            else
            {
                fruitRigidbody.interpolation = RigidbodyInterpolation.Extrapolate;
                Bounce(weapon.direct, weapon.SwordVelocity);
            }
        }

        //for reycyle
        else if (other.transform.CompareTag("ground"))
        {
            pooler.ReycleFruit(this);
        }
    }
예제 #2
0
    //Check you slice a fruit or not , and slice it!
    public void Slice(GameObject _Fruit, Weapon weapon)
    {
        SlicedHull slicedObject = Sliceed(_Fruit, weapon.slicePanel, sliceMaterial);

        if (slicedObject != null)
        {
            if (_Fruit.CompareTag("fruit"))
            {
                _Fruit.SetActive(false);
                Fruit fruit = _Fruit.GetComponent <Fruit>();
                pooler.ReycleFruit(fruit);
                if (fruit.particleTyp == particleType.Explosion)
                {
                    soundManager.BombSound();
                    weapon.Vibrate(0.5f);
                }
                else if (fruit.particleTyp == particleType.Ice)
                {
                    soundManager.FrozenSound();
                    uIManager.IncreaseScore(4);
                    weapon.Vibrate(0.2f);
                }
                else
                {
                    soundManager.SplashFruit();
                    uIManager.IncreaseScore(1);
                    weapon.Vibrate(0.1f);
                }
            }
            else if (_Fruit.CompareTag("button"))
            {
                weapon.Vibrate(0.1f);
                uIManager.BeforeSelectButton();
                soundManager.SplashFruit();
                StartCoroutine(Countdown(_Fruit));
            }
            pooler.GetParticle(_Fruit.GetComponent <Fruit>().particleTyp, _Fruit.transform.position, _Fruit.transform.rotation);
            GameObject upperPart = slicedObject.CreateUpperHull(_Fruit);
            GameObject lowPart   = slicedObject.CreateLowerHull(_Fruit);
            AddComponents(upperPart);
            AddComponents(lowPart);
        }
        else
        {
            Debug.Log("null");
        }
    }