Beispiel #1
0
        public void HistoryFileIntergrityTest()
        {
            string testFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "history.test");

            if (File.Exists(testFile))
            {
                File.Delete(testFile);
            }

            var inv1 = new ClientList {
                ClientId = (ClientId)10, Uid = (Uid)"Uid1", Name = "Invoker1"
            };
            var inv2 = new ClientList {
                ClientId = (ClientId)20, Uid = (Uid)"Uid2", Name = "Invoker2"
            };

            var ar1 = new AudioResource("asdf", "sc_ar1", "soundcloud");
            var ar2 = new AudioResource("./File.mp3", "me_ar2", "media");
            var ar3 = new AudioResource("kitty", "tw_ar3", "twitch");

            var data1 = new HistorySaveData(ar1, inv1.Uid);
            var data2 = new HistorySaveData(ar2, inv2.Uid);
            var data3 = new HistorySaveData(ar3, (Uid)"Uid3");

            var confHistory = ConfigTable.CreateRoot <ConfHistory>();

            confHistory.FillDeletedIds.Value = false;
            var confDb = ConfigTable.CreateRoot <ConfDb>();

            confDb.Path.Value = testFile;

            DbStore        db;
            HistoryManager hf;

            void CreateDbStore()
            {
                db = new DbStore(confDb);
                hf = new HistoryManager(confHistory, db);
            }

            CreateDbStore();

            hf.LogAudioResourceDelayed(data1);

            var lastXEntries = hf.GetLastXEntrys(1);

            Assert.True(lastXEntries.Any());
            var lastEntry = lastXEntries.First();

            Assert.AreEqual(ar1, lastEntry.AudioResource);

            db.Dispose();

            CreateDbStore();
            lastXEntries = hf.GetLastXEntrys(1);
            Assert.True(lastXEntries.Any());
            lastEntry = lastXEntries.First();
            Assert.AreEqual(ar1, lastEntry.AudioResource);

            hf.LogAudioResourceDelayed(data1);
            hf.LogAudioResourceDelayed(data2);

            lastXEntries = hf.GetLastXEntrys(1);
            Assert.True(lastXEntries.Any());
            lastEntry = lastXEntries.First();
            Assert.AreEqual(ar2, lastEntry.AudioResource);

            db.Dispose();

            // store and order check
            CreateDbStore();
            var lastXEntriesArray = hf.GetLastXEntrys(2).ToArray();

            Assert.AreEqual(2, lastXEntriesArray.Length);
            Assert.AreEqual(ar2, lastXEntriesArray[0].AudioResource);
            Assert.AreEqual(ar1, lastXEntriesArray[1].AudioResource);

            var ale1 = hf.FindEntryByResource(ar1);

            hf.RenameEntry(ale1, "sc_ar1X");
            hf.LogAudioResourceDelayed(new HistorySaveData(ale1.AudioResource, (Uid)"Uid4"));


            db.Dispose();

            // check entry renaming
            CreateDbStore();
            lastXEntriesArray = hf.GetLastXEntrys(2).ToArray();
            Assert.AreEqual(2, lastXEntriesArray.Length);
            Assert.AreEqual(ar1, lastXEntriesArray[0].AudioResource);
            Assert.AreEqual(ar2, lastXEntriesArray[1].AudioResource);

            var ale2 = hf.FindEntryByResource(ar2);

            hf.RenameEntry(ale2, "me_ar2_loong1");
            hf.LogAudioResourceDelayed(new HistorySaveData(ale2.AudioResource, (Uid)"Uid4"));

            ale1 = hf.FindEntryByResource(ar1);
            hf.RenameEntry(ale1, "sc_ar1X_loong1");
            hf.LogAudioResourceDelayed(new HistorySaveData(ale1.AudioResource, (Uid)"Uid4"));

            hf.RenameEntry(ale2, "me_ar2_exxxxxtra_loong1");
            hf.LogAudioResourceDelayed(new HistorySaveData(ale2.AudioResource, (Uid)"Uid4"));

            db.Dispose();

            // recheck order
            CreateDbStore();
            lastXEntriesArray = hf.GetLastXEntrys(2).ToArray();
            Assert.AreEqual(2, lastXEntriesArray.Length);
            Assert.AreEqual(ar2, lastXEntriesArray[0].AudioResource);
            Assert.AreEqual(ar1, lastXEntriesArray[1].AudioResource);
            db.Dispose();

            // delete entry 1
            CreateDbStore();
            hf.RemoveEntry(hf.FindEntryByResource(ar1));

            lastXEntriesArray = hf.GetLastXEntrys(3).ToArray();
            Assert.AreEqual(1, lastXEntriesArray.Length);

            // .. store new entry to check correct stream position writes
            hf.LogAudioResourceDelayed(data3);

            lastXEntriesArray = hf.GetLastXEntrys(3).ToArray();
            Assert.AreEqual(2, lastXEntriesArray.Length);
            db.Dispose();

            // delete entry 2
            CreateDbStore();
            // .. check integrity from previous store
            lastXEntriesArray = hf.GetLastXEntrys(3).ToArray();
            Assert.AreEqual(2, lastXEntriesArray.Length);

            // .. delete and recheck
            hf.RemoveEntry(hf.FindEntryByResource(ar2));

            lastXEntriesArray = hf.GetLastXEntrys(3).ToArray();
            Assert.AreEqual(1, lastXEntriesArray.Length);
            Assert.AreEqual(ar3, lastXEntriesArray[0].AudioResource);
            db.Dispose();


            File.Delete(testFile);
        }
    public string Account_CreatePlayer(string strJson)
    {
        log4net.LogManager.GetLogger("Account_CreatePlayer").DebugFormat("Args:{0}", strJson);
        // 先寫一筆資料
        int    LogID      = ReportDBLog("Account_CreatePlayer", strJson);
        string strCommand = "";
        List <List <object> > listDBResult = null;

        // 分析資料
        Dictionary <string, object> dictResult = new Dictionary <string, object>();

        // 取得資料
        Dictionary <string, object> dictInfo = JsonConvert.DeserializeObject <Dictionary <string, object> >(strJson);

        if (dictInfo == null)
        {
            return(ReportTheResult(dictResult, ErrorID.Json_Format_Error, LogID));
        }
        if (dictInfo.ContainsKey("SessionKey") == false)
        {
            return(ReportTheResult(dictResult, ErrorID.No_SessionKey, LogID));
        }
        string SessionKey = dictInfo["SessionKey"].ToString();

        // 轉 SessionKey To AccountID
        Dictionary <string, object> dictAccount = GetAccountInfoBySessionKey(SessionKey);

        if (dictAccount == null)
        {
            return(ReportTheResult(dictResult, ErrorID.SessionError, LogID));
        }
        int AccountID = System.Convert.ToInt32(dictAccount["AccountID"]);

        // 檢查角色
        int PlayerID = System.Convert.ToInt32(dictAccount["PlayerID"]);

        if (PlayerID != 0)
        {
            return(ReportTheResult(dictResult, ErrorID.Account_CreatePlayer_Exist_Player, LogID));
        }

        // 取得創角資料和建立角色
        string PlayerName = "";

        if (dictInfo.ContainsKey("PlayerName") == false)
        {
            PlayerName = GetRandomNameFromDB();
        }
        else
        {
            PlayerName = dictInfo["PlayerName"].ToString();
        }
        dictResult["PlayerName"] = PlayerName;

        strCommand             = string.Format("insert into a_member (PlayerName) values ('{0}')" + UseDB.GETID, PlayerName);
        listDBResult           = UseDB.GameDB.DoQueryCommand(strCommand);
        PlayerID               = System.Convert.ToInt32(listDBResult[0][0]);
        dictResult["PlayerID"] = PlayerID;

        // 塞回去 Account 中
        strCommand = string.Format("update a_account set PlayerID={0} where AccountID={1}", PlayerID, AccountID);
        UseDB.GameDB.DoCommand(strCommand);

        // 產生一隻新的 NPC 給玩家使用
        string        strCreateNPC  = ConfigTable.instance().Get("CreatePlayer_Start_Partner");
        List <string> listCreateNPC = Utility.Split(strCreateNPC, ",");
        string        strNPC        = Utility.GetRange(listCreateNPC);

        // 送給玩家

        // 進入主流程
        return(ReportTheResult(dictResult, ErrorID.Success, LogID));
    }
