コード例 #1
0
ファイル: SkillModule.cs プロジェクト: whisperlin/utils
    public void SkillLerpFloatChannel(int index, string skillId, int objId, LCHChannelType type, bool messsage = true)
    {
        LCHSkillData skill = GetSkill(skillId);

        if (!HasChannel(skill, objId, (int)type, index) && messsage)
        {
#if UNITY_EDITOR
            EditorUtility.DisplayDialog("提示", "相同轨迹已经存在", "确定");
#endif
            return;
        }

        LCHChannelData channel = new LCHChannelData();
        channel.type  = (int)type;
        channel.objId = objId;
        if (type == LCHChannelType.ScaleX || type == LCHChannelType.ScaleY || type == LCHChannelType.ScaleZ)
        {
            channel.AddKey(0, 0, 1f);
        }
        else
        {
            channel.AddKey(0, 0, 0f);
        }
        skill.subSkills[index].channels.Add(channel);


        SaveSkill(skill.id);
    }
コード例 #2
0
ファイル: SkillModule.cs プロジェクト: whisperlin/utils
    public void SkillAddSound(int index, string skillId)
    {
        LCHSkillData  skill    = GetSkill(skillId);
        var           v        = skill.subSkills[index].objs;
        int           objCount = v.Length;
        int           id       = 0;
        List <object> _list    = new List <object>();

        for (int i = 0; i < objCount; i++)
        {
            int _id = v[i].id;
            if (id <= _id)
            {
                id = _id + 1;
            }
        }
        LCHObjectData eo = new LCHObjectData();

        eo.type                  = 4;
        eo.id                    = id;
        eo.name                  = "声音-未命名";
        eo.propertys["mod"]      = "";
        eo.propertys["mod_name"] = "";


        LCHSkillData s = new LCHSkillData();

        skill.subSkills[index].objs = ArrayHelper.AddItem <LCHObjectData>(skill.subSkills[index].objs, eo);
        SaveSkill(skillId);
    }
コード例 #3
0
ファイル: SkillModule.cs プロジェクト: whisperlin/utils
    public int SkillAddObject(string skillId, int index)
    {
        LCHSkillData skill = GetSkill(skillId);
        var          v     = skill.subSkills[index].objs;

        int           objCount = v.Length;
        int           id       = 0;
        List <object> _list    = new List <object>();

        for (int i = 0; i < objCount; i++)
        {
            int _id = v[i].id;
            if (id <= _id)
            {
                id = _id + 1;
            }
        }
        LCHObjectData eo = new LCHObjectData();

        eo.type = 1;
        eo.id   = id;
        eo.name = "对象-未命名";
        LCHSkillData s = new LCHSkillData();

        skill.subSkills[index].objs = ArrayHelper.AddItem <LCHObjectData>(skill.subSkills[index].objs, eo);
        SaveSkill(skillId);
        return(id);
    }
コード例 #4
0
ファイル: SkillModule.cs プロジェクト: whisperlin/TA2019
    public void SkillAddObject(params object[] args)
    {
        string       skillId = (string)args[0];
        LCHSkillData skill   = GetSkill(skillId);
        var          v       = skill.objs;

        int           objCount = v.Length;
        int           id       = 0;
        List <object> _list    = new List <object>();

        for (int i = 0; i < objCount; i++)
        {
            int _id = v[i].id;
            if (id <= _id)
            {
                id = _id + 1;
            }
        }
        LCHObjectData eo = new LCHObjectData();

        eo.type = 1;
        eo.id   = id;
        eo.name = "对象-未命名";
        LCHSkillData s = new LCHSkillData();

        skill.objs = ArrayHelper.AddItem <LCHObjectData>(skill.objs, eo);
        SaveSkill(skillId);
    }
コード例 #5
0
ファイル: JSonHelper.cs プロジェクト: whisperlin/TA2019
    public static LCHSkillData DeserializeSkill(string str)
    {
        LCHSkillData _map = JsonConvert.DeserializeObject <LCHSkillData>(str);

        for (int i = 0, c = _map.objs.Length; i < c; i++)
        {
            var o = _map.objs[i];
        }
        return(_map);
    }
コード例 #6
0
ファイル: SkillModule.cs プロジェクト: whisperlin/TA2019
    bool HasEventChannel(LCHSkillData skill, int objId, int type, params object[] arg)
    {
        int len = skill.events.Count;

        for (int i = 0; i < len; i++)
        {
            var c = skill.events[i];
            if (c.type == type && c.objId == objId)
            {
                return(false);
            }
        }
        return(true);
    }
