Esempio n. 1
0
 public void PlayModelTestsSetUp()
 {
     playModel = new PlayModel()
     {
         AttemptId = 12345, ThemeId = 1
     };
 }
Esempio n. 2
0
    public void ToHighScores(PlayModel playModel, GameModeSetting currentSetting)
    {
        playUI.Unsubscribe(playModel);
        playUI.Deactivate();

        highScoreUI.Activate(currentSetting, playModel.Score);
    }
            public RecentPlayViewModel(IRepository repository, PlayModel play)
            {
                _repository = repository;
                _play       = play;

                Delete = ReactiveCommand.Create(() => _repository.DeletePlay(_play));
            }
Esempio n. 4
0
    private void UpdatePlayerToList(Online.League.Leaderboard board)
    {
        var leaguescore = PlayModel.GetScore();

        if (leaguescore < 1)
        {
            return;
        }

        board.current.Sort((x, y) => y.score - x.score);
        if (board.current.Count < 1 || leaguescore < board.current.LastOne().score)
        {
            return;
        }

        var mine = board.current.Find(x => x.username == Profile.Username);

        if (mine == null)
        {
            board.current.RemoveAt(board.current.LastIndex());
            mine = new Online.League.Profile()
            {
                avatar = Profile.Avatar.Json, nickname = Profile.Nickname, status = Profile.Status, username = Profile.Username, score = leaguescore
            };
            board.current.Add(mine);
        }
        else if (mine.score < leaguescore)
        {
            mine.score = leaguescore;
        }
    }
Esempio n. 5
0
    public void ToPlay(PlayModel playModel, int gameDurationInSeconds)
    {
        menuUI.Deactivate();

        playUI.Subscribe(playModel);
        playUI.Activate(gameDurationInSeconds);
    }
Esempio n. 6
0
        private async Task <bool> PlayNext()
        {
            _log.Information("[{0}] Executing next item in playlist", ChannelId);
            PlayModel result = null;

            try
            {
                result = await _playlistService.PlayNext(ChannelId);
            }
            catch (Exception e)
            {
                _log.Information(e, "[{0}] Failed to load next playlist item, trying to restart channel", ChannelId);
                StopInternal();
                return(false);
            }

            _status = result;

            if (result == null)
            {
                _log.Information("[{0}] Channel playlist is empty", ChannelId);
                await StopEmptyChannel();

                return(false);
            }
            else
            {
                _log.Information("[{0}] Playing media id: {1}, duration: {2}", ChannelId, _status.MediaId, _status.Duration);
                await PublishPlayEvent();

                return(true);
            }
        }
Esempio n. 7
0
    public static bool SetPlayModel()
    {
        if (Profile.Hearts < 1)
        {
            Game.Instance.OpenPopup <Popup_BuyHearts>();
            return(false);
        }
        else
        {
            Profile.Hearts--;
        }

        PlayModel.Reset(PlayModel.Type.Classic);
        PlayModel.ballId               = Profile.Avatar.BallId;
        PlayModel.level.name           = string.Format(LocalizationService.Get(111127), Profile.MaxClassicScore);
        PlayModel.level.theme          = Random.Range(0, 1000);
        PlayModel.level.pattern        = GlobalFactory.Patterns.Classic.Get();
        PlayModel.level.startBallCount = 5;
        PlayModel.level.minBlockHealth = 1;
        PlayModel.level.maxBlockHealth = 10;

        PlayModel.onPreLose = OnPreLose;
        PlayModel.onLose    = OnLose;

        return(true);
    }
