Ejemplo n.º 1
0
 public static DrawState GetDrawState(Skill fsm, SkillState state, SkillStateAction action)
 {
     if (fsm == null)
     {
         return(DrawState.Normal);
     }
     if (!Application.get_isPlaying())
     {
         return(DrawState.Normal);
     }
     if (!state.get_Active() || !action.get_Active())
     {
         return(DrawState.Normal);
     }
     if (GameStateTracker.CurrentState == GameState.Break)
     {
         return(DrawState.Normal);
     }
     if (GameStateTracker.CurrentState == GameState.Paused)
     {
         return(DrawState.Paused);
     }
     if (GameStateTracker.CurrentState == GameState.Running)
     {
         return(DrawState.Active);
     }
     if (GameStateTracker.CurrentState == GameState.Error)
     {
         return(DrawState.Error);
     }
     return(DrawState.Normal);
 }
Ejemplo n.º 2
0
    private void NextActionScreenshot()
    {
        if (this.CheckFinished())
        {
            this.FinishCapture();
            return;
        }
        if (this.selectedCategory > 0)
        {
            while (Actions.CategoryLookup.get_Item(this.actionIndex) != this.selectedCategoryName)
            {
                this.actionIndex++;
                if (this.CheckFinished())
                {
                    this.FinishCapture();
                    return;
                }
            }
        }
        Type type = Actions.List.get_Item(this.actionIndex);

        if (Actions.CategoryLookup.get_Item(this.actionIndex) == "Tests")
        {
            this.actionIndex++;
            this.NextActionScreenshot();
        }
        this.previewAction = (SkillStateAction)Activator.CreateInstance(type);
        this.previewAction.Reset();
        this.actionIndex++;
        base.Repaint();
    }
