Example #1
0
        /// <summary>
        /// </summary>
        public TownMove(GoalBase parent, int priority, Act2Town location)
            : base(parent, priority)
        {
            mArea     = AreaLevel.LutGholein;
            mLocation = (int)location;

            switch (location)
            {
            case Act2Town.Atma:
            case Act2Town.DeckardCain:
            case Act2Town.Drognan:
            case Act2Town.Elzix:
            case Act2Town.Fara:
            case Act2Town.Geglash:
            case Act2Town.Greiz:
            case Act2Town.Jerhyn:
            case Act2Town.Kaelan:
            case Act2Town.Lysander:
            case Act2Town.Meshif:
            case Act2Town.Warriv:
                mUnitType = UnitType.NPC;
                break;

            case Act2Town.Stash:
            case Act2Town.Waypoint:
                mUnitType = UnitType.GameObject;
                break;

            default:
                mUnitType = UnitType.Invalid;
                break;
            }

            Update();
        }
Example #2
0
        /// <summary>
        /// </summary>
        public TownMove(GoalBase parent, int priority, Act3Town location)
            : base(parent, priority)
        {
            mArea     = AreaLevel.KurastDocks;
            mLocation = (int)location;

            switch (location)
            {
            case Act3Town.Alkor:
            case Act3Town.Asheara:
            case Act3Town.DeckardCain:
            case Act3Town.Hratli:
            case Act3Town.Meshif:
            case Act3Town.Natalya:
            case Act3Town.Ormus:
                mUnitType = UnitType.NPC;
                break;

            case Act3Town.Stash:
            case Act3Town.Waypoint:
                mUnitType = UnitType.GameObject;
                break;

            default:
                mUnitType = UnitType.Invalid;
                break;
            }

            Update();
        }
Example #3
0
        /// <summary>
        /// </summary>
        public TownMove(GoalBase parent, int priority, Act5Town location)
            : base(parent, priority)
        {
            mArea     = AreaLevel.Harrogath;
            mLocation = (int)location;

            switch (location)
            {
            case Act5Town.Anya:
            case Act5Town.DeckardCain:
            case Act5Town.Larzuk:
            case Act5Town.Malah:
            case Act5Town.Nihlathak:
            case Act5Town.QualKehk:
                mUnitType = UnitType.NPC;
                break;

            case Act5Town.Stash:
            case Act5Town.Waypoint:
                mUnitType = UnitType.GameObject;
                break;

            default:
                mUnitType = UnitType.Invalid;
                break;
            }

            Update();
        }
Example #4
0
        /// <summary>
        /// </summary>
        public TownMove(GoalBase parent, int priority, Act1Town location)
            : base(parent, priority)
        {
            mArea     = AreaLevel.RogueEncampment;
            mLocation = (int)location;

            switch (location)
            {
            case Act1Town.Akara:
            case Act1Town.Charsi:
            case Act1Town.DeckardCain:
            case Act1Town.Gheed:
            case Act1Town.Kashya:
            case Act1Town.Warriv:
                mUnitType = UnitType.NPC;
                break;

            case Act1Town.Stash:
            case Act1Town.Waypoint:
                mUnitType = UnitType.GameObject;
                break;

            default:
                mUnitType = UnitType.Invalid;
                break;
            }

            Update();
        }
Example #5
0
        /// <summary>
        /// Updates the internal subgoals array.  Will rebuild if out of sync.
        /// </summary>
        public override void Update()
        {
            mSubGoals.Clear();

            PC pc = new PC();

            // should check if we are on a level that doesn't have a waypoint

            // get the waypoint's preset unit on the target level
            AreaLevel area = mSource == AreaLevel.None ? pc.Area : mSource;

            foreach (PresetUnit waypoint in PresetUnit.Get(area, UnitType.Object))
            {
                foreach (int classid in new int[] { 119, 145, 156, 157, 237, 238, 288, 323, 324, 398, 402, 429, 494, 496, 511, 539 })
                {
                    if (waypoint.ClassID == classid)
                    {
                        if (Math.Abs(pc.X - waypoint.X) > 5 || Math.Abs(pc.Y - waypoint.Y) > 5)
                        {
                            mSubGoals.Enqueue(new MoveToWaypoint(this, mPriority + 2, area, mTeleport));
                        }
                        goto WAYPOINTFOUND;
                    }
                }
            }
WAYPOINTFOUND:

            // call base classes Update()
            base.Update();
        }