コード例 #7
0
ファイル: SkillModule.cs プロジェクト: whisperlin/utils
    bool HasEventChannel(LCHSkillData skill, int objId, LCHChannelType type, int index)
    {
        int len = skill.subSkills[index].events.Count;

        for (int i = 0; i < len; i++)
        {
            var c = skill.subSkills[index].events[i];
            if (c.type == (int)type && c.objId == objId)
            {
                return(false);
            }
        }
        return(true);
    }
コード例 #8
0
ファイル: SkillModule.cs プロジェクト: whisperlin/utils
    bool HasChannel(LCHSkillData skill, int objId, int type, int index)
    {
        int len = skill.subSkills[index].channels.Count;

        for (int i = 0; i < len; i++)
        {
            var c = skill.subSkills[index].channels[i];
            if (c.type == type && c.objId == objId)
            {
                return(false);
            }
        }
        return(true);
    }
コード例 #9
0
ファイル: SkillEditorWindow.cs プロジェクト: whisperlin/utils
    bool TryDragFramePos(Vector2 pos)
    {
        if (null != SkillEditorMainWindow.golbalWindow && SkillEditorData.Instance.skillsData != null)
        {
            LCHSkillData skill           = SkillEditorData.Instance.skillsData.GetSkill(SkillEditorData.Instance.CurSkillId);
            int          c1              = skill.subSkills[SkillEditorData.Instance.subSkillIndex].channels.Count;
            int          c2              = skill.subSkills[SkillEditorData.Instance.subSkillIndex].events.Count;
            float        delta           = 20f * scale;
            float        width           = maxLength * 10f * delta;
            float        _curSelectFrame = maxLength * pos.x / width;
            int          selFrame        = ((int)((_curSelectFrame + 0.0000001f) * 10f));
            selFrame *= 10;

            if (null != selectNormalChannel)
            {
                if (selectNormalChannel.GetKeyframeIndex(selFrame) == -1)
                {
                    int _index = selectNormalChannel.GetKeyframeIndex(curSelectFrame);
                    if (_index != -1)
                    {
                        var v = selectNormalChannel.values[_index];
                        selectNormalChannel.DeleteFrame(_index);
                        if (selectNormalChannel.AddKeyFrame(selFrame, v))
                        {
                            curSelectFrame = selFrame;
                        }
                    }
                }
            }
            if (null != selectEventChannel)
            {
                //curSelectFrame
                if (null != selectEvent)
                {
                    if (null == selectEventChannel.GetKeyFrame(selFrame))
                    {
                        selectEventChannel.DeleteKeyFrame(selectEvent);
                        if (selectEventChannel.AddKeyFrame(selFrame, selectEvent))
                        {
                            curSelectFrame = selFrame;
                        }
                    }
                }
            }
        }
        return(false);
    }
コード例 #10
0
ファイル: SkillModule.cs プロジェクト: whisperlin/utils
    public void SkillEventChannel(string skillId, int objId, LCHChannelType type, int index)
    {
        LCHSkillData skill = GetSkill(skillId);

        if (!HasEventChannel(skill, objId, type, index))
        {
#if UNITY_EDITOR
            EditorUtility.DisplayDialog("提示", "相同轨迹已经存在", "确定");
#endif
            return;
        }
        LCHEventChannelData channel = new LCHEventChannelData();
        channel.type  = (int)type;
        channel.objId = objId;
        skill.subSkills[index].events.Add(channel);
        SaveSkill(skill.id);
    }
コード例 #11
0
    void UpdateCurFramePos(Vector2 pos)
    {
        if (null == SkillEditorMainWindow.golbalWindow && SkillEditorData.Instance.skillsData != null)
        {
            return;
        }
        LCHSkillData skill = SkillEditorData.Instance.skillsData.GetSkill(SkillEditorData.Instance.CurSkillId);
        int          c     = skill.channels.Count + skill.events.Count;

        curSelectChannel = (int)(pos.y / ChannelHeight);
        curSelectChannel = Mathf.Min(curSelectChannel, c - 1);
        float delta           = 20f * scale;
        float width           = maxLength * 10f * delta;
        float _curSelectFrame = maxLength * pos.x / width;

        curSelectFrame  = ((int)((_curSelectFrame + 0.0000001f) * 10f));
        curSelectFrame *= 10;//保留10
        SkillEditorMainWindow.toolbarInt = 1;
    }
