コード例 #1
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        public bool GetMonsterBirthPoint(int mapCode, int nMonsterID, out int posX, out int posY, out int radis)
        {
            posX  = 0;
            posY  = 0;
            radis = 0;
            GameMap gameMap = null;

            if (!GameManager.MapMgr.DictMaps.TryGetValue(mapCode, out gameMap))
            {
                return(false);
            }

            List <MonsterZone> monsterZoneList = null;

            if (!Map2MonsterZoneDict.TryGetValue(mapCode, out monsterZoneList))
            {
                return(false);
            }

            for (int i = 0; i < monsterZoneList.Count; i++)
            {
                MonsterZone zone = monsterZoneList[i];
                if (zone.Code == nMonsterID)
                {
                    Point p = Global.GridToPixel(mapCode, zone.ToX, zone.ToY);
                    posX = (int)p.X;
                    posY = (int)p.Y;

                    return(true);
                    //   Radius = (int)Global.GetSafeAttributeLong(monsterItem, "Radius") / gameMap.MapGridWidth,
                }
            }

            return(false);
        }
コード例 #2
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);
                    }
                }
            }
        }
コード例 #3
0
        public void AddDynamicMonsterZone(int mapCode)
        {
            bool        isFuBenMap  = FuBenManager.IsFuBenMap(mapCode);
            MonsterZone monsterZone = new MonsterZone
            {
                MapCode            = mapCode,
                ID                 = this.MonsterDynamicZoneDict.Count + 10000,
                Code               = -1,
                ToX                = -1,
                ToY                = -1,
                Radius             = 300,
                TotalNum           = 0,
                Timeslot           = 1,
                IsFuBenMap         = isFuBenMap,
                BirthType          = 3,
                ConfigBirthType    = -1,
                BirthTimePointList = null,
                BirthRate          = 10000
            };

            monsterZone.PursuitRadius = 0;
            lock (this.InitMonsterZoneMutex)
            {
                this.MonsterDynamicZoneDict.Add(mapCode, monsterZone);
                this.MonsterZoneList.Add(monsterZone);
                if (isFuBenMap)
                {
                    this.FuBenMonsterZoneList.Add(monsterZone);
                }
                this.AddMap2MonsterZoneDict(monsterZone);
            }
        }
コード例 #4
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 添加任意地图的动态怪物到生成队列 radius 是格子坐标范围,不是像素点坐标范围!!!!
        /// </summary>
        /// <param name="mapCode"></param>
        /// <param name="copyMap"></param>
        public void AddDynamicRobot(int mapCode, Robot robot, int copyMapID = -1, int addNum = 1, int gridX = 0, int gridY = 0, int radius = 3, int pursuitRadius = 0, SceneUIClasses managerType = SceneUIClasses.Normal, object tag = null)
        {
            //先打印下怪物日志,便于调试
            TraceAllDynamicMonsters();

            MonsterZone monsterZone = null;

            if (!MonsterDynamicZoneDict.TryGetValue(mapCode, out monsterZone))
            {
                return;
            }

            robot.MonsterZoneNode = monsterZone;

            //等待爆副本怪的队列
            lock (WaitingReloadRobotQueue) //线程锁
            {
                WaitingReloadRobotQueue.Enqueue(new MonsterZoneQueueItem()
                {
                    CopyMapID     = copyMapID,
                    BirthCount    = addNum,
                    MyMonsterZone = monsterZone,
                    seedMonster   = robot,
                    ToX           = gridX,
                    ToY           = gridY,
                    Radius        = radius,
                    PursuitRadius = pursuitRadius,
                    Tag           = tag,
                    ManagerType   = managerType,
                });
            }
        }
コード例 #5
0
        public void SendMonsterToGrave(Monster monster, YugiohGamePlayer player)
        {
            var index = MonsterZones.ToList().FindIndex(z => z.Monster == monster);

            MonsterZones[index] = new MonsterZone();
            player.DiscardPile.Add(monster);
            monster.Location = CardLocation.Graveyard;
        }