Beispiel #3
0
        /// <summary>
        /// 提取其他数据库
        /// </summary>
        /// <param name="dbName"></param>
        private void ExtractOtherOneDb(DataBaseName dbName)
        {
            var     bll = new SelectOtherTablesBll();
            DataSet ds  = null;

            log.Debug("提取其他数据库");
            try
            {
                ds = bll.Select(dbName);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            if (ds != null)
            {
                log.Debug("提取成功");
                foreach (DataTable dt in ds.Tables)
                {
                    try
                    {
                        List <Data> list = new List <Data>();
                        if (this.messagesShowEventHandler != null)
                        {
                            var msg = new StringBuilder();
                            msg.Append("提取").Append(dt.TableName).Append(dt.Rows.Count).Append("条数据");
                            log.Info(msg.ToString());
                            this.messagesShowEventHandler(
                                this,
                                new MessagesShowEventArgs {
                                MessageType = MsgType.Info, MessagesShow = msg.ToString()
                            });
                        }

                        if (dt != null && dt.Rows.Count > 0)
                        {
                            int  index        = 0;
                            bool flag         = false;
                            bool ultraSetFlag = false;//@Modify20150107by yww
                            int  flagCount    = 0;
                            ConcurrentDictionary <int, ConfigTableInfo> dic = new ConcurrentDictionary <int, ConfigTableInfo>();
                            ConfigTableInfo config = new ConfigTableInfo();
                            if (
                                !string.IsNullOrEmpty(
                                    TableFieldInfoDic.GetTableFieldInfoDic()
                                    .GeTableFieldInfo((int)dbName.ID, dt.TableName)
                                    .OtherFlag))
                            {
                                index = 1;
                            }


                            if (ConfigTableDic.GetConfigTableDic().SelectList().Count > 0)
                            {
                                ConfigTable configtable = ConfigTableDic.GetConfigTableDic().SelecConfigTable((int)dbName.ID);
                                //ConfigTable configtable = ConfigTableDic.GetConfigTableDic().SelecConfigTable((int)dbName.ID, dt.TableName);
                                if (configtable != null)
                                {
                                    flag      = true;
                                    flagCount = 1;
                                }
                                // 特殊处理(在有Sensor配置的时候直接拿SensorID做为模块号)
                                if (dt.TableName == "MainStreeData")
                                {
                                    ultraSetFlag = true;
                                    flag         = false;
                                    flagCount    = 1;
                                }
                            }
                            else
                            {
                                flag      = false;
                                flagCount = 2;
                            }

                            foreach (DataRow row in dt.Rows)
                            {
                                try
                                {
                                    var data = new Data
                                    {
                                        ProjectCode = Convert.ToInt16(row[0]),
                                        DataBaseId  = Convert.ToInt32(row[1]),
                                        SafeTypeId  = Convert.ToInt32(row[2]),
                                        ChannelId   = 1
                                    };
                                    data.DataSet = new List <double>();

                                    if (flag)
                                    {
                                        int    sensorid           = 0;
                                        bool   identifyBySerialNo = false;
                                        string serialNo           = "";
                                        if (row[4] != DBNull.Value)
                                        {
                                            if (int.TryParse(row[4].ToString(), out sensorid))
                                            {
                                                data.SensorId      = sensorid;
                                                identifyBySerialNo = false;
                                            }
                                            else
                                            {
                                                serialNo           = row[4].ToString();
                                                identifyBySerialNo = true;
                                            }
                                            //data.SensorId = Convert.ToInt32(row[4]);
                                            if (ConfigInfoTable.ConfigtableInfoDictionary.ContainsKey(data.DataBaseId))
                                            {
                                                dic = ConfigInfoTable.ConfigtableInfoDictionary[data.DataBaseId];
                                            }
                                            else
                                            {
                                                log.Error("字典中数据库ID关键字不存在");
                                                continue;
                                            }
                                            if (!identifyBySerialNo)
                                            {
                                                if (dic.ContainsKey(data.SensorId))
                                                {
                                                    config = dic[data.SensorId];
                                                }
                                                else
                                                {
                                                    log.Error("字典中传感器ID关键字不存在");
                                                    continue;
                                                }
                                            }
                                            else
                                            {
                                                config = (from s in dic.Values
                                                          where StringComparer.OrdinalIgnoreCase.Compare(s.Otherflag, serialNo) == 0
                                                          select s).FirstOrDefault();
                                                if (config == null)
                                                {
                                                    log.Error("字典中传感器唯一标示符不存在");
                                                    continue;
                                                }
                                            }

                                            data.ChannelId = config.ChannelId;
                                            data.MoudleNo  = config.MoudleNo;
                                        }
                                        else // 没有传感器ID
                                        {
                                            data.MoudleNo = "1";
                                        }
                                    }
                                    else
                                    {
                                        data.ChannelId = 1;
                                        if (!ultraSetFlag)
                                        {
                                            if (row[5] != DBNull.Value)
                                            {
                                                data.ChannelId = Convert.ToInt32(row[5]);
                                            }
                                        }
                                        if (row[4] != DBNull.Value)
                                        {
                                            data.MoudleNo = row[4].ToString();
                                        }
                                    }
                                    if (index == 1)
                                    {
                                        data.OFlag = Convert.ToInt32(row[6]);
                                    }

                                    // 采集时间转换问题,提供几种常见格式的时间转换
                                    DateTime acqtime = Convert.ToDateTime(row[3].ToString().Trim());
                                    //string timestr = ;
                                    //string[] timeformats =
                                    //    {
                                    //        "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm:ss.fff",
                                    //        "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss.fff", "yyyyMMddHHmmss",
                                    //        "yyyyMMddHHmmss.fff","yyyy-MM-dd h:mm:ss","yyyy-M-d h:mm:ss"
                                    //    };
                                    //timestr
                                    //bool isSuccess = DateTime.TryParseExact(
                                    //    timestr,
                                    //    timeformats,
                                    //    CultureInfo.CurrentCulture,
                                    //    DateTimeStyles.None,
                                    //    out acqtime); //AssumeLocal
                                    //if (!isSuccess)
                                    //{
                                    //    try
                                    //    {
                                    //        acqtime = Convert.ToDateTime(timestr);
                                    //    }
                                    //    catch
                                    //    {
                                    //        log.Error("时间格式转换失败;" + timestr);
                                    //    }
                                    //}
                                    data.CollectTime = acqtime;

                                    for (int i = 4 + flagCount + index; i < row.ItemArray.Length; i++)
                                    {
                                        double value;

                                        double.TryParse(row[i].ToString().Trim(), out value);
                                        data.DataSet.Add(value);
                                    }
                                    list.Add(data);
                                }
                                catch (Exception ex)
                                {
                                    log.Error(ex.Message);
                                }
                            }
                            string strtime = dt.Compute("Max(ACQUISITION_DATETIME)", Boolean.TrueString).ToString();
                            ExtractionConfigDic.GetExtractionConfigDic()
                            .UpdateExtractionConfig(
                                new ExtractionConfig
                            {
                                DataBaseId = (int)dbName.ID,
                                TableName  = dt.TableName,
                                Acqtime    = strtime
                            });
                        }

                        //添加到队列
                        foreach (Data data in list)
                        {
                            datasTobesent.Enqueue(data);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.Message);
                    }
                }
            }
            else
            {
                log.Debug("DataSet==null");
            }
        }
Beispiel #4
0
 public static Attribute Get(string pk)
 {
     return(ConfigTable.Get <Attribute>(pk));
 }
Beispiel #5
0
 public static BattleSkill Get(string key)
 {
     return(ConfigTable.Get <BattleSkill>(key));
 }
Beispiel #6
0
 /// <summary>
 /// 获取数据,如果不存在不会报警告
 /// </summary>
 public bool TryGetTable(int key, out ConfigTable tab)
 {
     return(_tables.TryGetValue(key, out tab));
 }
Beispiel #7
0
 public static Trigger Get(string pk)
 {
     return(ConfigTable.Get <Trigger>(pk));
 }
Beispiel #8
0
        //
        // FindServicePoint - Query using an Uri for a given server point
        //

        /// <include file='doc\ServicePointManager.uex' path='docs/doc[@for="ServicePointManager.FindServicePoint2"]/*' />
        /// <devdoc>
        /// <para>Findes an existing <see cref='System.Net.ServicePoint'/> or creates a new <see cref='System.Net.ServicePoint'/> to manage communications to the specified <see cref='System.Uri'/>
        /// instance.</para>
        /// </devdoc>
        public static ServicePoint FindServicePoint(Uri address, IWebProxy proxy)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            GlobalLog.Enter("ServicePointManager::FindServicePoint() address:" + address.ToString());

            string tempEntry;
            bool   isProxyServicePoint = false;

            ScavengeIdleServicePoints();

            //
            // find proxy info, and then switch on proxy
            //
            if (proxy != null && !proxy.IsBypassed(address))
            {
                // use proxy support
                // rework address
                Uri proxyAddress = proxy.GetProxy(address);
                if (proxyAddress.Scheme != Uri.UriSchemeHttps && proxyAddress.Scheme != Uri.UriSchemeHttp)
                {
                    Exception exception = new NotSupportedException(SR.GetString(SR.net_proxyschemenotsupported, proxyAddress.Scheme));
                    GlobalLog.LeaveException("ServicePointManager::FindServicePoint() proxy has unsupported scheme:" + proxyAddress.Scheme.ToString(), exception);
                    throw exception;
                }
                address = proxyAddress;

                isProxyServicePoint = true;

                //
                // Search for the correct proxy host,
                //  then match its acutal host by using ConnectionGroups
                //  which are located on the actual ServicePoint.
                //

                tempEntry = MakeQueryString(proxyAddress);
            }
            else
            {
                //
                // Typical Host lookup
                //
                tempEntry = MakeQueryString(address);
            }

            //
            // lookup service point in the table
            //
            ServicePoint servicePoint = null;

            lock (s_ServicePointTable) {
                //
                // once we grab the lock, check if it wasn't already added
                //
                WeakReference servicePointReference = (WeakReference)s_ServicePointTable[tempEntry];

                if (servicePointReference != null)
                {
                    servicePoint = (ServicePoint)servicePointReference.Target;
                }

                if (servicePoint == null)
                {
                    //
                    // lookup failure or timeout, we need to create a new ServicePoint
                    //
                    if (s_MaxServicePoints <= 0 || s_ServicePointTable.Count < s_MaxServicePoints)
                    {
                        //
                        // Determine Connection Limit
                        //
                        int    connectionLimit = InternalConnectionLimit;
                        string schemeHostPort  = MakeQueryString(address);

                        if (ConfigTable.ContainsKey(schemeHostPort))
                        {
                            connectionLimit = (int)ConfigTable[schemeHostPort];
                        }

                        // Note: we don't check permissions to access proxy.
                        //      Rather, we should protect proxy property from being changed

                        servicePoint          = new ServicePoint(address, s_MaxServicePointIdleTime, connectionLimit);
                        servicePointReference = new WeakReference(servicePoint);

                        // only set this when created, donates a proxy, statt Server
                        servicePoint.InternalProxyServicePoint = isProxyServicePoint;

                        s_ServicePointTable[tempEntry] = servicePointReference;
                    }
                    else
                    {
                        Exception exception = new InvalidOperationException(SR.GetString(SR.net_maxsrvpoints));
                        GlobalLog.LeaveException("ServicePointManager::FindServicePoint() reached the limit count:" + s_ServicePointTable.Count.ToString() + " limit:" + s_MaxServicePoints.ToString(), exception);
                        throw exception;
                    }
                }
            } // lock

            GlobalLog.Leave("ServicePointManager::FindServicePoint() servicePoint#" + ValidationHelper.HashString(servicePoint));

            return(servicePoint);
        }
