Exemplo n.º 1
0
        public static void Init(ActorConfigEditor actorEditor, ModelActionEditor modelAction, bool isAddAction, Action <ModelActionEditor> result = null)
        {
            var window = GetWindow <ActionWindow>(true, "行为配置窗口", true);

            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(400, 250);
            window.minSize  = new Vector2(400, 250);
            window.maxSize  = new Vector2(400, 250);

            window._nameStyle                  = SirenixGUIStyles.BoldTitleCentered;
            window._nameStyle.fontSize         = 30;
            window._nameStyle.fontStyle        = FontStyle.Bold;
            window._nameStyle.normal.textColor = Color.white;

            window._isAddAction     = isAddAction;
            window._selfActorEditor = actorEditor;
            window._modelAction     = modelAction;
            window._actionName      = modelAction.ActionName;
            window._clipName        = modelAction.ActionClip;
            window._otherModelName  = modelAction.OtherModelName;
            window._result          = result;
            if (!modelAction.IsFromOther)
            {
                window.LoadSelfAction();
            }
            else
            {
                window.LoadOtherAction(modelAction.OtherModelName);
            }
        }
Exemplo n.º 2
0
 public ActorConfigEditor(string path, ActorConfig cfg = null)
 {
     _path     = path;
     _actorCfg = cfg != null ? cfg : new ActorConfig();
     if (File.Exists(path))
     {
         _actorCfg.LoadAConfig(path);
     }
     if (CfgManager.Model.ContainsKey(_actorCfg.ModelName))
     {
         _model = CfgManager.Model[_actorCfg.ModelName];
     }
     if (_actorCfg != null)
     {
         foreach (var item in _actorCfg.GeneralActions)
         {
             var action = new ModelActionEditor(this, item.Value, false);
             action.ActState = ModelActionEditor.ActionState.New;
             GeneralActions.Add(action);
         }
         foreach (var item in _actorCfg.SkillActions)
         {
             var action = new ModelActionEditor(this, item.Value, true);
             action.ActState = ModelActionEditor.ActionState.New;
             SkillActions.Add(action);
         }
     }
 }
Exemplo n.º 3
0
        public void SetChildAction(ModelActionEditor action)
        {
            foreach (var item in _childActor)
            {
                ActorConfigEditor        actor = item.Value;
                List <ModelActionEditor> list  = null;
                if (action.IsSkillAction)
                {
                    list = actor.SkillActions;
                }
                else
                {
                    list = actor.GeneralActions;
                }

                int index = list.FindIndex(s => s.ActionName.Equals(action.ActionName));
                if (index == -1)
                {
                    ModelActionEditor add = Clipboard.Paste <ModelActionEditor>();
                    add.ActState = ModelActionEditor.ActionState.New;
                    list.Add(add);
                    continue;
                }

                if (list[index].ActState == ModelActionEditor.ActionState.Override)
                {
                    continue;
                }

                Clipboard.Copy(action, CopyModes.DeepCopy);
                ModelActionEditor temp = Clipboard.Paste <ModelActionEditor>();
                temp.ResetActorEditor(actor);
                list[index] = temp;
            }
        }
Exemplo n.º 4
0
 protected override void OnDestroy()
 {
     _modelAction      = null;
     _selfActorEditor  = null;
     _otherActorEditor = null;
     _result           = null;
     _actClipList      = null;
 }
Exemplo n.º 5
0
        private void CreateSkillAction()
        {
            var action = new ModelActionEditor(this, new SkillAction(), true);

            action.ActState = ModelActionEditor.ActionState.New;
            ActionWindow.Init(this, action, true, (act) =>
            {
                SkillActions.Add(act);
                OnCfgChange();
            });
        }
Exemplo n.º 6
0
        public void OpenSequence(ActorConfigEditor actor, ModelActionEditor action)
        {
            LoadSelf(actor);
            string targetName = _targetDisplayName;

            if (string.IsNullOrEmpty(targetName))
            {
                targetName = actor.ModelName;
            }
            LoadTarget(actor);
            //_sequence = FSequence.CreateSequence(SequenceRoot);


            //FluxEditor.FSequenceEditorWindow.Open(_sequence);
        }
Exemplo n.º 7
0
        public override bool Equals(object obj)
        {
            ModelActionEditor other = obj as ModelActionEditor;

            if (other == null)
            {
                return(false);
            }

            bool result = other.IsFromOther.Equals(IsFromOther);

            result &= other.OtherModelName.Equals(OtherModelName);
            result &= other.ActionClip.Equals(ActionClip);

            return(result);
        }