コード例 #6
0
        /// <summary>
        /// 添加任意地图的动态怪物到生成队列[角色采用召唤的方式动态生成宠物怪]
        /// </summary>
        /// <param name="mapCode"></param>
        /// <param name="copyMap"></param>
        public Boolean CallDynamicMonstersOwnedByRole(GameClient client, int monsterID, int callAsType = (int)MonsterTypes.DSPetMonster, int callNum = 1, int pursuitRadius = 0)
        {
            //先打印下怪物日志,便于调试
            TraceAllDynamicMonsters();

            int   mapCode = client.ClientData.MapCode;
            int   copyMapID = client.ClientData.CopyMapID;
            Point grid = client.CurrentGrid;
            int   gridX = (int)grid.X, gridY = (int)grid.Y;
            int   radius = 3;

            MonsterZone monsterZone = null;

            if (!MonsterDynamicZoneDict.TryGetValue(mapCode, out monsterZone))
            {
                return(false);
            }

            Monster seedMonster = GetDynamicMonsterSeed(monsterID);

            if (null == seedMonster)
            {
                return(false);
            }

            Monster realSeedMonster = seedMonster.Clone();

            //更改怪物类型,通过这个参数将怪物转换为非野外怪物
            realSeedMonster.MonsterType = callAsType;

            //更改怪物所有者,这样怪物接受该client的指令控制,同时,总跟着client跑
            realSeedMonster.OwnerClient = client;

            /// 重新计算道士召唤的怪物的属性
            if (callAsType == (int)MonsterTypes.DSPetMonster)
            {
                Global.RecalcDSMonsterProps(client, realSeedMonster);
            }

            //等待爆副本怪的队列
            lock (WaitingAddDynamicMonsterQueue) //线程锁
            {
                WaitingAddDynamicMonsterQueue.Enqueue(new MonsterZoneQueueItem()
                {
                    CopyMapID     = copyMapID,
                    BirthCount    = callNum,
                    MyMonsterZone = monsterZone,
                    seedMonster   = realSeedMonster,
                    ToX           = gridX,
                    ToY           = gridY,
                    Radius        = radius,
                    PursuitRadius = pursuitRadius,
                });
            }

            return(true);
        }
コード例 #7
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 返回动态刷怪区域
        /// </summary>
        /// <param name="mapCode"></param>
        /// <returns></returns>
        public MonsterZone GetDynamicMonsterZone(int mapCode)
        {
            MonsterZone zone = null;

            if (MonsterDynamicZoneDict.TryGetValue(mapCode, out zone))
            {
                return(zone);
            }

            return(null);
        }
コード例 #8
0
ファイル: ClientField.cs プロジェクト: mercury233/libWindbot
        public int GetRemainingCount(int cardId, int initialCount)
        {
            int remaining = initialCount;

            remaining = remaining - Hand.Count(card => card != null && card.IsOriginalCode(cardId));
            remaining = remaining - SpellZone.Count(card => card != null && card.IsOriginalCode(cardId));
            remaining = remaining - MonsterZone.Count(card => card != null && card.IsOriginalCode(cardId));
            remaining = remaining - Graveyard.Count(card => card != null && card.IsOriginalCode(cardId));
            remaining = remaining - Banished.Count(card => card != null && card.IsOriginalCode(cardId));
            return((remaining < 0) ? 0 : remaining);
        }
