예제 #1
0
        public static string[] PlacePiece(Ships placeShip, string name)
        {
            string[] placement = new string[8];
            Console.WriteLine("{0}, please enter the X coordinate for your {1}", name, placeShip.shipName);
            placement[0] = Console.ReadLine();
            Console.WriteLine("{0}, please enter the Y coordinate for your {1}", name, placeShip.shipName);
            placement[1] = Console.ReadLine();
            placement[0].ToUpper();

            return(placement);
        }
예제 #2
0
        public int Attack(int x, int y, Players Enemy)
        {
            Maps EnemyMap = Enemy.GetMyShipMap();

            if (!EnemyMap.IsCoordinateValid(x, 0, EnemyMap.GetMapLenght()))
            {
                return(-1);
            }
            if (!EnemyMap.IsCoordinateValid(y, 0, EnemyMap.GetMapHight()))
            {
                return(-1);
            }
            this.CurrGame.PlaySound(0, false);
            Enemy.SetLastShoot(x, y);
            Ships DestinationShip = Enemy.GetShipOnMapPos(x, y);

            if (DestinationShip != null)
            {
                DestinationShip.DetectImpact(x, y, EnemyMap, this.AttackMap);
                if (DestinationShip.GetIsSunken())
                {
                    this.CurrGame.PlaySound(4, false);
                    return(2);
                }
                this.CurrGame.PlaySound(1, false);
                return(1);
            }
            else
            {
                this.AttackMap.SetMapField(x, y, 'W');
                EnemyMap.SetMapField(x, y, 'W');
                this.CurrGame.PlaySound(2, false);
                return(0);
            }
            return(0);
        }