This commit is contained in:
2022-04-23 21:58:16 +07:00
parent 23cc872b33
commit 4172fc94ba
872 changed files with 2796830 additions and 0 deletions

View File

@ -0,0 +1,35 @@
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(ParticleSystem))]
public class CFX_AutoDestructShuriken : MonoBehaviour
{
public bool OnlyDeactivate;
void OnEnable()
{
StartCoroutine("CheckIfAlive");
}
IEnumerator CheckIfAlive ()
{
while(true)
{
yield return new WaitForSeconds(0.5f);
if(!GetComponent<ParticleSystem>().IsAlive(true))
{
if(OnlyDeactivate)
{
#if UNITY_3_5
this.gameObject.SetActiveRecursively(false);
#else
this.gameObject.SetActive(false);
#endif
}
else
GameObject.Destroy(this.gameObject);
break;
}
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6fd2e8874f60266498a388d7229a1bac
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,65 @@
using UnityEngine;
using System.Collections;
// Cartoon FX - (c) 2015, Jean Moreno
// Decreases a light's intensity over time.
[RequireComponent(typeof(Light))]
public class CFX_LightIntensityFade : MonoBehaviour
{
// Duration of the effect.
public float duration = 1.0f;
// Delay of the effect.
public float delay = 0.0f;
/// Final intensity of the light.
public float finalIntensity = 0.0f;
// Base intensity, automatically taken from light parameters.
private float baseIntensity;
// If <c>true</c>, light will destructs itself on completion of the effect
public bool autodestruct;
private float p_lifetime = 0.0f;
private float p_delay;
void Start()
{
baseIntensity = GetComponent<Light>().intensity;
}
void OnEnable()
{
p_lifetime = 0.0f;
p_delay = delay;
if(delay > 0) GetComponent<Light>().enabled = false;
}
void Update ()
{
if(p_delay > 0)
{
p_delay -= Time.deltaTime;
if(p_delay <= 0)
{
GetComponent<Light>().enabled = true;
}
return;
}
if(p_lifetime/duration < 1.0f)
{
GetComponent<Light>().intensity = Mathf.Lerp(baseIntensity, finalIntensity, p_lifetime/duration);
p_lifetime += Time.deltaTime;
}
else
{
if(autodestruct)
GameObject.Destroy(this.gameObject);
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c2255468ea97f384a9ebbb13e497e050
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,77 @@
using UnityEngine;
using System.Collections;
/**
* Handles the bullet hole decals:
* - Sets a random frame
* - Fades the material according to the defined lifetime
* - Optionally rotates the decal
*
* (c) 2015, Jean Moreno
**/
[RequireComponent(typeof(MeshFilter))]
public class WFX_BulletHoleDecal : MonoBehaviour
{
static private Vector2[] quadUVs = new Vector2[]{new Vector2(0,0), new Vector2(0,1), new Vector2(1,0), new Vector2(1,1)};
public float lifetime = 10f;
public float fadeoutpercent = 80;
public Vector2 frames;
public bool randomRotation = false;
public bool deactivate = false;
private float life;
private float fadeout;
private Color color;
private float orgAlpha;
void Awake()
{
color = this.GetComponent<Renderer>().material.GetColor("_TintColor");
orgAlpha = color.a;
}
void OnEnable()
{
//Random UVs
int random = Random.Range(0, (int)(frames.x*frames.y));
int fx = (int)(random%frames.x);
int fy = (int)(random/frames.y);
//Set new UVs
Vector2[] meshUvs = new Vector2[4];
for(int i = 0; i < 4; i++)
{
meshUvs[i].x = (quadUVs[i].x + fx) * (1.0f/frames.x);
meshUvs[i].y = (quadUVs[i].y + fy) * (1.0f/frames.y);
}
this.GetComponent<MeshFilter>().mesh.uv = meshUvs;
//Random rotate
if(randomRotation)
this.transform.Rotate(0f,0f,Random.Range(0f,360f), Space.Self);
//Start lifetime coroutine
life = lifetime;
fadeout = life * (fadeoutpercent/100f);
color.a = orgAlpha;
this.GetComponent<Renderer>().material.SetColor("_TintColor", color);
StopAllCoroutines();
StartCoroutine("holeUpdate");
}
IEnumerator holeUpdate()
{
while(life > 0f)
{
life -= Time.deltaTime;
if(life <= fadeout)
{
color.a = Mathf.Lerp(0f, orgAlpha, life/fadeout);
this.GetComponent<Renderer>().material.SetColor("_TintColor", color);
}
yield return null;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 395f3a2ded34a634fbd77ee83f9939a7
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,38 @@
using UnityEngine;
using System.Collections;
/**
* Rapidly sets a light on/off.
*
* (c) 2015, Jean Moreno
**/
[RequireComponent(typeof(Light))]
public class WFX_LightFlicker : MonoBehaviour
{
public float time = 0.05f;
private float timer;
void Start ()
{
timer = time;
StartCoroutine("Flicker");
}
IEnumerator Flicker()
{
while(true)
{
GetComponent<Light>().enabled = !GetComponent<Light>().enabled;
do
{
timer -= Time.deltaTime;
yield return null;
}
while(timer > 0);
timer = time;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 96d332ab3dbfaaf40bdd9745ff0b19f0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}