Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public override void DoAction(IEventArgs args)
        {
            if (update == null)
            {
                update = new FreeUIUpdateAction();
                update.SetKey("testUI");
                update.SetPlayer(FreeUtil.ReplaceVar(player, args));
                update.SetScope(FreeUtil.ReplaceInt(this.scope, args));

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

                update.AddValue(textValue);

                show = new FreeUIShowAction();
                show.SetKey("testUI");
                show.SetPlayer(FreeUtil.ReplaceVar(player, args));
                show.SetScope(FreeUtil.ReplaceInt(this.scope, args));
                show.SetTime("2000");

                if (interval == 0)
                {
                    interval = 0;
                }
            }

            if (Runtime.CurrentTimeMillis(false) - lastTime >= interval)
            {
                textValue.SetText(FreeUtil.ReplaceVar(message, args));

                update.DoAction(args);
                show.DoAction(args);

                lastTime = Runtime.CurrentTimeMillis(false);
            }
        }
Ejemplo n.º 3
0
        public override void DoAction(IEventArgs args)
        {
            IGameUnit player = GetPlayer(args);

            if (player != null)
            {
                if (StringUtil.IsNullOrEmpty(name))
                {
                    name = InventoryManager.DEFAULT;
                }
                ItemInventory    ii  = ((FreeData)player).freeInventory.GetInventoryManager().GetInventory(name);
                FreeUIShowAction fui = new FreeUIShowAction();
                fui.SetScope(SendMessageAction.SCOPE_PLYAER);
                fui.SetPlayer(this.player);
                if (alwaysOpen)
                {
                    fui.SetTime(FreeUIShowAction.ALWAYS);
                    ii.SetOpen(true);
                }
                else
                {
                    if (alwaysClose)
                    {
                        fui.SetTime(FreeUIShowAction.HIDE);
                        ii.SetOpen(false);
                    }
                    else
                    {
                        if (ii.IsOpen())
                        {
                            fui.SetTime(FreeUIShowAction.HIDE);
                            ii.SetOpen(false);
                        }
                        else
                        {
                            fui.SetTime(FreeUIShowAction.ALWAYS);
                            ii.SetOpen(true);
                        }
                    }
                }
                if (ii.IsOpen())
                {
                    // ii.reDraw(fr);
                    if (ii.GetOpenAction() != null)
                    {
                        ii.GetOpenAction().Act(args);
                    }
                }
                else
                {
                    if (ii.GetCloseAction() != null)
                    {
                        ii.GetCloseAction().Act(args);
                    }
                }
                fui.SetKey(ii.GetUIKey());
                fui.Act(args);
                foreach (ItemPosition ip in ii.GetItems())
                {
                    fui.SetKey(ip.GetUIKey());
                    fui.Act(args);
                }
            }
        }
Ejemplo n.º 4
0
        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);
        }