コード例 #12
0
ファイル: SkillModule.cs プロジェクト: whisperlin/utils
    public void DeleteSkill(string curSkillId)
    {
        LCHSkillData  sk   = GetSkill(curSkillId);
        LCHRoleData   role = GetRole(sk.roleId);
        List <string> ids  = new List <string>();

        for (int i = 0; i < role.skills.Length; i++)
        {
            var s = role.skills[i];
            if (s == curSkillId)
            {
                continue;
            }
            ids.Add(s);
        }
        role.skills = ids.ToArray();
        loader.DeleveFile(curSkillId, SkillDataType.SKILL);
        skills.Remove(curSkillId);
        SaveRole(sk.roleId);
    }
コード例 #13
0
ファイル: SkillModule.cs プロジェクト: whisperlin/TA2019
    public void SkillEventChannel(params object[] args)
    {
        string       skillId = (string)args[0];//pos_x
        int          objId   = (int)args[1];
        int          type    = (int)args[2];
        LCHSkillData skill   = GetSkill(skillId);

        if (!HasEventChannel(skill, objId, type))
        {
#if UNITY_EDITOR
            EditorUtility.DisplayDialog("提示", "相同轨迹已经存在", "确定");
#endif
            return;
        }
        LCHEventChannelData channel = new LCHEventChannelData();
        channel.type  = (int)type;
        channel.objId = objId;
        skill.events.Add(channel);
        SaveSkill(skill.id);
    }
コード例 #14
0
ファイル: SkillModule.cs プロジェクト: whisperlin/TA2019
    public void SkillAddBaseCollider(params object[] args)
    {
        string        skillId  = (string)args[0];
        int           objId    = (int)args[1];
        string        bindName = (string)args[2];
        LCHSkillData  skill    = GetSkill(skillId);
        var           v        = skill.objs;
        int           objCount = v.Length;
        int           id       = 0;
        List <object> _list    = new List <object>();

        for (int i = 0; i < objCount; i++)
        {
            int _id = v[i].id;
            if (id <= _id)
            {
                id = _id + 1;
            }
        }
        LCHObjectData eo = new LCHObjectData();

        eo.type = 3;
        eo.id   = id;
        eo.name = "触发器-未命名";
        if (bindName.Length > 0)
        {
            eo.propertys["bind"] = 2;
        }
        else
        {
            eo.propertys["bind"] = 1;
        }

        eo.propertys["objid"]     = objId;
        eo.propertys["bind_name"] = bindName;
        LCHSkillData s = new LCHSkillData();

        skill.objs = ArrayHelper.AddItem <LCHObjectData>(skill.objs, eo);
        SaveSkill(skillId);
    }
コード例 #15
0
ファイル: SkillModule.cs プロジェクト: whisperlin/TA2019
    public void CreateSkill(params object[] arg)
    {
        string id     = arg[0].ToString();
        string roidId = arg[1].ToString();

#if UNITY_EDITOR
        if (this.loader.Exists(id, SkillDataType.SKILL))
        {
            EditorUtility.DisplayDialog("提示", "同id技能已经存在", "确定");
            return;
        }
#endif
        var roid = GetRole(roidId);
        roid.skills = ArrayHelper.AddItem(roid.skills, id);

        LCHSkillData skill = new LCHSkillData();
        skill.id     = id;
        skill.roleId = roidId;
        string json = JsonConvert.SerializeObject(skill);
        loader.SaveFile(id, json, SkillDataType.SKILL);
        SaveRole(roidId);
    }
コード例 #16
0
ファイル: LCHSkill.cs プロジェクト: whisperlin/utils
 public LCHSkill(SkillResourceLoader loader, LCHRoleData r, LCHSkillData s)
 {
     this.loader = loader;
     roleData    = r;
     _skillData  = s;
 }
