public Monster(long ID, Type type, PolarCoordinates position, double life)
 {
     this.ID = ID;
     this.MonsterType = type;
     this.Position = position;
     this.Life = life;
 }
 private void ProjectileMoved(long projectileID, PolarCoordinates position)
 {
     _renderer.MessageBox.Add(Renderer.Message.ProjectileMoved(projectileID, position));
 }
 private void MonsterMoved(long monsterID, PolarCoordinates position)
 {
     _renderer.MessageBox.Add(Renderer.Message.MonsterMoved(monsterID, position));
 }
 public static bool PolarDistanceLessThan(PolarCoordinates a, PolarCoordinates b, double ε)
 {
     if (Math.Abs(a.R - b.R) >= ε) return false;
     return PolarDistance(a, b) < ε;
 }
 public static double PolarDistance(PolarCoordinates a, PolarCoordinates b)
 {
     return Math.Sqrt(a.R * a.R + b.R * b.R - 2 * a.R * b.R * Math.Cos(a.φ - b.φ));
 }
        private Point CoordinateTransformation(PolarCoordinates point)
        {
            var r = point.R * _radialScale;

            return new Point(r * Math.Cos(point.φ) + _width / 2, r * Math.Sin(point.φ) + _height / 2);
        }
 private void ProjectileMoved(long fieldObjectID, PolarCoordinates fieldObjectNewPosition)
 {
     _projectiles[fieldObjectID].Position = CoordinateTransformation(fieldObjectNewPosition);
 }
 private void newProjectile(long fieldObjectID, int fieldObjectLevel, PolarCoordinates fieldObjectNewPosition)
 {
     _projectiles.Add(fieldObjectID, new FieldObject() { Level = fieldObjectLevel, Position = CoordinateTransformation(fieldObjectNewPosition) });
 }
 private void NewMonster(long fieldObjectID, int fieldObjectType, PolarCoordinates fieldObjectNewPosition)
 {
     _monsters.Add(fieldObjectID, new FieldObject() { ObjectType = fieldObjectType, Position = CoordinateTransformation(fieldObjectNewPosition) });
 }
 private void newGun(long fieldObjectID, int fieldObjectType, int fieldObjectLevel, PolarCoordinates fieldObjectNewPosition)
 {
     _guns.Add(fieldObjectID, new FieldObject() { ObjectType = fieldObjectType, Level = fieldObjectLevel, Position = CoordinateTransformation(fieldObjectNewPosition) });
 }
 private void MonsterMoved(long fieldObjectID, PolarCoordinates fieldObjectNewPosition)
 {
     _monsters[fieldObjectID].Position = CoordinateTransformation(fieldObjectNewPosition);
 }
        /// <summary>
        /// Handler for mouse click.
        /// Sends request for new gun to game logic thread.
        /// </summary>
        private void window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!_selectingGunPlace) return;

            var screenPosition = e.GetPosition(contentGrid);
            screenPosition.X -= Gun.Radius * _radialScale;
            screenPosition.Y -= Gun.Radius * _radialScale;

            var p = (screenPosition - new Point(contentGrid.ActualWidth / 2, contentGrid.ActualHeight / 2)) / _radialScale;
            var polarCoordinates = new PolarCoordinates(Math.Sqrt(p.X * p.X + p.Y * p.Y), Math.Atan2(p.Y, p.X));
            if (polarCoordinates.φ < 0)
                polarCoordinates.φ += 2 * Math.PI;

            _logic.MessageBox.Add(GameLogic.Message.NewGun(_selectedGun.Type, _selectedGun.Level, polarCoordinates));
        }