void Start() { turnManager = new TurnManager(); turnManager.OnTurnChanged += onTurnChanged; for (int i = 0; i < Teams.Length; i++) { for (int j = 0; j < Teams[i].TeamMembers.Length; j++) { Teams[i].TeamMembers[j].OnClicked += onClicked; } turnManager.AddTeam(Teams[i].TurnEntitiesList); } turnManager.Start(); }
public void StartGame() { if (PlayerAmount > turns.Length || PlayerAmount > teamsControllers.Length) { throw new System.Exception("Too many players :("); } startGUI.SetActive(true); teamsUI.UpdateUI(PlayerAmount); for (int i = 0; i < PlayerAmount; i++) { teamsControllers[i].Init(PawnAmount); turnManager.AddTeam(turns[i]); } turnManager.NextTurn(); }
private void Init() { showInfoPanel = true; gameObject.SetActive(false); ToggleInfoPanels(); PlayModeOn = true; PlayerGroup.GatherAGroup(_teamForm.PlayerSquad); _playerSquad = _teamForm.PlayerSquad; //=================== DEBUG =====================// EnemySquad.GatherASquad(DebugEnemySquadCreated()); //===============================================// int i = 0; foreach (var unit in _playerSquad) { AvailableShips.SubShip(1, unit.WeaponType); i++; var freeTile = GetFreeTile().gameObject; if (freeTile == null) { return; //not enough space } var ship = Instantiate(unit.Ship, _playerSquadParent.transform); float halfShipHeight = ship.GetComponent <Collider>().bounds.extents.y; float halfTileHeight = freeTile.GetComponent <Collider>().bounds.extents.y; Vector3 freeCell = freeTile.transform.position; freeCell.y += halfTileHeight + halfShipHeight; ship.name = unit.Name + " Player " + i; ship.tag = "PlayerUnit"; ship.transform.position = freeCell; ship.AddComponent <PlayerMove>(); ship.AddComponent <CharInfo>(); ship.GetComponent <CharInfo>().Init(unit); _playerSquadGO.Add(ship.GetComponent <PlayerMove>()); AddShipInfoPonel(ship, true); ship.GetComponent <PlayerMove>().PreInit(); } TurnManager.AddTeam(_playerSquadGO); i = 0; foreach (var unit in EnemySquad.Squad) { i++; var freeTile = GetFreeTileForEnemy().gameObject; if (freeTile == null) { return; //not enough space } var ship = Instantiate(unit.Ship, _enemySquadParent.transform); float halfShipHeight = ship.GetComponent <Collider>().bounds.extents.y; float halfTileHeight = freeTile.GetComponent <Collider>().bounds.extents.y; Vector3 freeCell = freeTile.transform.position; freeCell.y += halfTileHeight + halfShipHeight; ship.name = unit.Name + " Enemy " + i; ship.tag = "EnemyUnit"; ship.transform.position = freeCell; ship.AddComponent <NPCmove>(); ship.AddComponent <CharInfo>(); ship.GetComponent <CharInfo>().Init(unit); _enemySquadGO.Add(ship.GetComponent <NPCmove>()); AddShipInfoPonel(ship, false); ship.GetComponent <NPCmove>().PreInit(); } TurnManager.AddTeam(_enemySquadGO); }