Ejemplo n.º 1
0
    public void AtShake()
    {
        AtQuakeInfo data = new AtQuakeInfo();

        data.UserUsed  = UserUsed;
        data.FadeTime  = FadeTime;
        data.Power     = Power;
        data.MaxRange  = AtMaxRange;
        data.LifeTime  = LifeTime;
        data.Direction = Direction;
        data.LoopCount = LoopCount;

        m_atQuakeUnit.Initialize(data);
        m_atQuakeUnit.Play((Offset));
    }
Ejemplo n.º 2
0
        public override void Initialize(ICameraShakeStock cameraEffectData)
        {
            m_atCameraData = (AtQuakeInfo)cameraEffectData;
            m_UserUsed     = cameraEffectData.User;

            m_Radius = m_atCameraData.MaxRange;
            m_Played = false;
            m_Finish = true;

            m_AtQuakeStock.Name  = m_atCameraData.Name;
            m_AtQuakeStock.Power = m_atCameraData.Power;
            if (m_atCameraData.Direction == Vector3.zero)
            {
                m_AtQuakeStock.Direction = (LEMath.RandomDirection());
            }
            else
            {
                m_AtQuakeStock.Direction = new Vector3(m_atCameraData.Direction.x * LEMath.s_fDegreeToRadian,
                                                       m_atCameraData.Direction.y * LEMath.s_fDegreeToRadian,
                                                       m_atCameraData.Direction.z * LEMath.s_fDegreeToRadian);
            }
        }
