Exemplo n.º 1
0
    public bool LogOut(myUpdate logout)
    {
        switch (logout.GetUpdateType())
        {
        case myUpdate.UpdateType.GUI:
            return(GUIUpdates.Remove(logout.GetPriorityInType()));

        case myUpdate.UpdateType.Map:
            return(MapUpdates.Remove(logout.GetPriorityInType()));

        case myUpdate.UpdateType.PoolThing:
            //储存引用
            SortedList <int, myUpdate> temp;
            //看看有没有这个id
            if (PoolThingUpdates.TryGetValue(logout.gameObject.GetInstanceID(), out temp))
            {
                //如果有,则将这个组件从对应敌人的更新队列中去除
                bool result1 = temp.Remove(logout.GetPriorityInType());
                bool result2 = true;
                if (temp.Count == 0)
                {
                    result2 = PoolThingUpdates.Remove(logout.gameObject.GetInstanceID());
                }
                return(result1 && result2);
            }
            else
            {
                //没有id直接false
                return(false);
            }

        case myUpdate.UpdateType.Player:
            return(PlayerUpdates.Remove(logout.GetPriorityInType()));

        case myUpdate.UpdateType.Enemy:
            //储存引用
            SortedList <int, myUpdate> temp1;
            //看看有没有这个id
            if (EnemyUpdates.TryGetValue(logout.gameObject.GetInstanceID(), out temp1))
            {
                //如果有,则将这个组件从对应敌人的更新队列中去除
                bool result1 = temp1.Remove(logout.GetPriorityInType());
                bool result2 = true;
                if (temp1.Count == 0)
                {
                    result2 = EnemyUpdates.Remove(logout.gameObject.GetInstanceID());
                }
                return(result1 && result2);
            }
            else
            {
                //没有id直接false
                return(false);
            }
        }
        return(false);
    }
Exemplo n.º 2
0
    public bool Register(myUpdate update)
    {
        switch (update.GetUpdateType())
        {
        case myUpdate.UpdateType.GUI:
            GUIUpdates.Add(update.GetPriorityInType(), update);
            return(true);

        case myUpdate.UpdateType.Map:
            MapUpdates.Add(update.GetPriorityInType(), update);
            return(true);

        case myUpdate.UpdateType.PoolThing:
            //储存引用
            SortedList <int, myUpdate> temp;
            //看看有没有这个id
            if (PoolThingUpdates.TryGetValue(update.gameObject.GetInstanceID(), out temp))
            {
                //如果有,则将这个组件加入到对应敌人的更新队列中去
                temp.Add(update.GetPriorityInType(), update);
            }
            else
            {
                //如果没有,增加这个敌人的队列,并且把这个组件加入进去
                temp = new SortedList <int, myUpdate>();
                temp.Add(update.GetPriorityInType(), update);
                PoolThingUpdates.Add(update.gameObject.GetInstanceID(), temp);
            }

            return(true);

        case myUpdate.UpdateType.Player:
            PlayerUpdates.Add(update.GetPriorityInType(), update);
            return(true);

        case myUpdate.UpdateType.Enemy:
            //储存引用
            SortedList <int, myUpdate> temp1;
            //看看有没有这个id
            if (EnemyUpdates.TryGetValue(update.gameObject.GetInstanceID(), out temp1))
            {
                //如果有,则将这个组件加入到对应敌人的更新队列中去
                temp1.Add(update.GetPriorityInType(), update);
            }
            else
            {
                //如果没有,增加这个敌人的队列,并且把这个组件加入进去
                temp1 = new SortedList <int, myUpdate>();
                temp1.Add(update.GetPriorityInType(), update);
                EnemyUpdates.Add(update.gameObject.GetInstanceID(), temp1);
            }

            return(true);
        }
        return(false);
    }
Exemplo n.º 3
0
 //向给定数组中注册
 private bool RegisterIntoArray(myUpdate update, myUpdate[] updateList, bool[] isValidList, in int maxIndex, out int newMaxIndex)