protected override void OnLoad(Microsoft.Xna.Framework.Content.ContentManager content, Microsoft.Xna.Framework.Graphics.GraphicsDevice gd) { LifeBar = new DrawableRectangle(new Vector2(MAX_WIDTH, NORMAL_HEIGHT), new Vector2(-MAX_WIDTH / 2f, -NORMAL_HEIGHT / 2f), IsAlly ? Color.Green: Color.DarkRed); AddChild(new DrawableRectangle(new Vector2(MAX_WIDTH + CONTOUR_WIDTH * 2f, NORMAL_HEIGHT + CONTOUR_WIDTH * 2f), new Vector2(-(MAX_WIDTH + CONTOUR_WIDTH * 2f) / 2f, -(NORMAL_HEIGHT + CONTOUR_WIDTH * 2f) / 2f), Color.White)); AddChild(LifeBar); }
private void LoadShapesToCanvas(CanvasControl canvas, IEnumerable <LoadedShape> shapes) { canvas.PreLoad(); foreach (LoadedShape shape in shapes) { Pen pen = CreatePen(shape); string shapeTypeUpper = shape.ShapeType.ToUpperInvariant(); switch (shapeTypeUpper) { case "LINE": DrawableLine line = CreateDrawableLine(shape, pen); canvas.AddLine(line); break; case "RECTANGLE": DrawableRectangle rectangle = CreateDrawableRectangle(shape, pen); canvas.AddRectangle(rectangle); break; case "ELLIPSE": DrawableEllipse ellipse = CreateDrawableEllipse(shape, pen); canvas.AddEllipse(ellipse); break; } } canvas.ResetView(); }
protected override void LoadContent() { base.LoadContent(); FadeOutRect = new DrawableRectangle(GraphicsDevice, new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.Black, true); }
public Intent(InputManager im, Camera c, Player p, Rectangle r) { inputManager = im; camera = c; player = p; DrawableRectangle = new DrawableRectangle(r); DrawableRectangle.Color = Color.DarkBlue; }
protected override void SetTexture() { var tex = new DrawableRectangle(Game1.graphics.GraphicsDevice, new Vector2(1280, 10), Color.White, true).Texture; sprite = new Image(tex); width = tex.Width; height = tex.Height; }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); overlay = new DrawableRectangle(rectangle_texture, new Rectangle(0, 0, 800, 480), Color.Black * 0.5f); win_font = content.Load<SpriteFont>("Arial-36px-Bold"); sub_font = content.Load<SpriteFont>("Arial-16px-Regular"); }
public Highscores(Game1 gameReference) : base(gameReference) { AddUiComponent(new Sprite(commonTextures["MainMenu"])); AddUiComponent(new Rain()); var backButton = new RectangleButton(inputManager, new Rectangle(0, 0, (int)(game.LogicalSize.X * 0.5f), (int)game.LogicalSize.Y / 10), fonts["Standard"], "BACK") { Color = Color.Gray * 0.3f, Filled = true, }; backButton.OnClick += (o, e) => game.ChangeState(new MainMenu(game)); menu = new VerticalNavigationMenu(inputManager, new List <IButton> { backButton, }); menu.Position = new Vector2(game.LogicalSize.X / 2 - menu.Size.X / 2, game.LogicalSize.Y * (0.925f) - menu.Size.Y / 2); currentLevelName = new Text(fonts["Standard"], LevelsInfo.LevelInfo[currentLevelSelected].Name); int margin = 30; currentLevelName.Position = new Vector2(menu.Rectangle.Center.X - currentLevelName.Size.X / 2, menu.Rectangle.Top - currentLevelName.Size.Y - margin); currentLevelName.AddSpecialEffect(new RainbowEffect()); rightLevelButton = new RectangleButton(inputManager, new Rectangle(0, 0, 80, 80), fonts["Standard"], ">"); rightLevelButton.OnClick += IncreaseSelectedLevel; rightLevelButton.Position = new Vector2(menu.Rectangle.Right - rightLevelButton.Size.X, currentLevelName.Rectangle.Center.Y - rightLevelButton.Size.Y / 2); leftLevelButton = new RectangleButton(inputManager, new Rectangle(0, 0, 80, 80), fonts["Standard"], "<"); leftLevelButton.OnClick += DecreaseSelectedLevel; leftLevelButton.Position = new Vector2(menu.Rectangle.Left, currentLevelName.Rectangle.Center.Y - rightLevelButton.Size.Y / 2); var backgroundMenu = new DrawableRectangle(new Rectangle(0, 0, (int)((menu.Size.X) * 1.1f), (int)((menu.Size.Y + currentLevelName.Size.Y + margin) * 1.2f))) { Color = Color.Black * 0.7f, Filled = true, }; backgroundMenu.Position = new Vector2(menu.Position.X - 0.05f * (menu.Size.X), currentLevelName.Position.Y - 0.1f * (menu.Size.Y + currentLevelName.Size.Y)); currentLevelImg = new Sprite(LevelsInfo.LevelInfo[currentLevelSelected].Texture, new Vector2(0.382f, 0.53f)) { Position = new Vector2(912, 108), Origin = new Vector2(380 / 2, 270 / 2), Rotation = 0.0872665f, }; CreateJobFolder(); AddUiComponent(backgroundMenu); AddUiComponent(menu); AddUiComponent(currentLevelName); AddUiComponent(leftLevelButton); AddUiComponent(rightLevelButton); AddUiComponent(currentLevelImg); OnSelectedChange(); }
public TextBox(GraphicsDevice graphics) { Size = Vector2.One; Font = SpriteFont; flashColor = Color.Transparent; cur = new DrawableRectangle(graphics, new Vector2(64, 64), Color.White, true); cursor = cur.Texture; }
static void Main(string[] args) { DrawableCircle circle = new DrawableCircle(0, 0, 3); DrawableLine line = new DrawableLine(0, 0, 1, 1); DrawableRectangle rectangle = new DrawableRectangle(5, 5, 2, 2); DrawableRing ring = new DrawableRing(3, 4, 5, 2); DrawableRound round = new DrawableRound(2, 8, 8); VectorGraphicsEditor.Draw(circle, line, rectangle, ring, round); }
protected override void OnLoad(Microsoft.Xna.Framework.Content.ContentManager content, Microsoft.Xna.Framework.Graphics.GraphicsDevice gd) { base.OnLoad(content, gd); AddChild(ChampionSprite); AddChild(ChampionRect = new DrawableRectangle(Champion.CreateCollisionRectangle(), Color.White * 0.7f)); ChampionRect.Visible = MainDrawableChampion.VIEW_DEBUG_RECTS; AddChild(LifeBar); }
private static void WriteLabelAndBoundingBox(IMagickImage outputImage, int imageHeight, string text, double[] bb, string drawColor) { DrawableStrokeColor strokeColor = new DrawableStrokeColor(new MagickColor(drawColor)); DrawableStrokeWidth strokeWidth = new DrawableStrokeWidth(3); DrawableFillColor fillColor = new DrawableFillColor(new MagickColor(50, 50, 50, 128)); DrawableRectangle dr = new DrawableRectangle(bb[0], bb[1], bb[4], bb[5]); DrawableText dt = new DrawableText(bb[0], bb[1], text); outputImage.Draw(strokeColor, strokeWidth, fillColor, dr, dt); }
public ClassCanvasItem(IClass ct) { classtype = ct; grad = new LinearGradientBrush( new PointF(0, 0), new PointF(1, 0), TitleBackground, Color.White); classItemHeaderedContent = new InteractiveHeaderedItem(titlesCollapsed, titlesExpanded, InitContentContainer(InitContent())); classItemContainer.Container = this; classItemContainer.Add(classItemHeaderedContent); Pen outlinePen = GetClassOutlinePen(); if (RoundedCorners) { int radius = CornerRadius; containingShape = new DrawableRectangle(null, outlinePen, radius, radius, radius, radius); } else { containingShape = new DrawableRectangle(null, outlinePen, 0, 0, 0, 0); } classItemContainer.Add(containingShape); classItemContainer.OrientationAxis = Axis.Z; if (RoundedCorners) { int radius = CornerRadius; titlesBackgroundCollapsed = new DrawableRectangle(grad, null, radius, radius, radius, radius); titlesBackgroundExpanded = new DrawableRectangle(grad, null, radius, radius, 0, 0); } else { titlesBackgroundCollapsed = new DrawableRectangle(grad, null, 0, 0, 0, 0); titlesBackgroundExpanded = new DrawableRectangle(grad, null, 0, 0, 0, 0); } titles.Border = 5; titlesCollapsed.Add(titlesBackgroundCollapsed); titlesCollapsed.Add(titles); titlesCollapsed.OrientationAxis = Axis.Z; titlesExpanded.Add(titlesBackgroundExpanded); titlesExpanded.Add(titles); titlesExpanded.OrientationAxis = Axis.Z; if (classtype != null) { typeclass = classtype.Modifiers.ToString(); typeclass += " " + classtype.ClassType.ToString(); } }
public SpawnDialogGameState(HaxxitGameState background_state, Haxxit.Maps.Map map, Haxxit.Maps.Point spawn_point, BoolWrapper newSpawnDialogStatus) : base() { this.background_state = background_state; this.map = map; this.spawn_point = spawn_point; spawnDialogStatus = newSpawnDialogStatus; spawnDialogStatus.Status = true; selectedProgram = null; lastSelectedRectangle = null; }
public void Constructor_WithRectangle_PropertiesAreSet() { var rectangle = new Rectangle(1, 2, 3, 4); var viewbox = new DrawableRectangle(rectangle); Assert.AreEqual(1, viewbox.UpperLeftX); Assert.AreEqual(2, viewbox.UpperLeftY); Assert.AreEqual(4, viewbox.LowerRightX); Assert.AreEqual(6, viewbox.LowerRightY); }
public void ShouldSetTheProperties() { var rectangle = new Rectangle(1, 2, 3, 4); var drawRectangle = new DrawableRectangle(rectangle); Assert.AreEqual(1, drawRectangle.UpperLeftX); Assert.AreEqual(2, drawRectangle.UpperLeftY); Assert.AreEqual(4, drawRectangle.LowerRightX); Assert.AreEqual(6, drawRectangle.LowerRightY); }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); arial_36px_bold = content.Load<SpriteFont>("Arial-36px-Bold"); Vector2 text_size = arial_36px_bold.MeasureString(dialog_text); text_position = new Point((int)Math.Floor((800 - text_size.X)/2), (int)Math.Floor((480 - text_size.Y)/2)); dialog_background = new DrawableRectangle(rectangle_texture, new Rectangle(text_position.X - 5, text_position.Y - 5, (int)Math.Floor(text_size.X + 10), (int)Math.Floor(text_size.Y + 10)), Color.Green); }
public void Area_RectangleCreation_CorrectValue() { double expected = 20; Color color = Color.Red; bool filled = false; Rectangle boundingRectangle = new Rectangle(0, 0, 4, 5); DrawableRectangle rectangle = new DrawableRectangle(color, filled, boundingRectangle); double result = rectangle.Area(); Assert.AreEqual(expected, result); }
public DrawableRectangle DrawProgramHead(Haxxit.Maps.Point p, Haxxit.Maps.ProgramHeadNode head_node) { DrawableRectangle retval; if (head_node.Program.AlreadyRanCommand()) retval = new DrawableRectangle(rounded_rect_back, display_map_state.HaxxitPointToXnaRectangle(p), Color.Black * (2.0f / 3.0f)); else if (!head_node.Program.Moves.CanMove()) retval = new DrawableRectangle(rounded_rect_back, display_map_state.HaxxitPointToXnaRectangle(p), Color.Black * (1.0f / 3.0f)); else retval = new DrawableRectangle(rounded_rect_back, display_map_state.HaxxitPointToXnaRectangle(p), Color.Transparent); retval.OnMouseLeftClick += OnProgramClick; return retval; }
public void LoadContent() { background = new DrawableRectangle(gameRef.GraphicsDevice, new Vector2(32, 32), Color.White, true).Texture; border = new DrawableRectangle(gameRef.GraphicsDevice, new Vector2(CANVAS_WIDTH, CANVAS_HEIGHT), Color.White, false); font = gameRef.Content.Load <SpriteFont>(@"Fonts\main_font"); playerSpawnTex = gameRef.Content.Load <Texture2D>("Images/player_spawn"); }
protected override void OnLoad(Microsoft.Xna.Framework.Content.ContentManager content, Microsoft.Xna.Framework.Graphics.GraphicsDevice gd) { Overlay = new DrawableRectangle(new GREATLib.Rect(0, 0, screenService.GameWindowSize.X, screenService.GameWindowSize.Y), Color.White); Overlay.Alpha = 0f; AddChild(Overlay); AddChild(Message = new DrawableLabel(), 2); Message.Scale = new Vector2(2f); Message.RelativeOrigin = new Vector2(0.5f); Message.SetPositionInScreenPercent(50, 50); base.OnLoad(content, gd); }
protected override void OnLoad(Microsoft.Xna.Framework.Content.ContentManager content, Microsoft.Xna.Framework.Graphics.GraphicsDevice gd) { Rect rect = Champion.CreateCollisionRectangle(); Parent.AddChild(ChampionServerRect = new DrawableRectangle(rect, Color.Green)); Parent.AddChild(ChampionSimulatedRect = new DrawableRectangle(rect, Color.Red)); Parent.AddChild(ChampionNoCorrection = new DrawableRectangle(rect, Color.Yellow * 0.5f)); Parent.AddChild(ChampionCorrectionUsed = new DrawableRectangle(rect, Color.Blue * 0.8f)); ChampionNoCorrection.Visible = ChampionServerRect.Visible = ChampionSimulatedRect.Visible = ChampionCorrectionUsed.Visible = VIEW_DEBUG_RECTS; base.OnLoad(content, gd); }
public TextBox(GraphicsDevice graphics) { Width = 1; Height = 1; Font = SpriteFont; flashColor = Color.Transparent; backColor = Color.Transparent; foreColor = Color.White; cur = new DrawableRectangle(graphics, new Vector2(6, 64), Color.White, true); cursor = cur.Texture; }
public override void OnFinishedClick(DrawableRectangle rectangle) { display_map_state.Map.FinishedSpawning(); //UserMapGameState new_state = new UserMapGameState(user_map_state.Map); //MapPlayGameState new_state = new MapPlayGameState(display_map_state); if (tutorialPlayer.CurrentNode == "Node2") { MapPlayGameState new_state = new MapPlayGameState(display_map_state); _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state)); } else { TutorialState new_state = new TutorialState(display_map_state); _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state)); } }
public void Test_Constructor_Rectangle() { var rectangle = new Rectangle(1, 2, 3, 4); var drawRectangle = new DrawableRectangle(rectangle); Assert.AreEqual(1, drawRectangle.UpperLeftX); Assert.AreEqual(2, drawRectangle.UpperLeftY); Assert.AreEqual(4, drawRectangle.LowerRightX); Assert.AreEqual(6, drawRectangle.LowerRightY); drawRectangle = (DrawableRectangle)rectangle; Assert.AreEqual(1, drawRectangle.UpperLeftX); Assert.AreEqual(2, drawRectangle.UpperLeftY); Assert.AreEqual(4, drawRectangle.LowerRightX); Assert.AreEqual(6, drawRectangle.LowerRightY); }
protected override void OnLoad(Microsoft.Xna.Framework.Content.ContentManager content, Microsoft.Xna.Framework.Graphics.GraphicsDevice gd) { RedRectangle = new DrawableRectangle(new GREATLib.Rect(0, 0, screenService.GameWindowSize.X, screenService.GameWindowSize.Y), Color.Red); RedRectangle.Alpha = 0f; AddChild(RedRectangle); DrawableLabel deathMessage = new DrawableLabel(); deathMessage.Text = "You died!"; deathMessage.Scale = new Vector2(2f); deathMessage.RelativeOrigin = new Vector2(0.5f); deathMessage.SetPositionInScreenPercent(50, 40); AddChild(deathMessage, 2); DeathTimer = new DrawableLabel(); DeathTimer.Text = DeathDuration.Seconds.ToString(); DeathTimer.Scale = new Vector2(2f); DeathTimer.RelativeOrigin = new Vector2(0.5f); DeathTimer.SetPositionInScreenPercent(50, 50); AddChild(DeathTimer, 2); }
public MainMenu(Game1 gameReference) : base(gameReference) { if (!game.IsThisSongPlaying(songs["MainMenu"])) { game.PlaySong(songs["MainMenu"]); } AddUiComponent(new Sprite(commonTextures["MainMenu"])); AddUiComponent(new Rain()); var playButton = new RectangleButton(inputManager, new Rectangle(0, 0, (int)(game.LogicalSize.X * 0.5f), (int)game.LogicalSize.Y / 10), fonts["Standard"], "PLAY") { Color = Color.Gray * 0.3f, Filled = true, }; playButton.OnClick += (o, e) => game.ChangeState(new ClubNeon(game, true)); var rankingButton = new RectangleButton(inputManager, new Rectangle(0, 0, (int)(game.LogicalSize.X * 0.5f), (int)game.LogicalSize.Y / 10), fonts["Standard"], "HIGHSCORES") { Color = Color.Gray * 0.3f, Filled = true, }; rankingButton.OnClick += (o, e) => game.ChangeState(new Rankings(game)); var menu = new VerticalNavigationMenu(inputManager, new List <IButton> { playButton, rankingButton, }); menu.Position = new Vector2(game.LogicalSize.X / 2 - menu.Size.X / 2, game.LogicalSize.Y * (4 / 5f) - menu.Size.Y / 2); var backgroundMenu = new DrawableRectangle(new Rectangle(0, 0, (int)(menu.Size.X * 1.1f), (int)(menu.Size.Y * 1.4f))) { Color = Color.Black * 0.7f, Filled = true, }; backgroundMenu.Position = new Vector2(menu.Position.X - 0.05f * menu.Size.X, menu.Position.Y - 0.2f * menu.Size.Y); AddUiComponent(backgroundMenu); AddUiComponent(menu); }
protected override DrawableItemsStack InitContentContainer(params IDrawableRectangle[] items) { DrawableItemsStack decorator = new DrawableItemsStack(); decorator.OrientationAxis = Axis.X; DrawableRectangle rect; if (RoundedCorners) { int radius = CornerRadius; rect = new DrawableRectangle(TitleBG, null, 0, 0, 0, radius); } else { rect = new DrawableRectangle(TitleBG, null, 0, 0, 0, 0); } rect.Width = 20; decorator.Add(rect); decorator.Add(base.InitContentContainer(items)); return(decorator); }
public SpellMenuItem(SpellCastInfo info, DrawableImage icon) : base(new DrawableImage("UIObjects/spellBox"), new DrawableImage("UIObjects/spellBox"), new DrawableImage("UIObjects/spellBox")) { Clickable = false; //StateClicking.Position = new Vector2(2, 2); AddChild(new DrawableImage("UIObjects/spellBoxDropShadow") { Position = new Vector2(2, 2) }, 0); //ClickAction = () => Cast(); Info = info; CoolDown = new DrawableRectangle(new Rectangle((int)NORMAL_WIDTH / 2, (int)NORMAL_WIDTH, (int)NORMAL_WIDTH, (int)NORMAL_WIDTH), Color.Aqua); CoolDown.RelativeOrigin = new Vector2(0.5f, 1f); CoolDown.Alpha = 0.3f; AddChild(CoolDown, 3); Icon = icon; AddChild(Icon, 2); }
public void OnMoveClick(DrawableRectangle rectangle) { Haxxit.Maps.Map map = user_map_state.display_map_state.Map; Haxxit.Maps.Point haxxit_location = user_map_state.display_map_state.XnaPointToHaxxitPoint(rectangle.Area.Center); Haxxit.Maps.Point direction = haxxit_location - selected_program; if (map.CanMoveProgram(selected_program, direction)) { _mediator_manager.Notify("haxxit.map.move", this, new Haxxit.Maps.MoveEventArgs(selected_program, direction)); if (map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(haxxit_location) && !map.GetNode<Haxxit.Maps.ProgramHeadNode>(haxxit_location).Program.AlreadyRanCommand()) { MapMovementGameState new_state = new MapMovementGameState(user_map_state, haxxit_location); _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state)); } else { _mediator_manager.Notify("haxxit.engine.state.pop", this, new EventArgs()); } } }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { ArialFontSize12 = content.Load<SpriteFont>("Arial-12px-Regular"); rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); overlay = new DrawableRectangle(rectangle_texture, new Rectangle(0, 0, 800, 480), Color.Black * 0.5f); win_font = content.Load<SpriteFont>("Arial-36px-Bold"); sub_font = content.Load<SpriteFont>("Arial-16px-Regular"); //------------------------------------------------------------------------- storyStringSpriteFont = content.Load<SpriteFont>("Arial-12px-Regular"); blankTexture = new Texture2D(graphics, 1, 1); blankTexture.SetData(new Color[] { Color.White }); buttonPressed = content.Load<Texture2D>("blackButtonPressed"); buttonReleased = content.Load<Texture2D>("blackButtonReleased"); storyPos = new Vector2(mWindowWidth / 2 - 200, 100); displayRect = new Rectangle(mWindowWidth / 2 - 210, 90, 420, 235); displayOutterEdgeRect = new Rectangle(mWindowWidth / 2 - 220, 80, 440, 255); tutorialRect1 = new Rectangle(mWindowWidth - 700, mWindowHeight - 170, 170, 110); tutorialEdgeRect1 = new Rectangle(mWindowWidth - 710, mWindowHeight -180, 190, 130); tutorialRect2 = new Rectangle(mWindowWidth - 450, mWindowHeight / 6, 170, 110); tutorialEdgeRect2 = new Rectangle(mWindowWidth - 460, mWindowHeight / 6 - 10, 190, 130); tutorialRect3 = new Rectangle(mWindowWidth - 450, mWindowHeight / 2 + 20, 320, 110); tutorialEdgeRect3 = new Rectangle(mWindowWidth - 460, mWindowHeight / 2 + 10, 340, 130); tutorialRect4 = new Rectangle(mWindowWidth - 210, mWindowHeight / 6 + 10, 170, 110); tutorialEdgeRect4 = new Rectangle(mWindowWidth - 220, mWindowHeight / 6, 190, 130); tutorialRect5 = new Rectangle(mWindowWidth - 700, mWindowHeight - 130, 170, 110); tutorialEdgeRect5 = new Rectangle(mWindowWidth - 710, mWindowHeight - 140, 190, 130); tutorialRect6 = new Rectangle(mWindowWidth - 410, mWindowHeight - 180, 170, 110); tutorialEdgeRect6 = new Rectangle(mWindowWidth - 420, mWindowHeight - 190, 190, 130); Vector2 length = storyStringSpriteFont.MeasureString("E"); length = storyStringSpriteFont.MeasureString(ContinueButtonString); ContinueButtonStringPos.X = ContinueButtonRect.X + ((ContinueButtonRect.Width - length.X) / 2); ContinueButtonStringPos.Y = ContinueButtonRect.Y + ((ContinueButtonRect.Height - length.Y) / 2); //------------------------------------------------------------------------- if (mPlayer1Tutorial.SpawnTutorial == true) { storyString = "Spawn Tutorial"; } else if (mPlayer1Tutorial.CurrentNode == "Node1") { storyString = "Level 1 Tutorial"; } else if (mPlayer1Tutorial.CurrentNode == "Node2") { storyString = "Level 2 Tutorial"; } //storyString = "This is only a placeholder."; }
public void DrawDebugPoints(List <Frame> frames, SpriteBatch spriteBatch, DynamicTextureAtlasManager atlas, DrawableRectangle point, Vector2 position, Vector2 scale) { if (_keyFrames.Count > 0 && CurrentFrame != null) { CurrentFrame.DrawDebugPoints(frames, spriteBatch, atlas, point, position, scale); } }
public ButtonHover(DrawableRectangle rectangle, Texture2D white_pixel, SpriteFont tooltip_font, string tooltip_text) { button_hover = new DrawableRectangle(rectangle.texture, rectangle.Area, Color.White * 0.5f); this.tooltip_font = tooltip_font; this.tooltip_text = tooltip_text; Vector2 tooltip_text_size = tooltip_font.MeasureString(tooltip_text); Rectangle tooltip_rect = new Rectangle(0, button_hover.Area.Y, (int)Math.Ceiling(tooltip_text_size.X), (int)Math.Ceiling(tooltip_text_size.Y)); tooltip_rect = tooltip_rect.LeftAlignOn(button_hover.Area).OffsetBy(0, -1 * tooltip_rect.Height - 6); tooltip_text_position = tooltip_rect.GetPosition(); tooltip_rect = tooltip_rect.BufferBy(8); tooltip_box = new DrawableRectangle(white_pixel, tooltip_rect, Color.White, 2, Color.Black); }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); rounded_rect_back = content.Load<Texture2D>("Map-Square-Background"); undo_button_texture = content.Load<Texture2D>("Map-Button-Undo"); turn_done_texture = content.Load<Texture2D>("Map-Button-TurnDone"); leave_map_texture = content.Load<Texture2D>("Map-Button-LeaveMap"); arial_16px_regular = content.Load<SpriteFont>("Arial-16px-Regular"); arial_12px_regular = content.Load<SpriteFont>("Arial-12px-Regular"); int button_size = 32; int buffer_size = 6; //turn_done_button = new DrawableRectangle(rectangle_texture, new Rectangle(690, 440, 100, 30), Color.Green); turn_done_button = new DrawableRectangle(turn_done_texture, new Rectangle(788 - button_size, 468 - button_size, button_size, button_size), Color.Green); turn_done_button.OnMouseLeftClick += OnTurnDoneClick; turn_done_button.OnMouseInside += OnButtonInside; turn_done_button.OnMouseOutside += OnButtonOutside; //undo_button = new DrawableRectangle(rectangle_texture, new Rectangle(580, 440, 100, 30), Color.Orange); undo_button = new DrawableRectangle(undo_button_texture, new Rectangle(788 - buffer_size - button_size * 2, 468 - button_size, button_size, button_size), Color.Yellow); undo_button.OnMouseLeftClick += OnUndoClick; undo_button.OnMouseInside += OnButtonInside; undo_button.OnMouseOutside += OnButtonOutside; //leave_map_button = new DrawableRectangle(rectangle_texture, new Rectangle(675, 400, 115, 30), Color.Red); leave_map_button = new DrawableRectangle(leave_map_texture, new Rectangle(788 - buffer_size * 2 - button_size * 3, 468 - button_size, button_size, button_size), Color.Red); leave_map_button.OnMouseLeftClick += OnLeaveMapClick; leave_map_button.OnMouseInside += OnButtonInside; leave_map_button.OnMouseOutside += OnButtonOutside; button_hover = null; Haxxit.Maps.Map map = display_map_state.Map; foreach (Haxxit.Maps.Point p in map.Low.IterateOverRange(map.High)) { if (map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(p)) { head_nodes[p] = DrawProgramHead(p, map.GetNode<Haxxit.Maps.ProgramHeadNode>(p)); } } }
public void OnSelectClick(DrawableRectangle rectangle) { map.SpawnProgram(selectedProgram, spawn_point); spawnDialogStatus.Status = false; _mediator_manager.Notify("haxxit.engine.state.pop", this, new EventArgs()); }
public void OnTurnDoneClick(DrawableRectangle rectangle) { _mediator_manager.Notify("haxxit.map.turn_done", this, new EventArgs()); }
private void OnProgramSelect(DrawableRectangle rectangle) { foreach (Tuple<Haxxit.Programs.ProgramFactory, DrawableRectangle> tuple in program_rectangles) { if (Object.ReferenceEquals(tuple.Item2, rectangle)) { selectedProgram = tuple.Item1; if (lastSelectedRectangle != null) { lastSelectedRectangle.FillColor = Color.White * 0.2f; } tuple.Item2.FillColor = Color.Yellow * 0.5f; lastSelectedRectangle = tuple.Item2; break; } } if (selectProgramButton == null) { selectProgramButton = new DrawableRectangle(selectTexture, new Rectangle(700, 400, 32, 32), Color.Green); selectProgramButton.OnMouseLeftClick += OnSelectClick; selectProgramButton.OnMouseInside += OnButtonInside; selectProgramButton.OnMouseOutside += OnButtonOutside; } }
public void DrawDebugPoints(SpriteBatch spriteBatch, DynamicTextureAtlasManager atlas, DrawableRectangle point, Vector2 position, Vector2 scale) { foreach (var part in Parts) { part.DrawDebugPoint(spriteBatch, atlas, point, position, scale); } }
public Player(PlayerIndex playerIndex) : base(Vector2.Zero) { this.playerIndex = playerIndex; // Initialize the player based on playerIndex // --------------------------------------------------------------- // I seperate the initialization of players into two if statements: // PlayerIndex.One and PlayerIndex.Two. As of right now, I won't // add any more (for laziness sake) and will keep initialization // like this. I'm sorry if this code offends you. // --------------------------------------------------------------- if (playerIndex == PlayerIndex.One) { // Set the position to be on the left side of the screen Position = new Vector2(0, Game1.GAME_HEIGHT / 2 - height / 2); // Set the shooting key based on playerIndex shootingKey = Keys.Tab; // Organize the moving keys movingKeys = new Keys[4] { Keys.W, Keys.S, Keys.A, Keys.D }; // Tint is chosen from the IntroState tint = IntroState.player1Color; sprite.Tint = tint; // First player will be facing right dir = 1; flipped = false; GunOffset = new Vector2(width / 2, 0); } else if (playerIndex == PlayerIndex.Two) { // Set the position to be on the right side of the screen Position = new Vector2(Game1.GAME_WIDTH - width, Game1.GAME_HEIGHT / 2 - height / 2); // Set the shooting key based on playerIndex shootingKey = Keys.RightControl; // Organize the moving keys movingKeys = new Keys[4] { Keys.Up, Keys.Down, Keys.Left, Keys.Right }; // Tint is chosen from the IntroState tint = IntroState.player2Color; sprite.Tint = tint; // Second player will be facing left dir = -1; flipped = true; GunOffset = new Vector2(-width / 2, 0); } else { // Remember how I said I only support PlayerIndex One and Two? // This is where I kindly remind you if you forget. // ---------------------------------------------------------- throw new Exception("Unsupported PlayerIndex - please only use indeces one and two"); } // Default weapons will be Pistols. If you wanna change it, go ahead // ------------------------------------------------------------------ equippedWeapon = new Shotgun(this, shootingKey); // This font is used for the player information that is on screen // -------------------------------------------------------------- font = Game1.content.Load <SpriteFont>("defaultFont"); // And here I make the animation for the player. Easy Peasy. // --------------------------------------------------------- Texture2D[] imgs = new Texture2D[] { Game1.content.Load <Texture2D>("helicopter1"), Game1.content.Load <Texture2D>("helicopter2") }; playerAnim = new Animation(imgs, 20f); // And here I have the basic rectangles used for the life bar. // The life bar stuff is pretty basic right now // ---------------------------------------------------------- var tex = new DrawableRectangle(Game1.graphics.GraphicsDevice, new Vector2(10, 10), Color.White, true).Texture; lifeBg = tex; lifeFg = tex; // Set the force field size to be bigger than the player // ----------------------------------------------------- forceFieldWidth = width + 30; forceFieldHeight = height + 30; // Temporary setting the force field texture to a white rectangle // -------------------------------------------------------------- forceFieldTex = new DrawableRectangle(Game1.graphics.GraphicsDevice, new Vector2(forceFieldWidth, forceFieldHeight), Color.White, true).Texture; }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { display_map_state.LoadContent(graphics, sprite_batch, content); rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); rounded_rect_border = content.Load<Texture2D>("Map-Square-Border"); finished_texture = content.Load<Texture2D>("Map-Button-TurnDone"); leave_map_texture = content.Load<Texture2D>("Map-Button-LeaveMap"); arial_16px_regular = content.Load<SpriteFont>("Arial-16px-Regular"); arial_12px_regular = content.Load<SpriteFont>("Arial-12px-Regular"); int button_size = 32; int buffer_size = 6; finished_button = new DrawableRectangle(finished_texture, new Rectangle(788 - button_size, 468 - button_size, button_size, button_size), Color.Green); finished_button.OnMouseLeftClick += OnFinishedClick; finished_button.OnMouseInside += OnButtonInside; finished_button.OnMouseOutside += OnButtonOutside; leave_map_button = new DrawableRectangle(leave_map_texture, new Rectangle(788 - buffer_size - button_size * 2, 468 - button_size, button_size, button_size), Color.Red); leave_map_button.OnMouseLeftClick += OnLeaveMapClick; leave_map_button.OnMouseInside += OnButtonInside; leave_map_button.OnMouseOutside += OnButtonOutside; button_hover = null; Haxxit.Maps.Map map = display_map_state.Map; foreach (Haxxit.Maps.Point p in map.Low.IterateOverRange(map.High)) { if (map.NodeIsType<Haxxit.Maps.SpawnNode>(p) && map.GetNode<Haxxit.Maps.SpawnNode>(p).Player == map.CurrentPlayer) { DrawableRectangle spawn = new DrawableRectangle(rounded_rect_border, display_map_state.HaxxitPointToXnaRectangle(p), Color.White); spawn.OnMouseLeftClick += OnSpawnClick; spawns.Add(p, spawn); } } }
private IEnumerable<DrawableRectangle> DrawProgramNodeConnector(Haxxit.Maps.Point p, Haxxit.Maps.Point connector_direction, Color node_color) { List<DrawableRectangle> rectangles = new List<DrawableRectangle>(); if (!connector_direction.IsDirectional()) { #if DEBUG throw new Exception(); #else return rectangles; #endif } DrawableRectangle connector = new DrawableRectangle(rectangle_texture, p.ToXNARectangle(map_rectangle_size, map_border_size), node_color); Rectangle area = connector.Area; if (connector_direction == new Haxxit.Maps.Point(0, 1)) // Down { area.Y += map_rectangle_size; area.Height /= (map_rectangle_size / map_border_size); area.Width /= 2; area.X += area.Width / 2; } else if (connector_direction == new Haxxit.Maps.Point(0, -1)) // Up { area.Y -= map_border_size; area.Height /= (map_rectangle_size / map_border_size); area.Width /= 2; area.X += area.Width / 2; } else if (connector_direction == new Haxxit.Maps.Point(1, 0)) // Right { area.X += map_rectangle_size; area.Width /= (map_rectangle_size / map_border_size); area.Height /= 2; area.Y += area.Height / 2; } else // Left { area.X -= map_border_size; area.Width /= (map_rectangle_size / map_border_size); area.Height /= 2; area.Y += area.Height / 2; } connector.Area = area; rectangles.Add(connector); return rectangles; }
public void DrawDebugPoints(List <Frame> frames, SpriteBatch spriteBatch, DynamicTextureAtlasManager atlas, DrawableRectangle point, Vector2 position, Vector2 scale) { var frame = GetFrame(frames); if (frame == null) { return; } frame.DrawDebugPoints(spriteBatch, atlas, point, position, scale); }
public void OnCancelClick(DrawableRectangle rectangle) { spawnDialogStatus.Status = false; _mediator_manager.Notify("haxxit.engine.state.pop", this, new EventArgs()); }
public override void LoadContent(GraphicsDevice newGraphics, SpriteBatch sprite_batch, ContentManager newContent) { graphics = newGraphics; content = newContent; rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); background = content.Load<Texture2D>("Map-Background-1"); rounded_rect_back = content.Load<Texture2D>("Map-Square-Background"); rounded_rect_border = content.Load<Texture2D>("Map-Square-Border"); rounded_rect_full = content.Load<Texture2D>("Map-Square-Full"); spawn_overlay = content.Load<Texture2D>("Map-Square-Spawn"); silicoin_overlay = content.Load<Texture2D>("Map-Square-Silicoin"); data_overlay = content.Load<Texture2D>("Map-Square-Data"); background_rectangle = new DrawableRectangle(background, new Rectangle(0, 0, 800, 480), Color.White); map_squares.Clear(); foreach (SmartboyDevelopments.Haxxit.Maps.Point p in Map.Low.IterateOverRange(Map.High)) map_squares[p] = MapNodeToRectangle(p); }
public void OnButtonOutside(DrawableRectangle rectangle) { MouseState mouse_state = Mouse.GetState(); if(selectProgramButton == null) { if(!cancelButton.Area.Contains(mouse_state.X, mouse_state.Y)) { buttonHover = null; } } else if (!selectProgramButton.Area.Contains(mouse_state.X, mouse_state.Y) && !cancelButton.Area.Contains(mouse_state.X, mouse_state.Y)) { buttonHover = null; } }
public void OnUndoClick(DrawableRectangle rectangle) { _mediator_manager.Notify("haxxit.undo_stack.trigger", this, new EventArgs()); }
public void Execute() { MontageConfig montageConfig = Config.Montages; if (montageConfig == null) { throw new ConfigurationException("Montage action performed, but no montages are defined in the configuration."); } string font = montageConfig.Font ?? DefaultFontFamily(); MontageSettings montageSettings = new MontageSettings() { BackgroundColor = MagickColors.None, Geometry = new MagickGeometry(2, 2, 0, 0), TileGeometry = new MagickGeometry(8, 0), Font = font }; MagickReadSettings magickSettings = new MagickReadSettings() { FontFamily = font, FontPointsize = 14, BackgroundColor = MagickColors.None, FillColor = MagickColors.White }; foreach (PatternConfig pattern in montageConfig.Patterns) { string name = pattern.Name; DataResolver resolver = new DataResolver(pattern.Source); List <ResolvedData> resolverData = resolver.Data; if (resolverData.Count == 0) { throw new ConfigurationException($"The pattern for montage {name} doesn't match any files, exiting the application."); } resolverData.Sort(); using (MagickImageCollection collection = new MagickImageCollection()) { foreach (ResolvedData resolvedFile in resolverData) { string filename = resolvedFile.Name; string fileShortName = Path.GetFileNameWithoutExtension(filename); MagickImage magickImage = resolvedFile.ToMagickImage(magickSettings); magickImage.Extent(128, 144, MagickColors.None); MagickColor color = MagickColor.FromRgba(0, 0, 0, 88); DrawableRectangle drawableRect = new DrawableRectangle(0, 128, 144, 144); DrawableFillColor drawableColor = new DrawableFillColor(color); magickImage.Draw(drawableColor, drawableRect); magickImage.Annotate(fileShortName, Gravity.South); collection.Add(magickImage); Logger.Debug("Appended montage {0} with: {1}", name, resolvedFile); } Logger.Debug("Finished collecting input, creating a montage of {0} images.", collection.Count); using (IMagickImage montage = collection.Montage(montageSettings)) { string filepath = Path.Combine("build", "montages", name + ".png"); FileInfo outputPath = new FileInfo(filepath); outputPath.Directory?.Create(); Logger.Debug("Writing monatage with name {0} to {1}.", name, filepath); montage.Write(outputPath); } } } }
public void OnButtonInside(DrawableRectangle rectangle) { string tooltip = ""; if (rectangle == selectProgramButton) tooltip = "Select this program for spawning."; else if (rectangle == cancelButton) tooltip = "Leave (exit) the spawn program dialog."; buttonHover = new ButtonHover(rectangle, rectangle_texture, arial_12px_regular, tooltip); }
protected override void SetBulletTexture() { var tex = new DrawableRectangle(Game1.graphics.GraphicsDevice, new Vector2(1366, 5), Color.Red, true).Texture; bulletTex = tex; }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); selectTexture = content.Load<Texture2D>("Map-Button-TurnDone"); cancelTexture = content.Load<Texture2D>("Map-Button-LeaveMap"); overlay = new DrawableRectangle(rectangle_texture, new Rectangle(0, 0, 800, 480), Color.Black * 0.5f); popup_window = new DrawableRectangle(rectangle_texture, new Rectangle(350, 20, 400, 350), Color.DarkBlue); commandInfoBox = new DrawableRectangle(rectangle_texture, new Rectangle(10, 385, 650, 60), Color.DarkBlue); cancelButton = new DrawableRectangle(cancelTexture, new Rectangle(740, 400, 32, 32), Color.Red); cancelButton.OnMouseLeftClick += OnCancelClick; cancelButton.OnMouseInside += OnButtonInside; cancelButton.OnMouseOutside += OnButtonOutside; buttonHover = null; arial_16px_regular = content.Load<SpriteFont>("Arial-16px-Regular"); arial_14px_regular = content.Load<SpriteFont>("Arial-14px-Regular"); arial_12px_regular = content.Load<SpriteFont>("Arial-12px-Regular"); arial_10px_regular = content.Load<SpriteFont>("Arial-10px-Regular"); List<Haxxit.Programs.ProgramFactory> programs = new List<Haxxit.Programs.ProgramFactory>(); programs.Add(null); // For "None" option foreach (Haxxit.Programs.ProgramFactory program in programs.Concat(map.CurrentPlayer.GetPrograms())) { Rectangle program_location = new Rectangle(popup_window.Area.X + 10, popup_window.Area.Y + program_rectangles.Count * 72 + 48, popup_window.Area.Width - 20, 60); DrawableRectangle program_rectangle = new DrawableRectangle(rectangle_texture, program_location, Color.White * 0.2f); program_rectangle.OnMouseLeftClick += OnProgramSelect; program_rectangles.Add(new Tuple<Haxxit.Programs.ProgramFactory, DrawableRectangle>(program, program_rectangle)); totalPrograms++; } // If there are enough programs that we'll need to support scrolling... if (totalPrograms > 4) { scrollUpTexture = content.Load<Texture2D>("ArrowUp"); scrollUpButton = new DrawableRectangle(rectangle_texture, new Rectangle(750, 20, 50, 50), Color.White); scrollUpButton.OnMouseLeftClick += OnScrollUp; scrollDownTexture = content.Load<Texture2D>("ArrowDown"); scrollDownButton = new DrawableRectangle(rectangle_texture, new Rectangle(750, 320, 50, 50), Color.White); scrollDownButton.OnMouseLeftClick += OnScrollDown; scrollGripTexture = content.Load<Texture2D>("ScrollGrip"); scrollBar = new DrawableRectangle(rectangle_texture, new Rectangle(760, 70, 30, 250), Color.DimGray); scrollGrip = new DrawableRectangle(rectangle_texture, new Rectangle(760, 70, 30, 50), Color.White); aboveGrip = new DrawableRectangle(rectangle_texture, new Rectangle(760, 70, 30, 0), Color.Red); aboveGrip.OnMouseLeftClick += OnScrollUp; belowGrip = new DrawableRectangle(rectangle_texture, new Rectangle(760, 120, 30, 200), Color.Green); belowGrip.OnMouseLeftClick += OnScrollDown; // Determine scroll grip positions for future use scrollGripPositions = new int[totalPrograms - 3]; int startingPosition = scrollGrip.Area.Location.Y; int endingPosition = startingPosition + scrollBar.Area.Height - scrollGrip.Area.Height; interval = (endingPosition - startingPosition) / (totalPrograms - 4); for (int i = 0; i < totalPrograms - 3; i++) { scrollGripPositions[i] = startingPosition + interval * i; } } }
public LevelSelect(Game1 gameReference) : base(gameReference) { AddUiComponent(new Sprite(content.Load <Texture2D>("Textures/LevelSelect/LevelSelectBackground"))); currentLevelImg = new Sprite(LevelsInfo.LevelInfo[currentLevelSelected].Texture) { Position = new Vector2(455, 45), }; AddUiComponent(currentLevelImg); AddUiComponent(new Sprite(content.Load <Texture2D>("Textures/LevelSelect/LevelSelectForeground"))); var playButton = new RectangleButton(inputManager, new Rectangle(0, 0, (int)(game.LogicalSize.X * 0.5f), (int)game.LogicalSize.Y / 10), fonts["Standard"], "PLAY") { Color = Color.Gray * 0.3f, Filled = true, }; playButton.OnClick += (o, e) => StartLevel(currentLevelSelected); var backButton = new RectangleButton(inputManager, new Rectangle(0, 0, (int)(game.LogicalSize.X * 0.5f), (int)game.LogicalSize.Y / 10), fonts["Standard"], "BACK") { Color = Color.Gray * 0.3f, Filled = true, }; backButton.OnClick += (o, e) => game.ChangeState(new MainMenu(game)); menu = new VerticalNavigationMenu(inputManager, new List <IButton> { playButton, backButton, }); menu.Position = new Vector2(game.LogicalSize.X / 2 - menu.Size.X / 2, game.LogicalSize.Y * (0.835f) - menu.Size.Y / 2); currentLevelName = new Text(fonts["Standard"], LevelsInfo.LevelInfo[currentLevelSelected].Name); int margin = 30; currentLevelName.Position = new Vector2(menu.Rectangle.Center.X - currentLevelName.Size.X / 2, menu.Rectangle.Top - currentLevelName.Size.Y - margin); currentLevelName.AddSpecialEffect(new RainbowEffect()); var backgroundMenu = new DrawableRectangle(new Rectangle(0, 0, (int)((menu.Size.X) * 1.1f), (int)((menu.Size.Y + currentLevelName.Size.Y + margin) * 1.2f))) { Color = Color.Black * 0.7f, Filled = true, }; backgroundMenu.Position = new Vector2(menu.Position.X - 0.05f * (menu.Size.X), currentLevelName.Position.Y - 0.1f * (menu.Size.Y + currentLevelName.Size.Y)); rightLevelButton = new RectangleButton(inputManager, new Rectangle(0, 0, 80, 80), fonts["Standard"], ">"); rightLevelButton.OnClick += IncreaseSelectedLevel; rightLevelButton.Position = new Vector2(menu.Rectangle.Right - rightLevelButton.Size.X, currentLevelName.Rectangle.Center.Y - rightLevelButton.Size.Y / 2); leftLevelButton = new RectangleButton(inputManager, new Rectangle(0, 0, 80, 80), fonts["Standard"], "<"); leftLevelButton.OnClick += DecreaseSelectedLevel; leftLevelButton.Position = new Vector2(menu.Rectangle.Left, currentLevelName.Rectangle.Center.Y - rightLevelButton.Size.Y / 2); AddUiComponent(backgroundMenu); AddUiComponent(leftLevelButton); AddUiComponent(rightLevelButton); AddUiComponent(menu); AddUiComponent(currentLevelName); }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); rounded_rect_attack = content.Load<Texture2D>("Map-Square-Attack"); arial_16px_regular = content.Load<SpriteFont>("Arial-16px-Regular"); arial_12px_regular = content.Load<SpriteFont>("Arial-12px-Regular"); selected_border = new DrawableRectangle(rectangle_texture, user_map_state.display_map_state.HaxxitPointToXnaRectangle(selected_program), Color.Transparent, 2, Color.White); Haxxit.Maps.Map map = user_map_state.display_map_state.Map; Haxxit.Programs.Program program = map.GetNode<Haxxit.Maps.ProgramHeadNode>(selected_program).Program; foreach (Haxxit.Maps.Point p in selected_program.GetPointsWithinDistance(program.GetCommand(selected_attack).Range)) { Rectangle attack_rectangle = user_map_state.display_map_state.HaxxitPointToXnaRectangle(p); if(attack_nodes.Count(x => x.Area == attack_rectangle) == 0 && map.IsInBounds(p)) { DrawableRectangle attack_node = null; Color attack_color = Color.Red * 0.25f; if (map.CanRunCommand(selected_program, p, selected_attack)) attack_color = Color.Red; attack_node = new DrawableRectangle(rounded_rect_attack, attack_rectangle, attack_color); if (!commandAI) { attack_node.OnMouseLeftClick += OnAttackNodeClick; } attack_nodes.Add(attack_node); } } if (commandAI) { popTime = System.Environment.TickCount + PlayerAI.ACTIONSTALLTIME_MSECS; } }
public void OnButtonInside(DrawableRectangle rectangle) { //button_hover = new DrawableRectangle(rectangle.texture, rectangle.Area, Color.White * 0.5f); string tooltip = ""; if (rectangle == turn_done_button) tooltip = "Ends your turn."; else if (rectangle == undo_button) tooltip = "Undo previous action."; else if (rectangle == leave_map_button) tooltip = "Leave (exit) the current map."; button_hover = new ButtonHover(rectangle, rectangle_texture, arial_12px_regular, tooltip); }
public void OnAttackNodeClick(DrawableRectangle rectangle) { Haxxit.Maps.Map map = user_map_state.display_map_state.Map; Haxxit.Maps.Point haxxit_location = user_map_state.display_map_state.XnaPointToHaxxitPoint(rectangle.Area.Center); if (map.CanRunCommand(selected_program, haxxit_location, selected_attack)) { _mediator_manager.Notify("haxxit.map.command", this, new Haxxit.Maps.CommandEventArgs(haxxit_location, selected_program, selected_attack)); if (map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(selected_program) && map.GetNode<Haxxit.Maps.ProgramHeadNode>(selected_program).Program.AlreadyRanCommand()) { List<Haxxit.Maps.Point> changed = new List<Haxxit.Maps.Point>(); changed.Add(selected_program); _mediator_manager.Notify("haxxit.map.nodes.changed", this, new Haxxit.Maps.MapChangedEventArgs(changed)); _mediator_manager.Notify("haxxit.engine.state.pop", this, new EventArgs()); } } }
public void OnButtonOutside(DrawableRectangle rectangle) { MouseState mouse_state = Mouse.GetState(); if(!undo_button.Area.Contains(mouse_state.X, mouse_state.Y) && !leave_map_button.Area.Contains(mouse_state.X, mouse_state.Y) && !turn_done_button.Area.Contains(mouse_state.X, mouse_state.Y)) button_hover = null; }
public override void LoadContent(GraphicsDevice graphics, SpriteBatch sprite_batch, ContentManager content) { rectangle_texture = new Texture2D(graphics, 1, 1); rectangle_texture.SetData(new Color[] { Color.White }); rounded_rect_border = content.Load<Texture2D>("Map-Square-Border"); rounded_rect_full = content.Load<Texture2D>("Map-Square-Full"); arial_16px_regular = content.Load<SpriteFont>("Arial-16px-Regular"); arial_12px_regular = content.Load<SpriteFont>("Arial-12px-Regular"); selected_border = new DrawableRectangle(rounded_rect_border, user_map_state.display_map_state.HaxxitPointToXnaRectangle(selected_program), Color.White); Haxxit.Maps.Map map = user_map_state.display_map_state.Map; foreach (Haxxit.Maps.Point p in selected_program.GetOrthologicalNeighbors()) { Haxxit.Maps.Point direction = p - selected_program; if (map.CanMoveProgram(selected_program, direction)) { DrawableRectangle move = new DrawableRectangle(rounded_rect_full, user_map_state.display_map_state.HaxxitPointToXnaRectangle(p), Color.White * 0.5f); if (!MoveAI) { move.OnMouseLeftClick += OnMoveClick; } movement.Add(move); } } Haxxit.Maps.ProgramHeadNode selected_node = map.GetNode<Haxxit.Maps.ProgramHeadNode>(selected_program); if (!selected_node.Program.AlreadyRanCommand()) { foreach (string command in selected_node.Program.GetAllCommands()) { Vector2 text_size = arial_16px_regular.MeasureString(command); DrawableRectangle rectangle = new DrawableRectangle(rounded_rect_full, new Rectangle(780 - (int)Math.Floor(text_size.X), 10 + ((int)Math.Floor(text_size.Y) + 15) * attacks.Count, (int)Math.Floor(text_size.X) + 10, (int)Math.Floor(text_size.Y) + 10), Color.Red); if (!MoveAI) { rectangle.OnMouseLeftClick += OnAttackClick; } attacks.Add(new Tuple<DrawableRectangle, string>(rectangle, command)); } } if (MoveAI) { popTime = System.Environment.TickCount + PlayerAI.ACTIONSTALLTIME_MSECS; } }
public void OnLeaveMapClick(DrawableRectangle rectangle) { // This shouldn't be how it operates. I should be able to pop the play and display states off the stack, // but it just restarts the map if I do that. Instead, I have to create a new overworld state, clear the // stack, then push the new state onto the stack in order to avoid the stack eventually overflowing. HaxxitGameState new_state = new ServerOverworldState(); _mediator_manager.Notify("haxxit.engine.state.clear_change", this, new ChangeStateEventArgs(new_state)); }
public void OnAttackClick(DrawableRectangle rectangle) { Haxxit.Maps.Map map = user_map_state.display_map_state.Map; foreach (Tuple<DrawableRectangle, string> attack in attacks) { if (attack.Item1 == rectangle) { if (!map.GetNode<Haxxit.Maps.ProgramHeadNode>(selected_program).Program.HasCommand(attack.Item2)) break; MapAttackGameState new_state = new MapAttackGameState(user_map_state, selected_program, attack.Item2); _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state)); } } }
public void OnProgramClick(DrawableRectangle rectangle) { Haxxit.Maps.Point haxxit_location = display_map_state.XnaPointToHaxxitPoint(rectangle.Area.Center); if (display_map_state.Map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(haxxit_location) && !display_map_state.Map.GetNode<Haxxit.Maps.ProgramHeadNode>(haxxit_location).Program.AlreadyRanCommand()) { MapMovementGameState new_state = new MapMovementGameState(this, haxxit_location); _mediator_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state)); } }
public void OnSpawnClick(DrawableRectangle rectangle) { Haxxit.Maps.Point haxxit_location = display_map_state.XnaPointToHaxxitPoint(rectangle.Area.Center); SpawnDialogGameState new_state = new SpawnDialogGameState(this, display_map_state.Map, haxxit_location, displayingSpawnDialog); _mediator_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state)); }
private void OnScrollUp(DrawableRectangle rectangle) { if (currentScrollLevel > 0) { foreach (DrawableRectangle program_rectangle in program_rectangles.Select(x => x.Item2)) { Rectangle area = program_rectangle.Area; area.Y += 72; program_rectangle.Area = area; } currentScrollLevel--; Rectangle scrollGripPosition = scrollGrip.Area; scrollGripPosition.Y = scrollGripPositions[currentScrollLevel]; scrollGrip.Area = scrollGripPosition; Rectangle modifyAboveRectangle = aboveGrip.Area; modifyAboveRectangle.Height = scrollGrip.Area.Y - scrollBar.Area.Y; aboveGrip.Area = modifyAboveRectangle; Rectangle modifyBelowRectangle = belowGrip.Area; modifyBelowRectangle.Y = scrollGrip.Area.Y + scrollGrip.Area.Height; modifyBelowRectangle.Height = scrollBar.Area.Y + scrollBar.Area.Height - (scrollGrip.Area.Y + scrollGrip.Area.Height); belowGrip.Area = modifyBelowRectangle; } }