示例#1
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));
            }
示例#2
0
        public virtual void Act(IEventArgs args)
        {
            long s         = FreeLog.Start(this, args);
            long startTime = FreeTimeDebug.RecordStart(this.GetType().Name);

            try
            {
                DoAction(args);
            }
            catch (Exception e)
            {
                string err = "action failed\nat " + FreeLog.ActionMark + "\n at " + this.ToMessage(args) + "\nat " + ExceptionUtil.GetExceptionContent(e);
                FreeLog.Error(err, this);
                Debug.LogError(err);
                _logger.Error(err);

                if (args.FreeContext.DebugMode)
                {
                    FreeUIUpdateAction update = new FreeUIUpdateAction();
                    update.SetKey("testUI");
                    //update.SetPlayer(FreeUtil.ReplaceVar(player, args));
                    update.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args));

                    FreeUITextValue textValue = new FreeUITextValue();
                    textValue.SetSeq("1");
                    update.AddValue(textValue);

                    FreeUIShowAction show = new FreeUIShowAction();
                    show.SetKey("testUI");
                    //show.SetPlayer(FreeUtil.ReplaceVar(player, args));
                    show.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args));
                    show.SetTime("3000");

                    long lastTime = 0L;
                    if (Runtime.CurrentTimeMillis() - lastTime >= 3000L)
                    {
                        textValue.SetText(FreeUtil.ReplaceVar(err, args));
                        update.DoAction(args);
                        show.DoAction(args);
                        lastTime = Runtime.CurrentTimeMillis();
                    }
                }
            }
            FreeTimeDebug.RecordEnd(this.GetType().Name, startTime);
            FreeLog.Stop(s, this, args);
        }
示例#3
0
        public virtual void Act(IEventArgs args)
        {
            long s         = FreeLog.Start(this, args);
            long startTime = FreeTimeDebug.RecordStart(this.GetType().Name);

            try
            {
                DoAction(args);
            }
            catch (Exception e)
            {
                string err = "action failed\nat    " + FreeLog.ActionMark + "\n at" + this.ToMessage(args) + "\nat    " + ExceptionUtil.GetExceptionContent(e);
                FreeLog.Error(err, this);
                Debug.LogError(err);
                _logger.Error(err);
            }
            FreeTimeDebug.RecordEnd(this.GetType().Name, startTime);
            FreeLog.Stop(s, this, args);
        }
        public virtual void Act(IEventArgs args)
        {
            long   s         = FreeLog.Start(this, args);
            string actName   = this.GetName();
            long   startTime = FreeTimeDebug.RecordStart(actName);

            try
            {
                SingletonManager.Get <DurationHelp>().ProfileStart(actName);
                DoAction(args);
            }
            catch (Exception e)
            {
                int length = _tempStringBuilder.Length;
                _tempStringBuilder.Remove(0, length);
                _tempStringBuilder.Append("action failed\nat ");
                _tempStringBuilder.Append(FreeLog.ActionMark);
                _tempStringBuilder.Append("\n at ");
                _tempStringBuilder.Append(this.ToMessage(args));
                _tempStringBuilder.Append("\nat ");
                _tempStringBuilder.Append(ExceptionUtil.GetExceptionContent(e));
#if UNITY_EDITOR
                string err = _tempStringBuilder.ToString();
                FreeLog.Error(err, this);
                Debug.LogError(err);
                _logger.Error(err);
#else
                string err = _tempStringBuilder.ToString();
                _logger.Error(err);
#endif

                if (args.FreeContext.DebugMode)
                {
                    FreeUIUpdateAction update = new FreeUIUpdateAction();
                    update.SetKey("testUI");
                    //update.SetPlayer(FreeUtil.ReplaceVar(player, args));
                    update.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args));

                    FreeUITextValue textValue = new FreeUITextValue();
                    textValue.SetSeq("1");
                    update.AddValue(textValue);

                    FreeUIShowAction show = new FreeUIShowAction();
                    show.SetKey("testUI");
                    //show.SetPlayer(FreeUtil.ReplaceVar(player, args));
                    show.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args));
                    show.SetTime("3000");

                    long lastTime = 0L;
                    if (Runtime.CurrentTimeMillis(false) - lastTime >= 3000L)
                    {
                        textValue.SetText(FreeUtil.ReplaceVar(err, args));
                        update.DoAction(args);
                        show.DoAction(args);
                        lastTime = Runtime.CurrentTimeMillis(false);
                    }
                }
            }
            finally
            {
                SingletonManager.Get <DurationHelp>().ProfileEnd(actName);
            }
            FreeTimeDebug.RecordEnd(this.GetType().Name, startTime);
            FreeLog.Stop(s, this, args);
        }