private async Task ReshuffleMailAsync(DeckRegularDict <MailCard> list) { await UIPlatform.ShowMessageAsync("Mail is being reshuffled"); _gameContainer.SaveRoot !.MailListLeft = list; _gameContainer.SaveRoot.OutCards.RemoveAllOnly(items => items.Deck <= 24); }
protected override async Task ProtectedAfterRollingAsync() { SingleInfo !.Score += _model !.Cup !.DiceList.Sum(Items => Items.Value); if (SaveRoot !.IsFaceOff == true) { if (PlayerList.Any(Items => Items.IsFaceOff == true && Items.Score == 0)) { WhoTurn = await PlayerList !.CalculateWhoTurnAsync(); await StartNewTurnAsync(); return; } await ExtendedFaceOffAsync(); return; } SingleInfo.NumberOfRolls++; if (SingleInfo.Score > 21) { await UIPlatform.ShowMessageAsync($"{SingleInfo.NickName} is out for going over 21"); await EndTurnAsync(); return; } await ContinueTurnAsync(); //if they get 21, they are responsible for ending turn. }
/// <summary> /// Gets user interface controls for platform. /// </summary> /// <param name="Platform"> /// The platform. /// </param> /// <returns> /// The user interface controls for platform. /// </returns> public List <UIControl> GetUIControlsForPlatform(UIPlatform Platform) { return((from d in this where d.Platform == Platform orderby d.ControlRole.ToString() select d).ToList()); }
public BasicGameMainShellView(IGamePlatform customPlatform, IGameInfo gameData, BasicData basicData, IStartUp start, IStandardScreen screen) { UIPlatform.ShowMessageAsync = (async message => { await DisplayAlert("Message", message, "Okay"); customPlatform.ResetPopups(); }); UIPlatform.ShowError = (async message => { await DisplayAlert("Error", message, "Okay"); UIPlatform.ExitApp(); }); NavigationPage.SetHasNavigationBar(this, false); GameData = gameData; BasicData = basicData; _start = start; _screen = screen; CustomPlatform = customPlatform; BuildXAMLAsync().Wait(); }
public async Task PlayerPileClickedAsync(MilkRunPlayerItem thisPlayer, PileInfo pileData) { int newDeck = _model !.PlayerHand1 !.ObjectSelected(); if (newDeck == 0) { await UIPlatform.ShowMessageAsync("Sorry, must choose a card to play"); return; } if (SaveRoot !.CardsDrawn < 2) { await UIPlatform.ShowMessageAsync("Sorry, must draw the 2 cards first before playing"); return; } int index = thisPlayer.Id; if (CanMakeMove(index, newDeck, pileData.Pile, pileData.Milk) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (BasicData !.MultiPlayer == true) { SendPlay thisSend = new SendPlay(); thisSend.Deck = newDeck; thisSend.Player = index; thisSend.Milk = pileData.Milk; thisSend.Pile = pileData.Pile; await Network !.SendAllAsync("play", thisSend); } await ProcessPlayAsync(index, newDeck, pileData.Pile, pileData.Milk); }
public async Task LayDownSetsAsync() { if (_mainGame !.SaveRoot !.PlayerWentOut > 0) { bool lats = await _mainGame.CanLaterLayDownAsync(); if (lats == false) { return; } var thisCol1 = _mainGame.ListValidSets(); await ProcessValidSetsAsync(thisCol1); return; } bool rets = _mainGame.HasInitialSet(); if (rets == false) { await UIPlatform.ShowMessageAsync("Sorry, you do not have the valid sets needed to go out"); return; } var thisCol2 = _mainGame.ListValidSets(); await ProcessValidSetsAsync(thisCol2); }
public async Task AddToReserveAsync() { if (GlobalClass.MainModel !.ReservePiles1 !.HowManyCards >= 8) { await UIPlatform.ShowMessageAsync("There can only be 8 cards to reserve. Therefore, cannot add any more cards to reserve"); return; } if (GlobalClass.MainModel.ReservePiles1.ObjectSelected() > 0) { await UIPlatform.ShowMessageAsync("There is already a card selected. Unselect the card first before adding a card to reserve"); return; } if (_thisMod !.WastePiles1 !.OneSelected() == -1) { await UIPlatform.ShowMessageAsync("There is no card selected to add to reserve"); return; } var thisCard = _thisMod.WastePiles1.GetCard(); GlobalClass.MainModel !.ReservePiles1.AddCard(thisCard); _thisMod.WastePiles1.RemoveSingleCard(); }
private async void ThisPlayer_Progress(string timeElapsed, string totalTime) { try { int els = Player !.TimeElapsed(); els += 3; if (els < ResumeSecs && ResumeSecs > 5 && els <= 5) { _attempts++; if (_attempts > 10) { UIPlatform.ShowError("Somehow; its failing to autoresume no matter what. Already tried 10 times. Therefore; its being closed out"); return; } await Player.PlayAsync(VideoLength, ResumeSecs); } VideoPosition = Player.TimeElapsed(); ProgressText = $"{timeElapsed}/{totalTime}"; } catch (Exception ex) { UIPlatform.ShowError(ex.Message); //for now, if there is an error on reloading, will be forced to show error and close out to see what the problem could be. } }
private async Task RunAnimationsAsync() { try { await Task.Delay(500); // so others can see what was put down before the animations start. int x; var loopTo = _totalSteps - 1; for (x = 1; x <= loopTo; x++) { await Task.Delay((int)_internval); foreach (var thisTrick in _trickList !) { thisTrick.CurrentX += thisTrick.DiffX; thisTrick.CurrenyY += thisTrick.DiffY; GameBoard !.SetLocation(thisTrick.Index, thisTrick.CurrentX, thisTrick.CurrenyY); } } foreach (var thisCard in _tempArea !.CardList) { thisCard.Visible = false; } foreach (var thisTrick in _trickList !) { GameBoard !.SetLocation(thisTrick.Index, thisTrick.StartX, thisTrick.StartY); } } catch (Exception ex) { UIPlatform.ShowError(ex.Message); //hopefully okay. return; } }
public ImageLoadingQueueManager() { //TODO: review here**** UIPlatform.RegisterTimerTask(50, TimImageLoadMonitor_Tick); //default img caching _imgCache = new ImageCacheSystem(); }
public async Task PlayCardAsync() { int decks = _model.PlayerHand1.ObjectSelected(); if (decks == 0) { await UIPlatform.ShowMessageAsync("Must choose a card to play"); return; } var thisCard = _mainGame.SingleInfo !.MainHandList.GetSpecificItem(decks); if (_mainGame.CanPlayCard(thisCard) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame.BasicData !.MultiPlayer) { await _mainGame.Network !.SendAllAsync("playcard", decks); } CommandContainer !.ManuelFinish = true; await _mainGame.PlayCardAsync(thisCard); }
protected override void OnStartDemo(SampleViewport viewport) { ImageBinder imgBinder = viewport.GetImageBinder2("../../Data/imgs/favorites32.png"); for (int i = 0; i < 100; ++i) { //share 1 img binder with multiple img boxes var imgBox = new CustomWidgets.ImageBox( imgBinder.Image.Width, imgBinder.Image.Height); imgBox.ImageBinder = imgBinder; imgBox.SetLocation(i * 32, 20); imgBox.MouseDown += (s, e) => { //test start animation int nsteps = 40; UIPlatform.RegisterTimerTask(20, timer => { imgBox.SetLocation(imgBox.Left, imgBox.Top + 10); nsteps--; if (nsteps <= 0) { timer.Remove(); } }); }; viewport.AddContent(imgBox); } }
protected override async Task <bool> HasOtherAsync(int pile) { if (GlobalClass.Stock !.ObjectSelected() == 0) { return(await base.HasOtherAsync(pile)); } int wastes = _thisMod !.WastePiles1 !.OneSelected(); if (wastes > -1) { await UIPlatform.ShowMessageAsync("Cannot choose both from the waste and the stock"); return(true); } var thisCard = GlobalClass.Stock.HandList.GetSpecificItem(GlobalClass.Stock.ObjectSelected()); if (_thisMod.WastePiles1.CanAddSingleCard(pile, thisCard) == false) { await UIPlatform.ShowMessageAsync("Illegal move"); return(true); } _thisMod.WastePiles1.AddSingleCard(pile, thisCard); GlobalClass.Stock.HandList.RemoveObjectByDeck(thisCard.Deck); return(true); }
public static async Task MessageGameOverAsync(this MinesweeperMainGameClass game, string message) { await UIPlatform.ShowMessageAsync(message); //rethink about anything else. await game.SendGameOverAsync(); }
private async Task MoveRoomAsync(int room) { if (_gameBoard.CanMoveToRoom(room) == false) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame !.SaveRoot !.GameStatus == EnumClueStatusList.MoveSpaces && _gameContainer.CurrentCharacter !.PreviousRoom > 0) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Sorry, since you rolled, you cannot go into a room"); return; } if (_gameContainer.BasicData !.MultiPlayer) { await _gameContainer.Network !.SendAllAsync("room", room); } _gameContainer.SaveRoot.MovesLeft = 0; _gameBoard.MoveToRoom(room); _gameContainer.SaveRoot.GameStatus = EnumClueStatusList.MakePrediction; //hopefully this is it. }
public async Task EndTurnAsync(bool didPlay, bool validSets) { if (SingleInfo !.PlayerCategory == EnumPlayerCategory.Self) { _model !.TempSets !.EndTurn(); _model.PlayerHand1 !.EndTurn(); if (BasicData.IsXamarinForms) { await Task.Delay(700); //try 30 to start with. } //await UIPlatform.ShowMessageAsync("Ending Turn"); } if (validSets == false) { if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { await UIPlatform.ShowMessageAsync("Failed to rearrange the sets. Therefore, you have to draw 3 tiles if any are left"); } await ResetAsync(); } _model !.MainSets1 !.EndTurn(); if (BasicData !.MultiPlayer) { if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { await Network !.SendAllAsync("finished", didPlay); } else { Check !.IsEnabled = true; return; } } await FinishedAsync(didPlay); }
private async Task HandList_ObjectClickedAsync(CardInfo payLoad, int index) { if (_gameContainer.CanGiveCard(payLoad) == false) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Sorry, the card cannot be given as a clue because its not part of the prediction"); return; } payLoad.IsSelected = true; if (_gameContainer.Test.NoAnimations == false) { await _gameContainer.Delay.DelaySeconds(.25); } var tempPlayer = _gameContainer !.PlayerList !.GetWhoPlayer(); if (_gameContainer.BasicData !.MultiPlayer) { await _gameContainer.Network !.SendToParticularPlayerAsync("cluegiven", payLoad.Deck, tempPlayer.NickName); } CommandContainer !.ManuelFinish = true; payLoad.IsSelected = false; _gameContainer.SaveRoot !.GameStatus = EnumClueStatusList.EndTurn; if (_gameContainer.BasicData.MultiPlayer == false) { throw new BasicBlankException("Computer should have never had this"); } _gameContainer.Check !.IsEnabled = true; //to wait for them to end turn. }
private async Task NewDiscardClickAsync(int deck) { if (_mainGame !.CanProcessDiscard(out bool pickUp, ref deck, out string message) == false) { await UIPlatform.ShowMessageAsync(message); return; } if (pickUp == true) { var thisCol = _model.DiscardList1 !.DiscardListSelected(deck); if (thisCol.Count > 1) { var newCol = _mainGame.AppendDiscardList(thisCol); if (_mainGame.CardContainsRummy(deck, newCol) == false) { await UIPlatform.ShowMessageAsync("Sorry, cannot pick up more than one card because either invalid rummy or no card left for discard"); return; } } if (_gameContainer.BasicData !.MultiPlayer == true) { await _gameContainer.Network !.SendAllAsync("pickupfromdiscard", deck); } await _mainGame.PickupFromDiscardAsync(deck); return; } await _gameContainer.SendDiscardMessageAsync(deck); await _mainGame.DiscardAsync(deck); }
protected override async Task ProcessDiscardClickedAsync() { var thisList = _model.PlayerHand1 !.ListSelectedObjects(); if (thisList.Count != 2) { await UIPlatform.ShowMessageAsync("Must select 2 cards to throw away"); return; } if (_mainGame !.IsValidMove(thisList) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame.BasicData !.MultiPlayer == true) { SendPair thisPair = new SendPair(); thisPair.Card1 = thisList.First().Deck; thisPair.Card2 = thisList.Last().Deck; await _mainGame.Network !.SendAllAsync("processplay", thisPair); } await _mainGame.ProcessPlayAsync(thisList.First().Deck, thisList.Last().Deck); }
/// <summary> /// Initializes a new instance of the UIControl class. /// </summary> /// <param name="uiPlatform"> /// The platform. /// </param> /// <param name="UIControlRole"> /// The control role. /// </param> /// <param name="ControlType"> /// Type of the control. /// </param> public UIControl(UIPlatform uiPlatform, UIControlRole UIControlRole, string ControlType) : this() { this.Platform = uiPlatform; this.ControlRole = UIControlRole; this.ControlType = ControlType; }
private async Task AnalyzeFaceOffAsync() { int tempTurn = WhoWonFaceOff(); if (tempTurn == 0) { await UIPlatform.ShowMessageAsync("There was a tie during the faceoff. Therefore; the faceoff is being done again"); ClearFaceOff(); await _gameContainer.EndTurnAsync !.Invoke(); return; } _gameContainer.WhoTurn = tempTurn; _gameContainer.SingleInfo = _gameContainer.PlayerList !.GetWhoPlayer(); await UIPlatform.ShowMessageAsync($"{_gameContainer.SingleInfo.NickName} has won the face off"); ClearFaceOff(); _gameContainer.SaveRoot !.IsFaceOff = false; if (_delegates.LoadMainGameAsync == null) { throw new BasicBlankException("Nobody is handling the load main screen. Rethink"); } await _delegates.LoadMainGameAsync.Invoke(); await _gameContainer.StartNewTurnAsync !.Invoke(); }
async Task IMovieLoaderLogic.FinishMovieAsync(IMainMovieTable selectedMovie) { selectedMovie.ResumeAt = null; await UpdateMovieAsync(selectedMovie); UIPlatform.ExitApp(); }
public async Task FreeSelectedAsync(int pile) { if (_thisMod !.WastePiles1 !.OneSelected() == -1) { if (_freepile !.OneSelected == pile) { _freepile.SelectUnselectCard(pile); return; } if (_freepile.OneSelected > -1) { await UIPlatform.ShowMessageAsync("Illegal move"); return; } if (_freepile.HasCard(pile) == false) { await UIPlatform.ShowMessageAsync("Illegal move"); return; } _freepile.SelectUnselectCard(pile); return; } if (_freepile !.HasCard(pile)) { await UIPlatform.ShowMessageAsync("Illegal move"); return; } var thisCard = _thisMod.WastePiles1.GetCard(); _freepile.AddCardToPile(pile, thisCard); _thisMod.WastePiles1.RemoveSingleCard(); }
protected override async Task AfterPlayerInitAsync() { try { if (_hasIntro) { var(StartTime, HowLong) = GetSkipData(); SkipSceneClass ThisSkip = new SkipSceneClass() { StartTime = StartTime, HowLong = HowLong }; var ThisList = new CustomBasicList <SkipSceneClass> { ThisSkip }; Player.AddScenesToSkip(ThisList); } var tvLength = Player.Length(); await CalculateDurationAsync(tvLength); } catch (Exception ex) { UIPlatform.ShowError(ex.Message); } }
/// <summary> /// Makes a label. /// </summary> /// <param name="uiPlatform"> /// The platform. /// </param> /// <param name="Column"> /// The column. /// </param> /// <param name="Row"> /// The row. /// </param> /// <param name="Content"> /// The content. /// </param> /// <param name="StringFormat"> /// The string format. /// </param> /// <param name="SilverlightVersion"> /// The silverlight version. /// </param> /// <returns> /// . /// </returns> public string MakeLabel(UIPlatform uiPlatform, int?Column, int?Row, string Content, string StringFormat, string SilverlightVersion) { var ctrl = GetUIControl(ControlType.Label, uiPlatform); var sb = new StringBuilder(1024); AppendFormat(sb, STR_GridColumnFormat, Column); AppendFormat(sb, STR_GridRowFormat, Row); if (uiPlatform == UIPlatform.WPF || SilverlightVersion.StartsWith("3")) { if (StringFormat.IsNotNullOrEmpty()) { AppendFormat(sb, STR_ContentBindingAndStringFormatFormat, Content, StringFormat.Replace(STR_BRACEOPEN, STR_BRACEOPENESCAPED). Replace(STR_BRACECLOSE, STR_BRACECLOSEESCAPED)); } else { AppendFormat(sb, STR_ContentBindingPathFormat, Content); } } else { AppendFormat(sb, STR_ContentBindingPathFormat, Content); } return(ctrl.MakeControlFromDefaults(sb.ToString(), true, Content)); }
private async Task MoveSpaceAsync(int space) { if (_gameContainer.Test.DoubleCheck) { _gameContainer.TempClicked = space; _gameBoard.RepaintBoard(); return; } if (_gameBoard.CanMoveToSpace(space) == false) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame.SaveRoot.MovesLeft == 0) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("No Moves Left. Try Rolling The Dice"); return; } if (_mainGame.BasicData.MultiPlayer) { await _mainGame.Network !.SendAllAsync("space", space); } _gameBoard.MoveToSpace(space); await _mainGame.ContinueMoveAsync(); }
public async Task MakeMoveAsync(int space) { if (space < 127) { if (SingleInfo !.CanSendMessage(BasicData !) == true) { await Network !.SendAllAsync("space", space); } } await GameBoard1 !.MakeMoveAsync(space, this); if (GameBoard1.WillMissNextTurn(this) == true) { SingleInfo !.MissNextTurn = true; if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { await UIPlatform.ShowMessageAsync("Miss next turn for falling in a pit"); } if (PlayerList.Any(Items => Items.MissNextTurn == true) == false) { throw new BasicBlankException("Did fall. Find out what happened"); } } if (space < 127) { await EndTurnAsync(); //decided to end turn automatically now. } }
protected async Task DisplayRootViewForAsync() { try { OurContainer!.RegisterType<TViewModel>(true); OurContainer!.RegisterType<TView>(true); //i think that the shell stuff needs to be singleton. //if i am wrong, rethink. object item = cons!.Resolve<TViewModel>()!; TView view = cons!.Resolve<TView>(); view.DataContext = item; await ShowWindowAsync(view, item); } catch (Exception ex) { if (TestData!.ShowErrorMessageBoxes == false) { CommonBasicStandardLibraries.BasicDataSettingsAndProcesses.VBCompat.Stop(); //so i can see the stacktrace, etc. } if (ex.InnerException != null) { UIPlatform.ShowError(ex.InnerException.Message); return; } //if we need the stack trace, rethink. UIPlatform.ShowError(ex.Message); //at least i get hints. } }
private async Task DiscardPiles_PileClickedAsync(int index, BasicPileInfo <FlinchCardInformation> thisPile) { int playerDeck = _model !.PlayerHand1 !.ObjectSelected(); if (playerDeck > 0) { if (_mainGame !.SaveRoot !.GameStatus == EnumStatusList.FirstOne && _mainGame.SaveRoot.PlayerFound == 0) { await UIPlatform.ShowMessageAsync("Sorry; cannot discard one because you need either a one or else pass on this turn"); _mainGame.UnselectAllCards(); return; } if (_model.DiscardPiles !.CanAddToDiscardFlinch(index) == false) { await UIPlatform.ShowMessageAsync("Sorry, cannot discard here because there is an empty one that has to be used first"); return; } await _mainGame !.AddToDiscardAsync(index, playerDeck); return; } if (_model.DiscardPiles !.HasCard(index) == false) { return; } if (_model.DiscardPiles.PileList ![index].IsSelected == true)
protected override void OnStart(AppHost host) { ImageBinder imgBinder = host.LoadImageAndBind("../Data/imgs/favorites32.png"); for (int i = 0; i < 100; ++i) { //share 1 img binder with multiple img boxes var imgBox = new CustomWidgets.ImageBox( imgBinder.Width, imgBinder.Height); imgBox.ImageBinder = imgBinder; imgBox.SetLocation(i * 32, 20); imgBox.MouseDown += (s, e) => { //test start animation int nsteps = 40; UIPlatform.RegisterTimerTask(20, timer => { imgBox.SetLocation(imgBox.Left, imgBox.Top + 10); nsteps--; if (nsteps <= 0) { timer.Remove(); } }); }; host.AddChild(imgBox); } }
public static void SetUIPlatform(UIPlatform uiPlatform) { currentUIPlatform = uiPlatform; }