Exemplo n.º 1
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Enemy")) // Столкновение с врагом
     {
         Enum_Elements enemyElement = collision.GetComponent <Abstract_Enemy>().Element;
         // Проверка соответствия стихий
         if (enemyElement == Enum_Elements.Fire && Element == Enum_Elements.Water ||
             enemyElement == Enum_Elements.Water && Element == Enum_Elements.Fire)
         {
             CollisionWithEnemy(collision);
         }
     }
 }
Exemplo n.º 2
0
    private void Awake()
    {
        startPosition = transform.position;
        rb2d          = GetComponent <Rigidbody2D>();

        aimRope = GetComponent <LineRenderer>();
        aimRope.positionCount = 2;
        aimRope.SetPosition(0, startPosition);
        aimRope.startColor = Color.gray;
        aimRope.endColor   = GetComponent <SpriteRenderer>().color;

        Element = Enum_Elements.Standard;
        Physics2D.IgnoreLayerCollision(8, 8);
    }
Exemplo n.º 3
0
    private void ChangeBallElement(Collision2D collision)   // Замена стихии мяча
    {
        if (collision.gameObject.GetComponent <GameBorder>().Element == Enum_Elements.Fire)
        {
            gameObject.GetComponent <Animator>().Play("Fireball");
            Element = Enum_Elements.Fire;
        }

        if (collision.gameObject.GetComponent <GameBorder>().Element == Enum_Elements.Water)
        {
            gameObject.GetComponent <Animator>().Play("Waterball");
            Element = Enum_Elements.Water;
        }
    }
Exemplo n.º 4
0
    private void Awake()
    {
        rectTransform = GetComponent <RectTransform>();
        boxCollider   = GetComponent <BoxCollider2D>();

        if (GetComponent <Image>().sprite.name == "Border_Fire")
        {
            Element = Enum_Elements.Fire;
        }
        else if (GetComponent <Image>().sprite.name == "Border_Water")
        {
            Element = Enum_Elements.Water;
        }
        else
        {
            Element = Enum_Elements.Standard;
        }
    }