Пример #1
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;
            }
        }
Пример #2
0
        public static GameObject Instantiate(ActorConfigEditor actorEditor)
        {
            GameObject role     = Instantiate(actorEditor.CharacterPath);
            GameObject avatargo = Instantiate(actorEditor.AvatarPath);

            Debug.Log("骨骼:" + actorEditor.CharacterPath + "\n蒙皮:" + actorEditor.AvatarPath);
            if (role != null && avatargo != null)
            {
                role.SetActive(false);
                Transform bip = role.transform.Find(ROOT_BONE);
                if (bip != null)
                {
                    UnityEngine.Object.DestroyImmediate(bip.gameObject, true);
                }

                while (avatargo.transform.childCount > 0)
                {
                    Transform trans = avatargo.transform.GetChild(0);
                    trans.parent = role.transform;
                }
                UnityEngine.Object.DestroyImmediate(avatargo, true);
                role.SetActive(true);
                role.transform.localScale = Vector3.one * actorEditor.ModelScale;
                role.tag = "Player";
            }
            var mc = role.AddComponent <MecanimControl>();

            return(role);
        }
Пример #3
0
        private void LoadTarget(ActorConfigEditor actor)
        {
            string modelName = CfgManager.Model[actor.ModelName].ModelPath;

            if (Target != null && Target.name.Equals(modelName))
            {
                return;
            }

            if (Target != null)
            {
                UnityEngine.Object.DestroyImmediate(Target);
            }
            Target = ActorHelper.Instantiate(actor);
            Target.transform.parent   = CharacterDir.transform;
            Target.transform.position = Vec3.forward * -10;
            Target.transform.forward  = Vec3.forward;
            var cap = Target.GetComponent <CapsuleCollider>();

            if (cap != null)
            {
                var collider = LoadCollider(_charColliderName, Target);
                collider.SetActive(_showCollider);
                float size = cap.radius;
                collider.transform.localScale = Vec3.one * size;
            }
            else
            {
                Debug.LogErrorFormat("{0} 角色没有渲染组件!", Target.name);
            }
        }
Пример #4
0
        public ModelActionEditor(ActorConfigEditor actorEditor, GeneralAction modelAction, bool isSkill)
        {
            ModelAction   = modelAction;
            IsSkillAction = isSkill;

            _actorEditor = actorEditor;
        }
Пример #5
0
        //-- 加载角色行为时加载资源
        private void LoadSelf(ActorConfigEditor actor)
        {
            string modelName = CfgManager.Model[actor.ModelName].ModelPath;

            if (Self != null && Self.name.Equals(modelName))
            {
                return;
            }

            if (Self != null)
            {
                UnityEngine.Object.DestroyImmediate(Self);
            }
            Self = ActorHelper.Instantiate(actor);
            Self.transform.parent   = CharacterDir.transform;
            Self.transform.position = Vec3.forward * 10;
            Self.transform.forward  = -Vec3.forward;
            //if (_showCollider)
            //{
            //    var ctrl = Self.GetComponent<CharacterController>();
            //    if (ctrl != null)
            //    {
            //        var collider = LoadCollider(_charColliderName);
            //        collider.transform.localScale = Vec3.one * ctrl.radius;
            //    }
            //}
        }
Пример #6
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);
            }
        }
Пример #7
0
 protected override void OnDestroy()
 {
     _modelAction      = null;
     _selfActorEditor  = null;
     _otherActorEditor = null;
     _result           = null;
     _actClipList      = null;
 }
Пример #8
0
 void RemoveChildActor(ActorConfigEditor childCfg)
 {
     childCfg.RemoveAllBaseAction();
     if (_childActor.ContainsKey(childCfg.ModelName))
     {
         _childActor.Remove(childCfg.ModelName);
     }
 }
Пример #9
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);
        }
Пример #10
0
 public void RemoveActor(ActorConfigEditor model)
 {
     if (!ModelGroupDict.ContainsKey(model.GroupType))
     {
         Debug.LogError("未定义组类型 " + model.GroupType);
         return;
     }
     if (!ModelGroupDict[model.GroupType].Remove(model))
     {
         Debug.LogErrorFormat("{0} 无法从分组中移除", model.MenuItemName);
     }
     if (_modelDict.ContainsKey(model.ModelName))
     {
         _modelDict.Remove(model.ModelName);
     }
 }
Пример #11
0
        /// <summary>
        /// 创建角色动作行为配置文本
        /// 每个角色只能有一套配置
        /// </summary>
        /// <returns></returns>
        private void Create()
        {
            ActorConfigEditor model = null;
            var models = CfgManager.Model.Keys;

            SimplePopupCreator.ShowDialog(new List <string>(models), (name) =>
            {
                var config = new ActorConfig()
                {
                    ModelName = name
                };
                string path = string.Format("{0}/{1}.xml", ActionHomeConfig.Instance.ActionConfigPath, name);
                model       = new ActorConfigEditor(path, config);
                model.Save();
            });
        }
Пример #12
0
 public void AddActor(ActorConfigEditor model)
 {
     if (ModelGroupDict.ContainsKey(model.GroupType))
     {
         ModelGroupDict[model.GroupType].Add(model);
     }
     else
     {
         ModelGroupDict.Add(model.GroupType, new List <ActorConfigEditor>());
         ModelGroupDict[model.GroupType].Add(model);
     }
     if (!_modelDict.ContainsKey(model.ModelName))
     {
         _modelDict.Add(model.ModelName, model);
     }
 }