Beispiel #9
0
        public List <Jyx2RoleItem> Items; //武功

        //立绘
        public string GetHeadAvata()
        {
            return(ConfigTable.Get <Jyx2RoleHeadMapping>(Head).HeadAvata);
        }
Beispiel #10
0
        private static void ParserList(Object configInstance, ConfigTable config, FieldInfo propertyInfo, out string error)
        {
            error = "";
            string fieldName = config.ConfigName + "Info";

            if (!propertyInfo.FieldType.Name.StartsWith("List"))
            {
                error = "error field type ,type must be list, now is " + propertyInfo.FieldType.Name;
                return;
            }
            var lineType = ReflectionManager.Instance.GetTypeByName(fieldName);

            if (null == lineType)
            {
                error = "cant' find type by name " + fieldName;
                return;
            }
            var content = Activator.CreateInstance(propertyInfo.FieldType);

            // set content line
            propertyInfo.SetValue(configInstance, content);
            var lineMethorInfo = content.GetType().GetMethod("Add");

            if (null == lineMethorInfo)
            {
                error = "cant' find method by name Add";
                return;
            }

            string parserCellErrorMsg = "";

            for (int j = 0; j < config.Content.Count; ++j)
            {
                var line = config.Content[j];

                if (line.Content.Count != config.FieldInfoList.Count)
                {
                    Logger.Instance.LogWarning("line content count != fieldInfo count");
                    continue;
                }

                var lineInstance = Activator.CreateInstance(lineType);
                for (int i = 0; i < config.FieldInfoList.Count; ++i)
                {
                    string posInfo = "error at pos line: " + (j + 4) + " col: " + (i + 1) + " ";

                    string parserErrorMsg = "";
                    var    fieldInfo      = config.FieldInfoList[i];
                    var    contentCell    = line.Content[i];
                    ParserCell(lineInstance, fieldInfo, contentCell, out parserErrorMsg);
                    if ("" != parserErrorMsg)
                    {
                        parserCellErrorMsg += posInfo + parserErrorMsg;
                    }
                }
                // do list.Add(lineInstance);
                lineMethorInfo.Invoke(content, new [] { lineInstance });
            }
            error = parserCellErrorMsg;
            return;
        }