Ejemplo n.º 3
0
    void OnEnable()
    {
        if (target == null)
        {
            return;
        }

        var camera2DShake = (CameraShake)target;

        //if (camera2DShake.Impl == null & Camera.main != null)
        //{
        //    camera2DShake.Impl = Camera.main.GetComponent<CameraImpl>();
        //}
        //if (camera2DShake.Impl == null)
        //{
        //    camera2DShake.Impl = FindObjectOfType<CameraImpl>();
        //}

        _script = MonoScript.FromMonoBehaviour(camera2DShake);

        // Get presets from play mode
        if (_playAtPresets == null)
        {
            _playAtPresets = new List <AtQuakeInfo>();
        }

        if (_playEyePresets == null)
        {
            _playEyePresets = new List <EyeQuakeInfo>();
        }

        serializedObject.Update();

#if UNITY_5_3_OR_NEWER
        if (_currentScene != UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name)
        {
            _playAtPresets.Clear();
            _playEyePresets.Clear();
        }

        _currentScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
#else
        if (_currentScene != EditorApplication.currentScene)
        {
            _playModePresets.Clear();
        }

        _currentScene = EditorApplication.currentScene;
#endif

        if (!Application.isPlaying && (_playAtPresets.Count > 0 || _playEyePresets.Count > 0))
        {
            var atlist = serializedObject.FindProperty("AtCameraDatas");
            atlist.ClearArray();
            for (int i = 0; i < _playAtPresets.Count; i++)
            {
                atlist.InsertArrayElementAtIndex(i);
                var preset = atlist.GetArrayElementAtIndex(i);
                preset.FindPropertyRelative("EffectName").stringValue = _playAtPresets[i].EffectName;
                preset.FindPropertyRelative("UserUsed").boolValue     = _playAtPresets[i].UserUsed;
                preset.FindPropertyRelative("LifeTime").floatValue    = _playAtPresets[i].LifeTime;
                preset.FindPropertyRelative("LoopCount").intValue     = _playAtPresets[i].LoopCount;
                preset.FindPropertyRelative("FadeTime").floatValue    = _playAtPresets[i].FadeTime;
                preset.FindPropertyRelative("Power").floatValue       = _playAtPresets[i].Power;
                preset.FindPropertyRelative("MaxRange").floatValue    = _playAtPresets[i].MaxRange;
                preset.FindPropertyRelative("Direction").vector3Value = _playAtPresets[i].Direction;
            }
            _playAtPresets.Clear();

            var eyelist = serializedObject.FindProperty("EyeCameraDatas");
            eyelist.ClearArray();
            for (int i = 0; i < _playEyePresets.Count; i++)
            {
                eyelist.InsertArrayElementAtIndex(i);
                var preset = eyelist.GetArrayElementAtIndex(i);
                preset.FindPropertyRelative("EffectName").stringValue = _playEyePresets[i].EffectName;
                preset.FindPropertyRelative("UserUsed").boolValue     = _playEyePresets[i].UserUsed;
                preset.FindPropertyRelative("eType").enumValueIndex   = (int)_playEyePresets[i].eType;
                preset.FindPropertyRelative("LoadCount").intValue     = _playEyePresets[i].LoadCount;
                preset.FindPropertyRelative("BlendWidth").intValue    = (int)_playEyePresets[i].BlendWidth;
                preset.FindPropertyRelative("StepCount").intValue     = _playEyePresets[i].StepCount;
                preset.FindPropertyRelative("TimeLength").floatValue  = _playEyePresets[i].TimeLength;
                preset.FindPropertyRelative("MaxRange").floatValue    = _playEyePresets[i].MaxRange;
                preset.FindPropertyRelative("RandState").boolValue    = _playEyePresets[i].RandState;
                preset.FindPropertyRelative("RandLength").floatValue  = _playEyePresets[i].RandLength;
                preset.FindPropertyRelative("LifeTime").floatValue    = _playEyePresets[i].LifeTime;
            }
            _playEyePresets.Clear();
        }
        serializedObject.ApplyModifiedProperties();

        // Shake presets list
        _atPresetsList = new ReorderableList(serializedObject, serializedObject.FindProperty("AtCameraDatas"), false, true, false, true);

        _atPresetsList.drawElementCallback = (rect, index, isActive, isFocused) =>
        {
            rect.y += 2;
            var element = _atPresetsList.serializedProperty.GetArrayElementAtIndex(index);

            // Name field
            EditorGUI.PropertyField(new Rect(
                                        rect.x,
                                        rect.y,
                                        rect.width / 4f,
                                        EditorGUIUtility.singleLineHeight * 1.1f),
                                    element.FindPropertyRelative("EffectName"), GUIContent.none);

            // Load button
            if (GUI.Button(new Rect(
                               rect.x + rect.width / 4f + 5,
                               rect.y,
                               rect.width / 4f - 5,
                               EditorGUIUtility.singleLineHeight * 1.1f), "Load"))
            {
                camera2DShake.LifeTime   = element.FindPropertyRelative("LifeTime").floatValue;
                camera2DShake.LoopCount  = element.FindPropertyRelative("LoopCount").intValue;
                camera2DShake.FadeTime   = element.FindPropertyRelative("FadeTime").floatValue;
                camera2DShake.Power      = element.FindPropertyRelative("Power").floatValue;
                camera2DShake.AtMaxRange = (uint)element.FindPropertyRelative("MaxRange").floatValue;
                camera2DShake.Direction  = element.FindPropertyRelative("Direction").vector3Value;

                EditorUtility.SetDirty(target);
            }

            // Save button
            if (GUI.Button(new Rect(
                               rect.x + 2 * rect.width / 4f + 5,
                               rect.y,
                               rect.width / 4f - 5,
                               EditorGUIUtility.singleLineHeight * 1.1f), "Save"))
            {
                element.FindPropertyRelative("LifeTime").floatValue    = camera2DShake.LifeTime;
                element.FindPropertyRelative("LoopCount").intValue     = camera2DShake.LoopCount;
                element.FindPropertyRelative("FadeTime").floatValue    = camera2DShake.FadeTime;
                element.FindPropertyRelative("Power").floatValue       = camera2DShake.Power;
                element.FindPropertyRelative("MaxRange").floatValue    = camera2DShake.AtMaxRange;
                element.FindPropertyRelative("Direction").vector3Value = camera2DShake.Direction;


                //proCamera2DShake.UseRandomInitialAngle = proCamera2DShake.InitialAngle < 0;

                EditorUtility.SetDirty(target);

                Repaint();
            }

            // Shake button
            GUI.enabled = Application.isPlaying;
            if (GUI.Button(new Rect(
                               rect.x + 3 * rect.width / 4f + 5,
                               rect.y,
                               rect.width / 4f - 5,
                               EditorGUIUtility.singleLineHeight * 1.1f), "Shake!"))
            {
                AtQuakeInfo data = new AtQuakeInfo();
                data.EffectName = "AtData" + camera2DShake.AtCameraDatas.Count;
                data.LifeTime   = element.FindPropertyRelative("LifeTime").floatValue;
                data.LoopCount  = element.FindPropertyRelative("LoopCount").intValue;
                data.FadeTime   = element.FindPropertyRelative("FadeTime").floatValue;
                data.Power      = element.FindPropertyRelative("Power").floatValue;
                data.MaxRange   = element.FindPropertyRelative("MaxRange").floatValue;
                data.Direction  = element.FindPropertyRelative("Direction").vector3Value;

                camera2DShake.AtShake(data);
            }
            GUI.enabled = true;
        };

        _atPresetsList.drawHeaderCallback = (Rect rect) =>
        {
            EditorGUI.LabelField(rect, "At Presets");
        };

        _atPresetsList.elementHeight = 30;
        _atPresetsList.draggable     = true;


        // Shake presets list
        _eyePresetsList = new ReorderableList(serializedObject, serializedObject.FindProperty("EyeCameraDatas"), false, true, false, true);

        _eyePresetsList.drawElementCallback = (rect, index, isActive, isFocused) =>
        {
            rect.y += 2;
            var element = _eyePresetsList.serializedProperty.GetArrayElementAtIndex(index);

            // Name field
            EditorGUI.PropertyField(new Rect(
                                        rect.x,
                                        rect.y,
                                        rect.width / 4f,
                                        EditorGUIUtility.singleLineHeight * 1.1f),
                                    element.FindPropertyRelative("EffectName"), GUIContent.none);

            // Load button
            if (GUI.Button(new Rect(
                               rect.x + rect.width / 4f + 5,
                               rect.y,
                               rect.width / 4f - 5,
                               EditorGUIUtility.singleLineHeight * 1.1f), "Load"))
            {
                camera2DShake.eType       = (EyeQuakeInfo.Type)element.FindPropertyRelative("eType").enumValueIndex;
                camera2DShake.LoadCount   = element.FindPropertyRelative("LoadCount").intValue;
                camera2DShake.BlendWidth  = (uint)element.FindPropertyRelative("BlendWidth").intValue;
                camera2DShake.StepCount   = element.FindPropertyRelative("StepCount").intValue;
                camera2DShake.TimeLength  = element.FindPropertyRelative("TimeLength").floatValue;
                camera2DShake.EyeMaxRange = element.FindPropertyRelative("MaxRange").floatValue;
                camera2DShake.RandState   = element.FindPropertyRelative("RandState").boolValue;
                camera2DShake.RandLength  = element.FindPropertyRelative("RandLength").floatValue;
                camera2DShake.EyeLifeTime = element.FindPropertyRelative("LifeTime").floatValue;

                //proCamera2DShake.UseRandomInitialAngle = proCamera2DShake.InitialAngle < 0;

                EditorUtility.SetDirty(target);
            }

            // Save button
            if (GUI.Button(new Rect(
                               rect.x + 2 * rect.width / 4f + 5,
                               rect.y,
                               rect.width / 4f - 5,
                               EditorGUIUtility.singleLineHeight * 1.1f), "Save"))
            {
                element.FindPropertyRelative("eType").enumValueIndex  = (int)camera2DShake.eType;
                element.FindPropertyRelative("LoadCount").intValue    = camera2DShake.LoadCount;
                element.FindPropertyRelative("BlendWidth").intValue   = (int)camera2DShake.BlendWidth;
                element.FindPropertyRelative("StepCount").intValue    = camera2DShake.StepCount;
                element.FindPropertyRelative("TimeLength").floatValue = camera2DShake.TimeLength;
                element.FindPropertyRelative("MaxRange").floatValue   = camera2DShake.EyeMaxRange;
                element.FindPropertyRelative("RandState").boolValue   = camera2DShake.RandState;
                element.FindPropertyRelative("RandLength").floatValue = camera2DShake.RandLength;
                element.FindPropertyRelative("LifeTime").floatValue   = camera2DShake.EyeLifeTime;

                //proCamera2DShake.UseRandomInitialAngle = proCamera2DShake.InitialAngle < 0;

                EditorUtility.SetDirty(target);

                Repaint();
            }

            // Shake button
            GUI.enabled = Application.isPlaying;
            if (GUI.Button(new Rect(
                               rect.x + 3 * rect.width / 4f + 5,
                               rect.y,
                               rect.width / 4f - 5,
                               EditorGUIUtility.singleLineHeight * 1.1f), "Shake!"))
            {
                EyeQuakeInfo info = new EyeQuakeInfo();
                info.EffectName = "EyeData" + camera2DShake.EyeCameraDatas.Count;
                info.eType      = (EyeQuakeInfo.Type)element.FindPropertyRelative("eType").enumValueIndex;
                info.LoadCount  = element.FindPropertyRelative("LoadCount").intValue;
                info.BlendWidth = (uint)element.FindPropertyRelative("BlendWidth").intValue;
                info.StepCount  = element.FindPropertyRelative("StepCount").intValue;
                info.TimeLength = element.FindPropertyRelative("TimeLength").floatValue;
                info.MaxRange   = element.FindPropertyRelative("MaxRange").floatValue;
                info.RandState  = element.FindPropertyRelative("RandState").boolValue;
                info.RandLength = element.FindPropertyRelative("RandLength").floatValue;
                info.LifeTime   = element.FindPropertyRelative("LifeTime").floatValue;

                camera2DShake.EyeShake(info);
            }
            GUI.enabled = true;
        };

        _eyePresetsList.drawHeaderCallback = (Rect rect) =>
        {
            EditorGUI.LabelField(rect, "Eye Presets");
        };

        _eyePresetsList.elementHeight = 30;
        _eyePresetsList.draggable     = true;
    }
Ejemplo n.º 4
0
 public void AtShake(AtQuakeInfo data)
 {
     m_atQuakeUnit.Initialize(data);
     m_atQuakeUnit.Play((Offset));
 }