Пример #13
0
 void OnGUI_Func()
 {
     EditorGUILayout.BeginHorizontal();
     GUIHelper.PushGUIPositionOffset(UnityEngine.Vector2.up * -2);
     if (GUILayout.Button("设置受击对象", GUILayout.Width(150)))
     {
         SimplePopupCreator.ShowDialog(new List <string>(CfgManager.Model.Keys), (name) =>
         {
             _targetDisplayName      = name;
             ActorConfigEditor actor = GetActorEditor(name);
             LoadTarget(actor);
         });
     }
     GUIHelper.PopGUIPositionOffset();
     EditorGUILayout.LabelField(_targetDisplayName, EditorStyles.textArea);
     EditorGUILayout.EndHorizontal();
 }
Пример #14
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);
            }
        }
Пример #15
0
        public void Delete()
        {
            if (EditorUtility.DisplayDialog("删除操作", "确定要删除文件 -> " + ModelName, "确定", "取消"))
            {
                if (File.Exists(_path))
                {
                    File.Delete(_path);
                }

                ActorCfgWindow window = ActorCfgWindow.GetWindow <ActorCfgWindow>();
                OdinMenuItem   item   = window.MenuTree.Selection.FirstOrDefault();
                if (item != null && item.Value != null)
                {
                    ActorConfigEditor model = item.Value as ActorConfigEditor;
                    HomeConfig.Instance.RemoveActor(model);
                    item.Parent.ChildMenuItems.Remove(item);
                    item.MenuTree.Selection.Clear();
                    item.Parent.Select();
                    item.MenuTree.UpdateMenuTree();
                    item.MenuTree.DrawMenuTree();
                }
            }
        }
Пример #16
0
 public void ResetActorEditor(ActorConfigEditor actorEditor)
 {
     _actorEditor = actorEditor;
     OnCfgChange();
 }
Пример #17
0
        public void LoadAll()
        {
            ClearAll();

            _config = ActionHomeConfig.Instance;
            CfgManager.ConfigDir = ConfigDir;
            CfgManager.LoadAll();

            //--初始化资源路径
            EUtil.GetAssetsInSubFolderRecursively(_config.CharacterRelativeDir, "*.prefab", ref AllCharacters);
            EUtil.GetAssetsInSubFolderRecursively(_config.AvatarRelativeDir, "*.prefab", ref AllAvatars);
            EUtil.GetAssetsInSubFolderRecursively(_config.EffectRelativeDir, "*.prefab", ref AllEffects);
            foreach (var item in AllCharacters)
            {
                string searchDir = item.Value.Substring(0, item.Value.LastIndexOf(@"/prefab")) + "/clips";
                var    selfClips = new Dictionary <string, string>();
                EUtil.GetAssetsInSubFolderRecursively(searchDir, "*.anim", ref selfClips);
                AllCharacterClips[item.Key] = selfClips;
            }

            //--初始化资源
            SequenceRoot     = ActorHelper.CreateGameObject("---行为序列---");
            RuntimeAssetRoot = ActorHelper.CreateGameObject("---运行时资源---");

            CharacterDir = ActorHelper.CreateGameObject("Characters", "/---运行时资源---/");
            EffectDir    = ActorHelper.CreateGameObject("Effects", "/---运行时资源---/");
            OtherDir     = ActorHelper.CreateGameObject("Others", "/---运行时资源---/");

            //--加载行为配置
            foreach (var model in CfgManager.Model)
            {
                var    modelName = model.Key;
                string path      = string.Format("{0}/{1}.xml", ActionConfigPath, modelName);
                if (!File.Exists(path))
                {
                    var config = new ActorConfig()
                    {
                        ModelName = modelName
                    };
                    string savePath = string.Format("{0}/{1}.xml", ActionHomeConfig.Instance.ActionConfigPath, modelName);
                    var    actor    = new ActorConfigEditor(savePath, config);
                    actor.Save(true);
                    Debug.LogFormat("<color=orange>新建Actor - {0}</color>", modelName);
                }
            }

            string[] files = Directory.GetFiles(ActionConfigPath, "*.xml", SearchOption.TopDirectoryOnly);
            foreach (var path in files)
            {
                var actor = new ActorConfigEditor(path);
                AddActor(actor);
            }
            foreach (var item in _modelDict)
            {
                item.Value.InitBaseModelAction();
            }

            var window = ActorCfgWindow.GetWindow <ActorCfgWindow>();

            window.RefreshTree();
            IsInit = true;
            Debug.Log("加载所有动作 完毕!");
        }
Пример #18
0
 private void LoadOtherAction(string name)
 {
     _otherModelName   = name;
     _otherActorEditor = HomeConfig.Instance.GetActorEditor(name);
     _actClipList      = _otherActorEditor.GetActionClips();
 }
Пример #19
0
 private void LoadSelfAction()
 {
     _otherModelName   = string.Empty;
     _otherActorEditor = null;
     _actClipList      = _selfActorEditor.GetActionClips();
 }