Esempio n. 1
0
        /// <summary>
        /// 加载数据
        /// </summary>
        public static void InitBoss(UserGuild userGuild)
        {
            try
            {
                if (_userGuildList.ContainsKey(userGuild.GuildID))
                {
                    _userGuildList[userGuild.GuildID] = userGuild;
                }
                else
                {
                    _userGuildList.Add(userGuild.GuildID, userGuild);
                }

                CombatGeneral general = CreateBossGeneral(userGuild);
                if (!_bossGeneralList.ContainsKey(userGuild.GuildID))
                {
                    _bossGeneralList.Add(userGuild.GuildID, new BossDictionary {
                        BossGeneral = general
                    });
                }
                else
                {
                    _bossGeneralList[userGuild.GuildID].BossGeneral = general;
                }
            }
            catch (Exception ex)
            {
                new BaseLog().SaveLog(ex);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 查询所在Team
 /// </summary>
 /// <param name="userId"></param>
 /// <returns>无:-1</returns>
 public int GetTeamId(string userId)
 {
     if (_userList != null && _userList.ContainsKey(userId))
     {
         return(_userList[userId]);
     }
     return(-1);
 }
Esempio n. 3
0
        private static bool CheckFileChanged(string fileName)
        {
            string scriptCode = GetScriptCode(fileName);

            if (_scriptCodeCache.ContainsKey(scriptCode))
            {
                var    script   = _scriptCodeCache[scriptCode];
                string hashcode = GetFileHashCode(fileName);
                return(script != null &&
                       !string.IsNullOrEmpty(hashcode) &&
                       script.HashCode != hashcode);
            }
            return(false);
        }
Esempio n. 4
0
 private static void SetCombatResult(int teamId, bool isWin)
 {
     if (_combatProcessList != null)
     {
         if (!_combatProcessList.ContainsKey(teamId))
         {
             _combatProcessList.TryAdd(teamId, new TeamCombatResult());
         }
         lock (ThisLock)
         {
             TeamCombatResult tempList = _combatProcessList[teamId];
             tempList.IsWin = isWin;
         }
     }
 }
Esempio n. 5
0
        private ScriptFileInfo LoadScript(string scriptPath, string fileName, bool isReLoad = false)
        {
            ScriptFileInfo scriptFileInfo = null;
            string         scriptCode     = GetScriptCode(fileName);

            if (!isReLoad && _csharpCodeCache.ContainsKey(scriptCode))
            {
                var old = _csharpCodeCache[scriptCode];
                if (!File.Exists(fileName) ||
                    old.HashCode == GetFileHashCode(fileName))
                {
                    return(old);
                }
            }
            scriptFileInfo = CreateScriptFile(fileName);
            if (scriptFileInfo != null)
            {
                if (scriptPath == _modelScriptPath)
                {
                    _modelCodeCache[scriptCode] = scriptFileInfo;
                }
                else
                {
                    _csharpCodeCache[scriptCode] = scriptFileInfo;
                }
            }
            return(scriptFileInfo);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public override bool VerifyScriptHashCode(string fileName)
        {
            string ext = Path.GetExtension(fileName);

            if (string.Compare(ext, ".cs", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(base.VerifyScriptHashCode(fileName));
            }
            string scriptCode = GetScriptCode(fileName);

            if (File.Exists(fileName))
            {
                if (fileName.EndsWith("AssemblyInfo.cs", StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
                ScriptFileInfo code = null;
                if (_modelCodeCache.ContainsKey(scriptCode))
                {
                    code = _modelCodeCache[scriptCode];
                }
                if (_csharpCodeCache.ContainsKey(scriptCode))
                {
                    code = _csharpCodeCache[scriptCode];
                }
                if (code == null)
                {
                    return(false);
                }
                string source = Decode(File.ReadAllText(fileName), ext);
                return(code.HashCode == CryptoHelper.ToMd5Hash(source));
            }
            return(false);
        }
Esempio n. 7
0
        /// <summary>
        /// 获得参战的玩家
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public BossUser GetCombatUser(string userId)
        {
            DictionaryExtend <string, BossUser> userGeneralList = BossDict.UserGeneralList;

            if (userGeneralList.ContainsKey(userId))
            {
                return(userGeneralList[userId]);
            }

            throw new Exception(string.Format("玩家{0}未加入公会Boss活动id:{1}", userId, _guildID));
        }
Esempio n. 8
0
        /// <summary>
        /// 加载数据
        /// </summary>
        public static void InitBoss(GameActive gameActive)
        {
            if (_gameActiveList.ContainsKey(gameActive.ActiveId))
            {
                _gameActiveList[gameActive.ActiveId] = gameActive;
            }
            else
            {
                _gameActiveList.Add(gameActive.ActiveId, gameActive);
            }

            CombatGeneral general = CreateBossGeneral(gameActive);

            if (!_bossGeneralList.ContainsKey(gameActive.ActiveId))
            {
                _bossGeneralList.Add(gameActive.ActiveId, new BossDictionary {
                    BossGeneral = general
                });
            }
            else
            {
                _bossGeneralList[gameActive.ActiveId].BossGeneral = general;
            }
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public override bool VerifyScriptHashCode(string fileName)
        {
            string ext = Path.GetExtension(fileName);

            if (string.Compare(ext, ".py", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(base.VerifyScriptHashCode(fileName));
            }
            string scriptCode = GetScriptCode(fileName);

            if (File.Exists(fileName) && _pythonCodeCache.ContainsKey(scriptCode))
            {
                var    old    = _pythonCodeCache[scriptCode];
                string source = Decode(File.ReadAllText(fileName), ext);
                return(old.HashCode == CryptoHelper.ToMd5Hash(source));
            }
            return(false);
        }
Esempio n. 10
0
        /// <summary>
        /// 设置赢的次数
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="plotId"></param>
        public void SetWinNum(string userId, int plotId)
        {
            if (_userTimesList == null)
            {
                return;
            }
            string key = userId + plotId;

            lock (ThisLock)
            {
                if (_userTimesList.ContainsKey(key))
                {
                    _userTimesList[key] = _userTimesList[key] + 1;
                }
                else
                {
                    _userTimesList.Add(key, 1);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="isReLoad"></param>
        /// <returns></returns>
        private PythonFileInfo LoadScript(string fileName, bool isReLoad = false)
        {
            PythonFileInfo scriptFileInfo = null;
            string         scriptCode     = GetScriptCode(fileName);

            if (!isReLoad && _pythonCodeCache.ContainsKey(scriptCode))
            {
                var old = _pythonCodeCache[scriptCode];
                if (!File.Exists(fileName) ||
                    old.HashCode == GetFileHashCode(fileName))
                {
                    return(old);
                }
            }
            scriptFileInfo = CreateScriptFile(fileName);
            if (scriptFileInfo != null)
            {
                _pythonCodeCache[scriptCode] = scriptFileInfo;
            }
            return(scriptFileInfo);
        }
Esempio n. 12
0
        /// <summary>
        /// 加载脚本对象
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="isUpdate"></param>
        public static ScriptFileInfo LoadScript(string fileName, bool isUpdate = false)
        {
            ScriptFileInfo scriptFileInfo = null;
            string         scriptCode     = GetScriptCode(fileName);

            if (!isUpdate && _scriptCodeCache.ContainsKey(scriptCode))
            {
                var old = _scriptCodeCache[scriptCode];
                if (!File.Exists(fileName) ||
                    old.HashCode == GetFileHashCode(fileName))
                {
                    return(old);
                }
            }
            scriptFileInfo = CreateScriptFile(fileName);
            if (scriptFileInfo != null)
            {
                _scriptCodeCache[scriptCode] = scriptFileInfo;
            }
            return(scriptFileInfo);
        }
Esempio n. 13
0
 /// <summary>
 /// entity data send to client
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventargs"></param>
 public static void OnChange(AbstractEntity sender, CacheItemEventArgs eventargs)
 {
     try
     {
         if (sender == null ||
             (sender as BaseEntity) == null ||
             !sender.GetSchema().IsEntitySync)
         {
             return;
         }
         string key = sender.GetKeyCode();
         if (!_syncPools.ContainsKey(key))
         {
             _syncPools[key] = true;
             _sendQueue.Enqueue(sender as BaseEntity);
             singal.Set();
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("EntitySync Notify error:{0}", ex);
     }
 }
Esempio n. 14
0
 /// <summary>
 /// 获取Team信息
 /// </summary>
 /// <param name="teamId"></param>
 /// <returns></returns>
 public MorePlotTeam GetTeam(int teamId)
 {
     return(_teamList != null && _teamList.ContainsKey(teamId) ? _teamList[teamId] : new MorePlotTeam());
 }
Esempio n. 15
0
 /// <summary>
 /// Get model entity assembly.
 /// </summary>
 /// <returns></returns>
 public static Assembly GetEntityAssembly()
 {
     return(_watcherDict.ContainsKey(ModelDirName)
         ? _watcherDict[ModelDirName].Assembly
         : null);
 }