Example #6
0
 /// <summary>
 /// </summary>
 public InteractWaypoint(GoalBase Parent, int Priority, AreaLevel source, AreaLevel destination, bool teleport)
     : base(Parent, Priority)
 {
     mDestination = destination;
     mSource      = source;
     mTeleport    = teleport;
 }
        /// <summary>
        /// 获取天气服务提供的区域信息
        /// </summary>
        /// <param name="level">区域等级</param>
        /// <param name="areaCode">区域代号,当level=1时请默认留空</param>
        /// <returns>区域信息</returns>
        public List <AreaCodeName> SearchAreaCode(AreaLevel level, string areaCode = "")
        {
            string redisKey = string.Format(RedisKeyPrefix.AREA_CODE_LIST, level, areaCode);
            List <AreaCodeName> areaInfoList = redisHelper.StringGet <List <AreaCodeName> >(redisKey);//先从缓存中读取

            if (areaInfoList != null)
            {
                return(areaInfoList);
            }
            string getUrl  = string.Format("http://www.weather.com.cn/data/list3/city{0}.xml?level={1}", areaCode, (int)level);
            string areaStr = SimulateRequest.HttpGet(getUrl);

            string[] areaResultAry = areaStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            areaInfoList = areaResultAry.Select(areaResult =>
            {
                string[] areaAry = areaResult.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                return(new AreaCodeName
                {
                    Code = areaAry[0],
                    Name = areaAry[1]
                });
            }).ToList();
            if (areaInfoList != null && areaInfoList.Count > 0)
            {
                redisHelper.StringSet(redisKey, areaInfoList, TimeSpan.FromSeconds(CacheTime.Term_S));
            }
            return(areaInfoList);
        }
Example #8
0
        /// <summary>
        /// </summary>
        public TownMove(GoalBase parent, int priority, Act4Town location)
            : base(parent, priority)
        {
            mArea     = AreaLevel.ThePandemoniumFortress;
            mLocation = (int)location;

            switch (location)
            {
            case Act4Town.DeckardCain:
            case Act4Town.Halbu:
            case Act4Town.Jamella:
            case Act4Town.Tyrael:
                mUnitType = UnitType.NPC;
                break;

            case Act4Town.Stash:
            case Act4Town.Waypoint:
                mUnitType = UnitType.GameObject;
                break;

            default:
                mUnitType = UnitType.Invalid;
                break;
            }

            Update();
        }
Example #9
0
 /// <summary>
 /// 下级地区等级
 /// </summary>
 /// <param name="value">地区等级</param>
 public static AreaLevel LowerLevel(this AreaLevel value)
 {
     if (value == AreaLevel.Town)
     {
         throw new Warning("已经是最低地区等级");
     }
     return(value + 1);
 }
Example #10
0
 /// <summary>
 /// 下级地区等级
 /// </summary>
 /// <param name="value">地区等级</param>
 /// <param name="result">下级地区等级</param>
 public static bool TryLowerLevel(this AreaLevel value, out AreaLevel?result)
 {
     if (value == AreaLevel.Town)
     {
         result = null;
         return(false);
     }
     result = value.LowerLevel();
     return(true);
 }
