Exemple #1
0
 static public int StartFadeOut(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         EZCameraShake.CameraShakeInstance self = (EZCameraShake.CameraShakeInstance)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         self.StartFadeOut(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemple #2
0
 static public int get_ScaleRoughness(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         EZCameraShake.CameraShakeInstance self = (EZCameraShake.CameraShakeInstance)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.ScaleRoughness);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemple #3
0
    public void OnTriggerEnter1(Collider col)
    {
        Destroyable destoyable = col.gameObject.GetComponent <Destroyable>();

        if (destoyable != null)
        {
            destoyable.OnCollisionObject(transform);
            library.score.AddScoreForDestroy(destoyable);
            library.energy.AddEnergy(destoyable);

            EZCameraShake.CameraShakeInstance c = EZCameraShake.CameraShaker.Instance.ShakeOnce(2, 4, 0.1f, 2f);


            AddDestroyable(destoyable.GetType().Name);
        }

        Letter letter = col.gameObject.GetComponent <Letter>();

        if (letter != null)
        {
            WordRide wordRide = library.level.GetComponentInChildren <WordRide>();

            if (wordRide != null)
            {
                wordRide.CheckLetter(letter.letterNum);
            }

            Destroy(letter.gameObject);
        }

        //   c.PositionInfluence = new Vector3(1,1,1);
        // c.PositionInfluence = new Vector3(1, 1, 1);
    }
        /// <summary>
        /// Shake the camera once, fading in and out  over a specified durations.
        /// </summary>
        /// <param name="magnitude">The intensity of the shake.</param>
        /// <param name="roughness">Roughness of the shake. Lower values are smoother, higher values are more jarring.</param>
        /// <param name="fadeInTime">How long to fade in the shake, in seconds.</param>
        /// <param name="fadeOutTime">How long to fade out the shake, in seconds.</param>
        /// <returns>A CameraShakeInstance that can be used to alter the shake's properties.</returns>
        public CameraShakeInstance ShakeOnce(float magnitude, float roughness, float fadeInTime, float fadeOutTime)
        {
            CameraShakeInstance shake = new CameraShakeInstance(magnitude, roughness, fadeInTime, fadeOutTime);
            shake.PositionInfluence = DefaultPosInfluence;
            shake.RotationInfluence = DefaultRotInfluence;
            cameraShakeInstances.Add(shake);

            return shake;
        }
Exemple #5
0
    public IEnumerator shake()
    {
        EZCameraShake.CameraShakeInstance shakeInstance = EZCameraShake.CameraShaker.Instance.StartShake(2, 2, 0.1f);

        yield return(new WaitForSeconds(0.15f));

        shakeInstance.StartFadeOut(0.1f);

        yield return(null);
    }
Exemple #6
0
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         int argc = LuaDLL.lua_gettop(l);
         EZCameraShake.CameraShakeInstance o;
         if (argc == 5)
         {
             System.Single a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             System.Single a4;
             checkType(l, 5, out a4);
             o = new EZCameraShake.CameraShakeInstance(a1, a2, a3, a4);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc == 3)
         {
             System.Single a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             o = new EZCameraShake.CameraShakeInstance(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemple #7
0
 void ShakeCamera()
 {
     /*
      * iTween.ShakePosition(library.cam,
      *  iTween.Hash(
      *      "amount", new Vector3(0.5f, 0.5f, 0.5f),
      *      "time", 0.8f
      *      )
      *  );*/
     EZCameraShake.CameraShakeInstance c = EZCameraShake.CameraShaker.Instance.ShakeOnce(2, 15, 0.1f, 1f);
 }
Exemple #8
0
 /// <summary>
 /// Start shaking the camera.
 /// </summary>
 /// <param name="magnitude">The intensity of the shake.</param>
 /// <param name="roughness">Roughness of the shake. Lower values are smoother, higher values are more jarring.</param>
 /// <param name="fadeInTime">How long to fade in the shake, in seconds.</param>
 /// <param name="posInfluence">How much this shake influences position.</param>
 /// <param name="rotInfluence">How much this shake influences rotation.</param>
 /// <returns>A CameraShakeInstance that can be used to alter the shake's properties.</returns>
 public CameraShakeInstance StartShake(float magnitude, float roughness, float fadeInTime, Vector3 posInfluence, Vector3 rotInfluence)
 {
     CameraShakeInstance shake = new CameraShakeInstance(magnitude, roughness);
     shake.PositionInfluence = posInfluence;
     shake.RotationInfluence = rotInfluence;
     shake.StartFadeIn(fadeInTime);
     cameraShakeInstances.Add(shake);
     return shake;
 }
Exemple #9
0
 /// <summary>
 /// Starts a shake using the given preset.
 /// </summary>
 /// <param name="shake">The preset to use.</param>
 /// <returns>A CameraShakeInstance that can be used to alter the shake's properties.</returns>
 public CameraShakeInstance Shake(CameraShakeInstance shake)
 {
     cameraShakeInstances.Add(shake);
     return shake;
 }
Exemple #10
0
    void OnGUI()
    {
        Slider s = delegate(float val, string prefix, float min, float max, int pad)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(prefix, GUILayout.MaxWidth(pad));
            val = GUILayout.HorizontalSlider(val, min, max);
            GUILayout.Label(val.ToString("F2"), GUILayout.MaxWidth(50));
            GUILayout.EndHorizontal();
            return val;
        };

        GUI.Box(new Rect(10, 10, 250, Screen.height - 15), "Make-A-Shake");
        GUILayout.BeginArea(new Rect(29f, 40, 215, Screen.height - 40));

        GUILayout.Label("--Position Infleunce--");
        posInf.x = s(posInf.x, "X", 0, 4, 25);
        posInf.y = s(posInf.y, "Y", 0, 4, 25);
        posInf.z = s(posInf.z, "Z", 0, 4, 25);

        GUILayout.Label("--Rotation Infleunce--");
        rotInf.x = s(rotInf.x, "X", 0, 4, 25);
        rotInf.y = s(rotInf.y, "Y", 0, 4, 25);
        rotInf.z = s(rotInf.z, "Z", 0, 4, 25);

        GUILayout.Label("--Other Properties--");

        magn = s(magn, "Magnitude:", 0, 10, 75);
        rough = s(rough, "Roughness:", 0, 20, 75);

        fadeIn = s(fadeIn, "Fade In:", 0, 10, 75);
        fadeOut = s(fadeOut, "Fade Out:", 0, 10, 75);

        GUILayout.Label("--Saved Shake Instance--");
        GUILayout.Label("You can save shake instances and modify their properties at runtime.");

        if (shake == null && GUILayout.Button("Create Shake Instance"))
        {
            shake = CameraShaker.Instance.StartShake(magn, rough, fadeIn);
            shake.DeleteOnInactive = false;
        }

        if (shake != null)
        {
            if (GUILayout.Button("Delete Shake Instance"))
            {
                shake.DeleteOnInactive = true;
                shake.StartFadeOut(fadeOut);
                shake = null;

            }

            if (shake != null)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Fade Out"))
                {
                    shake.StartFadeOut(fadeOut);
                }
                if (GUILayout.Button("Fade In"))
                {
                    shake.StartFadeIn(fadeIn);
                }
                GUILayout.EndHorizontal();

                modValues = GUILayout.Toggle(modValues, "Modify Instance Values");

                if (modValues)
                {
                    shake.ScaleMagnitude = magn;
                    shake.ScaleRoughness = rough;
                    shake.PositionInfluence = posInf;
                    shake.RotationInfluence = rotInf;
                }
            }
        }

        GUILayout.Label("--Shake Once--");
        GUILayout.Label("You can simply have a shake that automatically starts and stops too.");

        if (GUILayout.Button("Shake!"))
        {
            CameraShakeInstance c = CameraShaker.Instance.ShakeOnce(magn, rough, fadeIn, fadeOut);
            c.PositionInfluence = posInf;
            c.RotationInfluence = rotInf;
        }

        GUILayout.EndArea();

        float height;

        if (!showList)
            height = 120;
        else
            height = 120 + CameraShaker.Instance.ShakeInstances.Count * 130f;

        GUI.Box(new Rect(Screen.width - 310, 10, 300, height), "Shake Instance List");
        GUILayout.BeginArea(new Rect(Screen.width - 285, 40, 255, Screen.height - 40));

        GUILayout.Label("All shake instances are saved and stacked as long as they are active.");

        showList = GUILayout.Toggle(showList, "Show List");

        if (showList)
        {
            int index = 1;
            foreach (CameraShakeInstance c in CameraShaker.Instance.ShakeInstances)
            {
                string state = c.CurrentState.ToString();

                GUILayout.Label("#" + index + ": Magnitude: " + c.Magnitude.ToString("F2") + ", Roughness: " + c.Roughness.ToString("F2"));
                GUILayout.Label("      Position Influence: " + c.PositionInfluence);
                GUILayout.Label("      Rotation Influence: " + c.RotationInfluence);
                GUILayout.Label("      State: " + state);
                GUILayout.Label("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
                index++;
            }
        }
        GUILayout.EndArea();
    }
Exemple #11
0
 /// <summary>
 /// Starts a shake using the given preset.
 /// </summary>
 /// <param name="shake">The preset to use.</param>
 /// <returns>A CameraShakeInstance that can be used to alter the shake's properties.</returns>
 public CameraShakeInstance Shake(CameraShakeInstance shake)
 {
     cameraShakeInstances.Add(shake);
     return(shake);
 }
Exemple #12
0
 public void FadeOutAndRemoveShakeInstance(CameraShakeInstance shake, float fadeOutTime)
 {
     StartCoroutine(RemoveInstance(shake, fadeOutTime));
 }