コード例 #1
0
        public static string[] GetSpecialString(string[] ss)
        {
            IList <string> list = new List <string>();

            foreach (string s in ss)
            {
                bool added = false;
                if (s.Contains("-") && s.StartsWith("$"))
                {
                    string[] ns = StringUtil.Split(Sharpen.Runtime.Substring(s, 1), "-");
                    if (ns.Length == 2)
                    {
                        if (StringUtil.IsNumberString(ns[0]) && StringUtil.IsNumberString(ns[1]))
                        {
                            int start = NumberUtil.GetInt(ns[0]);
                            int end   = NumberUtil.GetInt(ns[1]);
                            for (int i = start; i <= end; i++)
                            {
                                list.Add(i.ToString());
                            }
                            added = true;
                        }
                    }
                }
                if (!added && !StringUtil.IsNullOrEmpty(s))
                {
                    list.Add(s);
                }
            }
            return(Sharpen.Collections.ToArray(list, new string[0]));
        }
コード例 #2
0
        public override void DoAction(IEventArgs args)
        {
            string realKeys = FreeUtil.ReplaceVar(keys, args);

            if (!cache.ContainsKey(realKeys))
            {
                string[] ks = StringUtil.Split(realKeys, new string[] { ",", "," });
                ks = GetSpecialString(ks);
                int[] priority = new int[ks.Length];
                for (int i = 0; i < ks.Length; i++)
                {
                    string   k  = ks[i];
                    string[] vs = StringUtil.Split(k, "=");
                    if (vs.Length == 2 && StringUtil.IsNumberString(vs[1]))
                    {
                        ks[i]       = vs[0].Trim();
                        priority[i] = NumberUtil.GetInt(vs[1]);
                    }
                    else
                    {
                        priority[i] = 1;
                    }
                }
                RandomStringAction.KeyProperty kp = new RandomStringAction.KeyProperty();
                kp.v            = realKeys;
                kp.ks           = ks;
                kp.priority     = priority;
                cache[realKeys] = kp;
            }
            string[] ks_1   = cache[realKeys].ks;
            int[]    proAcc = cache[realKeys].priority;
            if (all)
            {
                for (int i = 0; i < ks_1.Length; i++)
                {
                    HandleOne(ks_1.Length, i + 1, ks_1[i], args);
                }
            }
            else
            {
                if (StringUtil.IsNullOrEmpty(count))
                {
                    count = "1";
                }
                int   c   = FreeUtil.ReplaceInt(count, args);
                int[] ins = null;
                if (repeat)
                {
                    ins = RandomUtil.RandomWithProRepeat(0, proAcc, c);
                }
                else
                {
                    ins = RandomUtil.RandomWithPro(0, proAcc, c);
                }
                for (int i = 0; i < ins.Length; i++)
                {
                    HandleOne(ins.Length, i + 1, ks_1[ins[i]], args);
                }
            }
        }
コード例 #3
0
        public static int GetWeaponKey(string invName, FreeData fd)
        {
            if (invName.StartsWith("w"))
            {
                return(NumberUtil.GetInt(invName));
            }

            return(0);
        }
コード例 #4
0
        public override IValueOrder Parse(string type)
        {
            string[] ss = type.Split(UNDERLINE);
            RangeNumberValueOrder orderValue = new RangeNumberValueOrder();

            orderValue.SetStart(NumberUtil.GetInt(ss[1]));
            orderValue.SetEnd(NumberUtil.GetInt(ss[2]));
            orderValue.SetContainsStart(true);
            orderValue.SetContainsEnd(true);
            return(orderValue);
        }
コード例 #5
0
 public virtual int GetItemHeight()
 {
     if (!StringUtil.IsNullOrEmpty(iconSize))
     {
         string[] vs = StringUtil.Split(iconSize, ",");
         if (vs.Length > 1)
         {
             return(NumberUtil.GetInt(vs[1]));
         }
     }
     return(50);
 }
コード例 #6
0
 public static ItemPosition GetItemPosition(ISkillArgs args, string key, InventoryManager ins)
 {
     string[] xy = StringUtil.Split(key, SPLITER_COMMA);
     if (xy.Length == 3)
     {
         string        name      = xy[0];
         int           x         = NumberUtil.GetInt(xy[1]);
         int           y         = NumberUtil.GetInt(xy[2]);
         ItemInventory inventory = ins.GetInventory(name);
         if (inventory != null)
         {
             return(inventory.GetItem(x, y));
         }
     }
     return(null);
 }
