示例#1
0
    public IEnumerator addToHordeSpawn()
    {
        if (BoltNetwork.isClient)
        {
            yield break;
        }
        this.allWorldSpawns.RemoveAll((GameObject o) => o == null);
        this.allCaveSpawns.RemoveAll((GameObject o) => o == null);
        this.currentMaxActiveMutants = 25;
        this.sortSpawnPointsByDistance();
        this.spawnCounter = this.spawnCounterMin;
        if (this.allWorldSpawns.Count < 6 || this.activeWorldCannibals.Count < 8)
        {
            Transform spawnPoint = this.allSpawnPoints[this.spawnCounter].transform;
            this.spawnCounter++;
            if (this.spawnCounter >= 6)
            {
                this.spawnCounter = this.spawnCounterMin;
            }
            GameObject   newSpawn = UnityEngine.Object.Instantiate <GameObject>(this.spawnGo, spawnPoint.position, spawnPoint.rotation);
            spawnMutants spawn    = newSpawn.GetComponent <spawnMutants>();
            if (this.initMutantSpawnerCallback != null)
            {
                if (this.initMutantSpawnerCallback(spawn))
                {
                }
            }
            else
            {
                int num = UnityEngine.Random.Range(0, 15);
                if (num < 3)
                {
                    this.setupSkinnySpawn(spawn);
                }
                else if (num > 3 && num < 5)
                {
                    this.setupSkinnyPaleSpawn(spawn);
                }
                else if (num > 5 && num < 9)
                {
                    this.setupRegularSpawn(spawn);
                }
                else if (num > 9 && num < 12)
                {
                    this.setupPaleSpawn(spawn);
                }
                else if (num > 12 && num < 14)
                {
                    this.setupCreepySpawn(spawn);
                }
            }
            spawn.enabled = true;
            spawn.invokeSpawn();
            spawn.addToWorldSpawns();
            this.numActiveCannibals = this.activeWorldCannibals.Count;
            this.worldMutantsActive = false;
            yield return(YieldPresets.WaitPointTwoFiveSeconds);

            if (spawn)
            {
                spawn.SendMessage("updateSpawnConditions", SendMessageOptions.DontRequireReceiver);
            }
        }
        this.count = 0;
        yield break;
    }
