コード例 #1
0
        public void Update()
        {
            HashSet <GameObject> visibleNow = FogOfWarUtility.GetVisibleObjects(players);

            visibleObjetcs.RemoveWhere((GameObject go) =>
            {
                return(go == null);
            });

            foreach (GameObject gameObject in visibleObjetcs)
            {
                if (!visibleNow.Contains(gameObject))
                {
                    if (gameObject.GetComponent <INonExplorable>() == null)
                    {
                        MapObject mapObject = gameObject.GetComponent <MapObject>();
                        switch (mapObject.mapObjectType)
                        {
                        case MapObjectType.Station:
                            StationScout removeStation = null;
                            foreach (StationScout stationScout in knowScoutedStations)
                            {
                                if (stationScout.mapObjectId == mapObject.id)
                                {
                                    removeStation = stationScout;
                                    break;
                                }
                            }
                            if (removeStation != null)
                            {
                                knowScoutedStations.Remove(removeStation);
                            }
                            break;

                        case MapObjectType.Asteroid:
                            AsteroidScout removeAsteroid = null;
                            foreach (AsteroidScout asteroidScout in knowScoutedAsteroids)
                            {
                                if (asteroidScout.mapObjectId == mapObject.id)
                                {
                                    removeAsteroid = asteroidScout;
                                    break;
                                }
                            }
                            if (removeAsteroid != null)
                            {
                                knowScoutedAsteroids.Remove(removeAsteroid);
                            }
                            break;
                        }
                    }
                }
            }

            visibleObjetcs = visibleNow;
        }
コード例 #2
0
    private IEnumerator RenderEnumerator()
    {
        while (true)
        {
            ICollection <GameObject> visibleNow = FogOfWarUtility.GetVisibleObjects(players);

            foreach (GameObject gameObject in visibleObjects)
            {
                if (gameObject != null && !visibleNow.Contains(gameObject))
                {
                    if (gameObject.GetComponent <INonExplorable>() == null)
                    {
                        MapObject mapObject = gameObject.GetComponent <MapObject>();
                        switch (mapObject.mapObjectType)
                        {
                        case MapObjectType.Station:
                            StationController stationController = gameObject.GetComponent <StationController>();
                            GameObject        station           = Spawner.Instance.SpawnDummyStation(stationController.stationType, stationController.Station, gameObject.transform.position, gameObject.transform.rotation, stationController.constructionProgress, true);
                            dummyRealGameObjectAssociations.Add(new DummyRealGameObjectAssociation(gameObject, station));
                            break;

                        case MapObjectType.Asteroid:
                            AsteroidController asteroidController = gameObject.GetComponent <AsteroidController>();
                            GameObject         asteroid           = Spawner.Instance.SpawnDummyAsteroid(asteroidController.prefabIndex, asteroidController.resourceType, asteroidController.ResourceQuantity, gameObject.transform.position, gameObject.transform.rotation, true);
                            dummyRealGameObjectAssociations.Add(new DummyRealGameObjectAssociation(gameObject, asteroid));
                            break;
                        }
                    }

                    FogOfWarUtility.SetRendering(false, gameObject);
                }
            }

            foreach (GameObject gameObject in visibleNow)
            {
                if (!visibleObjects.Contains(gameObject))
                {
                    FogOfWarUtility.SetRendering(true, gameObject);
                    //if(dummyRealGameObjectAssociations.Conta)

                    dummyRealGameObjectAssociations.RemoveWhere((DummyRealGameObjectAssociation drgoa) =>
                    {
                        bool remove = drgoa.real.Equals(gameObject);
                        if (remove)
                        {
                            Destroy(drgoa.dummy);
                        }
                        return(remove);
                    });
                }
            }

            dummyRealGameObjectAssociations.RemoveWhere((DummyRealGameObjectAssociation drgoa) =>
            {
                bool remove = drgoa.real == null;
                if (remove)
                {
                    Destroy(drgoa.dummy);
                }
                return(remove);
            });

            visibleObjects = visibleNow;

            dummyRealGameObjectAssociations.RemoveWhere((DummyRealGameObjectAssociation drgoa) =>
            {
                bool remove = drgoa.real.Equals(gameObject);
                if (remove)
                {
                    Destroy(drgoa.dummy);
                }
                return(remove);
            });
            yield return(null);

            yield return(null);

            yield return(null);
        }
    }