public Tank(EntityPosition position, Player player) : base(position, DefaultSpeed) { this.Player = player; SetCollisionDistanceX(50); SetCollisionDistanceY(50); }
public Entity(EntityPosition position, double collisionDistanceX, double collisionDistanceY) { this.Id = Guid.NewGuid(); this.Position = position; SetCollisionDistanceX(collisionDistanceX); SetCollisionDistanceY(collisionDistanceY); }
public Wall(EntityPosition position, double width, double height) : base(position) { this.Width = width; this.Height = height; this.SetCollisionDistanceX(width); this.SetCollisionDistanceY(height); }
private EntityPosition GetProjectileLaunchPosition() { EntityPosition retVal = new EntityPosition(0, 0); switch (Orientation) { case EntityOrientation.Right: retVal.PosX = this.Position.PosX + CollisionDistanceX; retVal.PosY = this.Position.PosY + CollisionDistanceY / 2 - 3; break; case EntityOrientation.DownRight: retVal.PosX = this.Position.PosX + CollisionDistanceX - 7; retVal.PosY = this.Position.PosY + CollisionDistanceY - 7; break; case EntityOrientation.Down: retVal.PosX = this.Position.PosX + CollisionDistanceX / 2 - 5; retVal.PosY = this.Position.PosY + CollisionDistanceY; break; case EntityOrientation.DownLeft: retVal.PosX = this.Position.PosX - 3; retVal.PosY = this.Position.PosY + CollisionDistanceY - 4; break; case EntityOrientation.Left: retVal.PosX = this.Position.PosX - 7; retVal.PosY = this.Position.PosY + CollisionDistanceY / 2 - 2; break; case EntityOrientation.UpLeft: retVal.PosX = this.Position.PosX - 2; retVal.PosY = this.Position.PosY; break; case EntityOrientation.Up: retVal.PosX = this.Position.PosX + CollisionDistanceX / 2 - 6; retVal.PosY = this.Position.PosY - 7; break; case EntityOrientation.UpRight: retVal.PosX = this.Position.PosX + CollisionDistanceX - 9; retVal.PosY = this.Position.PosY + 2; break; } return(retVal); }
public EntityCollision Move(EntityOrientation direction, double speed) { this.Orientation = direction; EntityPosition newPosition = new EntityPosition(this.Position.PosX, this.Position.PosY); switch (direction) { case EntityOrientation.Left: newPosition.PosX -= speed; break; case EntityOrientation.UpLeft: newPosition.PosX -= speed / 2; newPosition.PosY -= speed / 2; break; case EntityOrientation.Up: newPosition.PosY -= speed; break; case EntityOrientation.UpRight: newPosition.PosX += speed / 2; newPosition.PosY -= speed / 2; break; case EntityOrientation.Right: newPosition.PosX += speed; break; case EntityOrientation.DownRight: newPosition.PosX += speed / 2; newPosition.PosY += speed / 2; break; case EntityOrientation.Down: newPosition.PosY += speed; break; case EntityOrientation.DownLeft: newPosition.PosX -= speed / 2; newPosition.PosY += speed / 2; break; } Entity collisionEntity = ParentCollection.Items.FirstOrDefault(x => x != this && x.IsColliding(newPosition, this.CollisionDistanceX, this.CollisionDistanceY)); if (collisionEntity != null) { if (this is Projectile) { if (((Projectile)this).IsValidCollision(collisionEntity)) { return(new EntityCollision(collisionEntity)); } } else { return(new EntityCollision(collisionEntity)); } } this.Position.PosX = newPosition.PosX; this.Position.PosY = newPosition.PosY; return(null); }
public MovableEntity(EntityPosition position, double speed) : base(position) { this.Speed = speed; }
public Entity(EntityPosition position) : this(position, 0, 0) { }
public Projectile(EntityPosition position, Tank owner) : base(position, DefaultSpeed) { this.Owner = owner; }