Ejemplo n.º 3
0
        private static bool TrySetValue(SkillStateAction action, FieldInfo fieldInfo, object value)
        {
            object value2 = fieldInfo.GetValue(action);

            if (fieldInfo.get_FieldType().get_IsArray())
            {
                Type elementType = fieldInfo.get_FieldType().GetElementType();
                if (elementType == null)
                {
                    return(false);
                }
                value = ActionUtility.TryConvertValue(elementType, value2, value);
                if (elementType.IsInstanceOfType(value))
                {
                    Array array = Array.CreateInstance(elementType, 1);
                    array.SetValue(value, 0);
                    fieldInfo.SetValue(action, array);
                    return(true);
                }
                return(false);
            }
            else
            {
                value = ActionUtility.TryConvertValue(fieldInfo.get_FieldType(), value2, value);
                if (fieldInfo.get_FieldType().IsInstanceOfType(value))
                {
                    fieldInfo.SetValue(action, value);
                    return(true);
                }
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static SkillStateAction AddPlayAnimationAction(Skill targetFsm, SkillState state, AnimationClip anim, SkillStateAction beforeAction = null)
        {
            SkillStateAction fsmStateAction = ActionUtility.AddAction(state, "HutongGames.PlayMaker.Actions.PlayAnimation", beforeAction);

            if (fsmStateAction == null)
            {
                return(null);
            }
            if (!ActionUtility.GameObjectHasAnimationClip(targetFsm.get_GameObject(), anim.get_name()) && Dialogs.YesNoDialog(Strings.get_ActionUtility_Add_Animation_Clip_to_GameObject()))
            {
                ActionUtility.AddAnimationClip(targetFsm.get_GameObject(), anim);
            }
            FieldInfo field = fsmStateAction.GetType().GetField("animName", 20);

            if (field != null)
            {
                FieldInfo   arg_68_0  = field;
                object      arg_68_1  = fsmStateAction;
                SkillString fsmString = new SkillString();
                fsmString.set_Value(anim.get_name());
                arg_68_0.SetValue(arg_68_1, fsmString);
            }
            SkillEditor.SetFsmDirty(targetFsm, true, false, true);
            SkillEditor.SaveActions(targetFsm);
            return(fsmStateAction);
        }
Ejemplo n.º 5
0
 private void DoSearch()
 {
     this.UpdateVariableList();
     this.FindEventsInGlobalTransitions();
     SkillState[] states = this.fsm.get_States();
     for (int i = 0; i < states.Length; i++)
     {
         SkillState fsmState = states[i];
         fsmState.set_Fsm(this.fsm);
         this.FindEventUsage(fsmState);
         SkillStateAction[] actions = fsmState.get_Actions();
         for (int j = 0; j < actions.Length; j++)
         {
             SkillStateAction fsmStateAction = actions[j];
             SkillSearch.currentInfo = new SkillInfo
             {
                 fsm    = this.fsm,
                 state  = fsmState,
                 action = fsmStateAction
             };
             this.FindEventsSentBy(fsmStateAction);
             this.FindVariableUsage(fsmStateAction, 0);
         }
     }
     this.UpdateUnusedEvents();
     this.UpdateUnusedVariables();
 }
Ejemplo n.º 6
0
        public static void SetActionFieldValue(SkillStateAction action, string fieldName, object value)
        {
            if (action == null)
            {
                Debug.LogError(Strings.get_Error_Action_is_null_());
                return;
            }
            FieldInfo field = action.GetType().GetField(fieldName, 20);

            if (field != null)
            {
                if (field.get_FieldType().IsInstanceOfType(value))
                {
                    field.SetValue(action, value);
                    return;
                }
                if (!ActionUtility.TrySetValue(action, field, value))
                {
                    Debug.LogError(string.Format(Strings.get_Error_Could_Not_Set_Action_Field_Value(), fieldName));
                    return;
                }
            }
            else
            {
                Debug.LogError(string.Format(Strings.get_Error_Could_Not_Find_Action_Field(), fieldName));
            }
        }
Ejemplo n.º 7
0
        private static void AddAction(object userdata)
        {
            ActionUtility.ActionCreationParams actionCreationParams = (ActionUtility.ActionCreationParams)userdata;
            SkillStateAction action = ActionUtility.AddAction(actionCreationParams.state, actionCreationParams.actionType, actionCreationParams.actionTarget, actionCreationParams.parameter, actionCreationParams.beforeAction);

            SkillEditor.SelectAction(action, true);
        }
Ejemplo n.º 8
0
        public static List <SkillInfo> FindStatesUsingAction(Skill fsm, Type actionType)
        {
            List <SkillInfo> list = new List <SkillInfo>();

            SkillState[] states = fsm.get_States();
            for (int i = 0; i < states.Length; i++)
            {
                SkillState fsmState = states[i];
                if (fsmState.get_ActionsLoaded())
                {
                    int num = 0;
                    SkillStateAction[] actions = fsmState.get_Actions();
                    for (int j = 0; j < actions.Length; j++)
                    {
                        SkillStateAction fsmStateAction = actions[j];
                        if (fsmStateAction.GetType() == actionType)
                        {
                            list.Add(new SkillInfo
                            {
                                fsm         = fsm,
                                state       = fsmState,
                                action      = fsmStateAction,
                                actionIndex = num
                            });
                        }
                        num++;
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 9
0
 public FsmError(SkillState state, SkillStateAction action, string errorString)
 {
     this.Action      = action;
     this.State       = state;
     this.Fsm         = state.get_Fsm();
     this.ErrorString = errorString;
 }
Ejemplo n.º 10
0
        private static void AddSetPropertyAction()
        {
            Type actionType = ActionData.GetActionType("HutongGames.PlayMaker.Actions.SetProperty");

            if (actionType == null)
            {
                Dialogs.MissingAction("Set Property");
                return;
            }
            SkillStateAction fsmStateAction = SkillEditor.Builder.InsertAction(SkillEditorMacros.droppedOnState, actionType, SkillEditorMacros.droppedOnAction);
            FieldInfo        field          = actionType.GetField("targetProperty", 20);

            if (field != null)
            {
                FieldInfo     arg_6B_0    = field;
                object        arg_6B_1    = fsmStateAction;
                SkillProperty fsmProperty = new SkillProperty();
                SkillProperty arg_5E_0    = fsmProperty;
                SkillObject   fsmObject   = new SkillObject();
                fsmObject.set_Value(SkillEditorMacros.droppedObject);
                arg_5E_0.TargetObject   = fsmObject;
                fsmProperty.setProperty = true;
                arg_6B_0.SetValue(arg_6B_1, fsmProperty);
            }
            SkillEditor.SetFsmDirty(SkillEditorMacros.droppedOnFsm, true, false, true);
            SkillEditor.SaveActions(SkillEditorMacros.droppedOnFsm);
        }
Ejemplo n.º 11
0
 private bool ActivateActions(int startIndex)
 {
     for (int i = startIndex; i < this.Actions.Length; i++)
     {
         this.activeActionIndex = i;
         SkillStateAction fsmStateAction = this.Actions[i];
         if (!fsmStateAction.Enabled)
         {
             fsmStateAction.Finished = true;
         }
         else
         {
             this.ActiveActions.Add(fsmStateAction);
             this.activeAction       = fsmStateAction;
             fsmStateAction.Active   = true;
             fsmStateAction.Finished = false;
             fsmStateAction.Init(this);
             fsmStateAction.Entered = true;
             fsmStateAction.OnEnter();
             if (this.Fsm.IsSwitchingState)
             {
                 return(false);
             }
             if (!fsmStateAction.Finished && this.isSequence)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 12
0
 public void SelectNone()
 {
     this.previewAction          = null;
     this.selectedAction         = null;
     this.selectedActionCategory = "";
     base.Repaint();
 }
Ejemplo n.º 13
0
 public static void SetOwnerDefault(Skill fsm, SkillStateAction action, Component component, string fieldName = "gameObject")
 {
     if (component == null)
     {
         return;
     }
     ActionUtility.SetOwnerDefault(fsm, action, component.get_gameObject(), fieldName);
 }
Ejemplo n.º 14
0
 public static Object GetAsset(SkillStateAction action)
 {
     if (action != null)
     {
         return(ActionScripts.GetAsset(action.GetType()));
     }
     return(null);
 }
Ejemplo n.º 15
0
 public static void OpenAction(SkillStateAction action, bool openState)
 {
     if (action == null)
     {
         return;
     }
     action.set_IsOpen(openState);
     SkillEditor.SaveActions(action.get_State(), false);
 }
Ejemplo n.º 16
0
        public static SkillStateAction InsertAction(SkillState state, Type actionType, SkillStateAction beforeAction)
        {
            SkillEditor.RegisterUndo(Strings.get_Command_Add_Action());
            SkillStateAction result = SkillEditor.Builder.InsertAction(SkillEditor.SelectedState, actionType, beforeAction);

            ActionSelector.AddActionToRecent(actionType);
            SkillEditor.UpdateActionUsage();
            return(result);
        }
Ejemplo n.º 17
0
        public static string UpdateTooltip(SkillStateAction action)
        {
            Actions.tooltipLookup.Remove(action);
            string text = Actions.GetTooltip(action);

            text = string.Format(Strings.get_Tooltip_Action(), Labels.NicifyVariableName(Labels.StripNamespace(action.GetType().ToString())), text);
            Actions.tooltipLookup.Add(action, text);
            return(text);
        }
Ejemplo n.º 18
0
 public void OnLateUpdate()
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.OnLateUpdate();
     }
     this.CheckAllActionsFinished();
 }
Ejemplo n.º 19
0
 public ActionCreationParams(ActionUtility.ActionCreationParams source)
 {
     this.fsm          = source.fsm;
     this.state        = source.state;
     this.actionType   = source.actionType;
     this.actionTarget = source.actionTarget;
     this.parameter    = source.parameter;
     this.beforeAction = source.beforeAction;
     this.position     = source.position;
 }
Ejemplo n.º 20
0
 public static void EnableAction(SkillStateAction action, bool enabledState)
 {
     if (action == null)
     {
         return;
     }
     SkillEditor.RegisterUndo(Strings.get_Command_Enable_Action());
     action.set_Enabled(enabledState);
     SkillEditor.SaveActions(action.get_State(), true);
 }
Ejemplo n.º 21
0
        public static string GetTooltip(SkillStateAction action)
        {
            string result;

            if (Actions.tooltipLookup.TryGetValue(action, ref result))
            {
                return(result);
            }
            return(Actions.UpdateTooltip(action));
        }
Ejemplo n.º 22
0
 public void OnGUI()
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.OnGUI();
     }
     this.RemoveFinishedActions();
 }
Ejemplo n.º 23
0
 public static void OpenAllActions(SkillState state, bool openState)
 {
     SkillStateAction[] actions = state.get_Actions();
     for (int i = 0; i < actions.Length; i++)
     {
         SkillStateAction fsmStateAction = actions[i];
         fsmStateAction.set_IsOpen(openState);
     }
     SkillEditor.SaveActions(state, false);
 }
Ejemplo n.º 24
0
 public static void RenameAction(SkillStateAction action, string newName)
 {
     if (action == null)
     {
         return;
     }
     SkillEditor.RegisterUndo(Strings.get_Command_Rename_Action());
     action.set_Name(newName);
     SkillEditor.SaveActions(action.get_State(), false);
     Actions.UpdateTooltip(action);
 }
Ejemplo n.º 25
0
 public bool OnAnimatorIK(int layerIndex)
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.DoAnimatorIK(layerIndex);
     }
     this.RemoveFinishedActions();
     return(this.fsm.IsSwitchingState);
 }
Ejemplo n.º 26
0
 public bool OnParticleCollision(GameObject other)
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.DoParticleCollision(other);
     }
     this.RemoveFinishedActions();
     return(this.fsm.IsSwitchingState);
 }
Ejemplo n.º 27
0
 public bool OnJointBreak2D(Joint2D joint)
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.DoJointBreak2D(joint);
     }
     this.RemoveFinishedActions();
     return(this.fsm.IsSwitchingState);
 }
Ejemplo n.º 28
0
 public bool OnControllerColliderHit(ControllerColliderHit collider)
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.DoControllerColliderHit(collider);
     }
     this.RemoveFinishedActions();
     return(this.fsm.IsSwitchingState);
 }
Ejemplo n.º 29
0
 public bool OnTriggerExit2D(Collider2D other)
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.DoTriggerExit2D(other);
     }
     this.RemoveFinishedActions();
     return(this.fsm.IsSwitchingState);
 }
Ejemplo n.º 30
0
 public bool OnCollisionExit2D(Collision2D collisionInfo)
 {
     for (int i = 0; i < this.ActiveActions.get_Count(); i++)
     {
         SkillStateAction fsmStateAction = this.ActiveActions.get_Item(i);
         fsmStateAction.Init(this);
         fsmStateAction.DoCollisionExit2D(collisionInfo);
     }
     this.RemoveFinishedActions();
     return(this.fsm.IsSwitchingState);
 }