public void SetBuild(HexCell originator, Cells.CellTypes type) { state = States.Building; cellBuildType = type; builder = originator; game.UI.HideCellInfo(); indicator.ShowBuild(type, player.ID, originator); }
public static T[] GetCells <T>(this Cells cells, int playerId, Cells.CellTypes cellType) where T : HexCell { var playerOwnedCells = cells.AllCells.Where(c => c.PlayerId == playerId); var matchedCells = playerOwnedCells as T[] ?? playerOwnedCells .OfType <T>() .Where(c => c.cellType == cellType).ToArray(); return(!matchedCells.Any() ? new T[0] : matchedCells.ToArray()); }
public bool HasTechnologyForCell(Cells.CellTypes cellType) { var action = config.buildActions.FirstOrDefault(a => a.prefab.cellType == cellType); if (action == null) { Debug.LogError("Failed to find build action for " + cellType); return(false); } return(HasTechnologies(action.techRequirements)); }
public int GetPlacementRadius(Cells.CellTypes cellType) { foreach (var action in Actions) { if (action is BuildAction buildAction && buildAction.prefab.cellType == cellType) { return(buildAction.placementRadius); } } return(0); }
public bool CanCreate(Cells.CellTypes cellType) { foreach (var action in Actions) { if (action is BuildAction buildAction && buildAction.prefab.cellType == cellType) { return(true); } } return(false); }
public void ShowBuild(Cells.CellTypes type, int playerID, HexCell origin) { Clear(); ui.SetGameCursor(HexCursor.None); projectedCell = cells.CreateIndicator(type, playerID); projectedCell.DisplayAsIndicator(cells.HoloShader, cells.GetColour(playerID)); var colour = new Color(0f, 1f, 0f, 0.5f); var coords = cells.GetValidPlacement(type, origin, true); ShowIndicatorGrid(coords, colour); }
public bool TryPlace(Int16 x, Int16 z, int playerID, Cells.CellTypes type) { var coords = new HexCoordinates(x, z); if (!cells.IsValidPlacement(type, coords, playerID)) { return(false); } var cellID = cells.GetUniqueCellID(); RpcCreateCell(x, z, (Int16)playerID, (Int16)type, (Int16)cellID); return(true); }
/// <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); } }