/// <summary> /// Indicates to the game mode that it is activated. /// </summary> public void Activate() { // If we don't have a game state, kick this over to the // new game state as an error condition. if (Game.State == null) Game.GameMode = new NewGameMode(); // Create the sprite manager sprites = new SpriteViewport(); sprites.IsMouseSensitive = true; sprites.ClipContents = true; Game.SpriteManager.Add(sprites); // Create the board viewport blockViewport = new BlockViewport(Game.State.Board, AssetLoader.Instance); blockViewport.ClipContents = true; blockViewport.IsMouseSensitive = true; blockViewport.MousePosition = 8; blockViewport.FocusPosition = Constants.FocusPosition; sprites.Add(blockViewport); // Create the top-down vertical explorer vertViewport = new VerticalViewport(Game.State.Board); vertViewport.Z = 50; vertViewport.BackgroundColor = Color.FromArgb(32, Color.Black); vertViewport.Padding = 2; vertViewport.BlockWidth = vertViewport.BlockHeight = 16; vertViewport.MaximumHeight = vertViewport.MinimumHeight = 4; vertViewport.Size = vertViewport.Extents.Size; vertViewport.Visible = false; vertViewport.Opacity = 0.75f; sprites.Add(vertViewport); // Speeches and overlays speeches = new SpriteViewport(); speeches.Z = 100; speeches.IsMouseSensitive = true; sprites.Add(speeches); // Connect our events for selectors blockViewport.StackMouseEnter += OnStackMouseEnter; blockViewport.StackMouseExit += OnStackMouseExit; // Create the scroller on the viewport scroller = new MouseEdgeScroller(); scroller.Register(blockViewport); // Create our selector icon selector = AssetLoader.Instance.CreateBlock("Selector"); selector.Height = 0; selector.CastsShadows = false; // Create the scores and other indicators CreateIndicators(); // Connect the events Game.State.Board.MovingChanged += OnMovingChanged; Game.State.Board.BlockMovingChanged += OnBlockMovingChanged; Game.State.Board.BlockMovingChanged += Game.Sound.BlockLanded; }
/// <summary> /// Indicates to the game mode that it is activated. /// </summary> public void Activate() { // If we don't have a game state, kick this over to the // new game state as an error condition. if (Game.State == null) { Game.GameMode = new NewGameMode(); } // Create the sprite manager sprites = new SpriteViewport(); sprites.IsMouseSensitive = true; sprites.ClipContents = true; Game.SpriteManager.Add(sprites); // Create the board viewport blockViewport = new BlockViewport(Game.State.Board, AssetLoader.Instance); blockViewport.ClipContents = true; blockViewport.IsMouseSensitive = true; blockViewport.MousePosition = 8; blockViewport.FocusPosition = Constants.FocusPosition; sprites.Add(blockViewport); // Create the top-down vertical explorer vertViewport = new VerticalViewport(Game.State.Board); vertViewport.Z = 50; vertViewport.BackgroundColor = Color.FromArgb(32, Color.Black); vertViewport.Padding = 2; vertViewport.BlockWidth = vertViewport.BlockHeight = 16; vertViewport.MaximumHeight = vertViewport.MinimumHeight = 4; vertViewport.Size = vertViewport.Extents.Size; vertViewport.Visible = false; vertViewport.Opacity = 0.75f; sprites.Add(vertViewport); // Speeches and overlays speeches = new SpriteViewport(); speeches.Z = 100; speeches.IsMouseSensitive = true; sprites.Add(speeches); // Connect our events for selectors blockViewport.StackMouseEnter += OnStackMouseEnter; blockViewport.StackMouseExit += OnStackMouseExit; // Create the scroller on the viewport scroller = new MouseEdgeScroller(); scroller.Register(blockViewport); // Create our selector icon selector = AssetLoader.Instance.CreateBlock("Selector"); selector.Height = 0; selector.CastsShadows = false; // Create the scores and other indicators CreateIndicators(); // Connect the events Game.State.Board.MovingChanged += OnMovingChanged; Game.State.Board.BlockMovingChanged += OnBlockMovingChanged; Game.State.Board.BlockMovingChanged += Game.Sound.BlockLanded; }