public void Move(ref int x, ref int y, FlyingDirection previousDir, FlyingDirection newDir, ref int speed) { if (previousDir == newDir) { if (newDir == FlyingDirection.Up) { y += (int)speed; } else if (newDir == FlyingDirection.Down) { y -= (int)speed; } else if (newDir == FlyingDirection.Right) { x += (int)speed; } else if (newDir == FlyingDirection.Left) { x -= (int)speed; } speed++; } else { speed = 0; } NotifyOtherDestroyers(); }
public Bitmap Visit(Destroyers.BigShip bigShip, FlyingDirection direction) { ShipL = ProxyImageFactory.GetProxyImage(@"..\..\Images\bigShipL.png"); ShipB = ProxyImageFactory.GetProxyImage(@"..\..\Images\bigShipB.png"); ShipF = ProxyImageFactory.GetProxyImage(@"..\..\Images\bigShipF.png"); ShipR = ProxyImageFactory.GetProxyImage(@"..\..\Images\bigShipR.png"); return(DirectionSwitcher(direction)); }
public Bitmap Visit(Rangers.SmallShip smallShip, FlyingDirection direction) { ShipL = ProxyImageFactory.GetProxyImage(@"..\..\Images\smallShipL.png"); ShipB = ProxyImageFactory.GetProxyImage(@"..\..\Images\smallShipB.png"); ShipF = ProxyImageFactory.GetProxyImage(@"..\..\Images\smallShipF.png"); ShipR = ProxyImageFactory.GetProxyImage(@"..\..\Images\smallShipR.png"); return(DirectionSwitcher(direction)); }
private void Fly(FlyAlgorithm algorithm, FlyingDirection newDirection) { int X = CoordinateX; int Y = CoordinateY; int S = Speed; algorithm.Move(ref X, ref Y, CurrentDirection, newDirection, ref S); CoordinateX = X; CoordinateY = Y; Speed = S; }
public Bitmap GetShipByType(int maxSpeed, FlyingDirection direction) { switch (maxSpeed) { case 50: IShipType smallShipType = new Visitor.Rangers.SmallShip(); return(smallShipType.Display(new ShipTypeDisplayVisitor(), direction)); case 30: IShipType mediumShipType = new Visitor.Destroyers.MediumShip(); return(mediumShipType.Display(new ShipTypeDisplayVisitor(), direction)); case 20: IShipType bigShipType = new Visitor.Destroyers.BigShip(); return(bigShipType.Display(new ShipTypeDisplayVisitor(), direction)); } return(null); }
private Bitmap DirectionSwitcher(FlyingDirection direction) { switch (direction) { case FlyingDirection.Left: return(ShipL.GetImage()); case FlyingDirection.Up: return(ShipF.GetImage()); case FlyingDirection.Right: return(ShipR.GetImage()); case FlyingDirection.Down: return(ShipB.GetImage()); default: return(null); } }
public void Move(ref int x, ref int y, FlyingDirection previousDir, FlyingDirection newDir, ref int speed) { if (newDir == FlyingDirection.Up) { y -= 5; } else if (newDir == FlyingDirection.Down) { y += 5; } else if (newDir == FlyingDirection.Right) { x += 10; } else if (newDir == FlyingDirection.Left) { x -= 10; } NotifyOtherDestroyers(); }
public Bitmap Display(IShipTypeVisitor shipTypeVisitor, FlyingDirection direction) { return(shipTypeVisitor.Visit(this, direction)); }
public void Fly(FlyingDirection direction) { Fly(_currentFlyingAlorithm, direction); CurrentDirection = direction; }