Example #1
0
        static public ExcelConfigSet AddConfig(string config_name, string protocol_name = "", string file_name = "")
        {
            if (protocol_name.Length == 0)
            {
                protocol_name = string.Format("lit.config.{0}", config_name);
            }
            else
            {
                protocol_name = string.Format("lit.config.{0}", protocol_name);
            }

            if (file_name.Length == 0)
            {
                file_name = string.Format("Table/{0}.bin", config_name);
            }

            if (null != Get(config_name))
            {
                LitLogger.ErrorFormat("configure name {0} already registered, can not register again", config_name);
                return(new ExcelConfigSet(factory, file_name, protocol_name));
            }

            ExcelConfigSet ret = new ExcelConfigSet(factory, file_name, protocol_name);

            allConfigures[config_name] = ret;
            return(ret);
        }
Example #2
0
    public void PlayAudio(string audio_name, bool isLoop = false)
    {
        AudioClip clip = GetClip(audio_name);

        if (clip == null)
        {
            LitLogger.ErrorFormat("Can'not Found {0} audio", audio_name);
            return;
        }
        audioPlayer.clip = clip;
        audioPlayer.Play();
    }
Example #3
0
        public EventEntity Serialize()
        {
            if (handler.isEmpty())
            {
                LitLogger.ErrorFormat("Can not Add LE_OnClick with no handler");
                return(null);
            }
            EventEntity eventEntity = new EventEntity();

            eventEntity.EventType  = LitEventType.LE_OnClick;
            eventEntity.EventParam = handler;
            return(eventEntity);
        }
Example #4
0
        public EventEntity Serialize()
        {
            if (UID.isEmpty())
            {
                LitLogger.ErrorFormat("Can not Add LE_UID with no domain : <{0}>", gameObject.name);
                return(null);
            }
            EventEntity eventEntity = new EventEntity();

            eventEntity.EventType  = LitEventType.LE_UID;
            eventEntity.EventParam = UID;
            return(eventEntity);
        }
Example #5
0
        public EventEntity Serialize()
        {
            if (script_path.isEmpty())
            {
                LitLogger.ErrorFormat("Can not Add LE_Handler with no script_path");
                return(null);
            }
            EventEntity eventEntity = new EventEntity();

            eventEntity.EventType  = LitEventType.LE_Handler;
            eventEntity.EventParam = script_path;
            return(eventEntity);
        }
Example #6
0
 private void DrawCreateBtn()
 {
     if (GUILayout.Button("Create Handle File"))
     {
         if (!isValidPaht(handler.script_path))
         {
             LitLogger.ErrorFormat("Invalid Path : {0}", handler.script_path);
         }
         string full_path = string.Concat(FileTools.EventHandleLuaPath, handler.script_path.Replace('.', '/'), ".lua");
         EnsureFold(full_path);
         CreateFile(full_path);
         AssetDatabase.Refresh();
     }
 }
Example #7
0
        public bool Reload()
        {
            Clear();

            string full_path = FileTools.GetDocFilePath(fileName);

            try {
                var header_desc = factory.GetMsgDiscriptor("com.owent.xresloader.pb.xresloader_datablocks");
                if (null == header_desc)
                {
                    LitLogger.ErrorFormat("load configure file {0} failed, com.owent.xresloader.pb.xresloader_datablocks not registered", fileName);
                    return(false);
                }

                var msg_desc = factory.GetMsgDiscriptor(protocol);
                if (null == msg_desc)
                {
                    LitLogger.ErrorFormat("load configure file {0} failed, {1} not registered", fileName, protocol);
                    return(false);
                }

                DynamicMessage data_set = factory.Decode(header_desc, File.OpenRead(full_path));
                if (null == data_set)
                {
                    LitLogger.ErrorFormat("load configure file {0} failed, {1}", fileName, factory.LastError);
                    return(false);
                }

                foreach (var cfg_item in data_set.GetFieldList("data_block"))
                {
                    DynamicMessage data_item = factory.Decode(msg_desc, new MemoryStream((byte[])cfg_item));
                    if (null == data_item)
                    {
                        LitLogger.ErrorFormat("load configure file {0} failed, {1}", fileName, factory.LastError);
                        continue;
                    }

                    bool filter_pass = true;
                    foreach (var fn in filters)
                    {
                        filter_pass = fn(data_item);
                        if (!filter_pass)
                        {
                            break;
                        }
                    }

                    if (!filter_pass)
                    {
                        continue;
                    }

                    datas.Add(data_item);

                    foreach (var index in kvIndex)
                    {
                        if (null != index.Handle)
                        {
                            Key key = index.Handle(data_item);
                            index.Index[key] = data_item;
                        }
                    }

                    foreach (var index in klIndex)
                    {
                        if (null != index.Handle)
                        {
                            List <DynamicMessage> ls;
                            Key key = index.Handle(data_item);
                            if (index.Index.TryGetValue(key, out ls))
                            {
                                ls.Add(data_item);
                            }
                            else
                            {
                                index.Index[key] = new List <DynamicMessage> {
                                    data_item
                                };
                            }
                        }
                    }
                }

                foreach (var index in klIndex)
                {
                    if (null != index.SortRule)
                    {
                        foreach (var ls in index.Index)
                        {
                            ls.Value.Sort(index.SortRule);
                        }
                    }
                }
            } catch (Exception e) {
                LitLogger.ErrorFormat("{0}", e.Message);
                return(false);
            }
            return(true);
        }