Esempio n. 8
0
        public void AddToPlay(PlayModel play)
        {
            var item = playList.FirstOrDefault(x => x.songid == play.songid);

            if (item != null)
            {
                mediaPlaybackList.MoveTo(Convert.ToUInt32(playList.IndexOf(item)));
                return;
            }
            if (!play.pic.Contains("300w_300h_1e_1c"))
            {
                play.pic = play.pic + "@300w_300h_1e_1c.jpg";
            }
            playList.Add(play);

            var binder = new MediaBinder();

            binder.Token    = play.songid.ToString();
            binder.Binding += Binder_Binding;
            var source = MediaSource.CreateFromMediaBinder(binder);

            source.CustomProperties["id"] = play.songid;
            mediaPlaybackList.Items.Add(new MediaPlaybackItem(source));
            mediaPlaybackList.MoveTo(Convert.ToUInt32(playList.IndexOf(play)));
            //var item = new MediaPlaybackItem(MediaSource.CreateFromUri(play.play_url));
            //mediaPlaybackList.Items.Add(item);
        }
Esempio n. 9
0
    private static void OnLose(System.Action <bool> exitplaying)
    {
        int score = PlayModel.GetScore();

        if (score > Profile.MaxClassicScore)
        {
            Profile.MaxClassicScore = score;
        }

        if (score > 0)
        {
            exitplaying(false);
            Game.Instance.OpenPopup <Popup_Lose>().Setup(replayFunc => OnReward(() =>
            {
                if (SetPlayModel())
                {
                    replayFunc();
                }
            }),
                                                         () => OnReward(() => Game.Instance.OpenState <State_Main>(true)));
        }
        else
        {
            exitplaying(true);
        }
    }
Esempio n. 10
0
    private static void OnLose(System.Action <bool> callback)
    {
        int score = PlayModel.GetScore();

        if (score > data.score)
        {
            var hashbase = "seganx_" + data.score + "&" + score + "#(" + info.id;
            Online.League.SetScore(info.id, data.score, score, hashbase.ComputeMD5(null).ToLower(), (success, value) => { });
            data.score += score;
        }

        if (score > 0)
        {
            callback(false);
            Game.Instance.OpenPopup <Popup_Lose>().Setup(replayFunc =>
            {
                if (SetPlayerModel())
                {
                    replayFunc();
                }
            },
                                                         () => Game.Instance.OpenState <State_Main>(true));
        }
        else
        {
            callback(true);
        }
    }
Esempio n. 11
0
    public static bool SetPlayerModel()
    {
        if (Profile.Hearts < 1)
        {
            Game.Instance.OpenPopup <Popup_BuyHearts>();
            return(false);
        }
        else
        {
            Profile.Hearts--;
        }

        PlayModel.Reset(info.playType);
        PlayModel.ballId               = Profile.Avatar.BallId;
        PlayModel.level.name           = info.name;
        PlayModel.level.theme          = Random.Range(0, 1000);
        PlayModel.level.pattern        = GlobalFactory.Patterns.Leagues.Get();
        PlayModel.level.startBallCount = Random.Range(info.startBallCount.x, info.startBallCount.y);
        PlayModel.level.minBlockHealth = PlayModel.level.startBallCount / 2;
        PlayModel.level.maxBlockHealth = PlayModel.level.startBallCount * 3 / 2;

        PlayModel.onPreLose = OnPreLose;
        PlayModel.onLose    = OnLose;

        return(true);
    }
Esempio n. 12
0
        public async Task <IActionResult> DeckList()
        {
            User user = await _userManager.GetUserAsync(User);

            var userWithDecks = await _context.Users
                                .Where(u => u.UserName == user.UserName)
                                .Include(u => u.Decks)
                                .FirstOrDefaultAsync();

            var createdDecks = _context.Decks
                               .Where(deck => deck.CreatorId == user.Id)
                               .ToList();

            var allDecks = createdDecks
                           .Concat(userWithDecks.Decks)
                           .ToList();

            var model = new PlayModel
            {
                Username  = (await _userManager.GetUserAsync(User)).UserName,
                UserDecks = allDecks
                            .Select(deck => new PlayDeckModel {
                    Name = deck.Name, Id = deck.Id
                })
                            .ToList()
            };

            return(View(model));
        }
Esempio n. 13
0
        public JsonResult StatusUpdate(PlayModel play)
        {
            play.ModifiedBy = 1;

            PlayModel playmodel = PlayDAC.Upsert(play, true);

            return(Json(playmodel, JsonRequestBehavior.AllowGet));
        }
