/// <summary> /// Реализация броска монеты /// </summary> /// <param name="_headsOrTailsModel">Модель</param> /// <param name="_statistic">Ссылка на статистику</param> public TossCoin(IHeadsOrTailsModel _headsOrTailsModel, Statistic _statistic) { headsOrTailsModel = _headsOrTailsModel; statistic = _statistic; ThrownCointAnimation = new AnimationSprite(); ThrownCointAnimation.AnimationStoped += (sender, sprite) => { SideOfCoin = sprite.HeadsOrTails; statistic.AllCoinThrowCount++; if (sprite.HeadsOrTails == HeadsOrTailsEnum.Heads) statistic.HeadsCount++; else { statistic.TailsCount++; } }; #region Команда броска монеты var Command = new ViewModelCommand(ThrownCointAnimation, "IsStopped"); // Бросить монету Command.Action = (o) => ThrowCoinMethod(); //Выполнятся может когда анимация остановлена Command.Predicate = o => ThrownCointAnimation.IsStopped; ThrowCoinCommand = Command; #endregion }
/// <summary> /// Реализация угадования броска монеты /// </summary> /// <param name="_headsOrTailsModel">Модель</param> /// <param name="_statistic">Ссылка на статистику</param> public GuessToss(IHeadsOrTailsModel _headsOrTailsModel, Statistic _statistic) { headsOrTailsModel = _headsOrTailsModel; statistic = _statistic; GuessCointAnimation = new AnimationSprite(); GuessCointAnimation.AnimationStoped += (sender, sprite) => { throw new Exception(); }; #region Команда броска угадывания монет var Command = new ViewModelCommand(this, "GuessSideOfCoin"); Command.Action = o => TryToGuess(); Command.Predicate = o => GuessSideOfCoin != null; // Если монета выбрана TryToGuessCommand = Command; #endregion }