Exemplo n.º 1
0
    void Search()
    {
        searchedOutput_ObjectDock = new ObjectDock[]{};
        searchedOutput_SpawnNPC = new SpawnNPC[]{};

        ObjectDock[] AllObjectDocks = Util.ConvertObjectArray<ObjectDock> (Object.FindObjectsOfType (typeof(ObjectDock)));
        SpawnNPC[] AllSpawnNPC = Util.ConvertObjectArray<SpawnNPC> (Object.FindObjectsOfType (typeof(SpawnNPC)));
        GameEventLifeCycle[] AllGameEventLifecycle = Util.ConvertObjectArray<GameEventLifeCycle> (Object.FindObjectsOfType(typeof(GameEventLifeCycle)));

        ObjectDock[] SearchedOutObjectDocksByEventType = new ObjectDock[]{};
        SpawnNPC[] SearchedOutSpawnNPCByEventType = new SpawnNPC[]{};
        GameEventLifeCycle[] SearchedOutGameEventLifeCycleByEventType = new GameEventLifeCycle[]{};

        ObjectDock[] SearchedOutObjectDocksByObjectReference = new ObjectDock[]{};
        SpawnNPC[] SearchedOutSpawnNPCByObjectReference = new SpawnNPC[]{};
        GameEventLifeCycle[] SearchedOutGameEventLifeCycleByObjectReference = new GameEventLifeCycle[]{};

        if (IsSearchByEventType) {
            //search every objectdocks, check gameevent type
            IEnumerable<ObjectDock> docks = AllObjectDocks.Where (x =>
                x.objectDockData.Count (y => y.event_at_start.Concat (y.event_at_end.AsEnumerable ()).Count (z => z.type == searchEventType) > 0) > 0
                );
            if (docks != null && docks.Count () > 0) {
                SearchedOutObjectDocksByEventType = docks.ToArray ();
            }
            //search every spawnNPC, check gameevent type
            IEnumerable<SpawnNPC> spawns = AllSpawnNPC.Where (x => x.Event_At_All_Spawned_DieOut.Count (
                y => y.type == searchEventType) > 0);
            if (spawns != null && spawns.Count () > 0) {
                SearchedOutSpawnNPCByObjectReference = spawns.ToArray ();
            }

            //search every gameevent lifecycle, check gameevent type
            IEnumerable<GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where (x =>
                x.eventOnBirth.Count (y => y.type == searchEventType) > 0)
                .Concat(
                    AllGameEventLifecycle.Where (x =>
                x.eventOnDestroy.Count (y => y.type == searchEventType) > 0))
                .Concat(
                    AllGameEventLifecycle.Where (x =>
                x.eventOnUnitDie.Count (y => y.type == searchEventType) > 0));

            if (gameEventLifeCycles != null && gameEventLifeCycles.Count () > 0) {
                SearchedOutGameEventLifeCycleByEventType = gameEventLifeCycles.ToArray ();
            }

            searchedOutput_ObjectDock = SearchedOutObjectDocksByEventType;
            searchedOutput_SpawnNPC = SearchedOutSpawnNPCByObjectReference;
            searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByEventType;
        }

        if (IsSearchByObjectInReceiverField) {
            //search every object dock, check gameevent 's receiver
            IEnumerable<ObjectDock> docks = AllObjectDocks.Where (x =>
                x.objectDockData.Count (y => y.event_at_start.Concat (y.event_at_end.AsEnumerable ()).Count (z => z.receiver == SearchObjectReference) > 0) > 0
                );
            if (docks != null && docks.Count () > 0) {
                SearchedOutObjectDocksByObjectReference = docks.ToArray ();
            }
            //search every spawnNPC, check gameevent 's receiver
            IEnumerable<SpawnNPC> spawns = AllSpawnNPC.Where (x => x.Event_At_All_Spawned_DieOut.Count (
                y => y.receiver == SearchObjectReference) > 0);
            if (spawns != null && spawns.Count () > 0) {
                SearchedOutSpawnNPCByObjectReference = spawns.ToArray ();
            }

            //search every gameevent lifecycle, check gameevent 's receiver
            IEnumerable<GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where (x =>
                x.eventOnBirth.Count (y => y.receiver == SearchObjectReference) > 0)
                .Concat(
                    AllGameEventLifecycle.Where (x =>
                x.eventOnDestroy.Count (y => y.receiver == SearchObjectReference) > 0))
                .Concat(
                    AllGameEventLifecycle.Where (x =>
                x.eventOnUnitDie.Count (y => y.receiver == SearchObjectReference) > 0));
            if (gameEventLifeCycles != null && gameEventLifeCycles.Count () > 0) {
                SearchedOutGameEventLifeCycleByObjectReference = gameEventLifeCycles.ToArray ();
            }

            if (searchedOutput_ObjectDock == null || searchedOutput_ObjectDock.Length == 0) {
                searchedOutput_ObjectDock = SearchedOutObjectDocksByObjectReference;
            } else {
                searchedOutput_ObjectDock = searchedOutput_ObjectDock.Intersect (SearchedOutObjectDocksByObjectReference.AsEnumerable ()).ToArray ();
            }

            if (searchedOutput_SpawnNPC == null || searchedOutput_SpawnNPC.Length == 0) {
                searchedOutput_SpawnNPC = SearchedOutSpawnNPCByObjectReference;
            } else {
                searchedOutput_SpawnNPC = searchedOutput_SpawnNPC.Intersect (SearchedOutSpawnNPCByObjectReference.AsEnumerable ()).ToArray ();
            }

            if (searchedOutput_GameEventLC == null || searchedOutput_GameEventLC.Length == 0) {
                searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByObjectReference;
            } else {
                searchedOutput_GameEventLC = searchedOutput_GameEventLC.Intersect (SearchedOutGameEventLifeCycleByObjectReference.AsEnumerable ()).ToArray ();
            }
        }
    }