Example #11
0
        /// <summary>
        /// 根据地区等级获取地区数据
        /// </summary>
        /// <param name="level"></param>
        /// <param name="up"></param>
        /// <returns></returns>
        static IReadOnlyList <IArea> GetAreasByLevel(AreaLevel level, int?up = null)
        {
            var list = Res.GetAll().Where(x => x.Level == level && x.Up == up).OrderBy(x => x.Id).ToList();

            if (!list.Any())
            {
                return(GroupEmpty);
            }
            list.Insert(0, mPleaseSelect);
            return(list);
        }
Example #12
0
        /// <summary>
        /// 查找范围树
        /// </summary>
        /// <param name="startLevel">起始地区级别:默认到省份级别</param>
        /// <param name="endLevel">结束地区级别:默认区县级别</param>
        public List <Tree <Model.Area> > FindBetweenTree(AreaLevel startLevel = AreaLevel.Province, AreaLevel endLevel = AreaLevel.County)
        {
            if (AreaLevel.Province > startLevel || AreaLevel.County < endLevel)
            {
                throw new Warning("地区级别错误");
            }
            var areas  = FindAll();
            var result = FindAllTree(areas, startLevel, endLevel);

            return(result);
        }
Example #13
0
    /// <summary>
    /// Upgrades this area, improving the worker's attributes
    /// </summary>
    public void UpgradeArea()
    {
        foreach (AreaAttribute <decimal> item in AreaAttributes)
        {
            item.Value += item.GetUpgradeAmount();
        }

        int newWorkers = Workers.GetUpgradeAmount();

        CurrentUpgradeCost += UpgradeCostMethod();
        AddWorkers(newWorkers);

        AreaLevel++;

        upgradeButton.SetText(AreaLevel.ToString());
    }
Example #14
0
        /// <summary>
        /// 获取天气服务提供的区域信息
        /// </summary>
        /// <param name="level">区域等级</param>
        /// <param name="areaCode">区域代号,当level=1时请默认留空</param>
        /// <returns>区域信息</returns>
        public List <AreaCodeName> SearchAreaCode(AreaLevel level, string areaCode = "")
        {
            string getUrl  = string.Format("http://www.weather.com.cn/data/list3/city{0}.xml?level={1}", areaCode, (int)level);
            string areaStr = SimulateRequest.HttpGet(getUrl);

            string[]            areaResultAry = areaStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <AreaCodeName> areaInfoList  = areaResultAry.Select(areaResult =>
            {
                string[] areaAry = areaResult.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                return(new AreaCodeName
                {
                    Code = areaAry[0],
                    Name = areaAry[1]
                });
            }).ToList();

            return(areaInfoList);
        }
Example #15
0
        /// <summary>
        /// Updates the internal subgoals array.  Will rebuild if out of sync.
        /// </summary>
        public override void Update()
        {
            mSubGoals.Clear();

            PC pc = new PC();

            // should check if we are on a level that doesn't have a waypoint

            // check if we are on the level with the target waypoint
            AreaLevel area = mArea == AreaLevel.None ? pc.Area : mArea;

            if (pc.Area != area)
            {
//				mSubGoals.Enqueue( new MoveToArea( this, mPriority+1, area, mTeleport ) );
            }

            // call base classes Update()
            base.Update();
        }
        public bool IsValid(AreaModel areaModel, AreaLevel level, out string errMsg)
        {
            errMsg = "";

            AreaItems p = null;

            if (level >= AreaLevel.省)
            {
                if (!Areas.ContainsKey(areaModel.ProvinceCode))
                {
                    errMsg = "请选择省";
                    return(false);
                }

                p = Areas[areaModel.ProvinceCode];
            }

            AreaItems c = null;

            if (level >= AreaLevel.市)
            {
                if (areaModel.CityCode.IsNullOrWhiteSpace() || !p.Children.ContainsKey(areaModel.CityCode))
                {
                    errMsg = "请选择市";
                    return(false);
                }

                c = p.Children[areaModel.CityCode];
            }

            if (level >= AreaLevel.区)
            {
                if (areaModel.AreaCode.IsNullOrWhiteSpace() || !c.Children.ContainsKey(areaModel.AreaCode))
                {
                    errMsg = "请选择区";
                    return(false);
                }
            }

            return(true);
        }
