Пример #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Cell")
        {
            CellScript tempCollisionCellScript = collision.gameObject.GetComponent <CellScript>();

            if (tempCollisionCellScript.CellOwner == "Green")
            {
                if (!tempCollisionCellScript.IsActive)
                {
                    tempCollisionCellScript.ActivateCell();
                    activeCells.Add(collision.gameObject);

                    collisionsCheckPre = activeCells.Count;
                }
            }

            else if (activeCells.Count > 0)
            {
                CellScript tempCellScript;
                foreach (GameObject cell in activeCells)
                {
                    tempCellScript = cell.GetComponent <CellScript>();
                    //add target removal & amount of subcells

                    StartCoroutine(SubcellSpawning(tempCellScript.CellCount / 2, cell.transform.position, collision.gameObject));

                    //collision.gameObject.GetComponent<CellScript>().CellHit("Green", cell.GetComponent<CellScript>().CellCount / 2);
                    tempCellScript.CellCount = tempCellScript.CellCount / 2;
                    tempCellScript.UpdateCellText();
                }

                ResetActiveCells();
            }
        }
    }