예제 #1
0
        private int ShowSphere(int x, int y, int effect)
        {
            int minX = To.GetX() - 1;
            int maxX = To.GetX() + 1;

            int minY = To.GetY() - 1;
            int maxY = To.GetY() + 1;

            if (x >= minX && x <= maxX && y >= minY && y <= maxY)
            {
                return(effect);
            }

            return(0);
        }
예제 #2
0
        public Location GetWithYinline()
        {
            ICoordinate pivot = this.Coordinates.ElementAt(2);

            IEnumerable <ICoordinate> coordinates = new List <ICoordinate>()
            {
                new Coordinate(pivot.GetX() - 2, pivot.GetY()),
                new Coordinate(pivot.GetX() - 1, pivot.GetY()),
                new Coordinate(pivot.GetX(), pivot.GetY()),
                new Coordinate(pivot.GetX() + 1, pivot.GetY()),
                new Coordinate(pivot.GetX() + 2, pivot.GetY())
            };

            return(new Location(coordinates));
        }
예제 #3
0
        private ICoordinate GetNewMissilePosition()
        {
            int newX = GetNewPosition(Missile.GetX(), To.GetX());
            int newY = GetNewPosition(Missile.GetY(), To.GetY());

            return(new Coordinate(newX, newY));
        }
예제 #4
0
        public bool CanInclude(ICoordinate position)
        {
            int x = position.GetX(), y = position.GetY();

            if (x > -1 && y > -1 && x < xSize && y < ySize)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        private ICoordinate TakeShot(Tuple <IKanon, IRadar> weaponcombi)
        {
            IRadar radar = weaponcombi.Item2;
            IKanon canon = weaponcombi.Item1;

            if (radar != null)
            {
                ICoordinate givenTarget = GetRandomShipCoordinate();
                ICoordinate target      = radar.Parse(givenTarget.GetX(), givenTarget.GetY());

                return(canon.Fire(target));
            }

            else
            {
                return(canon.Fire());
            }
        }
예제 #6
0
 public static bool AreSame(ICoordinate a, ICoordinate b)
 {
     return(a.GetX() == b.GetX() &&
            a.GetY() == b.GetY());
 }
예제 #7
0
        private ICoordinate MoveWest(ICoordinate from)
        {
            var to = new Coordinate(from.GetX() - 1, from.GetY());

            return(to);
        }
예제 #8
0
        private ICoordinate MoveSouth(ICoordinate from)
        {
            var to = new Coordinate(from.GetX(), from.GetY() + 1);

            return(to);
        }
 // Omdat de interface al is vrijgegeven deze methode hier opnemen
 // Hoort in de ICoordinate-interface thuis: Equals
 private bool AreSame(ICoordinate a, ICoordinate b)
 {
     return(a.GetX() == b.GetX() &&
            a.GetY() == b.GetY());
 }
예제 #10
0
 void Move(ICoordinate to)
 {
     x = to.GetX();
     y = to.GetY();
     z = to.GetZ();
 }
예제 #11
0
 public bool Equal(ICoordinate coordinate)
 {
     return(x == coordinate.GetX() && y == coordinate.GetY());
 }