public GameMap() { map = new GameCell[Settings.fieldSize.X, Settings.fieldSize.Y]; for (byte x = 0; x < map.GetLength(0); ++x) { for (byte y = 0; y < map.GetLength(1); ++y) { map[x, y] = new GameCell(); } } camPos = new CoordReal(Settings.camStartPos); }
public void FireAt(double x, double y) { foreach (var hero in body) { CoordReal heroPos = new CoordReal { X = Canvas.GetLeft(hero.image) + hero.image.DesiredSize.Width / 2, Y = Canvas.GetTop(hero.image) + hero.image.DesiredSize.Height / 2, }; double angle = Math.Atan2(y - heroPos.Y, x - heroPos.X) - Math.Atan2(0, 1); angle = (angle * 180.0 / 3.14159); hero.Shoot(angle, heroPos); } }
public Bullet(string path, double angle, CoordReal shootPos, byte speed) { pos = new CoordReal(shootPos); this.speed = speed; this.angle = angle; image = new Image(); image.LoadImg(path); image.RenderTransformOrigin = new Point(0.5, 0.5); image.RenderTransform = new RotateTransform(angle); Settings.gameWindow.GameCanvas.Children.Add(image); Canvas.SetZIndex(image, 10); Canvas.SetLeft(image, pos.X); Canvas.SetTop(image, pos.Y); Settings.game.bullets.Add(this); }
public override Bullet Shoot(double angle, CoordReal shootPos) { return(new Bullet("hero\\ghostBullet", angle, shootPos, 5)); }
abstract public Bullet Shoot(double angle, CoordReal shootPos);