Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Apple")
        {
            GoldenApple apple = collision.gameObject.GetComponentInParent <GoldenApple>();
            switch (apple.Type)
            {
            case AppleType.Golden:
                DeltaSpeed -= ChangeSpeed;
                Invoke(nameof(Speedtime), 5);
                break;

            case AppleType.Blue:
                Light2D SnakeLight = GetComponentInChildren <Light2D>();
                Invoke(nameof(SnakeVisionRadius), 10);
                SnakeLight.pointLightOuterRadius += 9;
                break;
            }

            GameObject.Destroy(collision.gameObject, 0.15f);
            result++;

            Score.text = "Score: " + result;
            IsApple    = true;
            AppleController.CreateApple();

            BodyCreate();
            SnakeEat.SetTrigger("Eat");
            return;
        }
        if (collision.tag == "Spikes" || collision.tag == "body" || collision.tag == "Enemy")
        {
            Dead();
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("AppleCollider");

        if (collision.tag == "Apple" && !SnakeControll.IsApple)
        {
            GameObject.Destroy(collision.gameObject);
            SnakeControll.IsApple = true;
            AppleController.CreateApple();
            // Debug.Log("AppleCollider");
            return;
        }
    }