コード例 #1
0
        private void InitDynamicMonsterSeedByMonserID(int monsterID)
        {
            MonsterZone monsterZone = new MonsterZone();
            Monster     myMonster   = null;

            if (!this._DictDynamicMonsterSeed.TryGetValue(monsterID, out myMonster) || null == myMonster)
            {
                int ID = 1;
                lock (this._DictDynamicMonsterSeed)
                {
                    ID = this._DictDynamicMonsterSeed.Count + 1;
                }
                monsterZone.MapCode = 1;
                monsterZone.ID      = ID;
                monsterZone.Code    = monsterID;
                monsterZone.LoadStaticMonsterInfo();
                myMonster = monsterZone.LoadDynamicMonsterSeed();
                lock (this._DictDynamicMonsterSeed)
                {
                    if (!this._DictDynamicMonsterSeed.ContainsKey(monsterID))
                    {
                        this._DictDynamicMonsterSeed.Add(monsterID, myMonster);
                    }
                }
            }
        }
コード例 #2
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 初始化动态召唤怪物的缓存
        /// </summary>
        /// <param name="monsterID"></param>
        private void InitDynamicMonsterSeedByMonserID(int monsterID)
        {
            MonsterZone monsterZone = new MonsterZone();

            Monster myMonster = null;

            //如果原来有,就不要再次加载了,重用就好,相当于增量加载
            if (_DictDynamicMonsterSeed.TryGetValue(monsterID, out myMonster) && null != myMonster)
            {
                return;
            }

            int ID = 1;

            lock (_DictDynamicMonsterSeed)
            {
                ID = _DictDynamicMonsterSeed.Count + 1;
            }

            monsterZone.MapCode = 1;//强行设置地图编号 后期进程允许过程中动态修改
            monsterZone.ID      = ID;
            monsterZone.Code    = monsterID;

            //加载静态的怪物信息
            monsterZone.LoadStaticMonsterInfo();

            //加载怪物
            myMonster = monsterZone.LoadDynamicMonsterSeed();

            lock (_DictDynamicMonsterSeed)
            {
                //不存在就加入
                if (!_DictDynamicMonsterSeed.ContainsKey(monsterID))
                {
                    _DictDynamicMonsterSeed.Add(monsterID, myMonster);
                }
            }
        }