Esempio n. 1
0
 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);
             }
         }
     }
 }
Esempio n. 2
0
    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);
            }
        }
    }
Esempio n. 3
0
    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();
    }