Exemplo n.º 1
0
 public VisibleSectorsStrategyAll(SectorManagerUnity sectorManagerUnity, SectorManager sectorManager)
 {
     foreach (Sector sector in sectorManager.sectors)
     {
         sectorManagerUnity.GetSectorUnityFromCache(sector);
     }
 }
        public override void Update()
        {
            TilePosition playerTilePosition = Graphics.Vector3ToTilePosition(player.position);

            Sector playerSector = sectorManager.GetSectorTile(playerTilePosition);

            if (playerSector != currentPlayerSector)
            {
                currentPlayerSector = playerSector;

                List <Sector> newVisibleVectors = FindSectorsNearPlayer();

                //Disable sectors far away
                for (int i = visibleSectors.Count - 1; i >= 0; i--)
                {
                    Sector sector = visibleSectors[i];

                    int pos = newVisibleVectors.IndexOf(sector);

                    if (pos < 0)
                    {
                        sectorManagerUnity.ReturnSectorUnityToCache((SectorUnity)sector.GetSectorGraphics());
                        visibleSectors.RemoveAt(i);
                    }
                    else
                    {
                        newVisibleVectors.RemoveAt(pos);
                    }
                }

                //Enable sectors near
                for (int i = newVisibleVectors.Count - 1; i >= 0; i--)
                {
                    Sector sector = newVisibleVectors[i];

                    visibleSectors.Add(sector);

                    sectorManagerUnity.GetSectorUnityFromCache(sector);
                }
            }
        }
 public VisibleSectorsStrategyAll(SectorManagerUnity sectorManagerUnity, SectorManager sectorManager)
 {
     foreach (Sector sector in sectorManager.sectors)
         sectorManagerUnity.GetSectorUnityFromCache(sector);
 }