private void processDraw(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16); yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16); if (xt != lxt || yt != lyt) { changed = true; } lxt = xt; lyt = yt; if (changed) { int l_index = FrmLogicTileSelector.Instance.CurrentLogicIndex; LogicFillAction action = new LogicFillAction(xt, yt, l_index, FrmLogicTileSelector.Instance.btnUseSameTypeLogic.Checked); foreach (LogicSetAction aa in action.Actions) { foreach (SetTileAction a in aa.Actions) { Map map = EditorEngine.Instance.CurrentMap; MockupTileBehavior b = map.GetBehavior(a.X, a.Y); b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId; } } EditorEngine.Instance.GetActionManager().Execute(action); } } changed = false; }
private void onMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { int xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16); int yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16); int z = TileEditorState.Instance.SelectedLayer; int tilesetIndex = TileEditorState.Instance.SelectedTileset; Rectangle selectedRegion = TileEditorState.Instance.SelectedRegion; Tileset tileset = EditorEngine.Instance.CurrentMap.Tilesets[tilesetIndex].Tileset; int tileIndex = tileset.Texture.GetIndex(selectedRegion.X, selectedRegion.Y); FillAction fillAction = new FillAction(xt, yt, tileIndex, tilesetIndex); EditorEngine.Instance.GetActionManager().Execute(fillAction); foreach (SetTileAction a in fillAction.Actions) { Map map = EditorEngine.Instance.CurrentMap; MockupTileBehavior b = map.GetBehavior(a.X, a.Y); b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId; } } }
public void OnMouseMove(object sender, MouseEventArgs e) { int xt = (e.X + hscrollbar.Value) / 16; int yt = (e.Y + vscrollbar.Value) / 16; if (xt < 0 || yt < 0) { return; } if (Tileset != null) { if (Mode == 1) { if (e.Button == MouseButtons.Left) { int col = Tileset.Texture.Texture.Width >> 4; int index = yt * col + xt; MockupTileBehavior tileBehavior = Tileset.Tiles[index].DefaultBehavior; if (switchOff) { Tileset.Tiles[index].DefaultBehavior.BehaviorId = TileBehavior.Height2.Id; } else { Tileset.Tiles[index].DefaultBehavior.BehaviorId = this.Behavior; } } } } }
public IEncodable Decode(BinaryInput stream) { this.spriteindex = stream.ReadInt32(); this.collidable = stream.ReadBoolean(); this.reflecting = stream.ReadBoolean(); this.animated = stream.ReadBoolean(); this.frames = stream.ReadInt32(); this.timeperframe = stream.ReadSingle(); this.DefaultBehavior = stream.ReadObject <MockupTileBehavior>(); return(this); }
private void Initialize(string name, string author, IRegionEntityFactory factory) { this.Name = name ?? "MAP_NO_NAME"; this.Author = author ?? "Anonymous"; this.Behaviors = new MockupTileBehavior[Width, Height]; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { Behaviors[i, j] = new MockupTileBehavior(TileBehavior.Height2.Id); } } Fill(-1, 0); }
public void onMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { //action.UnExecute(); temp.UnExecute(); EditorEngine.Instance.GetActionManager().Execute(action); foreach (SetTileAction a in action.Actions) { Map map = EditorEngine.Instance.CurrentMap; MockupTileBehavior b = map.GetBehavior(a.X, a.Y); b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId; } action = null; temp = null; } }
private void onMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Rectangle region = selection.Region; Rectangle tileRegion = TileEditorState.Instance.SelectedRegion; RectangleAction action = new RectangleAction(tileRegion, region, TileEditorState.Instance.SelectedTileset); EditorEngine.Instance.GetActionManager().Execute(action); foreach (SetTileAction a in action.Actions) { Map map = EditorEngine.Instance.CurrentMap; MockupTileBehavior b = map.GetBehavior(a.X, a.Y); b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId; } active = false; } }
private void onMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Map map = EditorEngine.Instance.CurrentMap; int xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16); int yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16); MockupTileBehavior _ref = map.GetBehavior(xt, yt); if (xt < 0 || yt < 0 || xt >= map.Width || yt >= map.Height) { return; } if (_ref == null) { return; } _ref.BehaviorId = BehaviorEditorState.Instance.SelectedTileBehaviorId; } }
public void onMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { capturedmouse = false; int l_index = FrmLogicTileSelector.Instance.logicViewerSelectorControl1.SelectedLogicIndex; Rectangle region = selection.Region; LogicRectangleAction action = new LogicRectangleAction(region, l_index); EditorEngine.Instance.GetActionManager().Execute(action); foreach (LogicSetAction aa in action.Actions) { foreach (SetTileAction a in aa.Actions) { Map map = EditorEngine.Instance.CurrentMap; MockupTileBehavior b = map.GetBehavior(a.X, a.Y); b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId; } } } }
public void Draw(GameTime gameTime) { int w = EditorEngine.Instance.CurrentMap.Width; int h = EditorEngine.Instance.CurrentMap.Height; int xs = EditorEngine.Instance.xCam; int ys = EditorEngine.Instance.yCam; Map m = EditorEngine.Instance.CurrentMap; SpriteBatch spriteBatch = m.World.ViewData.SpriteBatch; for (int yt = 0; yt < m.Height; yt++) { for (int xt = 0; xt < m.Width; xt++) { MockupTileBehavior _ref = m.GetBehavior(xt, yt); Texture2D pixel; if (!colors.ContainsKey(_ref.TileBehavior.Color)) { pixel = new Texture2D(EditorEngine.Instance.GraphicsDevice, 1, 1); pixel.SetData <Color>(new Color[] { _ref.TileBehavior.Color }); colors.Add(_ref.TileBehavior.Color, pixel); } pixel = colors[_ref.TileBehavior.Color]; Vector2 scroll = m.World.Camera.Location; float scale = m.World.Camera.Scale; const float opacity = .71f; Rectangle target = new Rectangle((int)(xt * 16 * scale), (int)(yt * 16 * scale), (int)(16 * scale), (int)(16 * scale)).Add(scroll); Rectangle targetFont = new Rectangle((int)((xt * 16 + 16 / 2f - Math.Floor(FontRenderer.Instance.Width(_ref.TileBehavior.Identifier, 2) / 2f)) * scale), (int)((yt * 16 + 14) * scale), (int)(16 * scale), (int)(16 * scale)).Add(scroll); spriteBatch.Draw(pixel, target, Color.White * opacity); FontRenderer.Instance.Draw(spriteBatch, _ref.TileBehavior.Identifier, 2, targetFont.X, targetFont.Y, opacity); } } this.ToolMachine.Draw(gameTime); }
private void onMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { int l_index = FrmLogicTileSelector.Instance.logicViewerSelectorControl1.SelectedLogicIndex; for (int i = 0; i < path.Count; i++) { LogicPathSquare sq = path[i]; LogicPathSquare sqm1 = null; if (i != 0) { sqm1 = path[i - 1]; } if (sqm1 != null) { if ((sq.dir == 0 || sq.dir == 1) && (sqm1.dir != 0 || sqm1.dir != 1) || (sq.dir == 2 || sq.dir == 3) && (sqm1.dir != 2 || sqm1.dir != 3)) { path.Insert(i, new LogicPathSquare((sqm1.dir == 2 ? sqm1.x - 1 : sqm1.dir == 3 ? sqm1.x + 1 : sqm1.x), (sqm1.dir == 0 ? sqm1.y - 1 : sqm1.dir == 1 ? sqm1.y + 1 : sqm1.y), sqm1.dir)); i++; } } } int _size = FrmLogicTileSelector.Instance.size; LogicPathAction action = new LogicPathAction(path, l_index, _size); foreach (SetTileAction a in action.Actions) { Map map = EditorEngine.Instance.CurrentMap; MockupTileBehavior b = map.GetBehavior(a.X, a.Y); b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId; } EditorEngine.Instance.GetActionManager().Execute(action); path.Clear(); } }
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { int xt = (e.X + hscrollbar.Value) / 16; int yt = (e.Y + vscrollbar.Value) / 16; if (xt < 0 || yt < 0) { return; } if (Tileset != null) { if (Mode == 1) { if (e.Button == MouseButtons.Left) { int col = Tileset.Texture.Texture.Width >> 4; int index = yt * col + xt; MockupTileBehavior tileBehavior = Tileset.Tiles[index].DefaultBehavior; if (tileBehavior.BehaviorId == this.Behavior) { Tileset.Tiles[index].DefaultBehavior.BehaviorId = TileBehavior.Height2.Id; switchOff = true; } else { Tileset.Tiles[index].DefaultBehavior.BehaviorId = this.Behavior; switchOff = false; } } } } base.OnMouseDown(e); }