Esempio n. 1
0
        public int CanPlace(int i, int j, int type, int style, int direction)
        {
            int count = 0;

            if (GetTileEntity() != null && GetTileEntity() is TEStorageCenter)
            {
                count++;
            }

            Point16           startSearch = new Point16(i - 1, j - 1);
            HashSet <Point16> explored    = new HashSet <Point16>();

            explored.Add(startSearch);
            Queue <Point16> toExplore = new Queue <Point16>();

            foreach (Point16 point in TEStorageComponent.AdjacentComponents(startSearch))
            {
                toExplore.Enqueue(point);
            }

            while (toExplore.Count > 0)
            {
                Point16 explore = toExplore.Dequeue();
                if (!explored.Contains(explore) && explore != killTile)
                {
                    explored.Add(explore);
                    if (TEStorageCenter.IsStorageCenter(explore))
                    {
                        count++;
                        if (count >= 2)
                        {
                            return(-1);
                        }
                    }
                    foreach (Point16 point in TEStorageComponent.AdjacentComponents(explore))
                    {
                        toExplore.Enqueue(point);
                    }
                }
            }
            return(count);
        }