public void BindAction(List <PlayerAction> actions, PCBoardBehavior boardBehavior) { BindCardRow(); BindWorkerBank(actions, boardBehavior); BindUnknown(actions); BindBuildings(actions, boardBehavior); BindSpriteUIButtons(actions, boardBehavior); BindHandCard(actions.Where( action => action.ActionType == PlayerActionType.DevelopTechCard || action.ActionType == PlayerActionType.PlayActionCard || action.ActionType == PlayerActionType.Revolution || action.ActionType == PlayerActionType.ElectLeader).ToList(), CivilCardFrame, boardBehavior); BindHandCard(actions.Where( action => action.ActionType == PlayerActionType.SetupTactic).ToList(), MilitaryCardFrame, boardBehavior); BindConstructingWonder(actions, boardBehavior); PoliticalPhaseDialogFrame.BindAction(actions, boardBehavior); }
private void BindBuildings(List <PlayerAction> actions, PCBoardBehavior boardBehavior) { foreach (Transform child in BuildingCellFrame.transform) { var frame = child.gameObject.GetComponent <BuildingCellActionBinder>(); frame.BindAction(actions, boardBehavior); } }
private void BindWorkerBank(List <PlayerAction> actions, PCBoardBehavior boardBehavior) { List <PlayerAction> acceptedActions = actions.Where( action => action.ActionType == PlayerActionType.IncreasePopulation).ToList(); WorkerBankActionTrigger.Bind(acceptedActions.Count > 0 ? acceptedActions[0] : null, boardBehavior); }
private void BindSpriteUIButtons(List <PlayerAction> actions, PCBoardBehavior boardBehavior) { var acceptedAction = actions.FirstOrDefault(action => action.ActionType == PlayerActionType.ResetActionPhase); if (acceptedAction != null) { EndActionPhaseButtonFrame.Bind(acceptedAction, boardBehavior); } }
private void BindConstructingWonder(List <PlayerAction> actions, PCBoardBehavior boardBehavior) { ConstructingWonderFrame.ActionOnMouseClick = () => { List <PlayerAction> acceptedActions = actions.Where( action => action.ActionType == PlayerActionType.BuildWonder).ToList(); acceptedActions.Sort((a, b) => ((int)a.Data[1]).CompareTo(b.Data[0])); //2017-05-15 ConstructingWonderMenuFrame.Popup(acceptedActions, boardBehavior); }; ConstructingWonderFrame.ActionOnMouseClickOutside = () => { ConstructingWonderMenuFrame.Collapse(); }; ConstructingWonderFrame.BoardBehavior = boardBehavior; }
private void BindHandCard(List <PlayerAction> acceptedActions, GameObject cardFrame, PCBoardBehavior boardBehavior) { var behaviorList = cardFrame.transform.Cast <Transform>() .Select(t => t.gameObject.GetComponent <PCBoardCardDisplayBehaviour>()) .Where(behave => behave != null) .ToList().Where(cardDisplayBehavior => cardDisplayBehavior.Card != null) .Where(cd => cd.gameObject.activeSelf == true); var cards = new Dictionary <CardInfo, List <PCBoardCardDisplayBehaviour> >(); foreach (var cd in behaviorList) { if (!cards.ContainsKey(cd.Card)) { cards[cd.Card] = new List <PCBoardCardDisplayBehaviour>(); } cards[cd.Card].Add(cd); } foreach (var action in acceptedActions) { var key = action.Data[0] as CardInfo; if (key == null) { LogRecorder.Log("Wrong Action"); continue; } if (!cards.ContainsKey(key)) { LogRecorder.Log("Missing Card"); continue; } foreach (var behavior in cards[key]) { var trg = behavior.gameObject.GetComponent <PCBoardBindedActionClickTrigger>(); var actionAsync = action; trg.Bind(new PlayerAction() { ActionType = PlayerActionType.ProgramDelegateAction, Data = new Dictionary <int, object>() { { 0, new Action(() => { HandCardMenuFrame.Popup(actionAsync, trg.gameObject, boardBehavior); }) } } }, boardBehavior); } } }