예제 #1
0
        public static FlashObject Load(SecurityElement element)
        {
            FlashObject flashObject = new FlashObject();

            flashObject.FlashID         = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Flash_ID"), ""), -1);
            flashObject.FlashPrefabName = StrParser.ParseStr(element.Attribute("FlashPrefabName"), "");
            return(flashObject);
        }
예제 #2
0
        public static FlashObject Deserialize(StreamReader reader)
        {
            var ret = new FlashObject("Base");
            var current = ret;
            var levels = new Stack<int>();
            levels.Push(0);

            while (levels.Count > 0)
            {
                if (reader.Peek() != ' ') //No Space? Well then it must be the end of the object
                    return ret;

                var line = reader.ReadLine();
                var kv = MatchLine(line);
                if (kv == null)
                    throw new NotSupportedException("Unable to parse (" + line + ")");

                while (levels.Count > 0 && GetLevel(line) <= levels.Peek())
                {
                    current = current.Parent;
                    levels.Pop();
                }

                var objname = GetObjectName(line);
                if (objname != null)
                {
                    var tmp = new FlashObject(objname, kv.Key, kv.Value) { Parent = current };
                    current[kv.Key] = tmp;
                    current = tmp;
                    levels.Push(GetLevel(line));
                }
                else
                {
                    if (kv.Value.Length > 0 && kv.Value[0] == '"')
                    {
                        var str = ParseString(kv.Value.Substring(1));
                        if (str != null)
                        {
                            //Singleline quote
                            kv.Value = str;
                        }
                        else
                        {
                            //Multiline quote
                            kv.Value = kv.Value.Substring(1) + ParseString(reader);
                            reader.ReadLine(); //Read the newline after the quote
                        }
                    }
                    current[kv.Key] = new FlashObject(kv.Key, kv.Value);
                }
            }

            return ret;
        }
예제 #3
0
    public bool GetFlashObj(int flashID, out FlashObject flashName)
    {
        flashName = null;
        foreach (FlashObject flash in FlashObjectDic.Values)
        {
            if (flash.FlashID == flashID)
            {
                flashName = flash;
                return(true);
            }
        }

        return(false);
    }
예제 #4
0
        private void _Poll()
        {
            int rank = Bot.Player.Rank;

            if (rank > _lastRank && _lastRank != -1)
            {
                using (FlashArray <object> skills = FlashObject <object> .Create("world.actions.active").ToArray())
                {
                    int k = 0;
                    foreach (FlashObject <object> skill in skills)
                    {
                        using (FlashObject <long> ts = skill.GetChild <long>("ts"))
                            ts.Value = _lastSkills[k++].LastUse;
                    }
                }
            }
            _lastRank   = rank;
            _lastSkills = Bot.Player.Skills;
            if (_provider?.ShouldUseSkill(Bot) == true)
            {
                int skill = _provider.GetNextSkill(Bot, out SkillMode mode);
                switch (mode)
                {
                case SkillMode.Optimistic:
                    if (Bot.Player.CanUseSkill(skill))
                    {
                        Bot.Player.UseSkill(skill);
                    }
                    break;

                case SkillMode.Wait:
                    if (skill != -1)
                    {
                        Bot.Wait.ForTrue(() => Bot.Player.CanUseSkill(skill), SkillTimeout, SkillTimer);
                        Bot.Player.UseSkill(skill);
                    }
                    break;
                }
            }
            else if (_provider?.ShouldUseSkill(Bot) == null)
            {
                _provider.GetNextSkill(Bot, out SkillMode mode);
            }
        }
예제 #5
0
    public override bool Load(SecurityElement element)
    {
        if (element.Tag != "Items")
        {
            return(false);
        }

        if (element.Children != null)
        {
            foreach (SecurityElement childrenElement in element.Children)
            {
                FlashObject flash = FlashObject.Load(childrenElement);
                if (!FlashObjectDic.ContainsKey(flash.FlashID))
                {
                    FlashObjectDic[flash.FlashID] = flash;
                }
            }
        }
        return(true);
    }
예제 #6
0
        /// <summary>
        /// Buys the specified item from the currently loaded shop.
        /// </summary>
        /// <param name="name">The name of the item to buy.</param>
        public void BuyItem(string name)
        {
            int             index;
            List <ShopItem> items = ShopItems;

            if (IsShopLoaded && (index = items.FindIndex(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) > -1)
            {
                if (Bot.Options.SafeTimings)
                {
                    Bot.Wait.ForActionCooldown(ScriptWait.GameActions.BuyItem);
                    Bot.Wait.ItemBuyEvent.Reset();
                }
                ExpandoObject item;
                using (FlashArray <ExpandoObject> fItems = FlashObject <ExpandoObject> .Create("world.shopinfo.items").ToArray())
                    using (FlashObject <ExpandoObject> fItem = fItems.Get(index))
                        item = fItem.Value;
                Bot.CallGameFunction("world.sendBuyItemRequest", item);
                if (Bot.Options.SafeTimings)
                {
                    Bot.Wait.ForItemBuy();
                }
            }
        }
예제 #7
0
 protected virtual void DoProcessObject(FlashObject obj)
 {
     if (ProcessObject != null)
         ProcessObject(obj);
 }