private void UpdateUpgradeBonus(BuildingCell cell, int upgradeIndex, Currency currency) { var upgradeDetailsField = InspectorUtil.GetPrivateField <BuildingCell>("upgradeDetails"); var details = (List <BuildingCell.UpgradeDetail>)upgradeDetailsField.GetValue(cell); var detail = details[upgradeIndex]; Undo.RecordObject(cell, "Update upgrade bonus"); detail.currencyBonus = currency; details[upgradeIndex] = detail; EditorUtility.SetDirty(cell); upgradeDetailsField.SetValue(cell, details); }
private PlayerData CreatePlayerData(BuildingCell startingCell) { var playerData = new PlayerData(null); playerData.Init(config); playerData.TurnNumber = 1; playerData.TechnologyData.AddTechnology(startingCell.Technology); var startingCurrency = startingCell.GetCurrencyBonus(); startingCurrency.supplies = config.startingSupply; playerData.CurrencyData.SetCurrency(startingCurrency); return(playerData); }
private void AddToActionGroups(BuildingCell building, List <VisualElement> buildingActions, List <VisualElement> unitActions, List <VisualElement> upgradeActions) { if (buildingActions.Any()) { var buildingGroup = new VisualElement(); buildingGroup.AddToClassList("cell-group"); var header = new Label(building.DisplayName); header.AddToClassList("cell-group-header"); buildingGroup.Add(header); buildingActions.ForEach(a => buildingGroup.Add(a)); buildActionRoot.Add(buildingGroup); } if (unitActions.Any()) { var unitGroup = new VisualElement(); unitGroup.AddToClassList("cell-group"); var header = new Label(building.DisplayName); header.AddToClassList("cell-group-header"); unitGroup.Add(header); unitActions.ForEach(a => unitGroup.Add(a)); unitActionRoot.Add(unitGroup); } if (upgradeActions.Any()) { var upgradeGroup = new VisualElement(); upgradeGroup.AddToClassList("cell-group"); var header = new Label(building.DisplayName); header.AddToClassList("cell-group-header"); upgradeGroup.Add(header); upgradeActions.ForEach(a => upgradeGroup.Add(a)); upgradeActionRoot.Add(upgradeGroup); } }
public static void LoadTownArtifact() { SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("Town_artifacts"); while (reader.Read()) { Town_artifacts townArtifact = new Town_artifacts(); townArtifact.ID = Convert.ToInt32(reader.GetString(reader.GetOrdinal("Id"))); townArtifact.isoName = reader.GetString(reader.GetOrdinal("Name")); townArtifact.vaSize = GetIntVector3FromStr(reader.GetString(reader.GetOrdinal("Size"))); string b_positions = reader.GetString(reader.GetOrdinal("B_position")); string npc_borns = reader.GetString(reader.GetOrdinal("NPC_born")); string tower_pos = reader.GetString(reader.GetOrdinal("Tower")); townArtifact.buildingCell = new List <BuildingCell>(); string[] buildingCellStr = b_positions.Split('_'); for (int i = 0; i < buildingCellStr.Count(); i++) { BuildingCell bc = new BuildingCell(); string[] posRotStr = buildingCellStr[i].Split(';'); bc.cellPos = GetVector3FromStr(posRotStr[0]); bc.cellRot = float.Parse(posRotStr[1]); townArtifact.buildingCell.Add(bc); } townArtifact.npcPos = new List <Vector3>(); string[] npcPosStr = npc_borns.Split('_'); for (int i = 0; i < npcPosStr.Count(); i++) { Vector3 npcPos = GetVector3FromStr(npcPosStr[i]); townArtifact.npcPos.Add(npcPos); } townArtifact.towerPos = GetVector3FromStr(tower_pos); townArtifactsData.Add(townArtifact.ID, townArtifact); } }
public abstract int CalculateProduction(BuildingCell cell, PlayerData data);
public abstract int CalculateSupplies(BuildingCell cell, PlayerData data);
public override int CalculateSupplies(BuildingCell cell, PlayerData data) { return(data.CurrencyData.Production.Available); }
public override int CalculatePopulation(BuildingCell cell, PlayerData data) { return(cell.GetCurrencyBonus().production); }
private static void ExtractBuildingBoard(TtaBoard board, string htmlShade) { board.Buildings = new Dictionary <BuildingType, Dictionary <Age, BuildingCell> >(); var titleMap = new List <BuildingType>(); var buildingBoardTableHtml = BgoRegexpCollections.ExtractBuildingBoard.Match(htmlShade).Groups[1].Value; var mcsRow = BgoRegexpCollections.ExtractBuildingBoardRow.Matches(buildingBoardTableHtml); //分析表头 var titleRowHtml = mcsRow[0].Groups[1].Value; foreach (Match mcTitle in BgoRegexpCollections.FindP.Matches(titleRowHtml)) { BuildingType bType; switch (mcTitle.Groups[1].Value) { case "Air Force": bType = BuildingType.AirForce; break; case " ": bType = BuildingType.Unknown; break; default: bType = (BuildingType)Enum.Parse(typeof(BuildingType), mcTitle.Groups[1].Value); break; } if (bType != BuildingType.Unknown) { titleMap.Add(bType); } } for (int rowIndex = 1; rowIndex < mcsRow.Count; rowIndex++) { //分析从第二行开始的内容 var mcsColumn = BgoRegexpCollections.ExtractBuildingBoardCell.Matches(mcsRow[rowIndex].Groups[1].Value); //第一格是时代 var strAge = BgoRegexpCollections.FindP.Match(mcsColumn[0].Groups[1].Value).Groups[1].Value.Replace("Age ", ""); var age = (Age)Enum.Parse(typeof(Age), strAge); //从第二格开始 for (int colIndex = 1; colIndex < mcsColumn.Count; colIndex++) { if (mcsColumn[colIndex].Groups[1].Value == " ") { continue; } BuildingCell cell = new BuildingCell(); var cellHtml = mcsColumn[colIndex].Groups[1].Value; var mcsNameAndCount = BgoRegexpCollections.FindP.Matches(cellHtml); var buildingName = mcsNameAndCount[0].Groups[1].Value; cell.Card = civilopedia.GetCardInfoByName(buildingName); var workerCount = mcsNameAndCount[1].Groups[1].Value == " " ? 0 : BgoRegexpCollections.ExtractBuildingBoardBuidingCount.Matches(mcsNameAndCount[1].Groups[1].Value).Count; cell.Worker = workerCount; var mcsResource = BgoRegexpCollections.ExtractBuildingBoardResourceCount.Matches(cellHtml); cell.Storage = mcsResource.Count; if (!board.Buildings.ContainsKey(titleMap[colIndex - 1])) { board.Buildings[titleMap[colIndex - 1]] = new Dictionary <Age, BuildingCell>(); } board.Buildings[titleMap[colIndex - 1]].Add(age, cell); } } }
private void BindCell(List <PlayerAction> actions, PCBoardBehavior BoardBehavior, SpecificCodeActionTrigger trigger, int index, BuildingCell cell) { trigger.BoardBehavior = null; if (BoardBehavior.InterAction == null) { //将点击建筑物面板作为主操作的,只有两个可能 //1、升级建筑物 //2、建造新的建筑物 //3、拆除和摧毁 if (BoardBehavior.CurrentPlayerBoardIndex != SceneTransporter.CurrentGame.MyPlayerIndex) { //不是自己的面板不显示操作菜单 return; } //因此按下的时候应该触发轮盘按钮 // trigger.ActionOnMouseClick = () => { //匿名方法参数传递 int localIndex = index; var localActions = actions; List <PlayerAction> acceptedActions = new List <PlayerAction>(); foreach (var action in localActions) { if (action.ActionType == PlayerActionType.BuildBuilding && ((CardInfo)action.Data[0]).InternalId == cell.Card.InternalId) { acceptedActions.Add(action); } if (action.ActionType == PlayerActionType.UpgradeBuilding) { if (((CardInfo)action.Data[0]).InternalId == cell.Card.InternalId || ((CardInfo)action.Data[1]).InternalId == cell.Card.InternalId) { acceptedActions.Add(action); } } if (action.ActionType == PlayerActionType.Disband || action.ActionType == PlayerActionType.Destory) { if (((CardInfo)action.Data[0]).InternalId == cell.Card.InternalId) { acceptedActions.Add(action); } } } MenuFrame.Collapse(); MenuFrame.Popup(acceptedActions, null); }; trigger.ActionOnMouseClickOutside = () => { MenuFrame.Collapse(); }; trigger.BoardBehavior = BoardBehavior; } else { //次要操作分门别类列在这里 } }
public override int CalculateSupplies(BuildingCell cell, PlayerData data) { return(cell.GetCurrencyBonus().supplies); }