Ejemplo n.º 1
0
        public override void DoAction(IEventArgs args)
        {
            IParable p = null;

            if (StringUtil.IsNullOrEmpty(key))
            {
                p = args.GetDefault();
            }
            else
            {
                p = args.GetUnit(key);
            }
            if (p != null && paras != null)
            {
                foreach (IPara para in paras)
                {
                    if (!p.GetParameters().HasPara(para) || @override)
                    {
                        IPara clone = (IPara)para.Copy();
                        clone.SetName(FreeUtil.ReplaceVar(clone.GetName(), args));
                        p.GetParameters().AddPara(clone);
                    }
                }
            }
        }
Ejemplo n.º 2
0
            public virtual string ToLog()
            {
                IList <string> list = new List <string>();

                list.Add(string.Format("\n    {0}", FreeLog.ToTrigger()));
                IList <FreeLog.LogKey> parents = GetParents();

                foreach (FreeLog.LogKey lk in parents)
                {
                    list.Add("\n    " + lk.action);
                }
                return(from.GetName() + ":" + from.GetValue() + "->" + to.GetValue() + " at " + StringUtil.GetStringFromStrings(list, string.Empty));
            }
Ejemplo n.º 3
0
 public static void Message(string msg, IEventArgs args)
 {
     if (enable)
     {
         IList <string> list = new List <string>();
         foreach (ParaExp pe in paras)
         {
             IPara pa = GetPara(args, pe);
             if (pa != null)
             {
                 list.Add(pa.GetName() + "=" + pa.GetValue());
             }
         }
         messageCount++;
         messages.Add(messageCount + "  " + DateTime.Now.ToString("u") + " " + msg + "\n   观察值:" + StringUtil.GetStringFromStrings(list, ", "));
         if (messages.Count > 1000)
         {
             messages.Remove(0);
         }
     }
 }
Ejemplo n.º 4
0
        public virtual IPara GetPara(IEventArgs args)
        {
            IParable parable = args.GetUnit(unit);

            if (parable != null)
            {
                ParaList pl = args.GetUnit(unit).GetParameters();
                if (pl.HasPara(para))
                {
                    return(pl.Get(para));
                }
                else
                {
                    bool     has  = (para.IndexOf('[') > -1);
                    bool     has2 = (para.IndexOf(']') > -1);
                    string[] vs   = Split(GetPara(), 1);

                    if (has && has2)
                    {
                        vs = new string[] { para };
                    }
                    if (vs.Length != 4)
                    {
                        if (has && has2 && para.Contains("[@") && para.Contains("']/@")) /* ¼õÉÙContainsµ÷ÓÃ */
                        {
                            vs = Split(GetPara(), 2);
                        }
                    }
                    if (vs.Length == 4)
                    {
                        IPara p = pl.Get(vs[0].Trim());
                        if (p != null && p is ParaListSet)
                        {
                            ParaListSet pls = (ParaListSet)p;
                            ParaList    sub = pls.GetParaList(vs[1].Trim(), vs[2].Trim(), args);
                            if (sub != null && sub.HasPara(vs[3].Trim()))
                            {
                                return(sub.Get(vs[3].Trim()));
                            }
                        }
                    }
                    else
                    {
                        if (has && has2)
                        {
                            vs = Split(para, 3);
                            if (vs.Length == 3 && StringUtil.IsNullOrEmpty(vs[2]))
                            {
                                IPara p = pl.Get(vs[0].Trim());
                                if (p != null && (p is MapPara || p is StringPara))
                                {
                                    if (p is MapPara)
                                    {
                                        MapPara mp = (MapPara)p;
                                        if (vs[1].Trim().Equals("length"))
                                        {
                                            return(new IntPara(p.GetName(), mp.Size()));
                                        }
                                        return(mp.GetValue(vs[1].Trim()));
                                    }
                                    if (p is StringPara)
                                    {
                                        if ("length".Equals(vs[1].Trim()))
                                        {
                                            return(new IntPara(p.GetName(), p.GetValue().ToString().Length));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return(null);
            }
            else
            {
                throw new GameConfigExpception("unit " + unit + " is not existed.\n" + GetUnit() + "." + GetPara());
            }
        }