예제 #1
0
        public Handler Create <T>(OnEventRecv <T> recv) where T : Event
        {
            if (!index_pool.CanAlloc())
            {
                index_pool.Grow(5);
                Array.Resize(ref handlers, handlers.Length + 5);
            }

            int             idx = index_pool.Alloc();
            RealHandler <T> h   = new RealHandler <T>(idx, recv);

            handlers[idx] = h;
            return(h);
        }
예제 #2
0
    public void Add(CGameUI ui)
    {
        if (!index_pool.CanAlloc())
        {
            LOG.TraceRed("ERROR: ui数量超出上限。ui name:{0}", ui.Name);
            return;
        }
        int index = index_pool.Alloc();

        if (uis[index] != null)
        {
            throw new Exception(string.Format("[CUIManager] ui index:{0} is already in use", index));
        }
        if (names.ContainsKey(ui.Name))
        {
            throw new Exception(string.Format("[CUIManager] ui name:{0} is already exist", ui.Name));
        }
        uis[index]     = ui;
        names[ui.Name] = ui;
        ui.index       = index;
        ui.SetPosition(new Vector3((ui.index + 1) * 100, 0, 0));
        // 最后显示该ui
        ui.Show();
    }