/// <summary>
        /// constructor, takes an actual taskevent and serialize it into its internal structure
        /// called during serialization
        /// </summary>
        public SerializableTaskEvent(TaskEvent taskEvent)
        {
            if (taskEvent != null)
            {
                TypeName = taskEvent.GetType().Name;
                switch (TypeName)
                {
                case "TransformTaskEvent":
                {
                    TransformTaskEvent castedEvent = taskEvent as TransformTaskEvent;
                    StartPos      = castedEvent.StartPos;
                    EndPos        = castedEvent.EndPos;
                    StartRotation = castedEvent.StartRotation;
                    EndRotation   = castedEvent.EndRotation;
                    Duration      = castedEvent.Duration;
                } break;

                case "AnimationTaskEvent":
                {
                    AnimationTaskEvent castedEvent = taskEvent as AnimationTaskEvent;
                    GameObject          = castedEvent.GameObject;
                    AnimatorParam       = castedEvent.AnimatorParam;
                    AnimatorParamValue  = castedEvent.AnimatorParamValue;
                    ModifyAnimatorParam = castedEvent.ModifyAnimatorParam;
                    AnimatorLayer       = castedEvent.AnimatorLayer;
                    AnimatorLayerAmount = castedEvent.AnimatorLayerAmount;
                    ModifyAnimatorLayer = castedEvent.ModifyAnimatorLayer;
                }
                break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// constructor taking a serializable task
        /// </summary>
        public Task(TaskList tl, SerializableTask task)
        {
            TaskDelay   = task.TaskDelay;
            TaskList    = tl;
            GameObject  = task.GameObject;
            TaskName    = task.TaskName;
            Description = task.Description;
            GOName      = task.GOName;

            foreach (var taskEvent in task.TaskEvents)
            {
                switch (taskEvent.TypeName)
                {
                case "TransformTaskEvent":
                {
                    TaskEvent newTaskEvent = new TransformTaskEvent(taskEvent);
                    newTaskEvent.Task = this;
                    this.TaskEvents.Add(newTaskEvent);
                }
                break;

                case "AnimationTaskEvent":
                {
                    TaskEvent newTaskEvent = new AnimationTaskEvent(taskEvent);
                    newTaskEvent.Task = this;
                    this.TaskEvents.Add(newTaskEvent);
                }
                break;
                }
            }
        }
        /// <summary>
        /// constructor taking a serializable task
        /// </summary>
        public Task(TaskList tl, SerializableTask task)
        {
            TaskList    = tl;
            GameObject  = task.GameObject;
            TaskName    = task.TaskName;
            Description = task.Description;
            GOName      = task.GOName;

            SerializableTaskEvent ste = task.TaskEvent;

            if (ste != null)
            {
                switch (ste.TypeName)
                {
                case "TransformTaskEvent":
                {
                    TaskEvent = new TransformTaskEvent(ste);
                }
                break;
                }

                if (TaskEvent != null)
                {
                    TaskEvent.Task = this;
                }
            }
        }
 /// <summary>
 /// constructor, takes an actual taskevent and serialize it into its internal structure
 /// called during serialization
 /// </summary>
 public SerializableTaskEvent(TaskEvent taskEvent)
 {
     if (taskEvent != null)
     {
         TypeName = taskEvent.GetType().Name;
         switch (TypeName)
         {
         case "TransformTaskEvent":
         {
             TransformTaskEvent castedEvent = taskEvent as TransformTaskEvent;
             StartPos      = castedEvent.StartPos;
             EndPos        = castedEvent.EndPos;
             StartRotation = castedEvent.StartRotation;
             EndRotation   = castedEvent.EndRotation;
         } break;
         }
     }
 }
        /// <summary>
        /// display task event of type transformtaskevent
        /// </summary>
        public void DisplayTransformTaskEventIOfTask(Task t, int index)
        {
            TransformTaskEvent tte = t.TaskEvents[index] as TransformTaskEvent;

            // to modify start and end position
            GUILayout.Label("Start");
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("x: ");
            float x = EditorGUILayout.FloatField(tte.StartPos.x);

            GUILayout.Label("y: ");
            float y = EditorGUILayout.FloatField(tte.StartPos.y);

            GUILayout.Label("z: ");
            float z = EditorGUILayout.FloatField(tte.StartPos.z);

            tte.StartPos = new Vector3(x, y, z);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("i: ");
            float i = EditorGUILayout.FloatField(tte.StartRotation.x);

            GUILayout.Label("j: ");
            float j = EditorGUILayout.FloatField(tte.StartRotation.y);

            GUILayout.Label("k: ");
            float k = EditorGUILayout.FloatField(tte.StartRotation.z);

            GUILayout.Label("w: ");
            float w = EditorGUILayout.FloatField(tte.StartRotation.w);

            tte.StartRotation = new Quaternion(i, j, k, w);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            // easily get the go current position as the goal pos
            if (GUILayout.Button("Use Current GO Position and rotation"))
            {
                if (t.GameObject != null)
                {
                    tte.StartPos      = obj.transform.InverseTransformPoint(t.GameObject.transform.position);
                    tte.StartRotation = Quaternion.Inverse(obj.transform.rotation) * t.GameObject.transform.rotation;
                }
            }

            GUILayout.Label("End");
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("x: ");
            float xend = EditorGUILayout.FloatField(tte.EndPos.x);

            GUILayout.Label("y: ");
            float yend = EditorGUILayout.FloatField(tte.EndPos.y);

            GUILayout.Label("z: ");
            float zend = EditorGUILayout.FloatField(tte.EndPos.z);

            tte.EndPos = new Vector3(xend, yend, zend);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("i: ");
            float endi = EditorGUILayout.FloatField(tte.EndRotation.x);

            GUILayout.Label("j: ");
            float endj = EditorGUILayout.FloatField(tte.EndRotation.y);

            GUILayout.Label("k: ");
            float endk = EditorGUILayout.FloatField(tte.EndRotation.z);

            GUILayout.Label("w: ");
            float endw = EditorGUILayout.FloatField(tte.EndRotation.w);

            tte.EndRotation = new Quaternion(endi, endj, endk, endw);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            // easily get the go current position as the goal pos
            if (GUILayout.Button("Use Current GO Position and rotation"))
            {
                if (t.GameObject != null)
                {
                    tte.EndPos      = obj.transform.InverseTransformPoint(t.GameObject.transform.position);
                    tte.EndRotation = Quaternion.Inverse(obj.transform.rotation) * t.GameObject.transform.rotation;
                }
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Duration ");
            tte.Duration = EditorGUILayout.FloatField(tte.Duration);
            GUILayout.EndHorizontal();
        }