Inheritance: MonoBehaviour
Ejemplo 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();
        }
    }
Ejemplo 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;
        }
    }
Ejemplo n.º 3
0
 private void Awake()
 {
     Instance = this;
 }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     apple  = GameObject.Find("apple");
     anim   = GetComponent <Animator>();
     script = apple.GetComponent <AppleController>();
 }