void TriggerEvent(AIClipEvent clipEvent) { if (clipEvent is SetVelocityEvent) { SetVelocityEvent velocityEvent = clipEvent as SetVelocityEvent; mOwner.SetExtrenalVelocity(velocityEvent.velocity); } else if (clipEvent is ShowEffectEvent) { ShowEffectEvent effectEvent = clipEvent as ShowEffectEvent; Object obj = Resources.Load(effectEvent.effectName); if (obj) { Vector3 pos = mOwner.transform.TransformPoint(effectEvent.startPosition); Object.Instantiate(obj, pos, Quaternion.identity); } } else if (clipEvent is AiActionEvent) { ConductAIAction(clipEvent as AiActionEvent); } else { Debug.LogError("未实现的事件类型" + clipEvent); } }
public static void OpenAsEditMode(AIClipEvent clipEvent) { AIEventEditWnd wnd = EditorWindow.GetWindow <AIEventEditWnd>(); wnd.OpenAsCreateMode(); wnd.mCurEvet = clipEvent; }
public void Update() { for (int i = 0; i < eventList.Count; i++) { AIClipEvent clipEvent = eventList[i]; if (mOwner.CurClipTime > clipEvent.triggerTime) { TriggerEvent(clipEvent); eventList.Remove(clipEvent); } } }
public static void SelectAIClip(AIClip aiClip) { if (selectedAiClip != aiClip) { selectedAiClip = aiClip; //要保证选择AI片断后自动选择这个片断所在的AI组 selecteClipGroup = FindOwnerClipGroup(aiClip); mSelectedLink = null; selectedHitData = null; aiEvent = null; } }
void CreateEvent(AIClipEvent clipEvent) { if (onCreate != null) { onCreate(clipEvent); //初始名为赋值为类型名 clipEvent.eventName = clipEvent.ToString(); mCurEvet = clipEvent; onCreate = null; } else { Debug.LogError("没有创建回调"); } }
void TriggerEvent(AIClipEvent clipEvent) { if (clipEvent is SetVelocityEvent) { SetVelocityEvent velocityEvent = clipEvent as SetVelocityEvent; mOwner.SetExtrenalVelocity(velocityEvent.velocity); }else if (clipEvent is ShowEffectEvent) { ShowEffectEvent effectEvent = clipEvent as ShowEffectEvent; Object obj= Resources.Load(effectEvent.effectName); if (obj) { Vector3 pos = mOwner.transform.TransformPoint(effectEvent.startPosition); Object.Instantiate(obj, pos, Quaternion.identity); } }else if (clipEvent is AiActionEvent) { ConductAIAction(clipEvent as AiActionEvent); } else { Debug.LogError("未实现的事件类型"+clipEvent); } }
public static void SelectedAIEvent(AIClipEvent clipEvent) { aiEvent = clipEvent; }
public void OpenAsCreateMode() { mCurEvet = null; }
public static void OpenAsEditMode(AIClipEvent clipEvent) { AIEventEditWnd wnd = EditorWindow.GetWindow<AIEventEditWnd>(); wnd.OpenAsCreateMode(); wnd.mCurEvet = clipEvent; }
/// <summary> /// 绘制片断时间列表 /// </summary> /// <param name="clip"></param> public static void DrawAiEvetList(AIClip clip) { GUILayout.BeginHorizontal(); GUILayout.Label("事件列表", GUILayout.Width(60)); #region copy and paste icons if (GUILayout.Button(AIFGUISKin.IconCopy, GUILayout.Width(30), GUILayout.Height(30))) { if (AIDataSelection.aiEvent != null) { CustomClipBoard.CopyData(AIDataSelection.aiEvent); } } if (GUILayout.Button(AIFGUISKin.IconPaste, GUILayout.Width(30), GUILayout.Height(30))) { object clipBoardObj; CustomClipBoard.GetCopyObject(out clipBoardObj); if (clipBoardObj == null) { Debug.LogError("剪切板没有内容可以粘贴"); } else { clipBoardObj = Utility.XmlDeepCloneObject(clipBoardObj); if (clipBoardObj is AIClipEvent) { clip.AiClipEvents.Add(clipBoardObj as AIClipEvent); } } } #endregion if (GUILayout.Button(AIFGUISKin.IconNewItem, GUILayout.Width(30), GUILayout.Height(30))) { AIEventEditWnd.OpenCreateEditor(delegate(AIClipEvent e) { clip.AiClipEvents.Add(e); }); } GUILayout.EndHorizontal(); if (clip.AiClipEvents.Count == 0) { GUILayout.Label("事件列表为空"); } else { for (int i = 0; i < clip.AiClipEvents.Count; i++) { AIClipEvent evet = clip.AiClipEvents[i]; GUILayout.BeginHorizontal(); Color col = AIDataSelection.aiEvent == evet ? Color.green : GUI.color; if (AIFUIUtility.LayoutButtonWithColor(evet.eventName, col, 150)) { AIDataSelection.SelectedAIEvent(evet); AIEventEditWnd.OpenAsEditMode(evet); } if (GUILayout.Button("X", GUILayout.Width(30))) { if (EditorUtility.DisplayDialog("警告", "确定删除事件吗", "确定", "取消")) { clip.AiClipEvents.Remove(evet); return; } } GUILayout.EndHorizontal(); } } }