Exemplo n.º 2
0
    void Search()
    {
        searchedOutput_ObjectDock = new ObjectDock[] {};
        searchedOutput_SpawnNPC   = new SpawnNPC[] {};

        ObjectDock[]         AllObjectDocks        = Util.ConvertObjectArray <ObjectDock> (Object.FindObjectsOfType(typeof(ObjectDock)));
        SpawnNPC[]           AllSpawnNPC           = Util.ConvertObjectArray <SpawnNPC> (Object.FindObjectsOfType(typeof(SpawnNPC)));
        GameEventLifeCycle[] AllGameEventLifecycle = Util.ConvertObjectArray <GameEventLifeCycle> (Object.FindObjectsOfType(typeof(GameEventLifeCycle)));

        ObjectDock[]         SearchedOutObjectDocksByEventType        = new ObjectDock[] {};
        SpawnNPC[]           SearchedOutSpawnNPCByEventType           = new SpawnNPC[] {};
        GameEventLifeCycle[] SearchedOutGameEventLifeCycleByEventType = new GameEventLifeCycle[] {};

        ObjectDock[]         SearchedOutObjectDocksByObjectReference        = new ObjectDock[] {};
        SpawnNPC[]           SearchedOutSpawnNPCByObjectReference           = new SpawnNPC[] {};
        GameEventLifeCycle[] SearchedOutGameEventLifeCycleByObjectReference = new GameEventLifeCycle[] {};

        if (IsSearchByEventType)
        {
            //search every objectdocks, check gameevent type
            IEnumerable <ObjectDock> docks = AllObjectDocks.Where(x =>
                                                                  x.objectDockData.Count(y => y.event_at_start.Concat(y.event_at_end.AsEnumerable()).Count(z => z.type == searchEventType) > 0) > 0
                                                                  );
            if (docks != null && docks.Count() > 0)
            {
                SearchedOutObjectDocksByEventType = docks.ToArray();
            }
            //search every spawnNPC, check gameevent type
            IEnumerable <SpawnNPC> spawns = AllSpawnNPC.Where(x => x.Event_At_All_Spawned_DieOut.Count(
                                                                  y => y.type == searchEventType) > 0);
            if (spawns != null && spawns.Count() > 0)
            {
                SearchedOutSpawnNPCByObjectReference = spawns.ToArray();
            }

            //search every gameevent lifecycle, check gameevent type
            IEnumerable <GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where(x =>
                                                                                               x.eventOnBirth.Count(y => y.type == searchEventType) > 0)
                                                                   .Concat(
                AllGameEventLifecycle.Where(x =>
                                            x.eventOnDestroy.Count(y => y.type == searchEventType) > 0))
                                                                   .Concat(
                AllGameEventLifecycle.Where(x =>
                                            x.eventOnUnitDie.Count(y => y.type == searchEventType) > 0));

            if (gameEventLifeCycles != null && gameEventLifeCycles.Count() > 0)
            {
                SearchedOutGameEventLifeCycleByEventType = gameEventLifeCycles.ToArray();
            }

            searchedOutput_ObjectDock  = SearchedOutObjectDocksByEventType;
            searchedOutput_SpawnNPC    = SearchedOutSpawnNPCByObjectReference;
            searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByEventType;
        }

        if (IsSearchByObjectInReceiverField)
        {
            //search every object dock, check gameevent 's receiver
            IEnumerable <ObjectDock> docks = AllObjectDocks.Where(x =>
                                                                  x.objectDockData.Count(y => y.event_at_start.Concat(y.event_at_end.AsEnumerable()).Count(z => z.receiver == SearchObjectReference) > 0) > 0
                                                                  );
            if (docks != null && docks.Count() > 0)
            {
                SearchedOutObjectDocksByObjectReference = docks.ToArray();
            }
            //search every spawnNPC, check gameevent 's receiver
            IEnumerable <SpawnNPC> spawns = AllSpawnNPC.Where(x => x.Event_At_All_Spawned_DieOut.Count(
                                                                  y => y.receiver == SearchObjectReference) > 0);
            if (spawns != null && spawns.Count() > 0)
            {
                SearchedOutSpawnNPCByObjectReference = spawns.ToArray();
            }

            //search every gameevent lifecycle, check gameevent 's receiver
            IEnumerable <GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where(x =>
                                                                                               x.eventOnBirth.Count(y => y.receiver == SearchObjectReference) > 0)
                                                                   .Concat(
                AllGameEventLifecycle.Where(x =>
                                            x.eventOnDestroy.Count(y => y.receiver == SearchObjectReference) > 0))
                                                                   .Concat(
                AllGameEventLifecycle.Where(x =>
                                            x.eventOnUnitDie.Count(y => y.receiver == SearchObjectReference) > 0));
            if (gameEventLifeCycles != null && gameEventLifeCycles.Count() > 0)
            {
                SearchedOutGameEventLifeCycleByObjectReference = gameEventLifeCycles.ToArray();
            }

            if (searchedOutput_ObjectDock == null || searchedOutput_ObjectDock.Length == 0)
            {
                searchedOutput_ObjectDock = SearchedOutObjectDocksByObjectReference;
            }
            else
            {
                searchedOutput_ObjectDock = searchedOutput_ObjectDock.Intersect(SearchedOutObjectDocksByObjectReference.AsEnumerable()).ToArray();
            }

            if (searchedOutput_SpawnNPC == null || searchedOutput_SpawnNPC.Length == 0)
            {
                searchedOutput_SpawnNPC = SearchedOutSpawnNPCByObjectReference;
            }
            else
            {
                searchedOutput_SpawnNPC = searchedOutput_SpawnNPC.Intersect(SearchedOutSpawnNPCByObjectReference.AsEnumerable()).ToArray();
            }

            if (searchedOutput_GameEventLC == null || searchedOutput_GameEventLC.Length == 0)
            {
                searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByObjectReference;
            }
            else
            {
                searchedOutput_GameEventLC = searchedOutput_GameEventLC.Intersect(SearchedOutGameEventLifeCycleByObjectReference.AsEnumerable()).ToArray();
            }
        }
    }