public void ReadJson(Dictionary <string, object> _jsonObj) { if (_jsonObj.ContainsKey("mTotalTime")) { mTotalTime = int.Parse(_jsonObj["mTotalTime"].ToString()); } mEvents.Clear(); if (_jsonObj.ContainsKey("mEvents")) { List <object> lst = _jsonObj["mEvents"] as List <object>; if (lst != null) { for (int i = 0; i < lst.Count; i++) { Dictionary <string, object> action_json = lst[i] as Dictionary <string, object>; ActionObject.ActionType actioinType = ActionObject.ActionType.DoNothing; if (action_json.ContainsKey("mActionType")) { actioinType = (ActionObject.ActionType) int.Parse(action_json["mActionType"].ToString()); } ActionEvent ev = ActionFactory.CreateActionEvent(actioinType); if (ev != null) { ev.ReadJson(action_json); } mEvents.Add(ev); } } } }
public virtual void ReadJson(Dictionary <string, object> _data) { if (_data.ContainsKey("mActionType")) { mActionType = (ActionObject.ActionType) int.Parse(_data["mActionType"].ToString()); } if (_data.ContainsKey("mTime")) { mTime = float.Parse(_data["mTime"].ToString()); } }
public static ActionEvent CreateActionEvent(ActionObject.ActionType _actionType) { ActionEvent ae = null; switch (_actionType) { case ActionObject.ActionType.Prefab: ae = new ActionEvent_Prefab(); break; case ActionObject.ActionType.Transform: break; case ActionObject.ActionType.Material: break; case ActionObject.ActionType.Animation: ae = new ActionEvent_Animation(); break; case ActionObject.ActionType.Sound: ae = new ActionEvent_Sound(); break; case ActionObject.ActionType.Camera: ae = new ActionEvent_Camera(); break; case ActionObject.ActionType.WaitTime: break; case ActionObject.ActionType.CharacterControl: ae = new ActionEvent_CharacterControl(); break; case ActionObject.ActionType.Tween: break; case ActionObject.ActionType.LaunchAmmo: break; case ActionObject.ActionType.MoveToPosition: break; } return(ae); }
public void Read(BinaryReader br) { // mName = br.ReadString(); mTotalTime = br.ReadSingle(); int count = br.ReadInt32(); mEvents.Clear(); for (int i = 0; i < count; i++) { ActionObject.ActionType actioinType = (ActionObject.ActionType)br.ReadInt32(); ActionEvent ev = ActionFactory.CreateActionEvent(actioinType); if (ev != null) { ev.SetActionObject(this); ev.Read(br); mEvents.Add(ev); } } }
public void Draw(ActionTable actable) { GUILayout.BeginVertical(); TimeLine(); for (int i = 0; i < mEvents.Count; i++) { float rate = mEvents[i].mTime / mTotalTime; TimeLine(rate, Color.red); } if (mCurrentEvent != null) { float rate = mCurrentEvent.mTime / mTotalTime; TimeLine(rate, Color.blue); } mTotalTimelineBGTex.Apply(); GUILayout.Label(mTotalTimelineBGTex); GUILayout.BeginHorizontal(); GUILayout.Label("============== Action ================="); GUILayout.EndHorizontal(); { GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal(); // this.mName = EditorGUILayout.TextField("Name",this.mName); this.mTotalTime = EditorGUILayout.FloatField("Total Time", this.mTotalTime); mActionEventType = (ActionObject.ActionType)EditorGUILayout.EnumPopup("Event Type", mActionEventType); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Change Event")) { if (mCurrentEventIndex >= 0 && mCurrentEventIndex < mEvents.Count) { ActionEvent ev = ActionFactory.CreateActionEvent(mActionEventType); if (ev != null) { ev.SetActionObject(this); this.mEvents[mCurrentEventIndex] = ev; this.mCurrentEvent = ev; } } } if (GUILayout.Button("Add Event")) { ActionEvent ev = ActionFactory.CreateActionEvent(mActionEventType); if (ev != null) { ev.SetActionObject(this); mCurrentEvent = ev; mCurrentEventIndex = mEvents.Count; this.mEvents.Add(ev); } } if (GUILayout.Button("Delete Event")) { if (EditorUtility.DisplayDialog("Remove Event", "Are you sure to remove Event?", "Remove", "Cancel")) { if (mCurrentEvent != null) { mEvents.Remove(mCurrentEvent); mCurrentEvent = null; mCurrentEventIndex = -1; } } } GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); } { GUILayout.BeginHorizontal(); for (int i = 0; i < mEvents.Count; i++) { ActionEvent ev = this.mEvents[i]; // ev.Draw(this); if (GUILayout.Button("" + i)) { mCurrentEvent = ev; mCurrentEventIndex = i; } } GUILayout.EndHorizontal(); GUILayout.BeginVertical(); if (mCurrentEvent != null) { GUILayout.Label("============== Event " + mCurrentEventIndex + " ================="); mCurrentEvent.Draw(this); } GUILayout.EndVertical(); } GUILayout.EndVertical(); }