示例#2
0
    public IEnumerator updateSpawns()
    {
        if (BoltNetwork.isClient)
        {
            yield break;
        }
        this.allWorldSpawns.RemoveAll((GameObject o) => o == null);
        this.allCaveSpawns.RemoveAll((GameObject o) => o == null);
        this.allSkinnySpawns.RemoveAll((GameObject o) => o == null);
        this.allSkinnyPaleSpawns.RemoveAll((GameObject o) => o == null);
        this.allRegularSpawns.RemoveAll((GameObject o) => o == null);
        this.allPaintedSpawns.RemoveAll((GameObject o) => o == null);
        this.allPaleSpawns.RemoveAll((GameObject o) => o == null);
        this.allCreepySpawns.RemoveAll((GameObject o) => o == null);
        this.allSkinnedSpawns.RemoveAll((GameObject o) => o == null);
        foreach (GameObject gameObject in this.allWorldSpawns)
        {
            gameObject.SendMessage("updateSpawnConditions", SendMessageOptions.DontRequireReceiver);
        }
        this.setDayConditions();
        if (Clock.Day == 0 && Scene.Atmosphere.TimeOfDay > 270f && Scene.Atmosphere.TimeOfDay < 359f && !LocalPlayer.IsInCaves)
        {
            yield return(new WaitForSeconds(0f));
        }
        if (!this.disableAllEnemies && !this.startDelay && !Cheats.NoEnemies)
        {
            this.sortSpawnPointsByDistance();
            this.spawnCounter = 4;
            bool allSpawned = false;
            while (!Scene.SceneTracker.waitForLoadSequence)
            {
                yield return(null);
            }
            while (Scene.SceneTracker.doingGlobalNavUpdate)
            {
                yield return(null);
            }
            yield return(YieldPresets.WaitOneSecond);

            yield return(YieldPresets.WaitOneSecond);

            yield return(YieldPresets.WaitOneSecond);

            while (this.mostCommonArea.Count == 0)
            {
                yield return(null);
            }
            while ((this.activeWorldCannibals.Count < this.currentMaxActiveMutants && !LocalPlayer.IsInCaves && !allSpawned) || (this.count < this.allCaveSpawns.Count && LocalPlayer.IsInCaves))
            {
                if (!LocalPlayer.IsInCaves)
                {
                    if (Cheats.NoEnemiesDuringDay && !Clock.Dark)
                    {
                        yield break;
                    }
                    Transform spawnPoint = this.allSpawnPoints[this.spawnCounter].transform;
                    this.spawnCounter++;
                    if (this.spawnCounter >= this.allSpawnPoints.Count)
                    {
                        this.spawnCounter = this.allSpawnPoints.Count;
                    }
                    GraphNode node      = AstarPath.active.GetNearest(spawnPoint.position, NNConstraint.Default).node;
                    int       areaCount = 0;
                    while (node.Area != this.mostCommonArea[areaCount])
                    {
                        node = AstarPath.active.GetNearest(this.allSpawnPoints[this.spawnCounter].transform.position, NNConstraint.Default).node;
                        areaCount++;
                        if (areaCount == this.mostCommonArea.Count)
                        {
                            areaCount = 0;
                        }
                        this.spawnCounter++;
                        if (this.spawnCounter >= this.allSpawnPoints.Count)
                        {
                            node.Area         = this.mostCommonArea[0];
                            this.spawnCounter = this.allSpawnPoints.Count;
                        }
                        spawnPoint = this.allSpawnPoints[this.spawnCounter].transform;
                        yield return(null);
                    }
                    this.lastValidSpawn = spawnPoint;
                    GameObject   newSpawn = UnityEngine.Object.Instantiate <GameObject>(this.spawnGo, spawnPoint.position, spawnPoint.rotation);
                    spawnMutants spawn    = newSpawn.GetComponent <spawnMutants>();
                    if (this.allCreepySpawns.Count < this.spawnManager.desiredCreepy)
                    {
                        this.setupCreepySpawn(spawn);
                        this.allCreepySpawns.Add(spawn.gameObject);
                    }
                    else if (this.allSkinnedSpawns.Count < this.spawnManager.desiredSkinned)
                    {
                        this.setupSkinnedSpawn(spawn);
                        this.allSkinnedSpawns.Add(spawn.gameObject);
                    }
                    else if (this.allPaintedSpawns.Count < this.spawnManager.desiredPainted)
                    {
                        this.setupRegularPaintedSpawn(spawn);
                        this.allPaintedSpawns.Add(spawn.gameObject);
                    }
                    else if (this.allRegularSpawns.Count < this.spawnManager.desiredRegular)
                    {
                        this.setupRegularSpawn(spawn);
                        this.allRegularSpawns.Add(spawn.gameObject);
                    }
                    else if (this.allPaleSpawns.Count < this.spawnManager.desiredPale)
                    {
                        this.setupPaleSpawn(spawn);
                        this.allPaleSpawns.Add(spawn.gameObject);
                    }
                    else if (this.allSkinnyPaleSpawns.Count < this.spawnManager.desiredSkinnyPale)
                    {
                        this.setupSkinnyPaleSpawn(spawn);
                        this.allSkinnyPaleSpawns.Add(spawn.gameObject);
                    }
                    else if (this.allSkinnySpawns.Count < this.spawnManager.desiredSkinny)
                    {
                        this.setupSkinnySpawn(spawn);
                        this.allSkinnySpawns.Add(spawn.gameObject);
                    }
                    else
                    {
                        allSpawned = true;
                    }
                    spawn.enabled = true;
                    spawn.invokeSpawn();
                    spawn.addToWorldSpawns();
                    this.numActiveCannibals = this.activeWorldCannibals.Count;
                    yield return(new WaitForFixedUpdate());
                }
                else if (LocalPlayer.IsInCaves)
                {
                    this.sortCaveSpawnsByDistance(LocalPlayer.Transform);
                    if (this.allCaveSpawns[this.count] != null)
                    {
                        spawnMutants component = this.allCaveSpawns[this.count].GetComponent <spawnMutants>();
                        if (!component.enabled)
                        {
                            component.enabled = true;
                            component.invokeSpawn();
                            if (!this.activeFamilies.Contains(this.allCaveSpawns[this.count]))
                            {
                                this.activeFamilies.Add(this.allCaveSpawns[this.count]);
                            }
                            this.numActiveCannibals = this.activeCannibals.Count;
                            this.count++;
                        }
                    }
                }
                this.worldMutantsActive = false;
                yield return(YieldPresets.WaitForFixedUpdate);

                yield return(YieldPresets.WaitForFixedUpdate);

                yield return(YieldPresets.WaitForFixedUpdate);

                foreach (GameObject gameObject2 in this.allWorldSpawns)
                {
                    if (gameObject2)
                    {
                        gameObject2.SendMessage("updateSpawnConditions", SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
        }
        this.count = 0;
        yield break;
    }
示例#3
0
    public IEnumerator updateHordeSpawns(int delay)
    {
        yield return(new WaitForSeconds((float)delay));

        if (BoltNetwork.isClient)
        {
            yield break;
        }
        this.allWorldSpawns.RemoveAll((GameObject o) => o == null);
        this.allCaveSpawns.RemoveAll((GameObject o) => o == null);
        this.currentMaxActiveMutants = 30;
        if (!this.startDelay)
        {
            this.sortSpawnPointsByDistance();
            this.spawnCounter = this.spawnCounterMin;
            bool allSpawned = false;
            while (!allSpawned)
            {
                Transform spawnPoint = this.allSpawnPoints[this.spawnCounter].transform;
                this.spawnCounter++;
                if (this.spawnCounter >= this.allSpawnPoints.Count)
                {
                    this.spawnCounter = this.spawnCounterMin;
                }
                GameObject   newSpawn = UnityEngine.Object.Instantiate <GameObject>(this.spawnGo, spawnPoint.position, spawnPoint.rotation);
                spawnMutants spawn    = newSpawn.GetComponent <spawnMutants>();
                if (this.initMutantSpawnerCallback != null)
                {
                    if (this.initMutantSpawnerCallback(spawn))
                    {
                        allSpawned = true;
                    }
                }
                else if (this.numActiveCreepySpawns < this.spawnManager.desiredCreepy)
                {
                    this.setupCreepySpawn(spawn);
                }
                else if (this.numActiveRegularSpawns < this.spawnManager.desiredRegular)
                {
                    this.setupRegularSpawn(spawn);
                }
                else if (this.numActiveSkinnedSpawns < this.spawnManager.desiredSkinned)
                {
                    this.setupSkinnedSpawn(spawn);
                }
                else if (this.numActivePaintedSpawns < this.spawnManager.desiredPainted)
                {
                    this.setupRegularPaintedSpawn(spawn);
                }
                else if (this.numActivePaleSpawns < this.spawnManager.desiredPale)
                {
                    this.setupPaleSpawn(spawn);
                }
                else if (this.numActiveSkinnyPaleSpawns < this.spawnManager.desiredSkinnyPale)
                {
                    this.setupSkinnyPaleSpawn(spawn);
                }
                else if (this.numActiveSkinnySpawns < this.spawnManager.desiredSkinny)
                {
                    this.setupSkinnySpawn(spawn);
                }
                else
                {
                    allSpawned = true;
                }
                spawn.enabled = true;
                spawn.invokeSpawn();
                spawn.addToWorldSpawns();
                this.numActiveCannibals = this.activeWorldCannibals.Count;
                this.worldMutantsActive = false;
                yield return(YieldPresets.WaitPointTwoFiveSeconds);

                if (this.activeWorldCannibals.Count >= this.currentMaxActiveMutants)
                {
                    allSpawned = true;
                }
            }
            foreach (GameObject gameObject in this.allWorldSpawns)
            {
                if (gameObject)
                {
                    gameObject.SendMessage("updateSpawnConditions", SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        this.count = 0;
        yield break;
    }