コード例 #1
0
        public static async Task AnimateSpinAsync(SpinnerPositionData thisSpin, LifeBoardGameGameContainer gameContainer)
        {
            _gameContainer  = gameContainer;
            CanBetween      = thisSpin.CanBetween;
            ChangePositions = thisSpin.ChangePositions;
            MaxHighSpeed    = thisSpin.HighSpeedUpTo;
            Phase           = 0;
            PhaseHI         = 0;
            if (_gameContainer.Test.NoAnimations)
            {
                MaxHighSpeed    = -1;
                ChangePositions = 30;
            }
            do
            {
                if (PhaseHI < MaxHighSpeed)
                {
                    PhaseHI += 1;
                    _gameContainer.HighSpeedPhase = PhaseHI;
                    if (_gameContainer.Test !.NoAnimations == false)
                    {
                        _gameContainer.SpinnerRepaint();
                        await Task.Delay(10);
                    }
                }
                else
                {
                    _gameContainer.HighSpeedPhase = 0;
                    Phase   += 1;
                    Position = AddPosition(CalculateSkips());
                    _gameContainer.SpinnerPosition = Position;
                    if (_gameContainer.Test.NoAnimations == false)
                    {
                        _gameContainer.SpinnerRepaint();
                        await Task.Delay(10);
                    }
                }
                if (Phase >= ChangePositions)
                {
                    if (CanBetween == true)
                    {
                        return;
                    }
                    if (_gameContainer.GetNumberSpun(Position) > 0)
                    {
                        return;
                    }
                }
                if (_gameContainer.Test.NoAnimations)
                {
                    await Task.Delay(2);

                    //_gameContainer.SpinnerRepaint();
                    //return;
                }
                //if (_gameContainer.Test.NoAnimations == false)
                //    await Task.Delay(2);
            }while (true);// will let the other classes know its finished if necessary
        }
コード例 #2
0
        public async Task StartSpinningAsync(SpinnerPositionData position)
        {
            if (_gameContainer.CardVisible !.Invoke())
            {
                await _gameContainer.HideCardAsync !.Invoke();
            }

            if (_gameContainer.SaveRoot !.GameStatus == EnumWhatStatus.NeedChooseHouse || _gameContainer.SaveRoot.GameStatus == EnumWhatStatus.NeedSellBuyHouse)
            {
                //if the hand has to be hidden, rethink.
                _gameContainer.SaveRoot.GameStatus = EnumWhatStatus.NeedToSpin;
                //ThisMod!.HandList!.Visible = false;
            }
            await SpinnerAnimationClass.AnimateSpinAsync(position, _gameContainer);

            var thisNumber = _gameContainer !.GetNumberSpun(_gameContainer.SpinnerPosition);

            _gameContainer.SaveRoot.SpinPosition   = _gameContainer.SpinnerPosition;
            _gameContainer.SaveRoot.ChangePosition = 0;
            _gameContainer.SaveRoot.NumberRolled   = thisNumber;
            await ResumeSpinnerCompletedAsync(); //forgor this part.
        }
        //protected override async Task ShowHumanCanPlayAsync()
        //{
        //    await base.ShowHumanCanPlayAsync();
        //    if (BasicData.IsXamarinForms && (SaveRoot.GameStatus == EnumWhatStatus.NeedTradeSalary || SaveRoot.GameStatus == EnumWhatStatus.NeedStealTile))
        //    {
        //        await UIPlatform.ShowMessageAsync("Trying to show human can continue");
        //        if (_gameContainer.SubmitPlayerCommand == null)
        //        {
        //            //UIPlatform.ShowError("Nobody set up the submit player command.  Rethink");
        //            return;
        //        }
        //        _gameContainer.SubmitPlayerCommand.ReportCanExecuteChange(); //try this way.
        //        //await Task.Delay(200); //try delay to fix second bug.
        //        //await UIPlatform.ShowMessageAsync("Choose Player Or End Turn");
        //        //_gameContainer.Command.ManualReport();
        //    }
        //}
        async Task IMiscDataNM.MiscDataReceived(string status, string content)
        {
            switch (status) //can't do switch because we don't know what the cases are ahead of time.
            {
            //put in cases here.
            case "spin":
                SpinnerPositionData spin = await js.DeserializeObjectAsync <SpinnerPositionData>(content);

                await _spinnerProcesses.StartSpinningAsync(spin);

                return;

            case "gender":
                EnumGender gender = await js.DeserializeObjectAsync <EnumGender>(content);

                if (_gameContainer.SelectGenderAsync == null)
                {
                    throw new BasicBlankException("Nobody is handling the selecting gender.  Rethink");
                }
                await _gameContainer.SelectGenderAsync.Invoke(gender);

                return;

            case "firstoption":
                EnumStart firsts = await js.DeserializeObjectAsync <EnumStart>(content);

                await _boardProcesses.OpeningOptionAsync(firsts);

                return;

            case "chosecareer":
                await _careerProcesses.ChoseCareerAsync(int.Parse(content));

                return;

            case "purchasecarinsurance":
                await _boardProcesses.PurchaseCarInsuranceAsync();

                return;

            case "purchasedstock":
                await _boardProcesses.PurchaseStockAsync();

                return;

            case "tradedlifeforsalary":
                await _boardProcesses.Trade4TilesAsync();     //i think

                return;

            case "tradedsalary":
                await _tradeSalaryProcesses.TradedSalaryAsync(content);

                return;

            case "stole":
                await _stolenTileProcesses.TilesStolenAsync(content);

                return;

            case "purchasedhouseinsurance":
                await _boardProcesses.PurchaseHouseInsuranceAsync();

                return;

            case "attendednightschool":
                await _boardProcesses.AttendNightSchoolAsync();

                return;

            case "choseretirement":
                EnumFinal finals = await js.DeserializeObjectAsync <EnumFinal>(content);

                await _boardProcesses.RetirementAsync(finals);

                return;

            case "chosestock":
                await _chooseStockProcesses.ChoseStockAsync(int.Parse(content));

                return;

            case "chosesalary":
                await _basicSalaryProcesses.ChoseSalaryAsync(int.Parse(content));

                return;

            case "stockreturned":
                await _returnStockProcesses.StockReturnedAsync(int.Parse(content));

                return;

            case "chosehouse":
                await _houseProcesses.ChoseHouseAsync(int.Parse(content));

                return;

            case "willsellhouse":
                await _boardProcesses.SellHouseAsync();

                return;

            case "twins":
                CustomBasicList <EnumGender> gList = await js.DeserializeObjectAsync <CustomBasicList <EnumGender> >(content);

                await _twinProcesses.GetTwinsAsync(gList);

                return;

            case "houselist":
                CustomBasicList <int> tempList = await js.DeserializeObjectAsync <CustomBasicList <int> >(content);

                SaveRoot !.HouseList.Clear();
                tempList.ForEach(thisIndex => SaveRoot.HouseList.Add(CardsModule.GetHouseCard(thisIndex)));
                await ContinueTurnAsync();

                return;

            default:
                throw new BasicBlankException($"Nothing for status {status}  with the message of {content}");
            }
        }