コード例 #7
0
        public static SimpleItemInfo GetGroundItemInfo(ServerRoom room, FreeData fd, string key)
        {
            SimpleItemInfo freeItem = new SimpleItemInfo();

            string[] xy = StringUtil.Split(key, ParaConstant.SPLITER_COMMA);
            if (xy.Length == 3)
            {
                string name = xy[0];
                int    x    = NumberUtil.GetInt(xy[1]);
                int    y    = NumberUtil.GetInt(xy[2]);

                if (x == 0)
                {
                    SceneObjectEntity entity = room.RoomContexts.sceneObject.GetEntityWithEntityKey(new EntityKey(y, (short)EEntityType.SceneObject));
                    if (entity != null)
                    {
                        freeItem.entityId = entity.entityKey.Value.EntityId;
                        freeItem.cat      = entity.simpleEquipment.Category;
                        freeItem.id       = entity.simpleEquipment.Id;
                        freeItem.count    = entity.simpleEquipment.Count;
                    }
                    else
                    {
                        FreeMoveEntity moveEntity = room.RoomContexts.freeMove.GetEntityWithEntityKey(new EntityKey(y, (short)EEntityType.FreeMove));
                        if (moveEntity != null)
                        {
                            SimpleItemInfo info = (SimpleItemInfo)SingletonManager.Get <DeadBoxParser>().FromString(moveEntity.freeData.Value);
                            freeItem.entityId = moveEntity.entityKey.Value.EntityId;
                            freeItem.cat      = info.cat;
                            freeItem.id       = info.id;
                            freeItem.count    = info.count;
                        }
                        else
                        {
                            Debug.LogErrorFormat("entity {0} not existed.", key);
                        }
                    }
                }
            }

            return(freeItem);
        }
コード例 #8
0
        public override IValueOrder Parse(string type)
        {
            string[] ss = type.Split(UNDERLINE);
            NumberSequenceValueOrder orderValue = new NumberSequenceValueOrder();
            int i1 = NumberUtil.GetInt(ss[1]);
            int i2 = NumberUtil.GetInt(ss[2]);

            if (i1 > i2)
            {
                orderValue.SetMin(i2);
                orderValue.SetMax(i1);
                orderValue.SetDesc(true);
            }
            else
            {
                orderValue.SetMin(i1);
                orderValue.SetMax(i2);
                orderValue.SetDesc(false);
            }
            return(orderValue);
        }
コード例 #9
0
        public virtual string Replace(string exp, IEventArgs args)
        {
            string value = exp.Replace(RANDOM, FreeUtil.EMPTY_STRING);

            string[] vs = StringUtil.Split(value, "_");
            if (vs.Length == 2 && StringUtil.IsNumberString(vs[0]) && StringUtil.IsNumberString(vs[1]))
            {
                return(RandomUtil.Random(NumberUtil.GetInt(vs[0]), NumberUtil.GetInt(vs[1])).ToString());
            }
            else
            {
                vs = StringUtil.Split(value, "-");
                if (vs.Length == 2 && StringUtil.IsNumberString(vs[0]) && StringUtil.IsNumberString(vs[1]))
                {
                    return(RandomUtil.Random(NumberUtil.GetInt(vs[0]), NumberUtil.GetInt(vs[1])).ToString());
                }
                else
                {
                    return(vs[RandomUtil.Random(0, vs.Length - 1)]);
                }
            }
        }
コード例 #10
0
ファイル: IntPara.cs プロジェクト: yangfan111/common
 private int GetInt(object v)
 {
     if (v is int)
     {
         return((int)v);
     }
     else
     {
         if (v is double)
         {
             return((int)(double)v);
         }
         else
         {
             if (v is long)
             {
                 return((int)(long)v);
             }
             else
             {
                 if (v is float)
                 {
                     return((int)(float)v);
                 }
                 else
                 {
                     if (v is string)
                     {
                         return(NumberUtil.GetInt((string)v));
                     }
                 }
             }
         }
     }
     throw new GameConfigExpception(v + " is not a valid long value");
 }