コード例 #9
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 添加任意地图的动态怪物到生成队列 radius 是格子坐标范围,不是像素点坐标范围!!!!
        /// </summary>
        /// <param name="mapCode"></param>
        /// <param name="copyMap"></param>
        /// <returns>怪物种子对象,并非实际的怪物对象</returns>
        public Monster AddDynamicMonsters(int mapCode, int monsterID, int copyMapID = -1, int addNum = 1, int gridX                      = 0, int gridY = 0, int radius = 3,
                                          int pursuitRadius = 0, SceneUIClasses managerType          = SceneUIClasses.Normal, object tag = null)
        {
            //先打印下怪物日志,便于调试
            TraceAllDynamicMonsters();

            MonsterZone monsterZone = null;

            if (!MonsterDynamicZoneDict.TryGetValue(mapCode, out monsterZone))
            {
                return(null);
            }

            Monster seedMonster = GetDynamicMonsterSeed(monsterID);

            if (null == seedMonster)
            {
                return(null);
            }

            int index = 0;

            if (copyMapID >= 0)
            {
                index = Global.Clamp(copyMapID % Max_WaitingAddDynamicMonsterQueneCount, 0, Max_WaitingAddDynamicMonsterQueneCount - 1);
            }
            else
            {
                index = Global.Clamp(mapCode % Max_WaitingAddDynamicMonsterQueneCount, 0, Max_WaitingAddDynamicMonsterQueneCount - 1);
            }

            //等待爆副本怪的队列
            lock (WaitingAddDynamicMonsterQueue) //线程锁
            {
                WaitingAddDynamicMonsterQueue[index].Enqueue(new MonsterZoneQueueItem()
                {
                    CopyMapID     = copyMapID,
                    BirthCount    = addNum,
                    MyMonsterZone = monsterZone,
                    seedMonster   = seedMonster,
                    ToX           = gridX,
                    ToY           = gridY,
                    Radius        = radius,
                    PursuitRadius = pursuitRadius,
                    Tag           = tag,
                    ManagerType   = managerType,
                });
            }

            return(seedMonster);
        }
コード例 #10
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 加入爆怪区域
        /// </summary>
        /// <param name="monsterZone"></param>
        private void AddMap2MonsterZoneDict(MonsterZone monsterZone)
        {
            List <MonsterZone> monsterZoneList = null;

            if (Map2MonsterZoneDict.TryGetValue(monsterZone.MapCode, out monsterZoneList))
            {
                monsterZoneList.Add(monsterZone);
                return;
            }

            monsterZoneList = new List <MonsterZone>();
            Map2MonsterZoneDict[monsterZone.MapCode] = monsterZoneList;
            monsterZoneList.Add(monsterZone);
        }
コード例 #11
0
        public Monster AddDynamicMonsters(int mapCode, int monsterID, int copyMapID = -1, int addNum = 1, int gridX = 0, int gridY = 0, int radius = 3, int pursuitRadius = 0, SceneUIClasses managerType = SceneUIClasses.Normal, object tag = null, MonsterFlags flags = null)
        {
            this.TraceAllDynamicMonsters();
            MonsterZone monsterZone = null;
            Monster     result;

            if (!this.MonsterDynamicZoneDict.TryGetValue(mapCode, out monsterZone))
            {
                result = null;
            }
            else
            {
                Monster seedMonster = this.GetDynamicMonsterSeed(monsterID);
                if (null == seedMonster)
                {
                    result = null;
                }
                else
                {
                    int index;
                    if (copyMapID >= 0)
                    {
                        index = Global.Clamp(copyMapID % 10, 0, 9);
                    }
                    else
                    {
                        index = Global.Clamp(mapCode % 10, 0, 9);
                    }
                    lock (this.WaitingAddDynamicMonsterQueue)
                    {
                        this.WaitingAddDynamicMonsterQueue[index].Enqueue(new MonsterZoneQueueItem
                        {
                            CopyMapID     = copyMapID,
                            BirthCount    = addNum,
                            MyMonsterZone = monsterZone,
                            seedMonster   = seedMonster,
                            ToX           = gridX,
                            ToY           = gridY,
                            Radius        = radius,
                            PursuitRadius = pursuitRadius,
                            Tag           = tag,
                            ManagerType   = managerType,
                            Flags         = flags
                        });
                    }
                    result = seedMonster;
                }
            }
            return(result);
        }