Exemplo n.º 8
0
        void AddChildActor(ActorConfigEditor childCfg)
        {
            var modelDict = childCfg.GetGeneralActionDict();

            foreach (var item in GeneralActions)
            {
                if (modelDict.ContainsKey(item.ActionName))
                {
                    modelDict[item.ActionName].ActState = ModelActionEditor.ActionState.Override;
                }
                else
                {
                    Clipboard.Copy(item, CopyModes.DeepCopy);
                    ModelActionEditor action = Clipboard.Paste <ModelActionEditor>();
                    action.ActState = ModelActionEditor.ActionState.Inherit;
                    childCfg.GeneralActions.Add(action);
                    action.ResetActorEditor(childCfg);
                }
            }
            var skillDict = childCfg.GetSkillActionDict();

            foreach (var item in SkillActions)
            {
                if (skillDict.ContainsKey(item.ActionName))
                {
                    skillDict[item.ActionName].ActState = ModelActionEditor.ActionState.Override;
                }
                else
                {
                    Clipboard.Copy(item, CopyModes.DeepCopy);
                    ModelActionEditor action = Clipboard.Paste <ModelActionEditor>();
                    action.ActState = ModelActionEditor.ActionState.Inherit;
                    childCfg.SkillActions.Add(action);
                    action.ResetActorEditor(childCfg);
                }
            }
            if (!_childActor.ContainsKey(childCfg.ModelName))
            {
                _childActor.Add(childCfg.ModelName, childCfg);
            }
        }
Exemplo n.º 9
0
        private void OnGUI()
        {
            EditorGUILayout.BeginHorizontal();
            Color  color    = Color.green;
            string actState = "新建";

            switch (ActState)
            {
            case ActionState.New:
                break;

            case ActionState.Inherit:
                color    = Color.yellow;
                actState = "继承";
                break;

            case ActionState.Override:
                color    = Color.red;
                actState = "重写";
                break;
            }
            GUIHelper.PushColor(color);
            GUILayout.Label(actState, SirenixGUIStyles.LabelCentered, GUILayout.Width(INHERIT_WIDTH));
            GUIHelper.PopColor();

            GUILayout.Label(ActionName, SirenixGUIStyles.LabelCentered, GUILayout.Width(ACT_NAME_WIDTH));
            GUILayout.Label(IsFromOther ? "其他" : "自己", SirenixGUIStyles.LabelCentered, GUILayout.Width(ACT_SRC_WIDTH));

            bool isClipMiss = string.IsNullOrEmpty(ActionClip);

            GUIHelper.PushColor(isClipMiss ? Color.red : Color.green);
            GUILayout.Label(isClipMiss ? "Error" : ActionClip, SirenixGUIStyles.LabelCentered, GUILayout.Width(ACT_CLIP_WIDTH));
            GUIHelper.PopColor();

            GUIHelper.PushGUIPositionOffset(Vector2.up * -4f);
            if (GUILayout.Button("加载", SirenixGUIStyles.ButtonLeft))
            {
                LoadSequence();
            }
            bool canOverride = ActState == ActionState.Inherit;

            if (GUILayout.Button(canOverride? "重写" : "修改", SirenixGUIStyles.ButtonRight))
            {
                Modifier();
            }
            bool isSelected = IsSelected;

            if (isSelected)
            {
                GUIHelper.PushColor(Color.green);
            }
            if (GUILayout.Button("选择", SirenixGUIStyles.Button, GUILayout.Width(40)))
            {
                IsSelected = !IsSelected;
            }
            if (isSelected)
            {
                GUIHelper.PopColor();
            }
            GUIHelper.PopGUIPositionOffset();
            if (ActState != ActionState.Inherit)
            {
                if (SirenixEditorGUI.IconButton(EditorIcons.X))
                {
                    if (ActState == ActionState.Override)
                    {
                        ActState = ActionState.Inherit;
                        var baseEditor           = HomeConfig.Instance.GetActorEditor(_actorEditor.BaseName);
                        ModelActionEditor action = null;
                        if (IsSkillAction)
                        {
                            action = baseEditor.SkillActions.Find(a => a.ActionName.Equals(ActionName));
                        }
                        else
                        {
                            action = baseEditor.GeneralActions.Find(a => a.ActionName.Equals(ActionName));
                        }
                        OtherModelName = action.OtherModelName;
                        ActionClip     = action.ActionClip;
                    }
                    else
                    {
                        if (IsSkillAction)
                        {
                            _actorEditor.SkillActions.Remove(this);
                        }
                        else
                        {
                            _actorEditor.GeneralActions.Remove(this);
                        }
                    }
                }
            }
            else
            {
                GUILayout.Label("", GUILayout.Width(18), GUILayout.Height(18));
            }

            EditorGUILayout.EndHorizontal();
        }