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); }
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); }
void OnKeyFrameAreaEvent(Vector2 pos) { if (Event.current.button == 1) { if (Event.current.type == EventType.MouseDown) { UpdateTime(pos.x, false); dragging = true; if (Event.current.control) { UpdateCurFramePos(pos); } } if (Event.current.type == EventType.MouseDrag) { UpdateTime(pos.x, false); } curSelectChannel = -1; curSelectFrame = -1; selectNormalChannel = null; selectEventChannel = null; GUI.FocusControl("FocusControl01"); } if (Event.current.button == 0) { if (Event.current.type == EventType.MouseDown) { UpdateCurFramePos(pos); UpdateTime(pos.x, true); GUI.FocusControl("FocusControl01"); } if (Event.current.type == EventType.MouseDrag) { if (TryDragFramePos(pos)) { UpdateTime(pos.x, true); } } } }
public void CmpObjectEvent(float curTime, float lastTime, LCHEventChannelData _e, ObjectContain contain, LCharacterInterface character, LChatacterInformationInterface information, Dictionary <int, ObjectContain> objs , CdState cdState , string cdName , int skillState , Vector3 baseGroundPos , ref float beginToTarget , ref float endToTarget , ref Vector3 beginTargetPoint ) { if (contain.isFlyTool) { if (null != contain.gameobject) { contain.gameobject.SetActive(false); } return; } LCHChannelType t = (LCHChannelType)_e.type; ObjDictionary value; float _time; float _keyFrameTime; if (t == LCHChannelType.Object) { int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time, out _keyFrameTime); if (res == 1) { if (null != contain.gameobject) { bool enable = value.GetValue <bool>("enable", true); if (_e.objId == -1) { //因為主對象直接設置 gameObject的Enable,所有腳本都不工作了. if (null != contain.roleRenders) { for (int n = 0; n < contain.roleRenders.Length; n++) { contain.roleRenders[n].enabled = enable; } } } else { if (enable) { contain.gameobject.SetActive(false); contain.gameobject.SetActive(true); } else { contain.gameobject.SetActive(enable); } } if (enable) { if (contain.type == 1) { string anim_name = value.GetValue <string>("anim", ""); if (anim_name.Length > 0) { if (null == contain.animaction) { contain.animaction = contain.gameobject.GetComponent <Animation>(); } if (null != contain.animaction) { bool cf = value.GetValue <bool>("crossFade", true); //crossFade contain.animaction[anim_name].time = _time; if (cf) { contain.animaction.CrossFade(anim_name, 0.05f); } else { contain.animaction[anim_name].time = 0f;//特么不这么干不重置。。。 contain.animaction.Play(anim_name); } } } int ex_action = value.GetValueInt("ex_action", 0); if (ex_action == 1) { //主模型. if (_e.objId == -1) { float ToTargetTime = value.GetValueFloat("ex_action", -1f); if (ToTargetTime > 0f) { beginToTarget = _keyFrameTime; endToTarget = _keyFrameTime + ToTargetTime; beginTargetPoint = baseGroundPos; } } } // else if (ex_action == 2) { contain.stopUpatePos = true; } } } } } else if (res == 0) { if (_e.objId != -1)//非主模型,一开始隐藏 { if (null != contain.gameobject) { if (contain.objId != -1) { contain.gameobject.SetActive(false); } } } } } if (t == LCHChannelType.Event) { int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time, out _keyFrameTime); if (res == 1) { if (contain.type == 2 || contain.type == 3) { if (null == contain.collider) { if (null != contain.gameobject) { contain.collider = contain.gameobject.GetComponent <Collider>(); contain.gameobject.layer = character.GetAttackLayer(); if (null != contain.collider) { contain.collider.isTrigger = true; } } } } if (null != contain.gameobject) { bool enable = value.GetValue <bool>("enable", true); contain.gameobject.SetActive(enable); if (contain.collider) { contain.collider.enabled = enable; if (enable) { if (null == contain.hitData) { LCharacterHitDataCmp hdc = contain.gameobject.GetComponent <LCharacterHitDataCmp>(); if (null == hdc) { hdc = contain.gameobject.AddComponent <LCharacterHitDataCmp>(); } contain.hitData = hdc.data; } contain.hitData.type = "hit"; LCharacterHitData hitData = new LCharacterHitData(); hitData.hittedObject.Clear(); hitData.value = value; hitData.characterId = character.GetId(); hitData.firstHit = true; hitData.cdName = cdName; hitData.skillState = skillState; hitData.cdState = cdState; int effectId = value.GetValueInt("hit_effect", -2); if (effectId != -2 && objs.ContainsKey(effectId)) { var ct = objs[effectId]; hitData.effect = ct.mod; hitData.effect_obj = ct.baseGameObject; } else { hitData.effect = null; hitData.effect_obj = null; } contain.hitData.data = hitData; int IsFlyTool = value.GetValueInt("IsFlyTool", 0); if (IsFlyTool == 1) { if (contain.type == 3) { float FlyToolTime = value.GetValueFloat("FlyToolTime", 20f); float FlyToolSpeed = value.GetValueFloat("FlyToolSpeed", 2f); if (null != contain.gameobject) { var g = GameObject.Instantiate(contain.gameobject); LCharacterHitDataCmp hdc0 = g.GetComponent <LCharacterHitDataCmp>(); g.name = "bullet"; LCHBullet bullet = g.AddComponent <LCHBullet>(); hdc0.data.data = hitData; hdc0.data.type = "hit"; contain.isFlyTool = true; bullet.type = LCHBullet.TYPE.NORMAL; bullet.speed = FlyToolSpeed; bullet.maxTime = FlyToolTime; g.SetActive(true); contain.gameobject.SetActive(false); } } } else if (IsFlyTool == 2) { if (contain.type == 3) { //float FlyToolTime = value.GetValueFloat("FlyToolTime", 20f); float FlyToolSpeed = value.GetValueFloat("FlyToolSpeed", 2f); if (null != contain.gameobject) { var g = GameObject.Instantiate(contain.gameobject); LCharacterHitDataCmp hdc0 = g.GetComponent <LCharacterHitDataCmp>(); g.name = "bullet"; LCHBullet bullet = g.AddComponent <LCHBullet>(); hdc0.data.data = hitData; hdc0.data.type = "hit"; contain.isFlyTool = true; bullet.type = LCHBullet.TYPE.FELLOW; bullet.speed = FlyToolSpeed; bullet.curTargetId = curTargetId; bullet.maxTime = 60f; g.SetActive(true); contain.gameobject.SetActive(false); } } } } } } } else if (res == 0) { if (null != contain.gameobject) { contain.gameobject.SetActive(false); } } } }
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(); }
public static void CmpObjectEvent(float curTime, float lastTime, LCHEventChannelData _e, ObjectContain contain, LChatacterInterface character, LChatacterInformationInterface information, Dictionary <int, ObjectContain> objs , CdState cdState , string cdName , int skillState ) { LCHChannelType t = (LCHChannelType)_e.type; ObjDictionary value; float _time; if (t == LCHChannelType.Object) { int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time); if (res == 1) { if (null != contain.gameobject) { bool enable = value.GetValue <bool>("enable", true); if (_e.objId == -1) { //因為主對象直接設置 gameObject的Enable,所有腳本都不工作了. if (null != contain.roleRenders) { for (int n = 0; n < contain.roleRenders.Length; n++) { contain.roleRenders[n].enabled = enable; } } } else { if (enable) { contain.gameobject.SetActive(false); contain.gameobject.SetActive(true); /*contain.gameobject.SetActive(enable); * for (int i = 0, l = contain.systems.Length; i < l; i++) * { * //Debug.Log(contain.systems[i].isStopped); * contain.systems[i].gameObject.SetActive(false); * contain.systems[i].gameObject.SetActive(true); * contain.systems[i].Play(true); * }*/ } else { contain.gameobject.SetActive(enable); } //Debug.LogError("_e.objId " + _e.objId + " " + enable); //contain.gameobject.SetActive(enable); } if (enable) { if (contain.type == 1) { string anim_name = value.GetValue <string>("anim", ""); if (anim_name.Length > 0) { if (null == contain.animaction) { contain.animaction = contain.gameobject.GetComponent <Animation>(); } if (null != contain.animaction) { bool cf = value.GetValue <bool>("crossFade", true); //crossFade contain.animaction[anim_name].time = _time; if (cf) { contain.animaction.CrossFade(anim_name, 0.05f); } else { contain.animaction[anim_name].time = 0f;//特么受击不这么干不重置。。。 contain.animaction.Play(anim_name); } } } } } } } else if (res == 0) { if (_e.objId != -1)//非主模型,一开始隐藏 { if (null != contain.gameobject) { if (contain.objId != -1) { contain.gameobject.SetActive(false); } } } } } if (t == LCHChannelType.Event) { int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time); if (res == 1) { if (contain.type == 2 || contain.type == 3) { if (null == contain.collider) { if (null != contain.gameobject) { contain.collider = contain.gameobject.GetComponent <Collider>(); contain.gameobject.layer = character.GetAttackLayer(); if (null != contain.collider) { contain.collider.isTrigger = true; } } } } if (null != contain.gameobject) { bool enable = value.GetValue <bool>("enable", true); contain.gameobject.SetActive(enable); if (contain.collider) { contain.collider.enabled = enable; if (enable) { if (null == contain.hitData) { LCharacterHitDataCmp hdc = contain.gameobject.GetComponent <LCharacterHitDataCmp>(); if (null == hdc) { hdc = contain.gameobject.AddComponent <LCharacterHitDataCmp>(); } contain.hitData = hdc.data; } contain.hitData.type = "hit"; LCharacterHitData hitData = new LCharacterHitData(); hitData.hittedObject.Clear(); hitData.value = value; hitData.characterId = character.GetId(); hitData.firstHit = true; hitData.cdName = cdName; hitData.skillState = skillState; hitData.cdState = cdState; int effectId = value.GetValueInt("hit_effect", -2); if (effectId != -2 && objs.ContainsKey(effectId)) { var ct = objs[effectId]; hitData.effect = ct.mod; hitData.effect_obj = ct.baseGameObject; } else { hitData.effect = null; hitData.effect_obj = null; } contain.hitData.data = hitData; } } } } else if (res == 0) { if (null != contain.gameobject) { contain.gameobject.SetActive(false); } } } }