コード例 #12
0
        public MonsterZone GetDynamicMonsterZone(int mapCode)
        {
            MonsterZone zone = null;
            MonsterZone result;

            if (this.MonsterDynamicZoneDict.TryGetValue(mapCode, out zone))
            {
                result = zone;
            }
            else
            {
                result = null;
            }
            return(result);
        }
コード例 #13
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 添加动态爆怪区域,每个地图有一个,所有参数都动态生成
        /// </summary>
        /// <param name="mapCode"></param>
        public void AddDynamicMonsterZone(int mapCode)
        {
            //判断是否是副本地图
            bool isFuBenMap = FuBenManager.IsFuBenMap(mapCode);

            MonsterZone monsterZone = new MonsterZone()
            {
                MapCode    = mapCode,
                ID         = MonsterDynamicZoneDict.Count + 10000, //动态配置 爆怪的区域ID,这个ID这样生成就可以
                Code       = -1,                                   //动态配置---区域怪物ID,需要生成的时候动态配置
                ToX        = -1,                                   //动态配置
                ToY        = -1,                                   //动态配置
                Radius     = 300,                                  //可以动态修改
                TotalNum   = 0,                                    //动态
                Timeslot   = 1,
                IsFuBenMap = isFuBenMap,
                //意味着该区域的怪不管是在副本还说非副本,都由外部代码动态控制怪物的加载,怪物不会被程序定期循环复活
                //同时该区域的怪物一旦死亡,直接销毁【将来或许需要加入一个针对这种类型的最大复活次数?】
                BirthType          = (int)MonsterBirthTypes.CrossMap, //这个字段非常重要,用于区分是动态刷怪区域还是 旧的系统怪区域!!!!!!
                ConfigBirthType    = -1,                              //配置文件可没配置
                BirthTimePointList = null,
                BirthRate          = 10000,                           //必爆
            };

            //追踪范围,动态配置
            monsterZone.PursuitRadius = 0;

            lock (InitMonsterZoneMutex)
            {
                //动态爆怪区域列表--->里面的怪物一旦死亡,移除
                MonsterDynamicZoneDict.Add(mapCode, monsterZone);

                //加入列表
                MonsterZoneList.Add(monsterZone);

                //如果是副本地图, 则加入副本爆怪区域列表
                if (isFuBenMap)
                {
                    FuBenMonsterZoneList.Add(monsterZone);
                }

                //加入爆怪区域
                AddMap2MonsterZoneDict(monsterZone);
            }
        }
コード例 #14
0
 public PlayerSideField()
 {
     this.monsterZone1 = new MonsterZone();
     this.monsterZone2 = new MonsterZone();
     this.monsterZone3 = new MonsterZone();
     this.monsterZone4 = new MonsterZone();
     this.monsterZone5 = new MonsterZone();
     this.mpZone1      = new TrapMagicZone();
     this.mpZone2      = new TrapMagicZone();
     this.mpZone3      = new TrapMagicZone();
     this.mpZone4      = new TrapMagicZone();
     this.mpZone5      = new TrapMagicZone();
     this.fieldZone    = new StackCard();
     this.Graveyard    = new StackCard();
     this.Extradeck    = new StackCard();
     this.Outzone      = new StackCard();
     this.Deck         = new StackCard();
 }
コード例 #15
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);
                }
            }
        }
コード例 #16
0
        public bool GetMonsterBirthPoint(int mapCode, int nMonsterID, out int posX, out int posY, out int radis)
        {
            posX  = 0;
            posY  = 0;
            radis = 0;
            GameMap gameMap = null;
            bool    result;

            if (!GameManager.MapMgr.DictMaps.TryGetValue(mapCode, out gameMap))
            {
                result = false;
            }
            else
            {
                List <MonsterZone> monsterZoneList = null;
                if (!this.Map2MonsterZoneDict.TryGetValue(mapCode, out monsterZoneList))
                {
                    result = false;
                }
                else
                {
                    for (int i = 0; i < monsterZoneList.Count; i++)
                    {
                        MonsterZone zone = monsterZoneList[i];
                        if (zone.Code == nMonsterID)
                        {
                            Point p = Global.GridToPixel(mapCode, (double)zone.ToX, (double)zone.ToY);
                            posX = (int)p.X;
                            posY = (int)p.Y;
                            return(true);
                        }
                    }
                    result = false;
                }
            }
            return(result);
        }
