public void Add(Ship ship) { if (Ships.TryAdd(ship.Player.ConnectionId, ship)) { collisionManager.Add(ship); } }
public ShipMovement(Ship ship, Vector2 position) { this.ship = ship; Position = position; Velocity = Vector2.Zero; Acceleration = Vector2.Zero; Rotation = 0.0f; }
public Bullet(Vector2 position, Vector2 velocity, Ship ship) : base() { Id = Interlocked.Increment(ref idCounter); Movement = new BulletMovement(position, velocity); Radius = 10.0f; Ship = ship; createdAt = DateTime.Now; }
public int AddPlayer(string connectionId) { Ship ship = new Ship(new Vector2(random.Next(worldWidth) - worldWidth / 2, random.Next(worldHeight) - worldHeight / 2), bulletManager); Player player = new Player(connectionId, ship); PlayerManager.Add(player); shipManager.Add(ship); return ship.Id; }
public Player(string connectionId, Ship ship) { ConnectionId = connectionId; Ship = ship; if (ship != null) { ship.Player = this; } }
private object[] Compress(Ship ship) { object[] compressedShip = new object[10]; compressedShip[0] = ship.Id; compressedShip[1] = ship.Movement.Position.X; compressedShip[2] = ship.Movement.Position.Y; compressedShip[3] = ship.Movement.Velocity.X; compressedShip[4] = ship.Movement.Velocity.Y; compressedShip[5] = ship.Movement.Acceleration.X; compressedShip[6] = ship.Movement.Acceleration.Y; compressedShip[7] = ship.Movement.Rotation; compressedShip[8] = ship.Alive; compressedShip[9] = ship.Health; return compressedShip; }
public ShipWeapons(Ship ship, BulletManager bulletManager) { lastBulletFiredAt = DateTime.Now; this.ship = ship; this.bulletManager = bulletManager; }