コード例 #1
0
        private void ProcessShot(Sea sea, Position shot)
        {
            List <Ship> fleet = new List <Ship>();

            if (sea is BootSea)
            {
                fleet = robotShips;
            }
            else
            {
                fleet = playerShips;
            }


            bool isShip = sea.RespondToHit(shot);

            if (isShip)
            {
                foreach (Ship ship in fleet)
                {
                    foreach (Position position in ship.GetBody())
                    {
                        if (position.Equals(shot))
                        {
                            bool destoroyed = ship.RespondToHit(shot);
                            if (destoroyed)
                            {
                                if (sea is BootSea)
                                {
                                    robotFleet++;
                                }
                                else
                                {
                                    playerFleet++;
                                }
                            }
                        }
                    }
                }
                //    foreach (Gift gift in robotGifts)
                //    {
                //        if (gift.StartPosition.Equals(playerShotPosition))
                //        {
                //            gift.RespondToHit();
                //        }
                //    }
            }
        }