public void Destroy() { field.tiles[(int)position.x, (int)position.y].GetComponent <TileScript>().occupier = null; for (int i = 0; i < field.cards.Count; i++) { if (field.cards[i] == gameObject.GetComponent <Card>()) { field.cards.RemoveAt(i); } } AI ai = FindObjectOfType <AI>(); Player player = FindObjectOfType <Player>(); if (playerOwned) { for (int i = 0; i < ai.playerUnits.Count; i++) { if (ai.playerUnits[i] == gameObject.GetComponent <Card>()) { ai.playerUnits.RemoveAt(i); } } for (int i = 0; i < player.ownUnits.Count; i++) { if (player.ownUnits[i] == gameObject.GetComponent <Card>()) { player.ownUnits.RemoveAt(i); } } } else { for (int i = 0; i < ai.ownUnits.Count; i++) { if (ai.ownUnits[i] == gameObject.GetComponent <Card>()) { ai.ownUnits.RemoveAt(i); } } } onField = false; if (ability) { ability.OnDestroy(); } //print("broke"); if (enhancement) { //print("enhancement will be destroyed"); enhancement.Destroy(); } if (!onField) { Destroy(gameObject); } }