Exemplo n.º 1
0
 private static int CompareDistance(CommandLabel.CommandInfo a, CommandLabel.CommandInfo b)
 {
     if (Singleton <Manager.Map> .IsInstance())
     {
         Vector3 position = Singleton <Manager.Map> .Instance.Player.Position;
         float   num1     = Vector3.Distance(a.Position, position);
         float   num2     = Vector3.Distance(b.Position, position);
         if ((double)num1 > (double)num2)
         {
             return(1);
         }
         if ((double)num2 < (double)num1)
         {
             return(-1);
         }
     }
     return(0);
 }
Exemplo n.º 2
0
 public void RefreshCommands()
 {
     foreach (CommandLabelOption commandLabel in this._commandLabels)
     {
         commandLabel.Visibility = 0;
     }
     this._commandLabels.Clear();
     this._commands.Clear();
     if (this._acception == CommandLabel.AcceptionState.InvokeAcception)
     {
         if (this._objectCommands.IsNullOrEmpty <CommandLabel.CommandInfo>() && this.SubjectCommand != null)
         {
             this._commands.Add(this.SubjectCommand);
         }
         for (int index = 0; index < this._objectCommands.Length; ++index)
         {
             this._commands.Add(this._objectCommands[index]);
         }
         List <CommandLabel.CommandInfo> commands = this._commands;
         // ISSUE: reference to a compiler-generated field
         if (CommandLabel.\u003C\u003Ef__mg\u0024cache0 == null)
         {
             // ISSUE: reference to a compiler-generated field
             CommandLabel.\u003C\u003Ef__mg\u0024cache0 = new Comparison <CommandLabel.CommandInfo>(CommandLabel.CompareDistance);
         }
         // ISSUE: reference to a compiler-generated field
         Comparison <CommandLabel.CommandInfo> fMgCache0 = CommandLabel.\u003C\u003Ef__mg\u0024cache0;
         commands.Sort(fMgCache0);
         for (int index = 0; index < this._commands.Count; ++index)
         {
             CommandLabel.CommandInfo command = this._commands[index];
             if (Object.op_Inequality((Object)command.Transform, (Object)null))
             {
                 CommandLabelOption commandLabelOption = this._objectPool.Rent();
                 ((Component)commandLabelOption).get_transform().SetParent(this._labelRoot, false);
                 ((Component)commandLabelOption).get_transform().set_localPosition(Vector3.get_zero());
                 commandLabelOption.CommandInfo = command;
                 this._commandLabels.Add(commandLabelOption);
             }
             else
             {
                 CommandLabelOption commandLabelOption = this._subjectPool.Rent();
                 if (Object.op_Inequality((Object)((Component)commandLabelOption).get_transform().get_parent(), (Object)this._subjectRoot))
                 {
                     ((Component)commandLabelOption).get_transform().SetParent(this._subjectRoot, false);
                 }
                 commandLabelOption.CommandInfo = command;
                 this._commandLabels.Add(commandLabelOption);
             }
         }
         this.CommandID = 0;
     }
     else
     {
         if (this._acception != CommandLabel.AcceptionState.CancelAcception)
         {
             return;
         }
         if (this._cancelCommand != null)
         {
             CommandLabelOption commandLabelOption = this._subjectPool.Rent();
             if (Object.op_Inequality((Object)((Component)commandLabelOption).get_transform().get_parent(), (Object)this._subjectRoot))
             {
                 ((Component)commandLabelOption).get_transform().SetParent(this._subjectRoot, false);
             }
             commandLabelOption.CommandInfo = this._cancelCommand;
             this._commandLabels.Add(commandLabelOption);
         }
         this.CommandID = 0;
     }
 }
Exemplo n.º 3
0
        private void OnInputAction(bool isDown)
        {
            if (this._acception == CommandLabel.AcceptionState.None || this._disposable != null)
            {
                return;
            }
            if (isDown)
            {
                switch (this._acception)
                {
                case CommandLabel.AcceptionState.InvokeAcception:
                    CommandLabel.CommandInfo element = this._commands.GetElement <CommandLabel.CommandInfo>(this._commandID);
                    if (element == null)
                    {
                        break;
                    }
                    if (element.IsHold)
                    {
                        if ((double)this._holdElapsedTime < (double)this._holdDuration && this._isPressedAction && (Singleton <Manager.Map> .IsInstance() && Object.op_Inequality((Object)Singleton <Manager.Map> .Instance.Player, (Object)null)) && this._acception == CommandLabel.AcceptionState.InvokeAcception)
                        {
                            this._holdElapsedTime += Time.get_deltaTime();
                        }
                        if ((double)this._holdElapsedTime < (double)this._holdDuration)
                        {
                            break;
                        }
                        PlayerActor player = Singleton <Manager.Map> .Instance.Player;
                        Func <PlayerActor, bool> condition = element.Condition;
                        bool?nullable = condition != null ? new bool?(condition(player)) : new bool?();
                        if ((!nullable.HasValue ? 1 : (nullable.Value ? 1 : 0)) != 0)
                        {
                            Action action = element.Event;
                            if (action != null)
                            {
                                action();
                            }
                        }
                        else if (element.ErrorText != null)
                        {
                            MapUIContainer.PushMessageUI(element.ErrorText(player), 2, 0, (Action)null);
                        }
                        this._holdElapsedTime = 0.0f;
                        this._isPressedAction = false;
                        break;
                    }
                    if (!this._isPressedAction || !Singleton <Manager.Map> .IsInstance() || !Object.op_Inequality((Object)Singleton <Manager.Map> .Instance.Player, (Object)null))
                    {
                        break;
                    }
                    PlayerActor player1 = Singleton <Manager.Map> .Instance.Player;
                    Func <PlayerActor, bool> condition1 = element.Condition;
                    bool?nullable1 = condition1 != null ? new bool?(condition1(player1)) : new bool?();
                    if ((!nullable1.HasValue ? 1 : (nullable1.Value ? 1 : 0)) != 0)
                    {
                        Action action = element.Event;
                        if (action != null)
                        {
                            action();
                        }
                    }
                    else if (element.ErrorText != null)
                    {
                        MapUIContainer.PushMessageUI(element.ErrorText(player1), 2, 0, (Action)null);
                    }
                    this._isPressedAction = false;
                    break;

                case CommandLabel.AcceptionState.CancelAcception:
                    if (this._cancelCommand == null)
                    {
                        break;
                    }
                    Debug.Log((object)"Run CancelCommand");
                    Action action1 = this._cancelCommand.Event;
                    if (action1 != null)
                    {
                        action1();
                    }
                    this._cancelCommand = (CommandLabel.CommandInfo)null;
                    break;
                }
            }
            else
            {
                this._isPressedAction = false;
                this._holdElapsedTime = 0.0f;
            }
        }