コード例 #17
0
        public bool CallDynamicMonstersOwnedByMonster(Monster owner, int monsterID, int magicLevel, int SurvivalTime, int callAsType = 1001, int callNum = 1, int pursuitRadius = 0)
        {
            this.TraceAllDynamicMonsters();
            int         mapCode     = owner.CurrentMapCode;
            int         copyMapID   = owner.CopyMapID;
            Point       grid        = owner.CurrentGrid;
            int         gridX       = (int)grid.X;
            int         gridY       = (int)grid.Y;
            int         radius      = 3;
            MonsterZone monsterZone = this.GetDynamicMonsterZone(mapCode);
            bool        result;

            if (null == monsterZone)
            {
                result = false;
            }
            else
            {
                Monster seedMonster = this.GetDynamicMonsterSeed(monsterID);
                if (null == seedMonster)
                {
                    result = false;
                }
                else
                {
                    Monster realSeedMonster = seedMonster.Clone();
                    realSeedMonster.MonsterInfo  = realSeedMonster.MonsterInfo.Clone();
                    realSeedMonster.MonsterType  = callAsType;
                    realSeedMonster.OwnerMonster = owner;
                    if (callAsType == 1001)
                    {
                        Global.RecalcDSMonsterProps(owner, realSeedMonster, magicLevel, SurvivalTime);
                    }
                    int index;
                    if (owner.CurrentCopyMapID >= 0)
                    {
                        index = Global.Clamp(owner.CurrentCopyMapID % 10, 0, 9);
                    }
                    else
                    {
                        index = Global.Clamp(owner.CurrentCopyMapID % 10, 0, 9);
                    }
                    lock (this.WaitingAddDynamicMonsterQueue)
                    {
                        this.WaitingAddDynamicMonsterQueue[index].Enqueue(new MonsterZoneQueueItem
                        {
                            CopyMapID     = copyMapID,
                            BirthCount    = callNum,
                            MyMonsterZone = monsterZone,
                            seedMonster   = realSeedMonster,
                            ToX           = gridX,
                            ToY           = gridY,
                            Radius        = radius,
                            PursuitRadius = pursuitRadius
                        });
                    }
                    result = true;
                }
            }
            return(result);
        }
