public override void Draw(SpriteBatch sb) { if (Visible) { BackgroundSprite.DrawNineCut(sb, AbsoluteBounds, new Rectangle(0, 0, BackgroundSprite.Width, BackgroundSprite.Height), Color); if (DrawTitlebar) { Rectangle titleBar = new Rectangle(AbsoluteLocation.X, AbsoluteLocation.Y, Size.Width, PROP_FORM_CLOSE_BUTTON_DIM + PROP_FORM_CLOSE_BUTTON_PADDING * 2); BackgroundSprite.DrawNineCut(sb, titleBar, null, Color.Multiply(Color, 0.8f)); } Vector2 measureText = Text.Measure(); Text.Draw(sb, new Vector2(AbsoluteLocation.X + Size.Width / 2 - measureText.X / 2, AbsoluteLocation.Y + measureText.Y / 2)); } base.Draw(sb); if (Visible) { foreach (Control child in ChildrenAndSubChildren) { if (child is ToolTip) { child.Draw(sb); } } } }
// Use this for initialization IEnumerator GenerateSprites() { allSprites.Clear(); if (backgroundPrefabObject == null) { backgroundPrefabObject = backgroundPrefab.gameObject; } // Setup variables GameObject clone = null; BackgroundSprite clonedScript = null; int numPrefab = 0, iteration = 0; Vector3 position = transform.position; // Generate background sprites for (; iteration < numIterations; ++iteration) { for (numPrefab = 0; numPrefab < numPrefabsPerIteration; ++numPrefab) { // Randomize z-axis position.z = Random.Range(zRange.x, zRange.y); // Clone the sprite clone = GlobalGameObject.Get <PoolingManager>().GetInstance( backgroundPrefabObject, position, Quaternion.identity); clonedScript = clone.GetComponent <BackgroundSprite>(); clonedScript.MaxDistanceFromShip = maxRange; clonedScript.Alpha = ZToAlpha(position.z); allSprites.Add(clonedScript); } yield return(new WaitForSeconds(gapPerIteration)); } }
public override void Draw(SpriteBatch sb) { if (Visible) { BackgroundSprite.DrawNineCut(sb, AbsoluteBounds, null, Color); ScrubberSprite.DrawNineCut(sb, scrubberPos, null, Color, 5); } base.Draw(sb); }
public GameOverScreen(Game i_Game) : base(i_Game) { m_GameState = Game.Services.GetService <GameState>(); m_Background = new SpaceBG(i_Game); m_Background.TintColor = Color.PaleVioletRed; this.Add(m_Background); m_GameOverMsg = new Sprite(@"Sprites\Messages\GameOverMsg", i_Game); this.Add(m_GameOverMsg); m_GameOverTextSprite = new TextSprite(i_Game, @"Fonts\GameOverScoreFont"); m_GameOverTextSprite.TintColor = Color.White; this.Add(m_GameOverTextSprite); m_InstructionsMsg = new Sprite(@"Sprites\Messages\GameOverOptionsMsg", i_Game); this.Add(m_InstructionsMsg); }
protected virtual CCPoint LocationFromTouch(CCTouch touch) { CCPoint touchLocation = touch.Location; // Get the touch position touchLocation = BackgroundSprite.WorldToParentspace(touchLocation); var size = BackgroundSprite.ContentSize; if (touchLocation.X < 0) { touchLocation.X = 0; } else if (touchLocation.X > size.Width) { touchLocation.X = size.Width; } return(touchLocation); }
protected override Drawable CreateBackground() => background = new BackgroundSprite();
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // load texture and contents messageFont = this.Content.Load <SpriteFont>(MessageFontContentName); scoreFont = this.Content.Load <SpriteFont>(ScoreFontContentName); laserTexture = this.Content.Load <Texture2D>(LaserContentName); spaceshipTexture = this.Content.Load <Texture2D>(SpaceshipContentName); enemy4Texture = this.Content.Load <Texture2D>(Enemy4ContentName); explosionTexture = this.Content.Load <Texture2D>(ExplosionsContentName); backgroundTexture = this.Content.Load <Texture2D>(BackgroundContentName); starTexture = this.Content.Load <Texture2D>(ParallaxStarContentName); //bgmEffect = this.Content.Load<SoundEffect>(BgmContentName); bgmEffect = this.Content.Load <SoundEffect>(this.settings.BgmSoundEffect); explosionSoundEffect = this.Content.Load <SoundEffect>(ExplosionSoundContentName); explosionSound = explosionSoundEffect.CreateInstance(); explosionSound.Volume = 1.0F; laserSoundEffect = this.Content.Load <SoundEffect>(LaserSoundContentName); laserSound = laserSoundEffect.CreateInstance(); laserSound.Volume = 1.0F; // create sprites spaceshipSprite = new SpaceshipSprite(spaceshipTexture); backgroundSprite = new BackgroundSprite(backgroundTexture, graphics); // create sprite generators enemyGenerator = new SpriteGenerator <EnemySprite>( () => new EnemySprite(enemy4Texture, new Vector2(Utils.GetRandomNumber(1, GraphicsDevice.Viewport.Width - enemy4Texture.Width), 1), Utils.GetRandomNumber(5, 10)), enemyPool, TimeSpan.FromMilliseconds(1000.0F / settings.NumOfEnemiesPerSecond)); starGenerator = new SpriteGenerator <ParallaxStarSprite>(() => new ParallaxStarSprite(starTexture, new Vector2( Utils.GetRandomNumber(1, GraphicsDevice.Viewport.Width - starTexture.Width), 1), Utils.GetRandomNumber(5, 20)), starPool, TimeSpan.FromMilliseconds(100)); gameOverScene = new GameOverScene(this, () => !spaceshipSprite.IsActive, () => { this.enemyPool.Clear(); this.laserPool.Clear(); this.explosionPool.Clear(); this.enemyGenerator.IsActive = false; if (explosionSound != null && !explosionSound.IsDisposed) { explosionSound.Stop(true); explosionSound.Dispose(); } if (laserSound != null && !laserSound.IsDisposed) { laserSound.Stop(true); laserSound.Dispose(); } bgmEffect.Dispose(); }) { IsActive = !settings.LiveForever }; var bgm = bgmEffect.CreateInstance(); bgm.IsLooped = true; bgm.Play(); }
public override void LoadSprites() { HeroLaser aLaser = new HeroLaser(myGame.Content.Load<Texture2D>("blueLaser"), new Vector2(0, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); Enemy dEnemy = new Enemy(myGame.Content.Load<Texture2D>("enemy-red"), new Vector2(myGraphics.PreferredBackBufferWidth + myGraphics.PreferredBackBufferWidth / 4 - myHero.myTexture.Width / 2, myGraphics.PreferredBackBufferHeight / 2 + myGraphics.PreferredBackBufferHeight / 4 - myGraphics.PreferredBackBufferHeight / 8), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); EnemyLaser dLaser = new EnemyLaser(myGame.Content.Load<Texture2D>("redLaser"), new Vector2(myGraphics.PreferredBackBufferWidth * -1, myGraphics.PreferredBackBufferHeight * -1), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); // Initial grass platform, others are cloned in the Manager class Platform grassPlatform = new Platform((myGame.Content.Load<Texture2D>("PlantPlatform")), myGame.Content.Load<Texture2D>("PlantPlatformDead"), new Vector2(myGraphics.PreferredBackBufferWidth / 2, myGraphics.PreferredBackBufferHeight - myGraphics.PreferredBackBufferHeight / 8), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); myFont = myGame.Content.Load<SpriteFont>("SpriteFont1"); movingSpritesList.Add(myHero); movingSpritesList.Add(aLaser); movingSpritesList.Add(dEnemy); movingSpritesList.Add(dLaser); platformsList.Add(grassPlatform); myBackgroundScreen = new Screen(myGame.Content.Load<Texture2D>("SpaceBackground"), new Vector2(0 - myGraphics.PreferredBackBufferWidth / 12, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); allSprites.Add(myHero); allSprites.Add(dLaser); allSprites.Add(aLaser); //adding the test background images/Sprites //their positions are tacked on to each other, so they form one long background image BackgroundSprite b1 = new BackgroundSprite(myGame.Content.Load<Texture2D>("PlantB1"), new Vector2(0 - myGraphics.PreferredBackBufferWidth/12, 0), 1.0f); BackgroundSprite b2 = new BackgroundSprite(myGame.Content.Load<Texture2D>("PlantB2"), new Vector2(b1.myPosition.X + b1.myTexture.Width, 0), 1.0f); BackgroundSprite b3 = new BackgroundSprite(myGame.Content.Load<Texture2D>("PlantB3"), new Vector2(b2.myPosition.X + b2.size.Width, myGraphics.PreferredBackBufferHeight - b2.myTexture.Height), 1.0f); BackgroundSprite b4 = new BackgroundSprite(myGame.Content.Load<Texture2D>("PlantB4"), new Vector2(b3.myPosition.X + b3.size.Width, myGraphics.PreferredBackBufferHeight - b3.myTexture.Height), 1.0f); myBackgroundSprites.Add(b1); myBackgroundSprites.Add(b2); myBackgroundSprites.Add(b3); myBackgroundSprites.Add(b4); // Add each BackgroundSprite to the movingSpritesList foreach (BackgroundSprite s in myBackgroundSprites) { movingSpritesList.Add(s); } // 0 - myGraphics.PreferredBackBufferWidth / 12, 0 myInstructionScreen = new Screen(myGame.Content.Load<Texture2D>("InstructionScreen (2)"), new Vector2(myGraphics.PreferredBackBufferWidth * -3, myGraphics.PreferredBackBufferHeight * -3), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); myGameOverScreen = new Screen(myGame.Content.Load<Texture2D>("death-screen"), new Vector2(0, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); myVictoryScreen1 = new Screen(myGame.Content.Load<Texture2D>("Stage1Cleared1st"), new Vector2(myGraphics.PreferredBackBufferWidth * -3, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); myVictoryScreen2 = new Screen(myGame.Content.Load<Texture2D>("Stage1Cleared2nd"), new Vector2(myGraphics.PreferredBackBufferWidth * -3, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); myVictoryScreen3 = new Screen(myGame.Content.Load<Texture2D>("Stage1Cleared3rd"), new Vector2(myGraphics.PreferredBackBufferWidth * -3, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); myVictoryScreen4 = new Screen(myGame.Content.Load<Texture2D>("Stage1Cleared4th"), new Vector2(myGraphics.PreferredBackBufferWidth * -3, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); myVictoryScreens.Add(myVictoryScreen1); myVictoryScreens.Add(myVictoryScreen2); myVictoryScreens.Add(myVictoryScreen3); myVictoryScreens.Add(myVictoryScreen4); myCutScene = new Screen(myGame.Content.Load<Texture2D>("CutScene"), new Vector2(myGraphics.PreferredBackBufferWidth * -3, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight)); SoundEffect levelMusic = myGame.Content.Load<SoundEffect>("CeresMusic"); scrollingManager = new ScrollingManager(myHero, myBackgroundSprites, myGraphics.PreferredBackBufferWidth, myBackgroundScreen); myTimeTravelManager = new TimeTravelManager(myGame.Content.Load<Texture2D>("timet-background"), new Vector2(0, 0), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight), myGame, movingSpritesList, myHero); myLevelManager = new CeresLevelManager(myGame.Content.Load<Texture2D>("blueLaser"), new Vector2(-1000, -1000), new Vector2(myGraphics.PreferredBackBufferWidth, myGraphics.PreferredBackBufferHeight), myGame, this, movingSpritesList, platformsList, myFont, (Asis)myHero, myInstructionScreen, myGameOverScreen, myVictoryScreens, myCutScene, myTimeTravelManager, levelMusic); allSprites.Add(myGameOverScreen); allSprites.Add(myVictoryScreen1); allSprites.Add(myVictoryScreen2); allSprites.Add(myVictoryScreen3); allSprites.Add(myVictoryScreen4); allSprites.Add(myCutScene); allSprites.Add(myTimeTravelManager); allSprites.Add(myLevelManager); }
public override void Update(GameTime gameTime) { if (!_gameHasStarted) { //_allowMusicHandling = false; MediaPlayer.Stop(); if (StateManager.Options.MusicEnabled) { MediaPlayer.Play(_gameSong); } //_allowMusicHandling = true; } base.Update(gameTime); BackgroundSprite bg = BackgroundSprite.Cast <BackgroundSprite>(); //TODO: UPDATE SPRITES KeyboardState keyboard = Keyboard.GetState(); if (_lastState.IsKeyUp(Keys.Escape) && keyboard.IsKeyDown(Keys.Escape)) { StateManager.ScreenState = ScreenType.Pause; //_allowMusicHandling = false; MediaPlayer.Pause(); } for (int i = 0; i < playerShip.FlyingBullets.Count; i++) { Bullet b = playerShip.FlyingBullets[i]; if (b.IsDead || b.X <= 0 || b.X >= bg.TotalWidth || b.Y <= 0 || b.Y >= bg.TotalHeight) { playerShip.FlyingBullets.RemoveAt(i); i--; } } for (int e = 0; e < enemies.Count; e++) { BaseEnemyShip enemy = enemies[e]; if (enemy.IsDead) { enemies.Remove(enemy); } for (int i = 0; i < enemy.FlyingBullets.Count; i++) { Bullet b = enemy.FlyingBullets[i]; if (b.IsDead || b.X <= 0 || b.X >= bg.TotalWidth || b.Y <= 0 || b.Y >= bg.TotalHeight) { enemy.FlyingBullets.RemoveAt(i); i--; } } } if (playerShip.GetType() == typeof(FighterCarrier)) { FighterCarrier ship = playerShip.Cast <FighterCarrier>(); foreach (Drone drone in ship.Drones) { for (int i = 0; i < drone.FlyingBullets.Count; i++) { if (drone.FlyingBullets[i].IsDead || drone.FlyingBullets[i].X <= 0 || drone.FlyingBullets[i].X >= bg.TotalWidth || drone.FlyingBullets[i].Y <= 0 || drone.FlyingBullets[i].Y >= bg.TotalHeight) { drone.FlyingBullets.RemoveAt(i); i--; } } } } foreach (Ship shootShip in StateManager.ActiveShips) { foreach (Ship hitShip in StateManager.ActiveShips) { if (shootShip != hitShip && shootShip.PlayerType != hitShip.PlayerType) { if (hitShip.PlayerType == PlayerType.MyShip && shootShip.PlayerType == PlayerType.Ally) { } else if (shootShip.PlayerType == PlayerType.MyShip && hitShip.PlayerType == PlayerType.Ally) { } else { foreach (Bullet b in shootShip.FlyingBullets) { if (b.Rectangle.Intersects(hitShip.Rectangle)) { hitShip.CurrentHealth -= b.Damage; b.IsDead = true; } } } } } } Vector2 camMove = Vector2.Zero; if (StateManager.InputManager.ShouldMove(MoveDirection.Up)) { float ymoveAmount = -playerShip.MovementSpeed.Y; #if XBOX ymoveAmount *= Math.Abs(GamePadManager.One.Current.ThumbSticks.Left.Y); #endif if (worldCam.Pos.Y + ymoveAmount >= bg.Height / 2) { camMove.Y = ymoveAmount; } else { camMove.Y = bg.Height / 2 - worldCam.Pos.Y; } } else if (StateManager.InputManager.ShouldMove(MoveDirection.Down)) { float ymoveAmount = playerShip.MovementSpeed.Y; #if XBOX ymoveAmount *= Math.Abs(GamePadManager.One.Current.ThumbSticks.Left.Y); #endif if (worldCam.Pos.Y + ymoveAmount <= bg.TotalHeight - (bg.Height / 2)) { camMove.Y = ymoveAmount; } else { camMove.Y = (bg.TotalHeight - (bg.Height / 2)) - worldCam.Pos.Y; } } if (StateManager.InputManager.ShouldMove(MoveDirection.Right)) { float xmoveAmount = playerShip.MovementSpeed.X; #if XBOX xmoveAmount *= Math.Abs(GamePadManager.One.Current.ThumbSticks.Left.X); #endif if (worldCam.Pos.X + xmoveAmount <= bg.TotalWidth - (bg.Width / 2)) { camMove.X = xmoveAmount; } else { camMove.X = (bg.TotalWidth - (bg.Width / 2)) - worldCam.Pos.X; } } else if (StateManager.InputManager.ShouldMove(MoveDirection.Left)) { float xmoveAmount = -playerShip.MovementSpeed.X; #if XBOX xmoveAmount *= Math.Abs(GamePadManager.One.Current.ThumbSticks.Left.X); #endif if (worldCam.Pos.X + xmoveAmount >= bg.Width / 2) { camMove.X = xmoveAmount; } else { camMove.X = bg.Width / 2 - worldCam.Pos.X; } } #if WINDOWS if (_lastState.IsKeyUp(Keys.M) && keyboard.IsKeyDown(Keys.M)) { miniMap.Color = miniMap.Color == Color.White ? Color.Transparent : Color.White; } #endif if (_lastState.IsKeyUp(Keys.F11) && keyboard.IsKeyDown(Keys.F11)) { StateManager.Options.ToggleFullscreen(); } worldCam.Move(camMove); playerShip.WorldCoords = worldCam.Pos; foreach (ISprite s in playerSbObjects) { if (s != miniMap) { if (s.GetType().Implements(typeof(ITimerSprite))) { s.Cast <ITimerSprite>().Update(gameTime); } else { s.Update(); } } } _gameHasStarted = true; miniMap.Update(); _lastState = keyboard; }
public void InitializeScreen <TShip>(ShipTier tier) where TShip : BaseAllyShip { //Reset music _gameHasStarted = false; //_allowMusicHandling = false; playerSbObjects.Clear(); Sprites.Sprites.Clear(); enemies.Clear(); BackgroundSprite bgspr = new BackgroundSprite(bgImg, Sprites.SpriteBatch, 10, 2); bgspr.Drawn += new EventHandler(bgspr_Drawn); worldCam.Pos = new Vector2(bgspr.TotalWidth / 2, bgspr.TotalHeight - (bgspr.Height / 2)); BackgroundSprite = bgspr; Vector2 minSpawnArea = _playableAreaOffset; Vector2 maxSpawnArea = new Vector2(bgspr.TotalWidth, bgspr.TotalHeight) - _playableAreaOffset; for (int i = 0; i < 4; i++) { Texture2D enemyTexture = GameContent.GameAssets.Images.Ships[ShipType.Drone, StateManager.RandomGenerator.NextShipTier(ShipTier.Tier1, ShipTier.Tier2)]; EnemyDrone enemy = new EnemyDrone(GameContent.GameAssets.Images.Ships[ShipType.EnemyBattleCruiser, ShipTier.Tier1], Vector2.Zero, Sprites.SpriteBatch); enemy.WorldCoords = StateManager.RandomGenerator.NextVector2(minSpawnArea, maxSpawnArea); //TODO: Different texture enemy.Color = Color.Green; enemy.Tier = ShipTier.Tier1; Sprites.Add(enemy); enemies.Add(enemy); } miniMap = new Sprite(new PlainTexture2D(Sprites.SpriteBatch.GraphicsDevice, 1, 1, new Color(Color.Navy.R, Color.Navy.G, Color.Navy.B, 128)), Vector2.Zero, playerSb); miniMap.Width = bgspr.TotalWidth / MinimapDivAmount; miniMap.Color = Color.Transparent; miniMap.Height = bgspr.TotalHeight / MinimapDivAmount; miniMap.Y = 7.5f; miniMap.Updated += new EventHandler(miniMap_Updated); miniMap.X = playerSb.GraphicsDevice.Viewport.Width - miniMap.Width - 7.5f; miniShipInfoBg = new Sprite(new PlainTexture2D(Sprites.SpriteBatch.GraphicsDevice, 1, 1, new Color(0, 0, 0, 192)), new Vector2(7.5f, miniMap.Y), playerSb); miniShipInfoBg.Height = 0.01f; miniShipInfoBg.Width = 767.5f - miniShipInfoBg.X - 7.5f - miniMap.Width - 266.6666667f; miniShipInfoBg.X = miniMap.X - miniShipInfoBg.Width - 7.5f; miniShipInfoBg.Color = Color.Transparent; playerSbObjects.Add(miniShipInfoBg); playerSbObjects.Add(miniMap); if (typeof(TShip) == typeof(Drone)) { throw new Exception("Can't create a Drone as the main ship"); } TShip ship = null; if (typeof(TShip) == typeof(FighterCarrier)) { ship = new FighterCarrier(null, Vector2.Zero, playerSb, GameContent.GameAssets.Images.Ships[ShipType.Drone, ShipTier.Tier1]).Cast <TShip>(); } else { ship = Activator.CreateInstance(typeof(TShip), null, Vector2.Zero, playerSb).Cast <TShip>(); } ship.Texture = GameContent.GameAssets.Images.Ships[ship.ShipType, ShipTier.Tier1]; ship.UseCenterAsOrigin = true; ship.WorldSb = Sprites.SpriteBatch; ship.Tier = tier; ship.Position = ship.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport, true); playerShip = ship; playerShip.IsPlayerShip = true; playerShip.RotateTowardsMouse = true; playerSbObjects.Add(ship); playerShip.InitialHealth = 100; //Set as own ship playerShip.PlayerType = PlayerType.MyShip; }
private void Init() { container = CreateChild <UguiObject>("container"); { container.Anchor = AnchorType.TopStretch; container.Pivot = PivotType.Top; container.SetOffsetHorizontal(0f); container.Height = ContainerHeight; container.Y = 0f; backgroundSprite = container.CreateChild <BackgroundSprite>("background"); { backgroundSprite.Anchor = AnchorType.Fill; backgroundSprite.RawSize = Vector2.zero; backgroundSprite.SetOffsetVertical(0f); } comboMenuButton = container.CreateChild <ComboMenuButton>("combo-menu"); { comboMenuButton.Anchor = AnchorType.LeftStretch; comboMenuButton.Pivot = PivotType.Left; comboMenuButton.SetOffsetVertical(0f); comboMenuButton.X = 0f; comboMenuButton.Width = 80f; } profileButton = container.CreateChild <ProfileMenuButton>("profile-menu"); { profileButton.Anchor = AnchorType.LeftStretch; profileButton.Pivot = PivotType.Left; profileButton.SetOffsetVertical(0f); profileButton.X = comboMenuButton.Width; profileButton.Width = 220f; } modeButton = container.CreateChild <ModeMenuButton>("mode-menu"); { modeButton.Anchor = AnchorType.LeftStretch; modeButton.Pivot = PivotType.Left; modeButton.SetOffsetVertical(0f); modeButton.X = profileButton.X + profileButton.Width; modeButton.Width = 80f; } notificationMenuButton = container.CreateChild <NotificationMenuButton>("notification-menu"); { notificationMenuButton.Anchor = AnchorType.RightStretch; notificationMenuButton.Pivot = PivotType.Right; notificationMenuButton.SetOffsetVertical(0f); notificationMenuButton.X = 0f; notificationMenuButton.Width = 80f; } settingsMenuButton = container.CreateChild <SettingsMenuButton>("settings-menu"); { settingsMenuButton.Anchor = AnchorType.RightStretch; settingsMenuButton.Pivot = PivotType.Right; settingsMenuButton.SetOffsetVertical(0f); settingsMenuButton.X = -notificationMenuButton.Width; settingsMenuButton.Width = 80f; } musicButton = container.CreateChild <MusicButton>("music-menu"); { musicButton.Anchor = AnchorType.RightStretch; musicButton.Pivot = PivotType.Right; musicButton.SetOffsetVertical(0f); musicButton.X = settingsMenuButton.X - settingsMenuButton.Width; musicButton.Width = 80f; } } menuButtons = GetComponentsInChildren <BaseMenuButton>(true); OnEnableInited(); }
public virtual void Draw(SpriteBatch spriteBatch) { BackgroundSprite.Draw(spriteBatch, BackgroundLocation); }
public virtual void Update() { BackgroundSprite.Update(); }
public void DrawBackground() { int i, i2, frame; Rectangle srcCornerRect = new Rectangle(0, 0, 16, 16); frame = 0; OuterSpace.spriteobj.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortDepthBackToFront); //draw background if (IsSpriteLoaded[0] == true) { for (i = windowRectangle.Left; i <= (windowRectangle.Right - 16); i += 16) { if (i < (windowRectangle.Right - 16) && i > windowRectangle.Left) { frame = 1; } BackgroundSprite.Draw(i, windowRectangle.Top, BackgroundSprite.sourceFrame[frame], 0, WindowColor); i2 = windowRectangle.Top + 16; while (i2 < (windowRectangle.Bottom - 16)) { BackgroundSprite.Draw(i, i2, BackgroundSprite.sourceFrame[frame + 3], 0, WindowColor); i2 = i2 + 16; } BackgroundSprite.Draw(i, windowRectangle.Bottom - 16, BackgroundSprite.sourceFrame[frame + 6], 0, WindowColor); frame++; } } //draw corners if (IsSpriteLoaded[1]) { CornerSprite[0].Draw(windowRectangle.Left, windowRectangle.Top, new Rectangle(0, 0, 16, 32), 0, Color.FromArgb(255, 255, 255, 255)); } if (IsSpriteLoaded[2]) { CornerSprite[1].Draw(windowRectangle.Right - CornerSprite[1].spritewidth, windowRectangle.Top, new Rectangle(0, 0, 16, 32), 0, Color.FromArgb(255, 255, 255, 255)); } if (IsSpriteLoaded[3]) { CornerSprite[2].Draw(windowRectangle.Right - CornerSprite[1].spritewidth, windowRectangle.Bottom - CornerSprite[2].spriteheight, srcCornerRect, 0, Color.FromArgb(255, 255, 255, 255)); } if (IsSpriteLoaded[4]) { CornerSprite[3].Draw(windowRectangle.Left, windowRectangle.Bottom - CornerSprite[3].spriteheight, srcCornerRect, 0, Color.FromArgb(255, 255, 255, 255)); } //draw borders if (IsSpriteLoaded[5]) { for (i = (windowRectangle.Left + BorderSprite[0].spritewidth); i <= (windowRectangle.Right - (BorderSprite[0].spritewidth * 2)); i += BorderSprite[0].spritewidth) { BorderSprite[0].Draw(i, windowRectangle.Top, new Rectangle(0, 0, 16, 32), 0, Color.FromArgb(255, 255, 255, 255)); } } if (IsSpriteLoaded[6]) { for (i = (windowRectangle.Top + CornerSprite[1].spriteheight); i <= (windowRectangle.Bottom - (CornerSprite[2].spriteheight * 2)); i += BorderSprite[1].spriteheight) { BorderSprite[1].Draw(windowRectangle.Right - BorderSprite[1].spritewidth, i, srcCornerRect, 0, Color.FromArgb(255, 255, 255, 255)); } } if (IsSpriteLoaded[7]) { for (i = (windowRectangle.Right - (CornerSprite[1].spritewidth * 2)); i >= (windowRectangle.Left + CornerSprite[3].spritewidth); i += -BorderSprite[2].spritewidth) { BorderSprite[2].Draw(i, windowRectangle.Bottom - BorderSprite[2].spriteheight, srcCornerRect, 0, Color.FromArgb(255, 255, 255, 255)); } } if (IsSpriteLoaded[8]) { for (i = (windowRectangle.Bottom - (CornerSprite[3].spriteheight * 2)); i >= (windowRectangle.Top + CornerSprite[0].spriteheight); i += -BorderSprite[3].spriteheight) { BorderSprite[3].Draw(windowRectangle.Left, i, srcCornerRect, 0, Color.FromArgb(255, 255, 255, 255)); } } //draw caption if (IsSpriteLoaded[9]) { int width = (CaptionSprite.spritewidth / 3); int newwidth = width; Rectangle captionSrcRect = new Rectangle(width, 0, width, CaptionSprite.spriteheight); i = windowRectangle.Left; CaptionSprite.Draw(windowRectangle.Left, windowRectangle.Top, new Rectangle(0, 0, width, CaptionSprite.spriteheight), 0, WindowColor); i += width; do { CaptionSprite.Draw(i, windowRectangle.Top, captionSrcRect, 0, WindowColor); i += newwidth; if (i + newwidth > windowRectangle.Right - newwidth) { newwidth = (windowRectangle.Right - newwidth) - i; } }while (i < (windowRectangle.Right - newwidth) & newwidth > 0); CaptionSprite.Draw(i, windowRectangle.Top, new Rectangle(width * 2, 0, width, CaptionSprite.spriteheight), 0, WindowColor); } OuterSpace.spriteobj.Flush(); OuterSpace.spriteobj.End(); //draw caption text OuterSpace.textfont.DrawText(windowRectangle.Left + 12, windowRectangle.Top + 8, Color.Black, GetWindowText()); OuterSpace.textfont.DrawText(windowRectangle.Left + 10, windowRectangle.Top + 6, WindowColor, GetWindowText()); }