Beispiel #11
0
    //void OnTest()
    //{
    //    m_Roles = new List<BattlePosRole>();
    //    m_Roles.Add(new BattlePosRole() { pos = "1", team = 0, roleKey = "0" });
    //    m_Roles.Add(new BattlePosRole() { pos = "2", team = 1, roleKey = "1" });
    //    m_Roles.Add(new BattlePosRole() { pos = "1", team = 1, roleKey = "3" });
    //    m_Roles.Add(new BattlePosRole() { pos = "1", team = 1, roleKey = "4" });
    //    m_Roles.Add(new BattlePosRole() { pos = "2", team = 0, roleKey = "5" });
    //    m_Roles.Add(new BattlePosRole() { pos = "2", team = 0, roleKey = "51" });

    //    GameRuntimeData.CreateNew();  //选一个没有用过的id
    //    MapRuntimeData.Instance.Clear();


    //    //测试等级
    //    runtime.TeamLevel = 10;

    //    InitBattle(null);
    //}


    void LoadJyx2Battle(int id, Action <BattleResult> callback)
    {
        Debug.Log("-----------BattleLoader.LoadJyx2Battle");
        if (GameRuntimeData.Instance == null)
        {
            GameRuntimeData.CreateNew();
        }


#if JYX2_TEST
        //临时用于测试
        var player = runtime.Team[0];
        player.MaxHp      = 999;
        player.MaxMp      = 999;
        player.Zuoyouhubo = 1;
        player.Qinggong   = 100;

        player.Attack = 50;
        player.Recover();

        runtime.AddItem(3, 100);//小还丹
#endif


        m_Roles = new List <BattlePosRole>();
        Jyx2Battle battle = ConfigTable.Get <Jyx2Battle>(id);
        if (battle == null)
        {
            Debug.LogError("载入了未定义的战斗,id=" + id);
            return;
        }

        AudioManager.PlayMusic(battle.Music);

        //设置了自动战斗人物
        if (battle.HasAutoTeamMates())
        {
            foreach (var v in battle.AutoTeamMates)
            {
                var roleId = v.Value;
                if (roleId == -1)
                {
                    continue;
                }
                AddRole(roleId, 0); //TODO IS AUTO
            }
            LoadJyx2BattleStep2(battle, null, callback);
        }
        else //否则让玩家选择
        {
            //必选人物
            Func <RoleInstance, bool> mustRoleFunc = (r) => {
                return(battle.TeamMates.Exists(t => t.Value.ToString() == r.Key));
            };

            //弹出选择人物面板
            //Jyx2RoleSelector.Create(runtime.Team, mustRoleFunc, (selectRoles) => {
            //    LoadJyx2BattleStep2(battle, selectRoles, callback);
            //});
            SelectRoleParams selectPram = new SelectRoleParams();
            selectPram.roleList   = runtime.Team;
            selectPram.mustSelect = mustRoleFunc;
            selectPram.title      = "选择上场角色";
            selectPram.maxCount   = 5;//TODO 最大上场人数
            selectPram.canCancel  = false;
            selectPram.callback   = (cb) =>
            {
                LoadJyx2BattleStep2(battle, cb.selectList, callback);
            };
            Jyx2_UIManager.Instance.ShowUI("SelectRolePanel", selectPram);
        }
    }
