public static void DestroyAllNonPlayer()
    {
        if (MonoBehaviourSingleton <StageObjectManager> .IsValid())
        {
            List <StageObject>   destroyList = new List <StageObject>();
            Action <StageObject> action      = delegate(StageObject o)
            {
                if (o is NonPlayer && !o.isDestroyWaitFlag && (o.IsCoopNone() || o.IsOriginal()))
                {
                    destroyList.Add(o);
                }
            };
            MonoBehaviourSingleton <StageObjectManager> .I.cacheList.ForEach(action);

            MonoBehaviourSingleton <StageObjectManager> .I.nonplayerList.ForEach(action);

            Action <StageObject> action2 = delegate(StageObject o)
            {
                Player player = o as Player;
                if (player != null && player.isNpc)
                {
                    destroyList.Add(o);
                }
            };
            MonoBehaviourSingleton <StageObjectManager> .I.playerList.ForEach(action2);

            for (int i = 0; i < destroyList.Count; i++)
            {
                StageObject stageObject = destroyList[i];
                stageObject.DestroyObject();
            }
        }
    }
    public static void ShrinkOriginalNonPlayer(int player_max)
    {
        if (MonoBehaviourSingleton <StageObjectManager> .IsValid())
        {
            int player_num = 0;
            MonoBehaviourSingleton <StageObjectManager> .I.playerList.ForEach(delegate(StageObject o)
            {
                if (!o.isDestroyWaitFlag)
                {
                    player_num++;
                }
            });

            MonoBehaviourSingleton <StageObjectManager> .I.cacheList.ForEach(delegate(StageObject o)
            {
                if (o is Player && !o.isDestroyWaitFlag)
                {
                    player_num++;
                }
            });

            int num = player_num - player_max;
            if (num > 0)
            {
                List <StageObject>   destroyList = new List <StageObject>();
                Action <StageObject> action      = delegate(StageObject o)
                {
                    if (o is NonPlayer && !o.isDestroyWaitFlag && (o.IsCoopNone() || o.IsOriginal()))
                    {
                        destroyList.Add(o);
                    }
                };
                MonoBehaviourSingleton <StageObjectManager> .I.cacheList.ForEach(action);

                MonoBehaviourSingleton <StageObjectManager> .I.nonplayerList.ForEach(action);

                int num2 = Math.Min(num, destroyList.Count);
                for (int i = 0; i < num2; i++)
                {
                    StageObject stageObject = destroyList[i];
                    stageObject.DestroyObject();
                }
            }
        }
    }
Пример #3
0
    private void Update()
    {
        int i = 0;

        for (int count = objectList.Count; i < count; i++)
        {
            StageObject stageObject = objectList[i];
            if (stageObject.isDestroyWaitFlag)
            {
                stageObject.DestroyObject();
            }
            if (count != objectList.Count)
            {
                count = objectList.Count;
                i--;
            }
        }
        int j = 0;

        for (int count2 = cacheList.Count; j < count2; j++)
        {
            StageObject stageObject2 = cacheList[j];
            if (stageObject2.isDestroyWaitFlag)
            {
                stageObject2.DestroyObject();
            }
            else
            {
                if (stageObject2.packetReceiver != null)
                {
                    stageObject2.packetReceiver.OnUpdate();
                }
                if (stageObject2.packetSender != null)
                {
                    stageObject2.packetSender.OnUpdate();
                }
            }
            if (count2 != cacheList.Count)
            {
                count2 = cacheList.Count;
                j--;
            }
        }
    }