コード例 #17
0
    void OnGUI()
    {
        var width100 = GUILayout.Width(100f);
        var width150 = GUILayout.Width(150f);
        var width50  = GUILayout.Width(50f);
        var width80  = GUILayout.Width(80f);
        var width30  = GUILayout.Width(30f);

        EditorGUI.BeginDisabledGroup(SkillEditorMainWindow.golbalWindow == null || SkillEditorData.Instance.CurSkillId.Length == 0 || SkillEditorData.Instance.skillsData == null);
        LCHSkillData skill = null;

        if (null == SkillEditorMainWindow.golbalWindow || SkillEditorData.Instance.skillsData == null)
        {
            viewHeight = 600f;
        }
        else
        {
            skill = SkillEditorData.Instance.skillsData.GetSkill(SkillEditorData.Instance.CurSkillId);
            if (null != skill)
            {
                viewHeight = Mathf.Max(600f, ChannelHeight * skill.channels.Count + 100f);
                int c = skill.channels.Count + skill.events.Count;
                curSelectChannel = Mathf.Min(curSelectChannel, c - 1);
                int c1 = skill.channels.Count;
                int c2 = skill.events.Count;
                if (SkillEditorWindow.curSelectChannel >= 0)
                {
                    if (SkillEditorWindow.curSelectChannel < c1)
                    {
                        selectNormalChannel    = skill.channels[SkillEditorWindow.curSelectChannel];
                        selectEvent            = null;
                        selectEventChannel     = null;
                        selNormalKeyFrameIndex = selectNormalChannel.GetKeyframeIndex(SkillEditorWindow.curSelectFrame);
                    }
                    else if (SkillEditorWindow.curSelectChannel < c2 + c1)
                    {
                        selectNormalChannel = null;
                        int index = SkillEditorWindow.curSelectChannel - c1;
                        selectEventChannel = skill.events[index];
                        selectEvent        = selectEventChannel.GetKeyFrame(SkillEditorWindow.curSelectFrame);
                    }
                }
            }
            else
            {
                selectNormalChannel    = null;
                selectEvent            = null;
                selectEventChannel     = null;
                selNormalKeyFrameIndex = -1;
            }
        }
        GUILayout.BeginArea(new Rect(0, 0, position.width, offset.y));
        GUILayout.BeginHorizontal();
        //GUI.SetNextControlName("FocusControl01");
        if (GUILayout.Button("添加", width50))
        {
            Rect buttonRect = new Rect(0f, 0f, 1f, 1f);
            PopupWindow.Show(buttonRect, new MenuDialog());
        }
        ;
        if (GUILayout.Button("删除", width50))
        {
            SkillEditorData.Instance.skillsData.RemoveChannel(skill.id, curSelectChannel);
        }
        GUILayout.Space(20f);
        if (SkillEditorData.Instance.playing)
        {
            if (GUILayout.Button("▍▍", width50))
            {
                SkillEditorData.Instance.playing = false;
            }
        }
        else
        {
            if (GUILayout.Button("▶", width50))
            {
                if (SkillEditorData.Instance.curTime == maxLength)
                {
                    SkillEditorData.Instance.curTime = 0f;
                }
                SkillEditorData.Instance.playing = true;
            }
        }
        if (GUILayout.Button("■", width50))
        {
            SkillEditorData.Instance.curTime = 0f;
            SkillEditorData.Instance.playing = false;
        }
        GUILayout.Space(50f);
        showCollider = EditorGUILayout.ToggleLeft("显示碰撞体", showCollider);
        GUILayout.Label("AI自动攻击范围", width100);
        if (null != skill)
        {
            skillRange = skill.skillRange = EditorGUILayout.Slider(skill.skillRange, 0f, 20f, width150);
        }
        else
        {
            EditorGUILayout.Slider(1f, 0f, 20f, width150);
        }
        GUILayout.Label("技能宽度", width100);
        if (null != skill)
        {
            skillWidth = skill.skillWidth = EditorGUILayout.Slider(skill.skillWidth, 0f, 20f, width150);
        }
        else
        {
            EditorGUILayout.Slider(1f, 0f, 20f, width150);
        }

        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Label("技能长度", width100);

        if (null != skill)
        {
            maxLength = skill.maxLength = EditorGUILayout.Slider(skill.maxLength, 0f, 10f);
        }
        else
        {
            maxLength = EditorGUILayout.Slider(maxLength, 0f, 5f, width150);
        }

        GUILayout.Label("工具条缩放", width50);
        scale = EditorGUILayout.Slider(scale, 0.2f, 2f, width150);

        GUILayout.Space(30f);
        EditorGUI.BeginDisabledGroup(null == skill);
        GUI.SetNextControlName("FocusControl01");
        if (GUILayout.Button("+", width30))
        {
            if (null != skill)
            {
                SkillEditorData.Instance.skillsData.AddKeyFrame(skill.id, curSelectChannel, curSelectFrame);
            }
        }
        if (GUILayout.Button("-", width30))
        {
            if (null != skill)
            {
                SkillEditorData.Instance.skillsData.RemoveKeyFrame(skill.id, curSelectChannel, curSelectFrame);
            }
        }

        if (GUILayout.Button("c", width30))
        {
            if (null != skill)
            {
                SkillEditorData.Instance.skillsData.CopyKeyFrame(skill.id, curSelectChannel, curSelectFrame);
            }
        }
        EditorGUI.EndDisabledGroup();

        GUILayout.Label("关键帧值:", width80);

        if (selectNormalChannel != null && selNormalKeyFrameIndex >= selectNormalChannel.values.Count)
        {
            selNormalKeyFrameIndex = selectNormalChannel.values.Count - 1;
        }
        if (selectNormalChannel == null || selNormalKeyFrameIndex == -1)
        {
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.FloatField(0f, width80);
            EditorGUI.EndDisabledGroup();
        }
        else
        {
            selectNormalChannel.values[selNormalKeyFrameIndex] = EditorGUILayout.FloatField(selectNormalChannel.values[selNormalKeyFrameIndex], width80);
        }
        GUILayout.Label("自动更新:", width80);
        autoUpdateKeyFrame = EditorGUILayout.Toggle(autoUpdateKeyFrame);


        GUILayout.Label("");
        GUILayout.EndHorizontal();
        SpeceLine();
        GUILayout.EndArea();
        float delta = 20f * scale;
        float width = maxLength * 10f * delta + 2f;

        scrollViewRect = new Rect(0, offset.y, position.width, position.height - offset.y);
        Rect scrollAreaRect = new Rect(0, 0, offset.x + width, viewHeight);

        scrollPosition = GUI.BeginScrollView(scrollViewRect, scrollPosition, scrollAreaRect);
        GUILayout.BeginArea(new Rect(offset.x + scrollPosition.x, 0, width - scrollPosition.x, viewHeight));
        int channelCount      = 0;
        int normalChanelCount = 0;
        int eventCount        = 0;

        List <int> [] times;
        if (skill == null)
        {
            times = new List <int> [0];
        }
        else
        {
            normalChanelCount = skill.channels.Count;
            eventCount        = skill.events.Count;
            channelCount      = normalChanelCount + eventCount;
            times             = new List <int> [channelCount];
            for (int i = 0; i < normalChanelCount; i++)
            {
                times[i] = skill.channels[i].times;
            }
            for (int i = 0; i < eventCount; i++)
            {
                times[i + normalChanelCount] = skill.events[i].times;
            }
        }
        TimeBarHelper.DrawChannels(maxLength, delta, fps, ChannelHeight, new Vector2(-scrollPosition.x, scrollPosition.y), SkillEditorData.Instance.curTime, channelCount, curSelectChannel, normalChanelCount);
        TimeBarHelper.DrawKeyFrames(maxLength, delta, fps, ChannelHeight, new Vector2(-scrollPosition.x, scrollPosition.y), curSelectChannel, curSelectFrame, times, normalChanelCount);
        TimeBarHelper.DrawTimeBar(maxLength, delta, fps, ChannelHeight, viewHeight, new Vector2(-scrollPosition.x, scrollPosition.y), SkillEditorData.Instance.curTime);
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(scrollPosition.x, 0, offset.x, viewHeight));

        if (skill == null)
        {
            ArrayHelper.ResizeArray <string>(ref channelNames, 0);
        }
        else
        {
            int c0 = skill.channels.Count;
            int c1 = skill.events.Count;
            ArrayHelper.ResizeArray <string>(ref channelNames, c0 + c1);
            for (int i = 0; i < c0; i++)
            {
                var c = skill.channels[i];
                channelNames[i] = skill.GetObjectName(c.objId) + c.GetTypeName();
            }
            for (int i = 0; i < c1; i++)
            {
                var c = skill.events[i];
                channelNames[i + c0] = skill.GetObjectName(c.objId) + c.GetTypeName();
            }
        }
        TimeBarHelper.DrawHeater(offset.x, ChannelHeight, new Vector2(-scrollPosition.x, scrollPosition.y), SkillEditorData.Instance.curTime, curSelectChannel, channelNames, normalChanelCount);
        Handles.color = Color.gray;
        Handles.DrawLine(new Vector2(offset.x - 1, 0), new Vector2(offset.x - 1, viewHeight));
        GUILayout.EndArea();
        GUI.EndScrollView();

        if (scrollViewRect.Contains(Event.current.mousePosition))
        {
            Vector2 pos = Event.current.mousePosition + scrollPosition - offset;
            if (Event.current.mousePosition.x >= offset.x)
            {
                OnKeyFrameAreaEvent(pos);
            }
            if (Event.current.type == EventType.MouseUp)
            {
                dragging = false;
            }
        }
        EditorGUI.EndDisabledGroup();
    }
