예제 #1
0
 private void AddTo(string[] fields, IParable target, ParaList to)
 {
     foreach (string field in fields)
     {
         FieldPair fp = FieldPair.Parse(field)[0];
         ParaList  tp = target.GetParameters();
         if (tp.HasPara(fp.GetFrom()))
         {
             IPara para = tp.Get(fp.GetFrom());
             if (para != null)
             {
                 IPara clone = (IPara)para.Copy();
                 clone.SetName(fp.GetTo());
                 if (@override || !to.HasPara(fp.GetTo()))
                 {
                     to.AddPara(clone);
                 }
                 else
                 {
                     to.AddPara(clone);
                 }
             }
         }
     }
 }
예제 #2
0
        public override void DoAction(IEventArgs args)
        {
            ParaList list = args.GetDefault().GetParameters();

            if (list.HasPara("resetpos"))
            {
                resetpos = (int)list.Get("resetpos").GetValue();
                var poss = args.FreeContext.Poss;
                if (!poss.ExsitIndex(TYPE, resetpos))
                {
                    poss.Remove(TYPE, resetpos);
                }
            }
        }
예제 #3
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());
            }
        }
예제 #4
0
        public virtual bool OnCreate(IEventArgs skill)
        {
            startTime = skill.Rule.ServerTime;

            this.ins       = new HashSet <long>();
            this.showedIds = new HashSet <long>();
            this.realKey   = FreeUtil.ReplaceVar(key, skill);
            this.realTime  = FreeUtil.ReplaceInt(time, skill);
            this.paras     = new SimpleParaList();

            this.posindex = -1;
            ParaList list = skill.GetDefault().GetParameters();

            if (list.HasPara("posindex"))
            {
                posindex = (int)list.Get("posindex").GetValue();
            }
            skill.TempUse("buf", this);

            IPosSelector pos = GetPos(region.GetCenter(skill));

            if (pos.Select(skill).GetInvalid())
            {
                return(false);
            }

            bool hasCreator = false;

            if (creator != null && creator.hasFreeData)
            {
                skill.TempUse("creator", (FreeData)this.creator.freeData.FreeData);
                hasCreator = true;
            }
            AddParas(skill);
            if (createAction != null)
            {
                createAction.Act(skill);
            }
            if (effectAction != null)
            {
                effectAction.SetSelector(pos);
                effectAction.SetKey("bufeffect_" + realKey);
            }
            else
            {
                if (show == null)
                {
                    show = new FreeEffectShowAction();
                    show.SetKey(effect);
                    show.SetPos(pos);
                }
            }
            skill.Resume("buf");
            if (creator != null && hasCreator)
            {
                skill.Resume("creator");
            }
            if (!StringUtil.IsNullOrEmpty(condition))
            {
                bufCondition = new ExpParaCondition(FreeUtil.ReplaceVar(condition, skill));
            }
            return(true);
        }