protected override void OnLoad() { base.OnLoad(); GL.ClearColor(0.0f, 0.2f, 0.45f, 1.0f); // Create UI refreshButton = new Button(new Bounds(-0.512f, -0.8f, -0.988f, -0.975f), " Refresh", RefreshData, this); exitButton = new Button(new Bounds(-0.012f, -0.8f, -0.488f, -0.975f), " Exit", Close, this); refreshSprite = new Sprite(new Bounds(-0.512f, -0.8f, -0.650f, -0.975f), Shader.GenBasicShader(), Texture.LoadFromBitmap(new Bitmap("Files/refresh.png"))); exitSprite = new Sprite(new Bounds(-0.012f, -0.8f, -0.150f, -0.975f), Shader.GenBasicShader(), Texture.LoadFromBitmap(new Bitmap("Files/x.png"))); tomorrowIoData = new WeatherDataLabel(new Bounds(0.988f, 0.975f, 0.006f, -0.775f), this); openWeatherMapData = new WeatherDataLabel(new Bounds(-0.012f, 0.975f, -0.988f, -0.775f), this); // Load UI refreshSprite.Load(); exitSprite.Load(); refreshButton.Load(); exitButton.Load(); tomorrowIoData.Load(); openWeatherMapData.Load(); // Set animations to bg. All animations except for the first one are rare if (new Random().Next() % 5 == 0) { bg = new AnimatedBackground(animatedBgSources[new Random().Next() % 6 + 1]); } else { bg = new AnimatedBackground(animatedBgSources[0]); } bg.Load(); // Force data refresh on start RefreshData(); }
/// <summary> /// Loads the content. /// </summary> public override void OnLoadContent() { _animatedBackground = new AnimatedBackground(Content.Load <Texture2D>("background.png")); _instructions = new Instructions(Content.Load <Texture2D>("instructions.png")) { Visible = true }; _player = new Player(Content.Load <Texture2D>("bird_sprite.png"), Content.Load <Texture2D>("bird_erased.png")); _receivedCoin = new SoundEffect(Content.Load <Sound>("score.wav")) { Volume = 0.2f }; _die = new SoundEffect(Content.Load <Sound>("dead.wav")) { Volume = 0.2f }; _scoreboard = new Scoreboard(); _pipeManager = new PipeManager(Content.Load <Texture2D>("pipe_body.png"), Content.Load <Texture2D>("pipe_bottom.png"), Content.Load <Texture2D>("pipe_top.png")); _swing = new SoundEffect(Content.Load <Sound>("swing.wav")) { Volume = 0.2f }; _pipeManager.ScoreChanged += _pipeManager_ScoreChanged; _font = new Font("Segoe UI", 9, TypefaceStyle.Regular); _deviceHintPosition = new Vector2(0, 0); int x = Convert.ToInt32(_resolution.Split('x')[0]); int y = Convert.ToInt32(_resolution.Split('x')[1]); SGL.Components.Get <RenderTarget>().Window.Size = new Vector2(x, y); SGL.Components.Get <GraphicsDevice>().BackBuffer.Scaling = true; }
private void CreateAreaBackgrounds() { _areas = new Dictionary <string, AnimatedBackground>(); foreach (XElement a in Data.Profile.SimpleAreaData) { if (!Unranked_Areas.Contains(a.Attribute("name").Value.ToLower())) { string area = a.Attribute("name").Value; AreaDataContainer areaData = Profile.GetDataForNamedArea(area); _areas.Add(area, AnimatedBackground.Create(areaData.SelectionTexture, new int[] { 0, 1, 2 })); } } }
private void FinalizeLevelSetup(XElement levelData) { string backgroundName = levelData.Element(Background_Data_Element).Attribute("texture").Value; int bgSeed = Profile.PlayingRaceMode ? RaceAreaName.Length : Profile.CurrentAreaData.LastSelectedLevel; AnimatedBackground inGameBackground = new AnimatedBackground(backgroundName, Map.MapWorldDimensions, bgSeed); inGameBackground.CreateComponents(); _registerGameObject(inGameBackground); Map.ViewportDimensionsInTiles = new Point( (BackgroundDimensions.X / Definitions.Grid_Cell_Pixel_Size) + 1, (BackgroundDimensions.Y / Definitions.Grid_Cell_Pixel_Size) + 3); Map.WireUpBombBlockBlastColliders(_registerGameObject); _registerGameObject(Map); Player.Map = Map; }
public void CreateBackgroundForScene(string reference, int[] componentSequence) { _animBackground = AnimatedBackground.Create(reference, componentSequence); RegisterGameObject(_animBackground); }