コード例 #18
0
    public override IEnumerator onInit(LChatacterRecourceInterface loader, LCharacterInterface character, AddCoroutineFun fun)
    {
        hasLoaded = false;
        CharactorLoadHandle handle0 = loader.LoadSkillDataFile(SkillId, fun);

        while (!handle0.isFinish)
        {
            yield return(null);
        }
        skillData = (LCHSkillData)handle0.asset;

        role.type  = 1;
        role.objId = -1;

        character.UpdateSkillRange(cdName, skillData.skillRange, skillData.skillWidth);
        //
        objs[role.objId] = role;
        objList          = new ObjectContain[skillData.objs.Length];
        for (int i = 0, l = skillData.objs.Length; i < l; i++)
        {
            var           o  = skillData.objs[i];
            ObjectContain oc = new ObjectContain();
            oc.SetInformation(o);
            objs[o.id] = oc;
            objList[i] = oc;
            if (o.id == -1)//不加载主模型。
            {
                continue;
            }
            else if (o.type == 1)//对象(特效,模型...)。
            {
                //Debug.LogError("load " + oc.mod);
                var handle = loader.loadResource(oc.mod_name, oc.mod, fun);
                while (!handle.isFinish)
                {
                    yield return(1);
                }
                if (null != handle.asset)
                {
                    if (handle.asset == null)
                    {
                        Debug.LogError("找不到资源,是否没打包 ? " + oc.mod);
                    }
                    else
                    {
                        oc.baseGameObject = (GameObject)handle.asset;
                        if (null != oc.baseGameObject)
                        {
                            oc.gameobject = GameObject.Instantiate(oc.baseGameObject);
                            oc.gameobject.SetActive(false);
                            oc.gameobject.name      = o.name;
                            oc.gameobject.hideFlags = HideFlags.None;
                            oc.systems = oc.gameobject.GetComponentsInChildren <ParticleSystem>();
                        }
                    }
                }
            }
            else if (o.type == 2)//(碰撞体)。
            {
                GameObject g = new GameObject();
                g.layer = character.GetAttackLayer();
                g.SetActive(false);
                g.AddComponent <BoxCollider>();
                g.hideFlags   = HideFlags.DontSave;
                oc.gameobject = g;
                g.name        = o.name;
            }
            else if (o.type == 3)//模型本身碰撞体。暂不连接。
            {
                continue;
            }
            else if (o.type == 4)//加载声音
            {
                GameObject g = new GameObject();
                g.name        = o.name;
                oc.gameobject = g;
                loader.loadResource(oc.mod_name, oc.mod, fun);
            }
        }
        for (int i = 0, c0 = skillData.events.Count; i < c0; i++)
        {
            var _e      = skillData.events[i];
            var contain = objs[_e.objId];
            contain.events.Add(_e);
        }

        for (int i = 0, c0 = skillData.channels.Count; i < c0; i++)
        {
            var _c      = skillData.channels[i];
            var contain = objs[_c.objId];
            contain.channels.Add(_c);
        }

        hasLoaded = true;
    }
