Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- //@Made by Pufferfiz
- /// <summary>
- /// Flasher.
- /// </summary>
- public class Flasher {
- /// <summary>
- /// Action Turn Sprite White
- /// </summary>
- private static System.Action<object> ActionTurnWhite = new System.Action<object> (TurnWhite);
- /// <summary>
- /// Action Turn Sprite back to full color.
- /// </summary>
- private static System.Action<object> ActionTurnColor = new System.Action<object> (TurnColor);
- /// <summary>
- /// Flash the specified inObj. MUST USE FLASH ENABLED SHADER
- /// </summary>
- /// <param name="inObj">In object.</param>
- static public void Flash ( GameObject inObj, float Speed)
- {
- LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setOnComplete (ActionTurnWhite, inObj);
- LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setDelay(Speed * 2 + (Speed/2.0f)).setOnComplete (ActionTurnColor, inObj);
- LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setDelay(Speed * 3 + (Speed/2.0f)).setOnComplete (ActionTurnWhite, inObj);
- LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setDelay(Speed * 4 + (Speed/2.0f)).setOnComplete (ActionTurnColor, inObj);
- //Can be modified to make it flash more or less.
- }
- /// <summary>
- /// Turns the sprite white.
- /// </summary>
- /// <param name="obj">Object.</param>
- static public void TurnWhite(object obj)
- {
- GameObject temp = obj as GameObject;
- temp.GetComponent<SpriteRenderer> ().material.SetInt ("_AltColorAmount", 1);
- }
- /// <summary>
- /// Turns the sprite full color.
- /// </summary>
- /// <param name="obj">Object.</param>
- static public void TurnColor(object obj)
- {
- GameObject temp = obj as GameObject;
- temp.GetComponent<SpriteRenderer> ().material.SetInt ("_AltColorAmount", 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement