private void Awake() { cellSelection = CellSelection.GetInstance(); unitsList = UnitsList.GetInstance(); unitSelection = UnitSelection.GetInstance(); for (int i = 0; i < toggles.GetComponentsInChildren <Toggle>().Length; i++) { foreach (Image image in toggles.GetComponentsInChildren <Toggle>()[i].GetComponentsInChildren <Image>()) { if (image.gameObject.name == "Image") { images[i] = image; } } } }
private void DoCapturings() { Debug.Log("Capturings: " + capturings.Count.ToString()); Debug.Log("Friendly units: " + UnitsList.GetInstance().GetAllFriends().Length); if (capturings.Count == 0) { return; } if (UnitsList.GetInstance().GetAllFriends().Length == 0) { return; } foreach (Vector3 portalPos in capturings) { foreach (Unit unit in UnitsList.GetInstance().GetAllFriends()) { if (unit.transform.position == portalPos) { Cell newPortal; Cell oldPortal = GetCell(portalPos); if (PlayerControler.GetInstance().FirstPlayerTurn()) { Debug.Log("!!!"); //newPortal = Instantiate(leftPortalPrefab, gameObject.transform); newPortal = Instantiate(leftPortalPrefab, oldPortal.transform.position, GetCell(portalPos).transform.rotation, gameObject.transform); } else { //newPortal = Instantiate(rightPortalPrefab, gameObject.transform); newPortal = Instantiate(rightPortalPrefab, oldPortal.transform.position, GetCell(portalPos).transform.rotation, gameObject.transform); } cells[cells.IndexOf(oldPortal)] = newPortal; Destroy(oldPortal.gameObject); } } } capturings.RemoveAll(pos => (int)PlayerControler.GetInstance().GetCurrentPlayer() == (int)GetCell(pos).type - 1); if (GameControler.WinCheck()) { Debug.Log("Win!!!"); GameEvents.GetInstance().ShowWinScreen(); } }