コード例 #1
0
ファイル: Ads.cs プロジェクト: TOgburn/MonoGame-Snake
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);
            if (this.State == AdState.Loading || this.State == AdState.Playing || this.State == AdState.NoAdsFound)
            {
                var rect = new Rectangle(0, 0, Engine.Game.CanvasWidth, Engine.Game.CanvasHeight);
                RectangleDrawer.Draw(sprite_batch, rect, new Color(0X04, 0X04, 0X04), layerDepth: 0.001f);

                var font            = ContentHolder.Get(AvailableFonts.retro_computer);
                var font_color      = new Color(0XCC, 0XCC, 0XCC);
                var splash_texture  = ContentHolder.Get(AvailableTextures.splash_ad_buffer);
                var splash_position = new Vector2(Engine.Game.CanvasWidth / 2 - splash_texture.Width / 2, 57);
                sprite_batch.Draw(splash_texture, splash_position, Color.White);
                sprite_batch.DrawString(font, "Snake Will Be Right Back", splash_position + new Vector2(splash_texture.Width / 2f, 188), font_color, scale: 0.4375f, draw_from: DrawFrom.TopCenter);

                string text;
                if (this.State == AdState.Loading)
                {
                    text = "Fetching Ad Data...";
                }
                else if (this.State == AdState.Playing)
                {
                    text = "Loading Ad";
                }
                else
                {
                    text = "No Ads Found";
                }
                sprite_batch.DrawString(font, text, new Vector2(Engine.Game.CanvasWidth / 2f, Engine.Game.CanvasHeight - 80), font_color, scale: 0.5f, draw_from: DrawFrom.TopCenter);
            }
        }
コード例 #2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            ContentHolder.Init(this, CustomContentLocations.TextureLocations);
            Levels.Init();
#if !ANDROID && !IOS
            Engine.SpawnInstance <ControlFullscreen>();
#endif
            Engine.SpawnInstance <ControlBack>();
            Engine.SpawnInstance <Background>();
#if DEBUG
            Engine.SpawnInstance(new DebuggerWithTerminal(ContentHolder.Get(AvailableFonts.retro_computer)));
#endif

#if ADS
#if ANDROID
#if AMAZON
            Engine.SpawnInstance <AndroidAds>();
#endif
#endif
#endif

#if XBOX_LIVE
            XboxLiveObject.SignOutCompleted += XboxLiveStatsManager.OnSignOutCompleted;
            XboxLiveObject.SignInCompleted  += XboxLiveStatsManager.OnSignInCompleted;
            ExitEvent += XboxLiveStatsManager.OnExitGame;
            XboxLiveObject.SignIn();
#endif

            Engine.ChangeRoom <RoomInit>();
        }
コード例 #3
0
ファイル: Activity1.cs プロジェクト: TOgburn/MonoGame-Snake
 protected override void OnDestroy()
 {
     ContentHolder.Deinit();
     SaveDataHandler.ResetCache();
     MainActivity.Game = null;
     base.OnDestroy();
 }
コード例 #4
0
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            if (XboxLiveObject.CurrentUser != null && XboxLiveObject.CurrentUser.IsSignedIn)
            {
                string gamertag_string = this._gamertagRegex.Replace(XboxLiveObject.CurrentUser.Gamertag, "");
                sprite_batch.DrawString(ContentHolder.Get(AvailableFonts.retro_computer), gamertag_string, this.Position, Color.Black, scale: XboxLiveIndicator.FontScale);
            }
            else
            {
                const string sign_in_string = "Sign In [X]";
                sprite_batch.DrawString(ContentHolder.Get(AvailableFonts.retro_computer), sign_in_string, this.Position, Color.Black, scale: XboxLiveIndicator.FontScale);
            }
        }