コード例 #19
0
    public override void OnGUI(Rect rect)
    {
        spos = EditorGUILayout.BeginScrollView(spos);
        if (null == SkillEditorMainWindow.golbalWindow)
        {
            editorWindow.Close();
            return;
        }
        if (SkillEditorData.Instance.CurSkillId.Length == 0)
        {
            editorWindow.Close();
            return;
        }
        LCHSkillData skill = SkillEditorData.Instance.skillsData.GetSkill(SkillEditorData.Instance.CurSkillId);

        if (null == skill)
        {
            editorWindow.Close();
            return;
        }
        int objLen = skill.subSkills[SkillEditorData.Instance.subSkillIndex].objs.Length;

        var layout100 = GUILayout.Width(100);

        GUILayout.Label("添加轨迹类型", EditorStyles.boldLabel);
        state["rolebase"] = EditorGUILayout.Foldout(getState("rolebase"), "(-1)角色");
        if (state["rolebase"])
        {
            OnGUITramsformItem(-1);
            OnGUIObjectStateItem(-1);

            OnGUIRoleStateStateItem(-1);
        }

        for (int i = 0; i < skill.subSkills[SkillEditorData.Instance.subSkillIndex].objs.Length; i++)
        {
            var _o = skill.subSkills[SkillEditorData.Instance.subSkillIndex].objs[i];

            string name = "未知";
            if (_o.type == 4)
            {
                continue;
            }
            else if (_o.type == 1)
            {
                name = "(" + _o.id + ")" + _o.name + " 对象";
            }
            else if (_o.type == 2 || _o.type == 3)
            {
                name = "(" + _o.id + ")" + _o.name + " 触发器";
            }
            string key = "name" + _o.id;
            state[key] = EditorGUILayout.Foldout(getState(key), name);
            if (state[key])
            {
                if (_o.type < 3)
                {
                    OnGUITramsformItem(_o.id);
                }
                if (_o.type == 2 || _o.type == 3)
                {
                    OnGUIEventItem(_o.id);
                }
                else
                {
                    OnGUIObjectStateItem(_o.id);
                }
            }
        }



        EditorGUILayout.EndScrollView();
    }