コード例 #18
0
ファイル: MonsterZoneManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 加载怪物
        /// </summary>
        public void AddMapMonsters(int mapCode, GameMap gameMap)
        {
            //对于每一个地图,都要加入一个动态刷怪区域,用于动态刷怪管理
            AddDynamicMonsterZone(mapCode);

            string   fileName = string.Format("Map/{0}/Monsters.xml", mapCode);
            XElement xml      = null;

            try
            {
                xml = XElement.Load(Global.ResPath(fileName));
            }
            catch (Exception)
            {
                throw new Exception(string.Format("加载地图怪物配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName));
            }

            IEnumerable <XElement> monsterItems = xml.Elements("Monsters").Elements();

            if (null == monsterItems)
            {
                return;
            }

            //判断是否是副本地图
            bool isFuBenMap = FuBenManager.IsFuBenMap(mapCode);

            foreach (var monsterItem in monsterItems)
            {
                String timePoints      = Global.GetSafeAttributeStr(monsterItem, "TimePoints");
                int    configBirthType = (int)Global.GetSafeAttributeLong(monsterItem, "BirthType");
                int    realBirthType   = configBirthType;

                String realTimePoints = timePoints;
                int    spawnMonstersAfterKaiFuDays = 0;
                int    spawnMonstersDays           = 0;
                List <BirthTimeForDayOfWeek> CreateMonstersDayOfWeek = new List <BirthTimeForDayOfWeek>();
                List <BirthTimePoint>        birthTimePointList      = null;

                //对于开服多少天之后才开始刷怪,进行特殊配置 格式:开服多少天;连续刷多少天[负数0表示一直];刷怪方式0或1;0或1的配置
                if ((int)MonsterBirthTypes.AfterKaiFuDays == configBirthType || (int)MonsterBirthTypes.AfterHeFuDays == configBirthType || (int)MonsterBirthTypes.AfterJieRiDays == configBirthType)
                {
                    String[] arr = timePoints.Split(';');
                    if (4 != arr.Length)
                    {
                        throw new Exception(String.Format("地图{0}的类型4的刷怪配置参数个数不对!!!!", mapCode));
                    }

                    spawnMonstersAfterKaiFuDays = int.Parse(arr[0]);
                    spawnMonstersDays           = int.Parse(arr[1]);
                    realBirthType  = int.Parse(arr[2]);
                    realTimePoints = arr[3];

                    if ((int)MonsterBirthTypes.TimePoint != realBirthType && (int)MonsterBirthTypes.TimeSpan != realBirthType)
                    {
                        throw new Exception(String.Format("地图{0}的类型4的刷怪配置子类型不对!!!!", mapCode));
                    }
                }

                // MU新增 一周中的哪天刷 TimePoints 配置形式 周几,时间点|周几,时间点|周几,时间点... [1/10/2014 LiaoWei]
                if ((int)MonsterBirthTypes.CreateDayOfWeek == configBirthType)
                {
                    String[] arrTime = timePoints.Split('|');

                    if (arrTime.Length > 0)
                    {
                        for (int nIndex = 0; nIndex < arrTime.Length; ++nIndex)
                        {
                            string sTimePoint = null;
                            sTimePoint = arrTime[nIndex];

                            if (sTimePoint != null)
                            {
                                String[] sTime = null;
                                sTime = sTimePoint.Split(',');

                                if (sTime != null && sTime.Length == 2)
                                {
                                    string sTimeString = null;
                                    int    nDayOfWeek  = -1;

                                    nDayOfWeek  = int.Parse(sTime[0]);
                                    sTimeString = sTime[1];

                                    if (nDayOfWeek != -1 && !string.IsNullOrEmpty(sTimeString))
                                    {
                                        string[] fields2 = sTimeString.Split(':');
                                        if (fields2.Length != 2)
                                        {
                                            continue;
                                        }

                                        string str1 = fields2[0].TrimStart('0');
                                        string str2 = fields2[1].TrimStart('0');

                                        BirthTimePoint birthTimePoint = new BirthTimePoint()
                                        {
                                            BirthHour   = Global.SafeConvertToInt32(str1),
                                            BirthMinute = Global.SafeConvertToInt32(str2),
                                        };

                                        BirthTimeForDayOfWeek BirthTimeTmp = new BirthTimeForDayOfWeek();

                                        BirthTimeTmp.BirthDayOfWeek = nDayOfWeek;
                                        BirthTimeTmp.BirthTime      = birthTimePoint;

                                        CreateMonstersDayOfWeek.Add(BirthTimeTmp);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    birthTimePointList = ParseBirthTimePoints(realTimePoints);
                }

                MonsterZone monsterZone = new MonsterZone()
                {
                    MapCode                     = mapCode,
                    ID                          = (int)Global.GetSafeAttributeLong(monsterItem, "ID"),
                    Code                        = (int)Global.GetSafeAttributeLong(monsterItem, "Code"),
                    ToX                         = (int)Global.GetSafeAttributeLong(monsterItem, "X") / gameMap.MapGridWidth,
                    ToY                         = (int)Global.GetSafeAttributeLong(monsterItem, "Y") / gameMap.MapGridHeight,
                    Radius                      = (int)Global.GetSafeAttributeLong(monsterItem, "Radius") / gameMap.MapGridWidth,
                    TotalNum                    = (int)Global.GetSafeAttributeLong(monsterItem, "Num"),
                    Timeslot                    = (int)Global.GetSafeAttributeLong(monsterItem, "Timeslot"),
                    IsFuBenMap                  = isFuBenMap,
                    BirthType                   = realBirthType,
                    ConfigBirthType             = configBirthType,
                    SpawnMonstersAfterKaiFuDays = spawnMonstersAfterKaiFuDays,
                    SpawnMonstersDays           = spawnMonstersDays,
                    SpawnMonstersDayOfWeek      = CreateMonstersDayOfWeek,
                    BirthTimePointList          = birthTimePointList,
                    BirthRate                   = (int)(Global.GetSafeAttributeDouble(monsterItem, "BirthRate") * 10000),
                };

                XAttribute attrib = monsterItem.Attribute("PursuitRadius");
                if (null != attrib)
                {
                    monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "PursuitRadius");
                }
                else
                {
                    monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "Radius");
                }

                lock (InitMonsterZoneMutex)
                {
                    //加入列表
                    MonsterZoneList.Add(monsterZone);

                    //如果是副本地图, 则加入副本爆怪区域列表
                    if (isFuBenMap)
                    {
                        FuBenMonsterZoneList.Add(monsterZone);
                    }

                    //加入爆怪区域
                    AddMap2MonsterZoneDict(monsterZone);
                }

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

                //加载怪物
                monsterZone.LoadMonsters();//暂时屏蔽怪物加载
            }
        }
コード例 #19
0
        public void AddMapMonsters(int mapCode, GameMap gameMap)
        {
            this.AddDynamicMonsterZone(mapCode);
            string   fileName = string.Format("Map/{0}/Monsters.xml", mapCode);
            XElement xml      = null;

            try
            {
                xml = XElement.Load(Global.ResPath(fileName));
            }
            catch (Exception)
            {
                throw new Exception(string.Format("加载地图怪物配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName));
            }
            IEnumerable <XElement> monsterItems = xml.Elements("Monsters").Elements <XElement>();

            if (null != monsterItems)
            {
                bool isFuBenMap = FuBenManager.IsFuBenMap(mapCode);
                foreach (XElement monsterItem in monsterItems)
                {
                    string timePoints                  = Global.GetSafeAttributeStr(monsterItem, "TimePoints");
                    int    configBirthType             = (int)Global.GetSafeAttributeLong(monsterItem, "BirthType");
                    int    realBirthType               = configBirthType;
                    string realTimePoints              = timePoints;
                    int    spawnMonstersAfterKaiFuDays = 0;
                    int    spawnMonstersDays           = 0;
                    List <BirthTimeForDayOfWeek> CreateMonstersDayOfWeek = new List <BirthTimeForDayOfWeek>();
                    List <BirthTimePoint>        birthTimePointList      = null;
                    if (4 == configBirthType || 5 == configBirthType || 6 == configBirthType)
                    {
                        string[] arr = timePoints.Split(new char[]
                        {
                            ';'
                        });
                        if (4 != arr.Length)
                        {
                            throw new Exception(string.Format("地图{0}的类型4的刷怪配置参数个数不对!!!!", mapCode));
                        }
                        spawnMonstersAfterKaiFuDays = int.Parse(arr[0]);
                        spawnMonstersDays           = int.Parse(arr[1]);
                        realBirthType  = int.Parse(arr[2]);
                        realTimePoints = arr[3];
                        if (1 != realBirthType && 0 != realBirthType)
                        {
                            throw new Exception(string.Format("地图{0}的类型4的刷怪配置子类型不对!!!!", mapCode));
                        }
                    }
                    if (7 == configBirthType)
                    {
                        string[] arrTime = timePoints.Split(new char[]
                        {
                            '|'
                        });
                        if (arrTime.Length > 0)
                        {
                            int nIndex = 0;
                            while (nIndex < arrTime.Length)
                            {
                                string sTimePoint = arrTime[nIndex];
                                if (sTimePoint != null)
                                {
                                    string[] sTime = sTimePoint.Split(new char[]
                                    {
                                        ','
                                    });
                                    if (sTime != null && sTime.Length == 2)
                                    {
                                        int    nDayOfWeek  = int.Parse(sTime[0]);
                                        string sTimeString = sTime[1];
                                        if (nDayOfWeek != -1 && !string.IsNullOrEmpty(sTimeString))
                                        {
                                            string[] fields2 = sTimeString.Split(new char[]
                                            {
                                                ':'
                                            });
                                            if (fields2.Length == 2)
                                            {
                                                string str = fields2[0].TrimStart(new char[]
                                                {
                                                    '0'
                                                });
                                                string str2 = fields2[1].TrimStart(new char[]
                                                {
                                                    '0'
                                                });
                                                BirthTimePoint birthTimePoint = new BirthTimePoint
                                                {
                                                    BirthHour   = Global.SafeConvertToInt32(str),
                                                    BirthMinute = Global.SafeConvertToInt32(str2)
                                                };
                                                CreateMonstersDayOfWeek.Add(new BirthTimeForDayOfWeek
                                                {
                                                    BirthDayOfWeek = nDayOfWeek,
                                                    BirthTime      = birthTimePoint
                                                });
                                            }
                                        }
                                    }
                                }
IL_2E5:
                                nIndex++;
                                continue;
                                goto IL_2E5;
                            }
                        }
                    }
                    else
                    {
                        birthTimePointList = this.ParseBirthTimePoints(realTimePoints);
                    }
                    MonsterZone monsterZone = new MonsterZone
                    {
                        MapCode                     = mapCode,
                        ID                          = (int)Global.GetSafeAttributeLong(monsterItem, "ID"),
                        Code                        = (int)Global.GetSafeAttributeLong(monsterItem, "Code"),
                        ToX                         = (int)Global.GetSafeAttributeLong(monsterItem, "X") / gameMap.MapGridWidth,
                        ToY                         = (int)Global.GetSafeAttributeLong(monsterItem, "Y") / gameMap.MapGridHeight,
                        Radius                      = (int)Global.GetSafeAttributeLong(monsterItem, "Radius") / gameMap.MapGridWidth,
                        TotalNum                    = (int)Global.GetSafeAttributeLong(monsterItem, "Num"),
                        Timeslot                    = (int)Global.GetSafeAttributeLong(monsterItem, "Timeslot"),
                        IsFuBenMap                  = isFuBenMap,
                        BirthType                   = realBirthType,
                        ConfigBirthType             = configBirthType,
                        SpawnMonstersAfterKaiFuDays = spawnMonstersAfterKaiFuDays,
                        SpawnMonstersDays           = spawnMonstersDays,
                        SpawnMonstersDayOfWeek      = CreateMonstersDayOfWeek,
                        BirthTimePointList          = birthTimePointList,
                        BirthRate                   = (int)(Global.GetSafeAttributeDouble(monsterItem, "BirthRate") * 10000.0)
                    };
                    XAttribute attrib = monsterItem.Attribute("PursuitRadius");
                    if (null != attrib)
                    {
                        monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "PursuitRadius");
                    }
                    else
                    {
                        monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "Radius");
                    }
                    lock (this.InitMonsterZoneMutex)
                    {
                        this.MonsterZoneList.Add(monsterZone);
                        if (isFuBenMap)
                        {
                            this.FuBenMonsterZoneList.Add(monsterZone);
                        }
                        this.AddMap2MonsterZoneDict(monsterZone);
                    }
                    monsterZone.LoadStaticMonsterInfo_2();
                    monsterZone.LoadMonsters();
                }
            }
        }
コード例 #20
0
 public void SetZone(MonsterZone zone)
 {
     _zone = zone;
 }
コード例 #21
0
    protected internal override void OnPreUsing()
    {
        base.OnPreUsing();

        _zone = null;
    }