Example #17
0
        /// <summary>
        /// 查找树
        /// </summary>
        /// <param name="id">编号</param>
        /// <param name="endLevel">结束地区级别:默认区县级别</param>
        public Tree <Model.Area> FindTree(Guid?id, AreaLevel endLevel = AreaLevel.County)
        {
            var area = Find(id);

            if (area.IsNull())
            {
                return(new Tree <Model.Area>());
            }
            if (area.Level.SafeValue() > endLevel)
            {
                endLevel = area.Level.SafeValue();
            }
            if (!area.Level.TryLowerLevel(out AreaLevel? lowerLevel))
            {
                return(new Tree <Model.Area>(area, null, area.SortId));
            }
            var areas   = FindAll();
            var subsets = FindAllTree(areas, lowerLevel.SafeValue(), endLevel, area.Id);

            return(new Tree <Model.Area>(area, subsets, area.SortId));
        }
Example #18
0
        /// <summary>
        /// 获取父级树
        /// </summary>
        /// <param name="areas">地区集合</param>
        /// <param name="startLevel">起始地区级别</param>
        private Tree <Model.Area> FindParentTree(List <Model.Area> areas, AreaLevel startLevel)
        {
            if (startLevel > AreaLevel.Town)
            {
                return(null);
            }
            var area = areas.FirstOrDefault(t => t.Level == startLevel);

            if (area.IsNull())
            {
                return(null);
            }
            if (!startLevel.TryLowerLevel(out AreaLevel? lowerLevel))
            {
                return(new Tree <Model.Area>(area, null, area?.SortId));
            }
            var subset = FindParentTree(areas, lowerLevel.SafeValue());

            return(new Tree <Model.Area>(area, new List <Tree <Model.Area> > {
                subset
            }));
        }
Example #19
0
        /// <summary>
        /// 查找所有树
        /// </summary>
        /// <param name="list">集合</param>
        /// <param name="startLevel">起始地区级别</param>
        /// <param name="endLevel">结束地区级别</param>
        /// <param name="parentId">父编号</param>
        private List <Tree <Model.Area> > FindAllTree(List <Model.Area> list, AreaLevel startLevel, AreaLevel endLevel, Guid?parentId = null)
        {
            var result = new List <Tree <Model.Area> >();

            if (startLevel > endLevel)
            {
                return(result);
            }
            var areas = list.Where(t => t.Level == startLevel).WhereIfNotEmpty(t => t.ParentId == parentId).ToList();

            foreach (var item in areas)
            {
                if (!startLevel.TryLowerLevel(out AreaLevel? lowerLevel))
                {
                    result.Add(new Tree <Model.Area>(item, null, item.SortId));
                    continue;
                }
                var subsets = FindAllTree(list, lowerLevel.SafeValue(), endLevel, item.Id);
                result.Add(new Tree <Model.Area>(item, subsets, item.SortId));
            }
            return(result.OrderBy(t => t.SortId).ToList());
        }