コード例 #5
0
        public static void Init(Game game, Dictionary <AvailableTextures, string> custom_texture_locations = null, Dictionary <AvailableFonts, string> custom_font_locations = null, Dictionary <AvailableMusic, string> custom_music_locations = null, Dictionary <AvailableSounds, string> custom_sound_locations = null)
        {
            ContentHolder.Deinit();

            foreach (AvailableTextures available_texture in Enum.GetValues(typeof(AvailableTextures)))
            {
                string texture_location = "textures/" + available_texture;
                if (custom_texture_locations != null && custom_texture_locations.ContainsKey(available_texture))
                {
                    texture_location = custom_texture_locations[available_texture];
                }

                ContentHolder.Textures.Add(available_texture, game.Content.Load <Texture2D>(texture_location));
            }

            foreach (AvailableFonts available_font in Enum.GetValues(typeof(AvailableFonts)))
            {
                string font_location = "fonts/" + available_font;
                if (custom_font_locations != null && custom_font_locations.ContainsKey(available_font))
                {
                    font_location = custom_font_locations[available_font];
                }

                ContentHolder.Fonts.Add(available_font, game.Content.Load <SpriteFont>(font_location));
            }

            foreach (AvailableMusic available_song in Enum.GetValues(typeof(AvailableMusic)))
            {
                string song_location = "music/" + available_song;
                if (custom_music_locations != null && custom_music_locations.ContainsKey(available_song))
                {
                    song_location = custom_music_locations[available_song];
                }

                Utilities.Try(() => ContentHolder.Songs.Add(available_song, game.Content.Load <Song>(song_location)));
            }

            foreach (AvailableSounds available_sound in Enum.GetValues(typeof(AvailableSounds)))
            {
                string sound_location = "sounds/" + available_sound;
                if (custom_sound_locations != null && custom_sound_locations.ContainsKey(available_sound))
                {
                    sound_location = custom_sound_locations[available_sound];
                }

                Utilities.Try(() => ContentHolder.Sounds.Add(available_sound, game.Content.Load <SoundEffect>(sound_location)));
            }
        }
コード例 #6
0
ファイル: Upgrade.cs プロジェクト: TOgburn/MonoGame-Snake
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);
            if (!(Engine.Room is RoomMain))
            {
                return;
            }

            if (!Upgrade.IsUpgraded && !this.FetchingIsUpgraded)
            {
                if (Settings.CurrentTheme == 6 || Settings.CurrentTheme == 7)
                {
                    Color wall_color;
                    if (Settings.CurrentTheme == 6)
                    {
                        wall_color = new Color(0xdf, 0x5a, 0x1f);
                    }
                    else
                    {
                        wall_color = new Color(0x84, 0xb0, 0x4e);
                    }
                    RectangleDrawer.Draw(sprite_batch, this.Position.X - Wall.Size / 2f, this.Position.Y - Wall.Size / 2f, Wall.Size, Wall.Size, wall_color);
                }

                var background_color = Color.White;
                if (Settings.CurrentTheme < this.BackgroundColors.Length)
                {
                    background_color = this.BackgroundColors[Settings.CurrentTheme];
                }
                RectangleDrawer.Draw(sprite_batch, this.Position.X - Wall.Size / 2f + 4, this.Position.Y - Wall.Size / 2f + 4, Wall.Size - 8, Wall.Size - 8, background_color);

                var text_color = Color.Black;
                if (Settings.CurrentTheme < this.FoodColors.Length)
                {
                    text_color = this.FoodColors[Settings.CurrentTheme];
                }
                for (int i = 0; i < 3; i++)
                {
                    RectangleDrawer.Draw(sprite_batch, this.Position.X - 8, this.Position.Y - 1.5f - 5 + 5 * i, 16, 3, text_color);
                }
                sprite_batch.DrawString(ContentHolder.Get(AvailableFonts.retro_computer), "Upgrade", this.Position + new Vector2(Wall.Size / 2 + 3, 0), text_color, scale: 0.3125f, draw_from: DrawFrom.LeftCenter);
            }
        }
コード例 #7
0
ファイル: SFXPlayer.cs プロジェクト: TOgburn/MonoGame-Snake
 public static void Play(AvailableSounds sound, float volume = 1.0f, float pitch = 0f, float pan = 0f)
 {
     Utilities.Try(() => ContentHolder.Get(sound).Play(volume, pitch, pan));
 }