예제 #1
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());
                }
            }
        }
예제 #2
0
    public override void OnCreate()
    {
        base.OnCreate();
        var ownerState = Owner;

        if (ownerState.FindEvent("Finish") == null)
        {
            var newEvent = BTEvent.Create(Owner);
            newEvent.Name = "Finish";
        }
    }
예제 #3
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;
            }
        }