Beispiel #12
0
        private static void ParserMap(Object configInstance, ConfigTable config, FieldInfo propertyInfo, out string error)
        {
            error = "";

            ConfigFieldInfo keyFieldInfo = null;

            foreach (var fieldInfo in config.FieldInfoList)
            {
                if (fieldInfo.Name == config.KeyFieldName)
                {
                    keyFieldInfo = fieldInfo;
                    break;
                }
            }
            if (null == keyFieldInfo)
            {
                error = "cant' find key fieldinfo by name " + config.KeyFieldName;
                return;
            }
            string keyFieldName = ConvertFieldInfo(keyFieldInfo.Type, out error);

            if ("" != error)
            {
                return;
            }

            string fieldName = config.ConfigName + "Info";

            if (!propertyInfo.FieldType.Name.StartsWith("Dictionary"))
            {
                error = "error field type ,type must be Dictionary, now is " + propertyInfo.FieldType.Name;
                return;
            }
            var lineType = ReflectionManager.Instance.GetTypeByName(fieldName);

            if (null == lineType)
            {
                error = "cant' find type by name " + fieldName;
                return;
            }
            var content = Activator.CreateInstance(propertyInfo.FieldType);

            // set content line
            propertyInfo.SetValue(configInstance, content);
            var ContainsKeyMethorInfo = content.GetType().GetMethod("ContainsKey");

            if (null == ContainsKeyMethorInfo)
            {
                error = "cant' find method by name ContainsKey";
                return;
            }
            var lineMethorInfo = content.GetType().GetMethod("Add");

            if (null == lineMethorInfo)
            {
                error = "cant' find method by name Add";
                return;
            }

            string parserCellErrorMsg = "";

            for (int j = 0; j < config.Content.Count; ++j)
            {
                var line = config.Content[j];

                if (line.Content.Count != config.FieldInfoList.Count)
                {
                    Logger.Instance.LogWarning("line content count != fieldInfo count");
                    continue;
                }

                var    lineInstance = Activator.CreateInstance(lineType);
                Object keyInstance  = null;
                for (int i = 0; i < config.FieldInfoList.Count; ++i)
                {
                    string posInfo = "error at pos line: " + (j + 4) + " col: " + (i + 1) + " ";

                    string parserErrorMsg = "";
                    var    fieldInfo      = config.FieldInfoList[i];
                    var    contentCell    = line.Content[i];
                    var    cellInstance   = ParserCell(lineInstance, fieldInfo, contentCell, out parserErrorMsg);
                    if ("" != parserErrorMsg)
                    {
                        parserCellErrorMsg += posInfo + parserErrorMsg;
                        continue;
                    }
                    if (fieldInfo.Name == config.KeyFieldName)
                    {
                        keyInstance = cellInstance;
                    }
                }
                if (null == keyInstance)
                {
                    parserCellErrorMsg += "error on parser may key at line " + (j + 4);
                    continue;
                }
                bool res = (bool)ContainsKeyMethorInfo.Invoke(content, new object[] { keyInstance });
                if (res)
                {
                    parserCellErrorMsg += "key already in map " + keyInstance + " at line: " + (j + 4);
                    continue;
                }

                // do map.Add(lineInstance);
                lineMethorInfo.Invoke(content, new[] { keyInstance, lineInstance });
            }
            error = parserCellErrorMsg;
            return;
        }
