Exemplo n.º 1
0
        }//YIELD RETURN!!!

        public static IEnumerable <Point> GetPointsToCheck(Ship sender, Point senderPoint)
        {
            //Metoda wykorzystywana w NPCShip.CheckCollisionsWithOthers()

            Cell checkCell = null;

            for (int i = 0; i < 100; i++)
            {
                int k = i / 10;
                int l = i % 10;

                if (Map.Cells[k, l].IsInTheCell(senderPoint))
                {
                    checkCell = Map.Cells[k, l];
                    break;
                }
            }

            for (int i = 0; i < Ships.Count; i++)
            {
                if (Ships[i] != sender)
                {
                    for (int j = 0; j < Ships[i].body.Count; j++)
                    {
                        BodyPiece bp = Ships[i].body[j];
                        if (checkCell.IsInTheCell(bp.location))
                        {
                            yield return(bp.location);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static IEnumerable <Point> GetPointsToCheck(Ship sender)
        {
            // Point sender, a nie Ship sender, bo w przypadku sprawdzania promieni, można
            // dostać złą listę punktów. Promień i głowa mogą znajdować się w innej komórce
            // mapy, przez co pewne punkty mogą zostać niesprawdzone.

            Cell checkCell = null;

            for (int i = 0; i < 100; i++)
            {
                int k = i / 10;
                int l = i % 10;

                if (Map.Cells[k, l].IsInTheCell(sender.Location))
                {
                    checkCell = Map.Cells[k, l];
                    break;
                }
            }


            for (int i = 0; i < Ships.Count; i++)
            {
                if (Ships[i] != sender)
                {
                    for (int j = 0; j < Ships[i].body.Count; j++)
                    {
                        BodyPiece bp = Ships[i].body[j];
                        if (checkCell.IsInTheCell(bp.location))
                        {
                            yield return(bp.location);
                        }
                    }
                }
            }

            /*foreach (Ship s2 in Ships)
             * {
             *  if (s2 != sender)
             *  {
             *      for (int i = 0; i < s2.body.Count; i++)
             *      {
             *          BodyPiece bp = s2.body[i];
             *          if (checkCell.IsInTheCell(bp.location))
             *              yield return bp.location;
             *      }
             *  }
             * }*/
        }//YIELD RETURN!!!