Example #20
0
        private void ZoneLevel(System.Windows.Forms.MouseEventArgs me)
        {
            int       blockSize = (int)NudBlockSize.Value;
            int       xVal      = (int)(me.Location.X / blockSize);
            int       yVal      = (int)(me.Location.Y / blockSize);
            Pen       mypen;
            AreaLevel z = listLevelBlock.GetAreaLevel(xVal, yVal);

            switch (z.ZPos)
            {
            case GameEnums.AreaLevel_ZPos.GROUND:
                listLevelBlock.EditZPos(GameEnums.AreaLevel_ZPos.PLAYER, xVal, yVal);
                mypen = new Pen(Color.Red, 2f);
                break;

            case GameEnums.AreaLevel_ZPos.PLAYER:
                listLevelBlock.EditZPos(GameEnums.AreaLevel_ZPos.SKY, xVal, yVal);
                mypen = new Pen(Color.Yellow, 2f);
                break;

            case GameEnums.AreaLevel_ZPos.SKY:
                listLevelBlock.EditZPos(GameEnums.AreaLevel_ZPos.GROUND, xVal, yVal);
                mypen = new Pen(Color.Black, 2f);
                break;

            case GameEnums.AreaLevel_ZPos.NONE:
            default:
                listLevelBlock.EditZPos(GameEnums.AreaLevel_ZPos.PLAYER, xVal, yVal);
                mypen = new Pen(Color.Red, 2f);
                break;
            }

            g = Graphics.FromImage(DrawArea);
            g.DrawRectangle(mypen, xVal * blockSize, yVal * blockSize, blockSize, blockSize);
            PbPic.Image = DrawArea;
            g.Dispose();
        }
 // Methods
 public AssignGameObject(byte[] data)
     : base(data)
 {
     this.uid = BitConverter.ToUInt32(data, 2);
     this.objectID = (GameObjectID) BitConverter.ToUInt16(data, 6);
     this.x = BitConverter.ToUInt16(data, 8);
     this.y = BitConverter.ToUInt16(data, 10);
     this.objectMode = (GameObjectMode) data[12];
     if (this.objectID == GameObjectID.TownPortal)
     {
         this.interactType = GameObjectInteractType.TownPortal;
         this.destination = (AreaLevel) data[13];
     }
     else
     {
         this.interactType = (GameObjectInteractType) data[13];
         this.destination = AreaLevel.None;
     }
 }
Example #22
0
        /// <summary>
        /// 查找所有子集
        /// </summary>
        /// <param name="list">集合</param>
        /// <param name="parentId">父编号</param>
        /// <param name="startLevel">起始地区级别</param>
        /// <param name="endLevel">结束地区级别</param>
        private List <Model.Area> FindAllSubset(List <Model.Area> list, Guid?parentId, AreaLevel startLevel, AreaLevel endLevel)
        {
            var result = new List <Model.Area>();

            if (startLevel > endLevel)
            {
                return(result);
            }
            var areas = list.Where(t => t.ParentId == parentId).Where(t => t.Level == startLevel).OrderBy(t => t.SortId).ToList();

            foreach (var item in areas)
            {
                result.Add(item);
                if (!startLevel.TryLowerLevel(out AreaLevel? lowerLevel))
                {
                    continue;
                }
                var subsets = FindAllSubset(list, item.Id, lowerLevel.SafeValue(), endLevel);
                result.AddRange(subsets);
            }
            return(result.ToList());
        }
 // Methods
 public MapRemove(byte[] data)
     : base(data)
 {
     this.x = BitConverter.ToUInt16(data, 1);
     this.y = BitConverter.ToUInt16(data, 3);
     this.area = (AreaLevel) data[5];
 }
 public MapRemove(AreaLevel area, int x, int y)
     : base(Build(area, x, y))
 {
     this.x = x;
     this.y = y;
     this.area = area;
 }
 public static byte[] Build(AreaLevel area, int x, int y)
 {
     return new byte[] { 8, ((byte) x), ((byte) (x >> 8)), ((byte) y), ((byte) (y >> 8)), ((byte) area) };
 }
Example #26
0
        public IActionResult GetTreeByKeyWord(string keyWord, AreaLevel?areaLevel = null, AreaLevel endLevel = AreaLevel.County)
        {
            var result = AreaService.GetTreeByKeyWord(keyWord, areaLevel, endLevel);

            return(Ok(result));
        }
 // Methods
 public LoadAct(byte[] data)
     : base(data)
 {
     this.act = (ActLocation) data[1];
     this.mapId = BitConverter.ToUInt32(data, 2);
     this.townArea = (AreaLevel) BitConverter.ToUInt16(data, 6);
 }