コード例 #20
0
    public void OnGUI1()
    {
        var   layourWidth30  = GUILayout.Width(30f);
        var   layourWidth80  = GUILayout.Width(80f);
        var   layourWidth20  = GUILayout.Width(20f);
        var   layourWidth100 = GUILayout.Width(100f);
        var   layourWidth200 = GUILayout.Width(200f);
        Color selectColor    = new Color(0.4f, 0.4f, 1.0f);

        if (null == roleData)
        {
            return;
        }

        if (SkillEditorData.Instance.CurSkillId.Length == 0)
        {
            return;
        }
        LCHSkillData skill = null;

        if (SkillEditorData.Instance.CurSkillId.Length > 0)
        {
            skill = SkillEditorData.Instance.skillsData.GetSkill(SkillEditorData.Instance.CurSkillId);
        }
        if (null == skill)
        {
            return;
        }
        var buttonRect = EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("添加对象", layourWidth80))
        {
            SkillEditorData.Instance.skillsData.SkillAddObject(SkillEditorData.Instance.CurSkillId);
        }
        if (GUILayout.Button("添加碰撞体", layourWidth80))
        {
            SkillEditorData.Instance.skillsData.SkillAddBoxCollider(SkillEditorData.Instance.CurSkillId);
        }

        EditorGUI.BeginDisabledGroup(null == anim);
        if (GUILayout.Button("原碰撞体", layourWidth80))
        {
            PopupWindow.Show(buttonRect, ColliderDialog.Show(anim.transform, OnColliderAdd, SkillEditorData.Instance.CurSkillId));
        }
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("音效", layourWidth80))
        {
            SkillEditorData.Instance.skillsData.SkillAddSound(SkillEditorData.Instance.CurSkillId);
        }


        EditorGUILayout.EndHorizontal();
        GUILayout.Label("对象列表:");

        scrollViewPos3 = GUILayout.BeginScrollView(scrollViewPos3, GUILayout.Height(120));

        {
            var rect = EditorGUILayout.BeginHorizontal();

            bool b0 = selectObjId == -1;
            if (b0)
            {
                EditorGUI.DrawRect(rect, selectColor);
            }
            if (EditorGUILayout.Toggle("", b0, layourWidth20))
            {
                selectObjId = -1;
            }

            EditorGUI.BeginDisabledGroup(true);
            GUILayout.TextField("角色", layourWidth80);
            EditorGUILayout.ObjectField(anim, typeof(Animation), false);
            GUILayout.Button("-", layourWidth30);
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();
        }

        if (skill != null)
        {
            for (int i = 0; i < skill.objs.Length; i++)
            {
                LCHObjectData obj  = skill.objs[i];
                var           rect = EditorGUILayout.BeginHorizontal();
                bool          b0   = selectObjId == obj.id;
                if (b0)
                {
                    EditorGUI.DrawRect(rect, selectColor);
                }
                if (EditorGUILayout.Toggle("", b0, layourWidth20))
                {
                    selectObjId = obj.id;
                }
                obj.name = GUILayout.TextField(obj.name, layourWidth80);

                if (obj.type == 1)
                {
                    UpdateGameObject(obj);
                }
                else if (obj.type == 2 || obj.type == 3)
                {
                    EditorGUI.BeginDisabledGroup(true);
                    GUILayout.TextField("触发器");
                    EditorGUI.EndDisabledGroup();
                }
                else if (obj.type == 4)
                {
                    UpdateSound(obj);
                }
                if (GUILayout.Button("-", layourWidth30))
                {
                    if (selectObjId == obj.id)
                    {
                        selectObjId = -1;
                    }
                    SkillEditorData.Instance.skillsData.RemoveObject(skill.id, obj.id);
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        GUILayout.EndScrollView();
        SpeceLine();
        GUILayout.Label("属性列表:");

        scrollViewPos4 = GUILayout.BeginScrollView(scrollViewPos4, GUILayout.Height(200));
        LCHObjectData selectObject = null;

        if (selectObjId > -1)
        {
            selectObject = skill.GetObject(selectObjId);
            if (selectObject.type == 3)
            {
                var rect = EditorGUILayout.BeginHorizontal();
                //EditorGUI.BeginDisabledGroup(selectObject.type == 3);
                //selectObject.type
                GUILayout.Label("绑定对象", GUILayout.Width(80f));
                int bind0 = selectObject.propertys.GetValueInt("bind", 0);
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextField(selectObject.propertys.GetValue <string>("bind_name", ""));
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();
            }
            if (selectObject.type != 4)
            {
                var rect = EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginDisabledGroup(selectObject.type == 3);
                //selectObject.type
                GUILayout.Label("绑定方式", GUILayout.Width(80f));
                int bind0 = selectObject.propertys.GetValueInt("bind", 0);
                int bind  = EditorGUILayout.Popup(bind0, bindingStr, GUILayout.Width(100f));
                selectObject.propertys["bind"] = bind;
                if (bind == 2)
                {
                    selectObject.propertys["bind_name"] = EditorGUILayout.TextField(selectObject.propertys.GetValue <string>("bind_name", ""));
                    if (GUILayout.Button(".."))
                    {
                        PopupWindow.Show(rect, ChildsNameDialog.Show(OnBindNameCallBack, selectObject.propertys));
                    }
                }
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();
            }
        }
        GUILayout.EndScrollView();
        SpeceLine();
        GUILayout.Label("事件属性:");
        GUILayout.BeginHorizontal();
        //1
        Dictionary <string, object> property_params = new Dictionary <string, object>();

        scrollViewPos5 = GUILayout.BeginScrollView(scrollViewPos5, GUILayout.Height(200));
        if (skill != null)
        {
            if (null != SkillEditorWindow.selectEvent && null != SkillEditorWindow.selectEventChannel)
            {
                int objId   = SkillEditorWindow.selectEventChannel.objId;
                var _object = skill.GetObject(objId);

                LCHChannelType _type = (LCHChannelType)SkillEditorWindow.selectEventChannel.type;
                if (_type == LCHChannelType.Event)
                {
                    GUILayout.BeginHorizontal();//2
                    PropertyHelper.DrawPropertyTips("激活状态");
                    bool eEnable = EditorGUILayout.Toggle(SkillEditorWindow.selectEvent.GetValue <bool>("enable", true));
                    SkillEditorWindow.selectEvent["enable"] = eEnable;
                    GUILayout.EndHorizontal();//2
                    string[]  sounds      = ArrayHelper.emptyStringList;
                    int[]     soundIds    = ArrayHelper.emptyIntList;
                    string [] objectNames = ArrayHelper.emptyStringList;
                    int[]     objectid    = ArrayHelper.emptyIntList;
                    if (null != SkillEditorData.Instance.skill)
                    {
                        SkillEditorData.Instance.skill.GetAllObjectList(objId, ref sounds, ref soundIds, ref objectNames, ref objectid);
                    }
                    if (eEnable)
                    {
                        property_params["sounds"]      = sounds;
                        property_params["soundIds"]    = soundIds;
                        property_params["objectNames"] = objectNames;
                        property_params["objectid"]    = objectid;
                        PropertyHelper.DrawPropertys(SkillEditorWindow.selectEvent, SkillEditorData.Instance.skillsData.GetEventTemp(), SkillEditorData.Instance.skillsData.GetEventNames(), property_params);
                    }
                }
                else if (_type == LCHChannelType.Object)
                {
                    string [] anims = ArrayHelper.emptyStringList;

                    if (null != SkillEditorData.Instance.skill)
                    {
                        anims = SkillEditorData.Instance.skill.GetAnimList(objId);
                    }

                    property_params["anims"] = anims;
                    PropertyHelper.DrawPropertys(SkillEditorWindow.selectEvent, SkillEditorData.Instance.skillsData.GetObjecctTemp(), SkillEditorData.Instance.skillsData.GetObjectNames(), property_params);
                }
                else if (_type == LCHChannelType.RoleState)
                {
                    string[] anims = ArrayHelper.emptyStringList;

                    if (null != SkillEditorData.Instance.skill)
                    {
                        anims = SkillEditorData.Instance.skill.GetAnimList(objId);
                    }

                    PropertyHelper.DrawPropertys(SkillEditorWindow.selectEvent, SkillEditorData.Instance.skillsData.GetRoleStateTemp(), SkillEditorData.Instance.skillsData.GetRoleStateNames(), null);
                }
            }
        }
        GUILayout.EndScrollView();
        GUILayout.EndHorizontal();//1
    }