public void Move(ScreenCanvas canvas, Common.Geometry.Point location) { if (_dragging) { canvas.Margin = new Thickness(canvas.Margin.Left + location.X - _dragAnchorOffset.X, canvas.Margin.Top + location.Y - _dragAnchorOffset.Y, 0, 0); } }
public void Release(ScreenCanvas canvas, Point location) { held = false; int x_start = Math.Min(tx1, tx2); int x_end = Math.Max(tx1, tx2) - 1; int y_start = Math.Min(ty1, ty2); int y_end = Math.Max(ty1, ty2) - 1; startTiles = new int?[canvas.Screen.Width, canvas.Screen.Height]; endTiles = new int?[canvas.Screen.Width, canvas.Screen.Height]; for (int y = y_start; y <= y_end; y += brush.Cells[0].Length) { for (int x = x_start; x <= x_end; x += brush.Cells.Length) { Draw(canvas, x, y); } } var changes = new List <TileChange>(); for (int y = 0; y < canvas.Screen.Height; y++) { for (int x = 0; x < canvas.Screen.Width; x++) { if (startTiles[x, y].HasValue && endTiles[x, y].HasValue && startTiles[x, y].Value != endTiles[x, y].Value) { changes.Add(new TileChange(canvas.Screen, x, y, startTiles[x, y].Value, endTiles[x, y].Value)); } } } canvas.Screen.SetSelection(0, 0, 0, 0); }
private void Flood(ScreenCanvas canvas, int tile_x, int tile_y, int tile_id, int brush_x, int brush_y) { var selection = canvas.Screen.Selection; if (selection != null) { // only paint inside selection if (!selection.Value.Contains(tile_x, tile_y)) { return; } } var old = canvas.Screen.TileAt(tile_x, tile_y); // checking whether this is already the new tile prevents infinite recursion, but // it can prevent filling a solid area with a brush that uses that same tile if (old == null || old.Id != tile_id || old.Id == _brush.Cells[brush_x][brush_y].tile.Id) { return; } _brush.DrawOn(canvas.Screen, tile_x, tile_y); changes.Add(new TileChange(canvas.Screen, tile_x, tile_y, tile_id, _brush.Cells[brush_x][brush_y].tile.Id)); Flood(canvas, tile_x - 1, tile_y, tile_id, (brush_x == 0) ? width - 1 : brush_x - 1, brush_y); Flood(canvas, tile_x + 1, tile_y, tile_id, (brush_x == width - 1) ? 0 : brush_x + 1, brush_y); Flood(canvas, tile_x, tile_y - 1, tile_id, brush_x, (brush_y == 0) ? height - 1 : brush_y - 1); Flood(canvas, tile_x, tile_y + 1, tile_id, brush_x, (brush_y == height - 1) ? 0 : brush_y + 1); }
public GameController() { GameStatus = GameMode.Prep; _lastDrawn = false; ActionSounds.SoundTriggered += PlaySound; _screenCanvas = new ScreenCanvas(new Rectangle()); }
public void Click(ScreenCanvas surface, Point location) { tx1 = location.X / surface.Screen.Tileset.TileSize; ty1 = location.Y / surface.Screen.Tileset.TileSize; tx2 = tx1; ty2 = ty1; held = true; }
private void SetSelection(ScreenCanvas surface) { surface.Screen.SetSelection( Math.Min(tx1, tx2), Math.Min(ty1, ty2), Math.Abs(tx2 - tx1), Math.Abs(ty2 - ty1) ); }
public void Click(ScreenCanvas canvas, Point location) { var screen = canvas.Screen; changes = new List <TileChange>(); Point tilePos = new Point(location.X / screen.Tileset.TileSize, location.Y / screen.Tileset.TileSize); var selection = screen.Selection; if (selection != null) { // only paint inside selection if (!selection.Value.Contains(tilePos)) { startTiles = null; endTiles = null; return; } } startTiles = new int?[screen.Width, screen.Height]; endTiles = new int?[screen.Width, screen.Height]; // check for line drawing if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { var xdist = Math.Abs(tilePos.X - currentTilePos.X); var ydist = Math.Abs(tilePos.Y - currentTilePos.Y); if (xdist >= ydist) { var min = Math.Min(currentTilePos.X, tilePos.X); var max = Math.Max(currentTilePos.X, tilePos.X); for (int i = min; i <= max; i++) { Draw(screen, i, currentTilePos.Y); } } else { var min = Math.Min(currentTilePos.Y, tilePos.Y); var max = Math.Max(currentTilePos.Y, tilePos.Y); for (int i = min; i <= max; i++) { Draw(screen, currentTilePos.X, i); } } } else { Draw(screen, tilePos.X, tilePos.Y); held = true; } currentTilePos = tilePos; }
public void Click(ScreenCanvas canvas, Common.Geometry.Point location) { _dragging = true; _dragAnchorOffset = new Vector(location.X, location.Y); canvas.CaptureMouse(); Canvas.SetZIndex(canvas, 100); }
public void Move(ScreenCanvas surface, Point location) { if (held) { tx2 = (int)Math.Round(location.X / (float)surface.Screen.Tileset.TileSize); ty2 = (int)Math.Round(location.Y / (float)surface.Screen.Tileset.TileSize); SetSelection(surface); } }
public void RightClick(ScreenCanvas canvas, Point location) { var i = canvas.Screen.FindEntityAt(location); if (i >= 0) { var e = canvas.Screen.GetEntity(i); canvas.Screen.RemoveEntity(e); canvas.Screen.Stage.PushHistoryAction(new RemoveEntityAction(e, canvas.Screen)); } }
/// <summary> /// Creates a new instance of <see cref="GameController"/>. /// </summary> public GameController() { GameStatus = GameMode.Prep; _lastDrawn = false; Sounds.ActionSounds.SoundTriggered += PlaySound; _screenCanvas = new ScreenCanvas(new Rectangle()); _textManager = new TextManager(_screenCanvas); _scoreManager = new ScoreManager(_textManager); _currentTitle = new TitleScreen(_textManager, _screenCanvas); }
public void Release(ScreenCanvas canvas, Point location) { var args = new TestLocationSelectedEventArgs() { Screen = canvas.Screen.Name, X = location.X, Y = location.Y }; ViewModelMediator.Current.GetEvent <TestLocationSelectedEventArgs>().Raise(this, args); }
public void Release(ScreenCanvas canvas, Point location) { if (startTiles == null) { return; } held = false; canvas.Screen.Stage.PushHistoryAction(new DrawAction("Brush", changes)); }
public void RightClick(ScreenCanvas surface, Point location) { int tile_x = location.X / surface.Screen.Tileset.TileSize; int tile_y = location.Y / surface.Screen.Tileset.TileSize; var tile = surface.Screen.TileAt(tile_x, tile_y); ViewModelMediator.Current.GetEvent <TileSelectedEventArgs>().Raise(this, new TileSelectedEventArgs() { Tile = tile }); }
internal AsteroidsGame() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; _gameState = GameState.Init; _screenCanvas = new ScreenCanvas(); _score = new Score(); _currTitle = new TitleScreen(); _population = new Population(this, 20); this.IsFixedTimeStep = true; }
public void Click(ScreenCanvas canvas, Point location) { int tile_x = location.X / canvas.Screen.Tileset.TileSize; int tile_y = location.Y / canvas.Screen.Tileset.TileSize; var old = canvas.Screen.TileAt(tile_x, tile_y); Flood(canvas, tile_x, tile_y, old.Id, 0, 0); canvas.Screen.Stage.PushHistoryAction(new DrawAction("Fill", changes)); changes.Clear(); }
public void Release(ScreenCanvas canvas, Common.Geometry.Point location) { _dragging = false; canvas.ReleaseMouseCapture(); Canvas.SetZIndex(canvas, 1); ViewModelMediator.Current.GetEvent <LayoutScreenDroppedEventArgs>().Raise(canvas, new LayoutScreenDroppedEventArgs() { Canvas = canvas }); }
public void Click(ScreenCanvas canvas, Point location) { var placement = new Common.EntityPlacement() { entity = _entity.Name, direction = Common.Direction.Unknown, screenX = location.X, screenY = location.Y }; canvas.Screen.AddEntity(placement); canvas.Screen.Stage.PushHistoryAction(new AddEntityAction(placement, canvas.Screen)); }
public void Draw(ScreenCanvas screenCanvas, int width, int height) { if (_letterSize > 1000 || _letterSize < 40) { _increment = -_increment; if (_letterSize < 40) { _title = _title != "GAME OVER" ? "GAME OVER" : "ASTEROIDS"; } } _letterSize += _increment; screenCanvas.AddText(_title, Justify.Center, 3750 - _letterSize, _letterSize, _letterSize * 2, width, height); _asteroids.Move(); _asteroids.Draw(screenCanvas, width, height); }
public void Move(ScreenCanvas canvas, Point location) { var screen = canvas.Screen; if (!held) { return; } Point pos = new Point(location.X / screen.Tileset.TileSize, location.Y / screen.Tileset.TileSize); if (pos == currentTilePos) { return; // don't keep drawing on the same spot } Draw(screen, pos.X, pos.Y); }
private void GetComponentsOnScene() { _pauseMenuPanel = ScreenCanvas.GetComponentsInChildren <Image>() .Single(c => c.name == "PauseMenu"); _timeoutText = ScreenCanvas.GetComponentsInChildren <Text>() .Single(c => c.name == "TimeoutText"); _currentPlayerText = ScreenCanvas.GetComponentsInChildren <Text>() .Single(c => c.name == "CurrentPlayerText"); _chargeMeterSlider = ScreenCanvas.GetComponentsInChildren <Slider>() .Single(c => c.name == "ChargeMeterSlider"); _highlightBg = ScreenCanvas.GetComponentsInChildren <RawImage>() .Single(c => c.name == "Tank Highlight BG"); _weaponSpriteRenderer = ScreenCanvas.GetComponentsInChildren <Image>() .Single(c => c.name == "Weapon Circle") .GetComponentInChildren <SpriteRenderer>(); }
private void Draw(ScreenCanvas surface, int tile_x, int tile_y) { // first track the changes i'm going to make for undo purposes foreach (TileBrushCell cell in brush.Cells.SelectMany(c => c)) { int tx = cell.x + tile_x; int ty = cell.y + tile_y; if (tx < 0 || tx >= surface.Screen.Width || ty < 0 || ty >= surface.Screen.Height) { continue; } if (startTiles[tx, ty] == null) // don't overwrite existing data { startTiles[tx, ty] = surface.Screen.TileAt(tx, ty).Id; } endTiles[tx, ty] = cell.tile.Id; } brush.DrawOn(surface.Screen, tile_x, tile_y); }
/// <summary> /// Creates a new instance of <see cref="TextManager"/>. /// </summary> /// <param name="canvas"><see cref="ScreenCanvas"/> to draw text on.</param> public TextManager(ScreenCanvas canvas) { _screenCanvas = canvas; }
public void Click(ScreenCanvas canvas, Point location) { }
public void Move(ScreenCanvas canvas, Point location) { }
/// <summary> /// Creates a new instance of <see cref="DrawingManager"/> /// </summary> /// <param name="cache">Screen object cache to draw.</param> /// <param name="canvas">Canvas to draw cache to.</param> public DrawingManager(CacheManager cache, ScreenCanvas canvas) { _cache = cache; _canvas = canvas; }
public void RightClick(ScreenCanvas canvas, Common.Geometry.Point location) { }
public void Release(ScreenCanvas canvas, Point location) { canvas.Screen.Stage.AddContinuePoint(canvas.Screen, location); }
public void Release(ScreenCanvas canvas, Point location) { }
public void Release(ScreenCanvas canvas, Point location) { int tilePosX = location.X / canvas.Screen.Tileset.TileSize; canvas.Screen.CleaveVertically(tilePosX); }