Esempio n. 1
0
        public void OnFireEvent(BTState state, BTEvent btEvent)
        {
            //XLogger.Log( state.ToString(), state );
            var currNode = FindBTNode(state);

            currNode.FireEvent(btEvent);
        }
Esempio n. 2
0
        public void ClickNode(object obj)
        {
            var className = obj as string;
            var btNode    = currNode as BTNode;

            if (className == "NewEvent")
            {
                BTEvent.Create(btNode.BtState);
            }
            else if (className == "OpenScript")
            {
                btNode.OpenScript();
            }
            else if (className == "DeleteState")
            {
                DeleteCurrState();
            }
            else if (className == "CopyState")
            {
                copyState = btNode.BtState;
            }
            else
            {
                var type = Type.GetType(className);
                if (type.IsSubclassOf(typeof(BTAction)))
                {
                    var newAction = CreateAction(type, btNode.BtState);
                    newAction.OnCreate();
                    EditorUtility.SetDirty(newAction);
                    Debug.Log(type.ToString());
                }
            }
        }
Esempio n. 3
0
    public virtual void Sorting()
    {
        BTEvent highestEvent = null;

        for (int i = 0; i < totalEvent.Count; i++)
        {
            var currEvent = totalEvent[i];
            if (currEvent.TargetState == null)
            {
                continue;
            }
            else if (highestEvent == null)
            {
                highestEvent = currEvent;
            }
            else if (currEvent.TargetState.Priority > highestEvent.TargetState.Priority)
            {
                highestEvent = currEvent;
            }
        }

        if (highestEvent != null)
        {
            Owner.FireEvent(highestEvent);
        }
    }
Esempio n. 4
0
    public override void OnCreate()
    {
        base.OnCreate();
        var ownerState = Owner;

        if (ownerState.FindEvent("Finish") == null)
        {
            var newEvent = BTEvent.Create(Owner);
            newEvent.Name = "Finish";
        }
    }
Esempio n. 5
0
 protected override void OnSelectNode(DragNode node)
 {
     if (currentEvent != null)
     {
         var currentNode = node as BTNode;
         currentEvent.TargetState = currentNode.BtState;
         currentEvent             = null;
         Dirty();
     }
     else
     {
         base.OnSelectNode(node);
     }
 }
Esempio n. 6
0
 public override void OnNoneSelectedNode()
 {
     if (target != null)
     {
         Selection.objects = new Object[] { target.gameObject }
     }
     ;
     if (currentEvent != null)
     {
         currentEvent.TargetState = null;
         currentEvent             = null;
         currentEventRect         = new Rect(0, 0, 0, 0);
     }
 }
Esempio n. 7
0
 public void FireEvent(BTEvent targetEvent)
 {
     for (int i = 0; i < BtState.totalEvent.Count; i++)
     {
         if (BtState.totalEvent[i] == targetEvent && targetEvent.TargetState != null)
         {
             var key = BtState.totalEvent[i];
             if (totalRunningEvent.ContainsKey(key))
             {
                 totalRunningEvent.Remove(key);
             }
             totalRunningEvent.Add(key, 0);
         }
     }
 }
Esempio n. 8
0
        public void ClickNone(object obj)
        {
            var para = obj as string;

            switch (para)
            {
            case "NewGlobalEvent":
            {
                var newEvent = BTEvent.Create(currFsm);
                var newState = BTState.Create <BTState>(currFsm);
                newEvent.TargetState = newState;
                newState.GlobalEvent = newEvent;
                BTEditorWindow.instance.AddNewBTNode(newState);
                AddStateToFsm(currFsm, newState);
            }
            break;

            case "NewState":
            {
                var newState = BTState.Create <BTState>(currFsm);
                newState.Name = "NewState";
                var newNode = BTEditorWindow.instance.AddNewBTNode(newState);
                newNode.SetPosition(BTEditorWindow.instance.GetMousePosition());
                EditorUtility.SetDirty(currFsm);
                AddStateToFsm(currFsm, newState);
            }
            break;

            case "PasteState":
            {
                var newState = BTState.Create(currFsm, copyState);
                newState.Name = "NewState";
                newState.OnCreate();
                BTEditorWindow.instance.AddNewBTNode(newState);
                EditorUtility.SetDirty(currFsm);
                AddStateToFsm(currFsm, newState);
                for (int i = 0; i < newState.totalActions.Count; i++)
                {
                    AddActionToState(newState, newState.totalActions[i]);
                }
            }
            break;

            case "CancelEditFsm":
                BTEditorWindow.target = null;
                break;

            default:
            {
                var type = Type.GetType(para);
                if (type.IsSubclassOf(typeof(BTVariable)))
                {
                    var newVariable = CreateVariable(type, currFsm);
                    newVariable.OnCreate();
                    EditorUtility.SetDirty(newVariable);
                    Debug.Log(type.ToString());
                }
            }
            break;
            }
        }
Esempio n. 9
0
 public void SetCurrentEvent(BTEvent currentEvent)
 {
     this.currentEvent = currentEvent;
 }
Esempio n. 10
0
 public BluetoothMediumEvent(BTEvent t, string p)
 {
     Type  = t;
     Param = p;
 }