public HexCell Create(CellTypes type, NetworkGamePlayerHex owner, int cellID) { var cell = CreateCell(type); if (cell == null) { return(cell); } cell.SetupTech(data, owner.ID); cell.Init(this, data, owner); allCells.Add(cellID, cell); foreach (var observer in cellEventObservers) { cell.RegisterEventObserver(observer); } foreach (var observer in cellLifecycleObservers) { observer.OnCellCreated(cell); } return(cell); }
public PlayerActions(NetworkGamePlayerHex player, GameManager game) { this.player = player; this.game = game; indicator = new CellIndicator(game.Cells, game.UI); input = new PlayerInput(); input.RegisterObserver(this); state = States.None; }
public void Init(Cells cells, GameData data, NetworkGamePlayerHex owner) { GameData = data; CellData = cells; Owner = owner; PlayerId = Owner.ID; foreach (var action in actions) { action.Init(data, PlayerId); } OnInit(); }
/// <summary> /// Called by the server to validate placement /// </summary> public void TryPlace(NetworkGamePlayerHex player, Int16 x, Int16 z, Cells.CellTypes type) { if (!IsCurrentPlayer(player)) { return; } var playerData = Data.GetPlayerData(player); var cost = Cells.GetCost(type); if (!playerData.CurrencyData.CanAfford(cost)) { return; } if (!playerData.TechnologyData.HasTechnologyForCell(type)) { return; } if (Grid.TryPlace(x, z, player.ID, type)) { playerData.CurrencyData.Purchase(cost); } }
public PlayerData(NetworkGamePlayerHex player) { Player = player; }
public void RemoveGamePlayer(NetworkGamePlayerHex player) { GamePlayers.Remove(player); Game.Data.UnregisterPlayer(player); }
public void AddGamePlayer(NetworkGamePlayerHex player) { GamePlayers.Add(player); }
public void SetGamePlayer(NetworkGamePlayerHex player) { gamePlayer = player; UI.Init(player); }
public bool IsCurrentPlayer(NetworkGamePlayerHex player) => Data.IsCurrentPlayer(player.ID);
public void SetStartingLocation(NetworkGamePlayerHex player) { var startLocation = GetStartLocation(player.ID); TryPlace((Int16)startLocation.X, (Int16)startLocation.Z, (Int16)player.ID, Cells.CellTypes.Home); }
public void UnregisterPlayer(NetworkGamePlayerHex player) { playerData.RemoveAt(playerData.FindIndex(p => p.Player.ID == player.ID)); }
public PlayerData GetPlayerData(NetworkGamePlayerHex player) { return(playerData.First(p => p.Player.ID == player.ID)); }
public void OnSuppliesChanged(NetworkGamePlayerHex player, int newSupplies) { RpcSetSupplies((Int16)player.ID, (Int16)newSupplies); }
public void OnPopulationUtilisationChanged(NetworkGamePlayerHex player, int newUtilisation) { RpcSetPopulationUtilisation((Int16)player.ID, (Int16)newUtilisation); }
public void OnMaxPopulationChanged(NetworkGamePlayerHex player, int newPopulation) { RpcSetMaxPopulation((Int16)player.ID, (Int16)newPopulation); }