Beispiel #13
0
 public Jyx2Item GetItem()
 {
     return(ConfigTable.Get <Jyx2Item>(_id));
 }
Beispiel #14
0
 public bool CanUseItem(int itemId)
 {
     return(CanUseItem(ConfigTable.Get <Jyx2Item>(itemId)));
 }
Beispiel #15
0
 public GetConfigTable(string sTableName)
 {
     m_sTableName = sTableName;
     Result       = new ConfigTable[0];
 }         // constructor
Beispiel #16
0
 //模型
 public string GetModel()
 {
     return(ConfigTable.Get <Jyx2RoleHeadMapping>(Head).Model);
 }
Beispiel #17
0
 public static LevelFactor Get(int level)
 {
     return(ConfigTable.Get <LevelFactor>(level));
 }
Beispiel #18
0
 public string GetWeaponMount()
 {
     return(ConfigTable.Get <Jyx2RoleHeadMapping>(Head).WeaponMount);
 }
Beispiel #19
0
        //
        // FindServicePoint - Query using an Uri for a given server point
        //

        /// <devdoc>
        /// <para>Findes an existing <see cref='System.Net.ServicePoint'/> or creates a new <see cref='System.Net.ServicePoint'/> to manage communications to the specified <see cref='System.Uri'/>
        /// instance.</para>
        /// </devdoc>
        internal static ServicePoint FindServicePoint(string host, int port)
        {
            if (host == null)
            {
                throw new ArgumentNullException("address");
            }
            GlobalLog.Enter("ServicePointManager::FindServicePoint() host:" + host.ToString());

            string tempEntry           = null;
            bool   isProxyServicePoint = false;


            //
            // Search for the correct proxy host,
            //  then match its acutal host by using ConnectionGroups
            //  which are located on the actual ServicePoint.
            //
            tempEntry = "ByHost:" + host + ":" + port.ToString(CultureInfo.InvariantCulture);
            // lookup service point in the table
            ServicePoint servicePoint = null;

            GlobalLog.Print("ServicePointManager::FindServicePoint() locking and looking up tempEntry:[" + tempEntry.ToString() + "]");
            lock (s_ServicePointTable) {
                // once we grab the lock, check if it wasn't already added
                WeakReference servicePointReference = s_ServicePointTable[tempEntry] as WeakReference;
                GlobalLog.Print("ServicePointManager::FindServicePoint() lookup returned WeakReference#" + ValidationHelper.HashString(servicePointReference));
                if (servicePointReference != null)
                {
                    servicePoint = (ServicePoint)servicePointReference.Target;
                    GlobalLog.Print("ServicePointManager::FindServicePoint() successfull lookup returned ServicePoint#" + ValidationHelper.HashString(servicePoint));
                }
                if (servicePoint == null)
                {
                    // lookup failure or timeout, we need to create a new ServicePoint
                    if (s_MaxServicePoints <= 0 || s_ServicePointTable.Count < s_MaxServicePoints)
                    {
                        // Determine Connection Limit
                        int    connectionLimit = InternalConnectionLimit;
                        bool   userDefined     = s_UserChangedLimit;
                        string schemeHostPort  = host + ":" + port.ToString(CultureInfo.InvariantCulture);

                        if (ConfigTable.ContainsKey(schemeHostPort))
                        {
                            connectionLimit = (int)ConfigTable[schemeHostPort];
                            userDefined     = true;
                        }
                        servicePoint = new ServicePoint(host, port, s_ServicePointIdlingQueue, connectionLimit, tempEntry, userDefined, isProxyServicePoint);
                        GlobalLog.Print("ServicePointManager::FindServicePoint() created ServicePoint#" + ValidationHelper.HashString(servicePoint));
                        servicePointReference          = new WeakReference(servicePoint);
                        s_ServicePointTable[tempEntry] = servicePointReference;
                        GlobalLog.Print("ServicePointManager::FindServicePoint() adding entry WeakReference#" + ValidationHelper.HashString(servicePointReference) + " key:[" + tempEntry + "]");
                    }
                    else
                    {
                        Exception exception = new InvalidOperationException(SR.GetString(SR.net_maxsrvpoints));
                        GlobalLog.LeaveException("ServicePointManager::FindServicePoint() reached the limit count:" + s_ServicePointTable.Count.ToString() + " limit:" + s_MaxServicePoints.ToString(), exception);
                        throw exception;
                    }
                }
            }

            GlobalLog.Leave("ServicePointManager::FindServicePoint() servicePoint#" + ValidationHelper.HashString(servicePoint));
            return(servicePoint);
        }
