void Start() { if (!DataPersistance.GameStateExists()) { throw new System.InvalidProgramException("Game state don't exist!"); } CurrentGameId = DataPersistance.GetCurrentGameId(); PopupsController = GetComponent <PopupsController>(); if (GSP.GameState.ItsMyTurn()) { if (GSP.GameState.HasNotStarted()) { GameEngine.StartGame(); } } UpdateUI(); CheckTheTurn(); if (GSP.GameState.GetAvailableActions().FindAll((Action obj) => obj.Type == ActionType.EndTurn).Count == 1) { EndTurnParticleSystemVisible = true; } else { EndTurnParticleSystemVisible = false; } }
public static PopupsController getInstance() { if (!_Instance) { _Instance = new PopupsController(); } return(_Instance); }
void Start() { more_duels.onClick.AddListener(() => { MoreDuels(); }); less_duels.onClick.AddListener(() => { LessDuels(); }); more_tournaments.onClick.AddListener(() => { MoreTournaments(); }); less_tournaments.onClick.AddListener(() => { LessTournaments(); }); _1v1_cash_confident.onClick.AddListener(() => { object[] _params = { ChallengeManager.FEE_1V1_PRO_CONFIDENT.ToString("N2"), ChallengeManager.WIN_1V1_PRO_CONFIDENT.ToString("N2"), ChallengeManager.CHALLENGE_WIN_TYPE_CASH, ChallengeManager.CHALLENGE_TYPE_1V1 }; PopupsController.getInstance().ShowPopup(PopupsController.PopupType.DUELS, _params); }); _1v1_cash_champion.onClick.AddListener(() => { object[] _params = { ChallengeManager.FEE_1V1_PRO_CHAMPION.ToString("N2"), ChallengeManager.WIN_1V1_PRO_CHAMPION.ToString("N2"), ChallengeManager.CHALLENGE_WIN_TYPE_CASH, ChallengeManager.CHALLENGE_TYPE_1V1 }; PopupsController.getInstance().ShowPopup(PopupsController.PopupType.DUELS, _params); }); _1v1_cash_legend.onClick.AddListener(() => { object[] _params = { ChallengeManager.FEE_1V1_PRO_LEGEND.ToString("N2"), ChallengeManager.WIN_1V1_PRO_LEGEND.ToString("N2"), ChallengeManager.CHALLENGE_WIN_TYPE_CASH, ChallengeManager.CHALLENGE_TYPE_1V1 }; PopupsController.getInstance().ShowPopup(PopupsController.PopupType.DUELS, _params); }); _bracket_cash_confident.onClick.AddListener(() => { object[] _params = { TournamentManager.FEE_BRACKET_CASH_CONFIDENT.ToString("N2"), TournamentManager.WIN_BRACKET_CASH_CONFIDENT.ToString("N2"), ChallengeManager.CHALLENGE_WIN_TYPE_CASH, ChallengeManager.CHALLENGE_TYPE_BRACKET }; PopupsController.getInstance().ShowPopup(PopupsController.PopupType.DUELS, _params); }); _bracket_cash_champion.onClick.AddListener(() => { object[] _params = { TournamentManager.FEE_BRACKET_CASH_CHAMPION.ToString("N2"), TournamentManager.WIN_BRACKET_CASH_CHAMPION.ToString("N2"), ChallengeManager.CHALLENGE_WIN_TYPE_CASH, ChallengeManager.CHALLENGE_TYPE_BRACKET }; PopupsController.getInstance().ShowPopup(PopupsController.PopupType.DUELS, _params); }); _bracket_cash_legend.onClick.AddListener(() => { object[] _params = { TournamentManager.FEE_BRACKET_CASH_LEGEND.ToString("N2"), TournamentManager.WIN_BRACKET_CASH_LEGEND.ToString("N2"), ChallengeManager.CHALLENGE_WIN_TYPE_CASH, ChallengeManager.CHALLENGE_TYPE_BRACKET }; PopupsController.getInstance().ShowPopup(PopupsController.PopupType.DUELS, _params); }); /*free_bubbles.onClick.AddListener(() => * { * * }); * extra_bubbles.onClick.AddListener(() => * { * * });*/ }
public static GameObject DrawBuildProjectCard(Card c, Vector2 coords) { GameObject gameObject = DrawCard(c, coords.x, coords.y, D.CardWidth, D.CardHeight, false); DropCardController dcc = gameObject.AddComponent <DropCardController>(); dcc.Card = c; dcc.DragDropAction = DragDropAction.BuildProject; gameObject.AddComponent <ClickActionScript>() .ClickMethod = (item) => { PopupsController.ShowCardZoomPopup(c); }; return(gameObject); }
void ShowPopup(PopupsController.PopupType popup, object[] popup_details) { PopupsController.getInstance().ShowPopup(popup, popup_details); }
private void OnEnable() { _Instance = this; }
public static void ApplyCompletingSingleBuildingBonus(this Player player, Card card, System.Action doneCallback) { GameState gameState = GSP.GameState; Deck goodsDeck = gameState.GoodsDeck; Deck animalsDeck = gameState.AnimalsDeck; switch (card.Class) { case CardClass.ActionCastle: player.BonusActionCards.Add(new Card(CardClass.BonusCastle, CardDice.All)); break; case CardClass.ActionMine: player.SilverCount = player.SilverCount + 2; break; case CardClass.ActionCloister: break; case CardClass.ActionKnowledge: player.WorkersCount = player.WorkersCount + 2; break; case CardClass.ActionShip: PopupsController.ShowChooseGoodsPopup(1, doneCallback); break; case CardClass.ActionPasture: PopupsController.ShowChooseAnimalPopup(1, doneCallback); break; case CardClass.ActionCarpenter: var carpenterAvilableBonuses = GSP.GameState.AvailableProjectCards .FindAll((obj) => obj.Card.IsBuildingType() || obj.Card.Class == CardClass.ActionKnowledge) .ConvertAll((ProjectCard input) => input.Card); if (carpenterAvilableBonuses.IsNotEmpty()) { PopupsController.ShowTakeBuildingRewardCard(doneCallback, CardClass.ActionCarpenter); } else { doneCallback(); } break; case CardClass.ActionChurch: var churchAvilableBonuses = GSP.GameState.AvailableProjectCards .ConvertAll((ProjectCard input) => input.Card) .FindAll((obj) => obj.Class == CardClass.ActionCloister || obj.Class == CardClass.ActionCastle || obj.Class == CardClass.ActionMine); if (churchAvilableBonuses.IsNotEmpty()) { PopupsController.ShowTakeBuildingRewardCard(doneCallback, CardClass.ActionChurch); } else { doneCallback(); } break; case CardClass.ActionMarket: var marketAvilableBonuses = GSP.GameState.AvailableProjectCards .ConvertAll((ProjectCard input) => input.Card) .FindAll((obj) => obj.Class == CardClass.ActionPasture || obj.Class == CardClass.ActionShip); if (marketAvilableBonuses.IsNotEmpty()) { PopupsController.ShowTakeBuildingRewardCard(doneCallback, CardClass.ActionMarket); } else { doneCallback(); } break; case CardClass.ActionWatchtower: player.Score = player.Score + 1; break; case CardClass.ActionBank: player.SilverCount = player.SilverCount + 3; break; case CardClass.ActionBoardinghouse: var animalsOrGoodsExists = GSP.GameState.AnimalsDeck.Cards.IsNotEmpty() || GSP.GameState.GoodsDeck.Cards.IsNotEmpty(); if (animalsOrGoodsExists) { PopupsController.ShowTakeGoodsOrAnimal(doneCallback); } else { doneCallback(); } break; case CardClass.ActionWarehouse: PopupsController.ShowChooseGoodsPopup(1, doneCallback); break; case CardClass.ActionCityHall: var cityHallAvilableBonuses = GSP.GameState.AvailableProjectCards .ConvertAll((ProjectCard input) => input.Card); if (cityHallAvilableBonuses.IsNotEmpty()) { PopupsController.ShowTakeBuildingRewardCard(doneCallback, CardClass.ActionCityHall); } else { doneCallback(); } break; } switch (card.Class) { case CardClass.ActionCastle: case CardClass.ActionMine: case CardClass.ActionCloister: case CardClass.ActionWatchtower: case CardClass.ActionBank: case CardClass.ActionKnowledge: doneCallback(); break; case CardClass.ActionWarehouse: case CardClass.ActionBoardinghouse: case CardClass.ActionCarpenter: case CardClass.ActionChurch: case CardClass.ActionMarket: case CardClass.ActionCityHall: case CardClass.ActionShip: case CardClass.ActionPasture: break; } }
private void ChooseBonus(int number) { bool bonusAquired = true; Player currentPlayer = GSP.GameState.CurrentPlayer; switch (GSP.GameState.CurrentRound) { case Round.A: switch (number) { case 1: currentPlayer.Score = currentPlayer.Score + 3; break; case 2: PopupsController.ShowChooseAnimalPopup(2, DoneCallback); Destroy(gameObject); break; case 3: PopupsController.ShowChooseGoodsPopup(2, DoneCallback); Destroy(gameObject); break; case 4: currentPlayer.WorkersCount = currentPlayer.WorkersCount + 3; break; case 5: currentPlayer.SilverCount = currentPlayer.SilverCount + 3; break; default: bonusAquired = false; break; } break; case Round.B: switch (number) { case 1: PopupsController.ShowChooseAnimalPopup(2, DoneCallback); Destroy(gameObject); break; case 2: PopupsController.ShowChooseGoodsPopup(2, DoneCallback); Destroy(gameObject); break; case 4: currentPlayer.WorkersCount = currentPlayer.WorkersCount + 3; break; case 5: currentPlayer.SilverCount = currentPlayer.SilverCount + 3; break; default: bonusAquired = false; break; } break; case Round.C: switch (number) { case 1: PopupsController.ShowChooseAnimalPopup(1, DoneCallback); Destroy(gameObject); break; case 2: PopupsController.ShowChooseGoodsPopup(1, DoneCallback); Destroy(gameObject); break; case 3: currentPlayer.WorkersCount = currentPlayer.WorkersCount + 2; break; case 4: currentPlayer.SilverCount = currentPlayer.SilverCount + 2; break; case 5: currentPlayer.WorkersCount = currentPlayer.WorkersCount + 1; currentPlayer.SilverCount = currentPlayer.SilverCount + 1; break; default: bonusAquired = false; break; } break; case Round.D: switch (number) { case 3: currentPlayer.WorkersCount = currentPlayer.WorkersCount + 2; break; case 4: currentPlayer.SilverCount = currentPlayer.SilverCount + 2; break; case 5: currentPlayer.WorkersCount = currentPlayer.WorkersCount + 1; currentPlayer.SilverCount = currentPlayer.SilverCount + 1; break; default: bonusAquired = false; break; } break; case Round.E: switch (number) { case 1: currentPlayer.WorkersCount = currentPlayer.WorkersCount + 1; break; case 2: currentPlayer.SilverCount = currentPlayer.SilverCount + 1; break; default: bonusAquired = false; break; } break; } if (bonusAquired) { Destroy(gameObject); DoneCallback(); } }
public static void ProcessAction(this Action action, System.Action doneCallback = null) { var cp = GSP.GameState.CurrentPlayer; var availableProjectCards = GSP.GameState.AvailableProjectCards; if (!GSP.GameState.GetAvailableActions().Has(action)) { throw new System.InvalidProgramException("Cannot use and action that is not in the available actions!"); } if (doneCallback == null) { doneCallback = () => { 0.print_("here"); }; } UnityEngine.Debug.Log(cp.NickName + " used " + action.Describe()); switch (action.Type) { case ActionType.TakeProject: cp.WithdrawUsedCard(action.ActionCard); cp.UseWorkers(action.WorkersNeeded); cp.ProjectArea.Add(action.TargetCard); availableProjectCards.RemoveCardFromProjects(action.TargetCard); doneCallback(); break; case ActionType.BuildProject: cp.WithdrawUsedCard(action.ActionCard); cp.UseWorkers(action.WorkersNeeded); cp.ApplyCompletingSingleBuildingBonus(action.TargetCard, () => { UnityEngine.Debug.Log("single bonus done"); if (cp.GetNotCompletedTriplesForCard(action.TargetCard).IsEmpty()) { UnityEngine.Debug.Log("there are no not completed triples for this card"); int newTripleId = cp.CompletedProjects.Count + 1; bool didFinishTriple = GSP.GameState.CompleteProject(action.TargetCard, newTripleId); GSP.GameState.CurrentPlayer.ApplyAllKindsSevenBonusIfPossible(); if (didFinishTriple) { UnityEngine.Debug.Log("triple finished"); cp.ApplyCompletingTripleBonusPoints(newTripleId); PopupsController.ShowChooseTripleBonusPopup(() => { UnityEngine.Debug.Log("triple bonus done"); doneCallback(); }); } else { UnityEngine.Debug.Log("triple not yet finished"); doneCallback(); } } else { UnityEngine.Debug.Log("there are some not completed triples. Show popup"); PopupsController.ShowChooseTripleStackPopup(action.TargetCard, (tripleId) => { UnityEngine.Debug.Log("choose triple stack done"); bool didFinishTriple = GSP.GameState.CompleteProject(action.TargetCard, tripleId); GSP.GameState.CurrentPlayer.ApplyAllKindsSevenBonusIfPossible(); if (didFinishTriple) { UnityEngine.Debug.Log("triple finished"); cp.ApplyCompletingTripleBonusPoints(tripleId); PopupsController.ShowChooseTripleBonusPopup(() => { UnityEngine.Debug.Log("triple bonus done"); doneCallback(); }); } else { UnityEngine.Debug.Log("triple not yet finished"); doneCallback(); } }); } }); break; case ActionType.ShipGoods: cp.WithdrawUsedCard(action.ActionCard); cp.UseWorkers(action.WorkersNeeded); cp.ShipGoods(action.TargetCard); cp.MoveFirstPlayerBonusCard(); doneCallback(); break; case ActionType.BuyWorkers: cp.WithdrawUsedCard(action.ActionCard); if (cp.WorkersCount < 2) { cp.WorkersCount = 2; } doneCallback(); break; case ActionType.BuySilver: cp.WithdrawUsedCard(action.ActionCard); cp.SilverCount += 1; doneCallback(); break; case ActionType.SellSilverAndWorkers: cp.WithdrawUsedCard(action.ActionCard); cp.SilverCount -= action.SilverSell; cp.WorkersCount -= action.WorkersSell; cp.Score += (action.WorkersSell + action.SilverSell) / 3; doneCallback(); break; case ActionType.UseSilver: cp.SilverCount = cp.SilverCount - 3; Utils.Repeat(3, () => { cp.BonusActionCards.Add(GSP.GameState.MainDeck.DrawCard()); }); cp.SilverActionDoneThisTurn = true; doneCallback(); break; case ActionType.TakeSilverProject: cp.ProjectArea.Add(action.ActionCard); cp.BonusActionUsed(action.ActionCard); doneCallback(); break; case ActionType.EndTurn: GameEngine.ExecuteEndTurnAction(); cp.SilverActionDoneThisTurn = false; doneCallback(); break; default: throw new System.InvalidProgramException("Unknown action type: " + action.Describe()); } }