Example #28
0
        /// <summary>
        /// 根据关键字查找树
        /// </summary>
        /// <param name="keyWord">关键字</param>
        /// <param name="areaLevel">地区级别:默认为null,为null查询所有</param>
        /// <param name="endLevel">结束地区级别:默认区县级别</param>
        public List <Tree <Model.Area> > FindTreeByKeyWord(string keyWord, AreaLevel?areaLevel = null, AreaLevel endLevel = AreaLevel.County)
        {
            var result = new List <Tree <Model.Area> >();

            if (keyWord.IsEmpty())
            {
                return(result);
            }
            var areas = FindByKeyWord(keyWord, areaLevel);

            foreach (var item in areas)
            {
                var subset = FindTree(item.Id, endLevel);
                result.Add(subset);
            }
            return(result.OrderBy(t => t.SortId).ToList());
        }
Example #29
0
 /// <summary>
 /// </summary>
 public MoveToWaypoint(GoalBase parent, int priority, AreaLevel area, bool teleport)
     : base(parent, priority)
 {
     mArea     = area;
     mTeleport = teleport;
 }
 // Methods
 public PartyMemberUpdate(byte[] data)
     : base(data)
 {
     this.isPlayer = Convert.ToBoolean(data[1]);
     this.lifePercent = BitConverter.ToUInt16(data, 2);
     this.uid = BitConverter.ToUInt32(data, 4);
     this.area = (AreaLevel) BitConverter.ToUInt16(data, 8);
 }
Example #31
0
        /// <summary>
        /// 获取树
        /// </summary>
        /// <param name="id">编号</param>
        /// <param name="endLevel">结束地区级别:默认区县级别</param>
        public Tree <AreaDto> GetTree(string id, AreaLevel endLevel = AreaLevel.County)
        {
            var area = AreaRepository.FindTree(id.ToGuidOrNull(), endLevel);

            return(area.ToDto());
        }
Example #32
0
        /// <summary>
        /// 根据关键字获取树
        /// </summary>
        /// <param name="keyWord">关键字</param>
        /// <param name="areaLevel">地区级别:默认为null,为null查询所有</param>
        /// <param name="endLevel">结束地区级别:默认区县级别</param>
        public List <Tree <AreaDto> > GetTreeByKeyWord(string keyWord, AreaLevel?areaLevel = null, AreaLevel endLevel = AreaLevel.County)
        {
            var areas = AreaRepository.FindTreeByKeyWord(keyWord, areaLevel, endLevel);

            return(areas.ToDto());
        }
Example #33
0
        /// <summary>
        /// 获取范围树
        /// </summary>
        /// <param name="startLevel">起始地区级别:默认到省份级别</param>
        /// <param name="endLevel">结束地区级别:默认区县级别</param>
        public List <Tree <AreaDto> > GetBetweenTree(AreaLevel startLevel = AreaLevel.Province, AreaLevel endLevel = AreaLevel.County)
        {
            var areas = AreaRepository.FindBetweenTree(startLevel, endLevel);

            return(areas.ToDto());
        }
Example #34
0
 /// <summary>
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="priority"></param>
 /// <param name="destination"></param>
 public SelectDestination(GoalBase parent, int priority, AreaLevel destination)
     : base(parent, priority)
 {
     mDestination = destination;
 }
Example #35
0
 /// <summary>
 /// </summary>
 public InteractWaypoint(GoalBase Parent, int Priority, AreaLevel destination, bool teleport)
     : this(Parent, Priority, AreaLevel.None, destination, teleport)
 {
 }
Example #36
0
        public IActionResult GetTree(string id, AreaLevel endLevel = AreaLevel.County)
        {
            var result = AreaService.GetTree(id, endLevel);

            return(Ok(result));
        }
 // Methods
 public PortalInfo(byte[] data)
     : base(data)
 {
     this.state = (TownPortalState) data[1];
     this.destination = (AreaLevel) data[2];
     this.uid = BitConverter.ToUInt32(data, 3);
 }