Beispiel #1
0
    //Removes the selected stones from all lists and destroys them.
    public void removeSelected()
    {
        if (selectedList != null && selectedList.Count > 0)
        {
            foreach (GameObject s in selectedList)
            {
                s.SetActive(false);
                selectedGroup.stonesList.Remove(s);
                Object.Destroy(s);
            }
            if (selectedGroup.Size() == 0)
            {
                pieces.groups.Remove(selectedGroup.gameObject);//remove empty group
                selectedGroup.gameObject.SetActive(false);
                Object.Destroy(selectedGroup.gameObject);
            }

            if (pieces.groups.Count == 0)  // all groups are empty
            {
                menu.enabled = true;
                menu.EndGame(turnController.CurrentPlayer() + " wins!!!");
            }

            turnController.ChangePlayer();
        }
        isSelecting  = false; //Deselect the group and stones.
        selectedList = null;
        if (selectedGroup != null)
        {
            selectedGroup.isSelected = false;
        }
        selectedGroup = null;
    }