Beispiel #20
0
 public string GetBattleAnimator()
 {
     return(ConfigTable.Get <Jyx2RoleHeadMapping>(Head).BattleAnimator);
 }
Beispiel #21
0
        private static ServicePoint FindServicePointHelper(Uri address, bool isProxyServicePoint)
        {
            GlobalLog.Enter("ServicePointManager::FindServicePointHelper() address:" + address.ToString());

            if (isProxyServicePoint)
            {
                if (address.Scheme != Uri.UriSchemeHttp)
                {
                    // <



                    Exception exception = new NotSupportedException(SR.GetString(SR.net_proxyschemenotsupported, address.Scheme));
                    GlobalLog.LeaveException("ServicePointManager::FindServicePointHelper() proxy has unsupported scheme:" + address.Scheme.ToString(), exception);
                    throw exception;
                }
            }

            //
            // Search for the correct proxy host,
            //  then match its acutal host by using ConnectionGroups
            //  which are located on the actual ServicePoint.
            //
            string tempEntry = MakeQueryString(address, isProxyServicePoint);

            // lookup service point in the table
            ServicePoint servicePoint = null;

            GlobalLog.Print("ServicePointManager::FindServicePointHelper() locking and looking up tempEntry:[" + tempEntry.ToString() + "]");
            lock (s_ServicePointTable) {
                // once we grab the lock, check if it wasn't already added
                WeakReference servicePointReference = s_ServicePointTable[tempEntry] as WeakReference;
                GlobalLog.Print("ServicePointManager::FindServicePointHelper() lookup returned WeakReference#" + ValidationHelper.HashString(servicePointReference));
                if (servicePointReference != null)
                {
                    servicePoint = (ServicePoint)servicePointReference.Target;
                    GlobalLog.Print("ServicePointManager::FindServicePointHelper() successful lookup returned ServicePoint#" + ValidationHelper.HashString(servicePoint));
                }
                if (servicePoint == null)
                {
                    // lookup failure or timeout, we need to create a new ServicePoint
                    if (s_MaxServicePoints <= 0 || s_ServicePointTable.Count < s_MaxServicePoints)
                    {
                        // Determine Connection Limit
                        int    connectionLimit = InternalConnectionLimit;
                        string schemeHostPort  = MakeQueryString(address);
                        bool   userDefined     = s_UserChangedLimit;
                        if (ConfigTable.ContainsKey(schemeHostPort))
                        {
                            connectionLimit = (int)ConfigTable[schemeHostPort];
                            userDefined     = true;
                        }
                        servicePoint = new ServicePoint(address, s_ServicePointIdlingQueue, connectionLimit, tempEntry, userDefined, isProxyServicePoint);
                        GlobalLog.Print("ServicePointManager::FindServicePointHelper() created ServicePoint#" + ValidationHelper.HashString(servicePoint));
                        servicePointReference          = new WeakReference(servicePoint);
                        s_ServicePointTable[tempEntry] = servicePointReference;
                        GlobalLog.Print("ServicePointManager::FindServicePointHelper() adding entry WeakReference#" + ValidationHelper.HashString(servicePointReference) + " key:[" + tempEntry + "]");
                    }
                    else
                    {
                        Exception exception = new InvalidOperationException(SR.GetString(SR.net_maxsrvpoints));
                        GlobalLog.LeaveException("ServicePointManager::FindServicePointHelper() reached the limit count:" + s_ServicePointTable.Count.ToString() + " limit:" + s_MaxServicePoints.ToString(), exception);
                        throw exception;
                    }
                }
            }

            GlobalLog.Leave("ServicePointManager::FindServicePointHelper() servicePoint#" + ValidationHelper.HashString(servicePoint));
            return(servicePoint);
        }
