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();
 }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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;
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
 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();
 }
예제 #8
0
 public Bitmap Display(IShipTypeVisitor shipTypeVisitor, FlyingDirection direction)
 {
     return(shipTypeVisitor.Visit(this, direction));
 }
예제 #9
0
 public void Fly(FlyingDirection direction)
 {
     Fly(_currentFlyingAlorithm, direction);
     CurrentDirection = direction;
 }