Пример #1
0
    private void Awake()
    {
        instance = this;

        allyCollisions  = new List <BattleUnit>(3);
        enemyCollisions = new List <BattleUnit>(4);

        CircleCollider2D circleCollider = GetComponentInChildren <CircleCollider2D>(true);

        circleCollider.gameObject.SetActive(false);
        m_circleCollider = new System.Tuple <CircleCollider2D, SpriteRenderer>(circleCollider, circleCollider.GetComponentInChildren <SpriteRenderer>());
        m_circleCollider.Item1.GetComponent <CollisionCallbacks2D>().TriggerEnter2D += TriggerEnter2D;
        m_circleCollider.Item1.GetComponent <CollisionCallbacks2D>().TriggerExit2D  += TriggerExit2D;

        BoxCollider2D boxCollider = GetComponentInChildren <BoxCollider2D>(true);

        boxCollider.gameObject.SetActive(false);
        m_boxCollider = new System.Tuple <BoxCollider2D, SpriteRenderer>(boxCollider, boxCollider.GetComponentInChildren <SpriteRenderer>());
        m_boxCollider.Item1.GetComponent <CollisionCallbacks2D>().TriggerEnter2D += TriggerEnter2D;
        m_boxCollider.Item1.GetComponent <CollisionCallbacks2D>().TriggerExit2D  += TriggerExit2D;

        m_activeCollider = new System.Tuple <Collider2D, SpriteRenderer>(m_boxCollider.Item1, m_boxCollider.Item2);
    }