Beispiel #22
0
    //执行指令
    public void ExecuteCommand(string command, List <GameObject> paraGameObjects)
    {
        if (string.IsNullOrEmpty(command))
        {
            return;
        }

        m_ParaGameObjects = paraGameObjects;

        string cmd   = command.Split('#')[0].ToLower();
        string value = command.Substring(cmd.Length + 1); //command.Split('#')[1];

        if (cmd == "dialog")
        {
            //dialogPanel.Show("", value, null);
            Jyx2_UIManager.Instance.ShowUI("ChatUIPanel", ChatType.RoleKey, "", value);
        }
        else if (cmd == "selfsay")
        {
            GameRuntimeData.Instance.Player.View.Say(value);
        }
        else if (cmd == "loadlevel")
        {
            SceneManager.LoadScene(value);
        }
        else if (cmd == "loadmap")
        {
            var loadPara = new LevelMaster.LevelLoadPara()
            {
                loadType = LevelMaster.LevelLoadPara.LevelLoadType.Load
            };
            LevelLoader.LoadGameMap(value, loadPara);
        }
        else if (cmd == "mapevt")
        {
            MapEvt mapEvt = ConfigTable.Get <MapEvt>(value);

            if (mapEvt != null)
            {
                //如果已经执行过,返回
                if (mapEvt.IsFinished(runtime))
                {
                    return;
                }

                //标记为正在执行
                mapEvt.MarkAsExecuting(runtime);

                m_CurrentMapEvt = mapEvt;
                PlayStory(mapEvt.ExecuteCode.Split('\n'), mapEvt.Result);
            }
            else
            {
                Debug.LogError("载入了错误的mapevt:" + value);
            }
        }
        else if (cmd == "timeline")
        {
            PlayTimeline(value, null);
        }
        else if (cmd == "runtimestory")
        {
            PlayStory(new string[] { value }, "");
        }
        else if (cmd == "transport")
        {
            var levelMaster = FindObjectOfType <LevelMaster>();
            levelMaster.Transport(value);
        }
        else if (cmd == "win")
        {
            BattleHelper battleHelper = FindObjectOfType <BattleHelper>();
            var          model        = battleHelper.GetModel();
            foreach (var role in model.Roles)
            {
                if (role.team != 0)
                {
                    role.Hp = 0;
                }
                role.CheckDeath();
            }

            HSUtilsEx.CallWithDelay(this, () => {
                battleHelper.SwitchStatesTo(BattleHelper.BattleViewStates.WaitingForNextActiveBattleRole);
            }, 1f);
        }
        else if (cmd == "lose")
        {
            BattleHelper battleHelper = FindObjectOfType <BattleHelper>();
            var          model        = battleHelper.GetModel();
            foreach (var role in model.Roles)
            {
                if (role.team == 0)
                {
                    role.Hp = 0;
                }
                role.CheckDeath();
            }
            HSUtilsEx.CallWithDelay(this, () =>
            {
                battleHelper.SwitchStatesTo(BattleHelper.BattleViewStates.WaitingForNextActiveBattleRole);
            }, 1f);
        }
        else if (cmd == "testlua")
        {
            LuaExecutor.Execute(value);
        }
        else if (cmd == "jyx2event")
        {
            LuaExecutor.Execute("jygame/ka" + value);
        }
        else if (cmd == "battle")
        {
            LevelLoader.LoadBattle(int.Parse(value), null);
        }
    }