示例#1
0
        public void When_InFirstRollOfFrameKnockDownAllPins_then_SumScoreFromNextFrame()
        {
            var strikeFrame = new StrikeFrame();
            var nextFrame   = new DefaultFrame(3, 4);

            _theGame.Roll(strikeFrame);
            _theGame.Roll(nextFrame);

            int score = _theGame.Score();

            Assert.That(score, Is.EqualTo(24));
        }
示例#2
0
        public void When_InOneFrameKnockDownAllPinsUsingTwoRolls_then_SumScoreFromNextRoll()
        {
            var spareFrame = new SpareFrame(4);
            var nextFrame  = new DefaultFrame(3, 3);

            _theGame.Roll(spareFrame);
            _theGame.Roll(nextFrame);

            int score = _theGame.Score();

            Assert.That(score, Is.EqualTo(19));
        }
示例#3
0
        public Sprite Solidify()
        {
            Sprite sprite = new Sprite();

            sprite.DefaultFrame     = DefaultFrame.Solidify().First();
            sprite.DefaultAnimation = DefaultAnimation;

            sprite.Animations = new Dictionary <string, Animation>();
            foreach (_Animation _animation in Animations)
            {
                sprite.Animations.Add(_animation.Name, _animation.Solidify());
            }

            return(sprite);
        }
示例#4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Frame PageFrame = Window.Current.Content as Frame;

            if (PageFrame == null)
            {
                PageFrame = new Frame();
            }

            var settings = await ApplicationData.Current.RoamingFolder.TryGetItemAsync("Settings.json") == null ? null : await UserDataHelper.GetSettings("Settings.json");

            if (settings == null)
            {
                ApplicationLanguages.PrimaryLanguageOverride = "en";
                DefaultFrame.Navigate(typeof(FirstUse));
                LoadingControl.IsLoading = false;
                return;
            }

            string Language = settings.Language ?? "en";

            ApplicationLanguages.PrimaryLanguageOverride = Language;

            bool IsConnected = NetworkInformation.GetInternetConnectionProfile() != null ? true : false;

            string TimeFormat = settings.DataFormat.TimeFormat == "24h" ? "H:mm" : "h:mmtt";

            if (IsConnected == false && e.Parameter == null)
            {
                if (await ApplicationData.Current.LocalFolder.TryGetItemAsync("HomeWeather.json") == null)
                {
                    NoInternetGrid.Visibility = Visibility.Visible;
                    return;
                }
                _CityData = await UserDataHelper.GetSavedHomeWeather();

                _CityData.IsLocalData = true;
                var _File = await ApplicationData.Current.LocalFolder.GetFileAsync("HomeWeather.json");

                _CityData.LastUpdate = System.IO.File.GetLastWriteTime(_File.Path).ToString(TimeFormat);
                PageFrame.Navigate(typeof(WeatherPage), _CityData);
                return;
            }

            if (e.Parameter != null)
            {
                if (IsConnected == true)
                {
                    _PlaceInfo = e.Parameter as PlaceInfo;
                    _CityData  = (await WeatherData.GetWeather(_PlaceInfo, settings.DataFormat, Language));

                    if (_CityData.Current.cod == 200)
                    {
                        _CityData.LastUpdate = DateTime.Now.ToLocalTime().ToString(TimeFormat);
                        PageFrame.Navigate(typeof(WeatherPage), _CityData);
                        return;
                    }
                }
                NoInternetGrid.Visibility = Visibility.Visible;
            }
            else
            {
                if (settings.CheckLocation == 1)
                {
                    var coords = await Geolocation.GetLocationInfo();

                    if (coords.Latitude == 0 && coords.Longitude == 0)
                    {
                        LoadingControl.IsLoading = false;
                        NotFoundGrid.Visibility  = Visibility.Visible;
                        NotFoundText.Text        = "Sorry! Can't locate you!";
                        NotFoudHint.Text         = "You can try searching instead";
                        return;
                    }
                    else
                    {
                        var plid = await PlacesSearch.GetCityNameByCoordinate(coords.Latitude, coords.Longitude);

                        if (plid != null)
                        {
                            _PlaceInfo = new PlaceInfo()
                            {
                                Latitude = plid.Latitude, Longitude = plid.Longitude, DisplayName = plid.DisplayName, PlaceId = plid.PlaceId
                            };
                        }
                        else
                        {
                            LoadingControl.IsLoading = false;
                            NotFoundGrid.Visibility  = Visibility.Visible;
                            NotFoundText.Text        = "Sorry! Can't locate you!";
                            NotFoudHint.Text         = "You can try searching instead";
                            return;
                        }
                    }
                }
                else
                {
                    _PlaceInfo = new PlaceInfo {
                        Latitude = settings.DefaultLocation.Latitude, Longitude = settings.DefaultLocation.Longitude, DisplayName = settings.DefaultLocation.DisplayName, PlaceId = settings.DefaultLocation.PlaceId
                    };
                }

                _CityData            = (await WeatherData.GetWeather(_PlaceInfo, settings.DataFormat, Language));
                _CityData.LastUpdate = DateTime.Now.ToLocalTime().ToString(TimeFormat);
                bool _SaveData = await UserDataHelper.SaveHomeWeather(_CityData);

                PageFrame.Navigate(typeof(WeatherPage), _CityData);
            }
            LoadingControl.IsLoading = false;

            /*try
             * {
             * }
             * catch (Exception)
             * {
             *  await new MessageDialog("Unexpected exception occurred: 7221252017").ShowAsync();
             * }*/
        }