Esempio n. 14
0
        private void OnPlayEventReceived(object sender, BasicDeliverEventArgs e)
        {
            _log.Information("[{0}] PlayEvent Received", channelId);
            var body    = e.Body;
            var message = Encoding.UTF8.GetString(body.ToArray());

            _status = JsonConvert.DeserializeObject <PlayModel>(message);

            _ = SendPlayEvent();
        }
Esempio n. 15
0
        private async Task LoadStatus()
        {
            using (var conn = DataFactory.OpenConnection())
            {
                _status = await conn.QueryFirstOrDefaultAsync <PlayModel>(@"SELECT ph.ChannelId, ph.MediaId, ph.StartDateUTC, ph.Duration FROM play_history ph
WHERE ph.ChannelId = @channelId
ORDER BY ph.StartDateUTC DESC
LIMIT 1", new { channelId });
            }
        }
Esempio n. 16
0
        public ActionResult PlayLoto(long?Id)
        {
            PlayModel oPlay = PlayDAC.Get(new PlayModel {
                Id = Id
            }, true).FirstOrDefault();

            PlayLoadCombos(oPlay.Game.Id, oPlay.CreatedOn);

            return(View(oPlay));
        }
Esempio n. 17
0
        public PlayPresenter(View view, Model model)
        {
            this.View  = (PlayView)view;
            this.Model = (PlayModel)model;

            this.View.Presenter  = this;
            this.Model.Presenter = this;

            // Init the View
            Initialization();
        }
Esempio n. 18
0
 private static void OnPreLose(System.Action <bool> exitplaying)
 {
     if (PlayModel.GetScore() < Profile.MaxClassicScore)
     {
         Game.Instance.OpenPopup <Popup_Confirm>().Setup(111128, true, true, ok => exitplaying(ok)).GetComponent <UiCharacter>(true, true).SetBody(1).SetFace(2);
     }
     else
     {
         exitplaying(true);
     }
 }
Esempio n. 19
0
        //[ResponseCache(Duration = 30, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new []{"player1","player2"})]
        public async Task <IActionResult> Play(int team1, int team2)
        {
            var model = new PlayModel();

            model.Team1 = await _teamService.GetTeam(team1);

            model.Team2 = await _teamService.GetTeam(team2);

            ViewData.Model = model;
            return(View("Play_m"));
        }
Esempio n. 20
0
    public void LoadUserDataFile()
    {
        Debug.Log("=============LoadUserDataFile " + GameConstants.SAVEFILE_PATH);
        ByteBuffer bb       = new ByteBuffer(File.ReadAllBytes(GameConstants.SAVEFILE_PATH));
        UserModel  userMode = UserModel.GetRootAsUserModel(bb);

        int      score    = userMode.Score;
        int      coin     = userMode.Coin;
        PlayData playData = null;

        if (userMode.PlayData.HasValue)
        {
            //lastparts
            LastBlocks     lastParts      = null;
            PlayModel      playModel      = userMode.PlayData.Value;
            LastPartsModel?lastPartsModel = playModel.LastPartsData;
            if (lastPartsModel.HasValue)
            {
                lastParts = new LastBlocks(lastPartsModel.Value.GetCellPartsArrayArray(), lastPartsModel.Value.AngleValue);
            }

            //cells
            int[,] cells = new int[GameConstants.CELL_ARRAY_SIZE, GameConstants.CELL_ARRAY_SIZE];

            for (int i = 0; i < playModel.CellArrayLength; i++)
            {
                //Debug.Log("CellArrayLength = " + i + " / CellArrayLength : " + playModel.CellArrayLength);
                int x     = playModel.CellArray(i).Value.X;
                int y     = playModel.CellArray(i).Value.Y;
                int value = playModel.CellArray(i).Value.Value;
                cells[x, y] = value;
            }

            ItemUseCountInfo itemUseCountInfo = new ItemUseCountInfo();
            for (int i = 0; i < playModel.ItemUseCountArrayLength; i++)
            {
                itemUseCountInfo.AddCount((ItemType)i, playModel.ItemUseCountArray(i));
            }

            playData = new PlayData(playModel.Score, playModel.Coin, cells, lastParts, itemUseCountInfo, playModel.AdContinueWatchCount);
        }
        UserRewardInfo userRewardInfo = new UserRewardInfo(userMode.DailyRewardDay, userMode.CoinBoxRewardDay, userMode.CointBoxRewardCount, userMode.CointBoxRewardTimeStamp);

        _userData = new UserData(score, coin, playData, userRewardInfo);
        Debug.Log("Score : " + _userData.Score);
        Debug.Log("Coin : " + _userData.Coin);
        Debug.Log("DailyRewardDay : " + _userData.UserRewardInfo.DailyRewardDay);
        Debug.Log("CoinBoxRewardDay : " + _userData.UserRewardInfo.CoinBoxRewardDay);
        Debug.Log("CointBoxRewardCount : " + _userData.UserRewardInfo.CoinBoxRewardCount);
        Debug.Log("CointBoxRewardTimeStamp : " + _userData.UserRewardInfo.CointBoxRewardTimeStamp);
        // if(_userData.PlayData !=null)
        //     _userData.PlayData.Print();
    }
Esempio n. 21
0
 /// <summary>
 /// 清除播放列表
 /// </summary>
 public void ClearPlaylist()
 {
     playList.Clear();
     playInfo = new PlayModel()
     {
         title = "哔哩哔哩 (゜-゜)つロ 干杯~",
         pic   = "ms-appx:///Assets/StoreLogo.scale-100.png"
     };
     mediaPlaybackList.Items.Clear();
     bufferingProgress  = 0;
     this.totalDuration = 0;
     this.position      = 0;
     this.durationStr   = "00:00 / 00:00";
 }
Esempio n. 22
0
    private IEnumerator Start()
    {
        scoreLabel.SetText("0");

        int totalBalls = PlayModel.result.totalBalls + PlayModel.level.startBallCount;

        descLabel.SetFormatedText(PlayModel.result.totalTurn.ToString(), PlayModel.result.totalBlocks.ToString(), totalBalls);

        inviteButton.onClick.AddListener(() =>
        {
            var str = string.Format(GlobalConfig.Socials.invitationText, Profile.Username, GlobalConfig.Market.storeUrl);
            SocialAndSharing.ShareText(str);
        });

        replayButton.onClick.AddListener(() =>
        {
            onReplayFunc(() =>
            {
                base.Back();
                UIBackground.Hide();
                Game.Instance.ClosePopup(true);
                Game.Instance.OpenState <State_Playing>();
            });
        });

        baloon.gameObject.SetActive(false);
        UiShowHide.ShowAll(transform);
        yield return(new WaitForSeconds(0.5f));

        // Incentive  text
        {
            var index        = BaloonIndex++ % 25;
            var incentiveStr = LocalizationService.Get(111090 + index);
            baloon.SetText(incentiveStr);
            baloon.gameObject.SetActive(true);
        }

        float t = 0;
        float curscore = 0, maxscore = PlayModel.GetScore();
        var   wait = new WaitForEndOfFrame();

        while (t < 1)
        {
            t       += Time.deltaTime * 0.75f;
            curscore = Mathf.Lerp(0, maxscore, t);
            scoreLabel.SetText(Mathf.RoundToInt(curscore).ToString());
            yield return(wait);
        }
    }
Esempio n. 23
0
        public void PlayModelPropertiesTest(int attemptId, int curriculumChapterTopicId, TopicTypeEnum topicType, string topicName)
        {
            var playModel = new PlayModel
            {
                AttemptId = attemptId,
                CurriculumChapterTopicId = curriculumChapterTopicId,
                TopicType = topicType,
                TopicName = topicName
            };

            Assert.AreEqual(attemptId, playModel.AttemptId);
            Assert.AreEqual(curriculumChapterTopicId, playModel.CurriculumChapterTopicId);
            Assert.AreEqual(topicType, playModel.TopicType);
            Assert.AreEqual(topicName, playModel.TopicName);
        }
Esempio n. 24
0
    public virtual void Init(TargetPresenter presenter, PlayModel playModel)
    {
        this.presenter = presenter;
        this.playModel = playModel;

        targetMoveBehaviour = GetComponent <TargetMoveBehaviour>();
        if (targetMoveBehaviour == null)
        {
            Debug.LogError("No ITargetMoveBehaviour found for WhackTarget");
        }
        else
        {
            targetMoveBehaviour.MoveToStartPos();
        }
    }
Esempio n. 25
0
        public ActionResult Play(PlayModel play)
        {
            try
            {
                PlayLoadCombos();

                List <PlayModel> oLst = PlayDAC.Get(play, false);

                return(View(oLst));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 26
0
 public void PlayerLose()
 {
     if (PlayModel.onLose != null)
     {
         PlayModel.onLose(ok => { if (ok)
                                  {
                                      base.Back();
                                  }
                          });
     }
     else
     {
         base.Back();
     }
 }
Esempio n. 27
0
    public void StartGame(int gameDurationInSeconds, int slotCount)
    {
        playModel = new PlayModel();

        currentGameModeSetting = new GameModeSetting(gameDurationInSeconds, slotCount);

        targetGenerator.GenerateTargets(slotCount);
        List <RoundDefinition> roundDefinitions = roundsGenerator.GenerateRounds(gameDurationInSeconds, slotCount);

        roundsController.StartRounds(roundsGenerator.TargetTypeCollection, roundDefinitions, playModel);

        roundsController.OnRoundsFinished        += EndGame;
        platformLoader.SelectionManager.IsBlocked = false;

        OnGameStart?.Invoke(playModel, gameDurationInSeconds);
    }
Esempio n. 28
0
        private void MessageCenter_Logined(object sender, object e)
        {
            if (mediaPlaybackList.Items.Count == 0)
            {
                return;
            }
            PlayModel[] list = new PlayModel[playList.Count];
            playList.CopyTo(list, 0);

            var now = playInfo;

            ReplacePlayList(list);
            var id   = now.songid;
            var item = mediaPlaybackList.Items.FirstOrDefault(x => x.Source.CustomProperties["id"].Equals(id));

            mediaPlaybackList.MoveTo(Convert.ToUInt32(mediaPlaybackList.Items.IndexOf(item)));
        }
Esempio n. 29
0
        /// <summary>
        /// 删除播放项
        /// </summary>
        /// <param name="playModel"></param>
        public void DeletePlayitem(PlayModel playModel)
        {
            if (mediaPlaybackList.Items.Count == 1)
            {
                ClearPlaylist();
                return;
            }
            //if (playModel.select)
            //{
            //    mediaPlaybackList.MoveNext();
            //}

            var id       = playModel.songid;
            var playitem = mediaPlaybackList.Items.FirstOrDefault(x => x.Source.CustomProperties["id"].Equals(id));

            playList.Remove(playModel);
            mediaPlaybackList.Items.Remove(playitem);
        }
Esempio n. 30
0
        public Engine(Model model, ShootListener listener)
        {
            // Reference of the model
            this.Model         = (PlayModel)model;
            this.shootListener = listener;

            randInvader = new Random();

            currentMoveCount = 0;
            currentMoveSens  = Direction.Right;

            // Timer for moving invaders
            timerMovingInvaders          = new System.Timers.Timer(700);
            timerMovingInvaders.Elapsed += new ElapsedEventHandler(OnMoveInvaders);
            timerMovingInvaders.Start();

            // creation of a timer for generating missile from invaders
            timerInvadersMissile          = new System.Timers.Timer(INTERVAL_INVADER_MISSILE_SHOOT);
            timerInvadersMissile.Elapsed += new ElapsedEventHandler(OnGenerateMissile);
            timerInvadersMissile.Start();
        }