ооооо
This commit is contained in:
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
[RequireComponent(typeof (SphereCollider))]
|
||||
public class AfterburnerPhysicsForce : MonoBehaviour
|
||||
{
|
||||
public float effectAngle = 15;
|
||||
public float effectWidth = 1;
|
||||
public float effectDistance = 10;
|
||||
public float force = 10;
|
||||
|
||||
private Collider[] m_Cols;
|
||||
private SphereCollider m_Sphere;
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Sphere = (GetComponent<Collider>() as SphereCollider);
|
||||
}
|
||||
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
m_Cols = Physics.OverlapSphere(transform.position + m_Sphere.center, m_Sphere.radius);
|
||||
for (int n = 0; n < m_Cols.Length; ++n)
|
||||
{
|
||||
if (m_Cols[n].attachedRigidbody != null)
|
||||
{
|
||||
Vector3 localPos = transform.InverseTransformPoint(m_Cols[n].transform.position);
|
||||
localPos = Vector3.MoveTowards(localPos, new Vector3(0, 0, localPos.z), effectWidth*0.5f);
|
||||
float angle = Mathf.Abs(Mathf.Atan2(localPos.x, localPos.z)*Mathf.Rad2Deg);
|
||||
float falloff = Mathf.InverseLerp(effectDistance, 0, localPos.magnitude);
|
||||
falloff *= Mathf.InverseLerp(effectAngle, 0, angle);
|
||||
Vector3 delta = m_Cols[n].transform.position - transform.position;
|
||||
m_Cols[n].attachedRigidbody.AddForceAtPosition(delta.normalized*force*falloff,
|
||||
Vector3.Lerp(m_Cols[n].transform.position,
|
||||
transform.TransformPoint(0, 0, localPos.z),
|
||||
0.1f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
//check for editor time simulation to avoid null ref
|
||||
if(m_Sphere == null)
|
||||
m_Sphere = (GetComponent<Collider>() as SphereCollider);
|
||||
|
||||
m_Sphere.radius = effectDistance*.5f;
|
||||
m_Sphere.center = new Vector3(0, 0, effectDistance*.5f);
|
||||
var directions = new Vector3[] {Vector3.up, -Vector3.up, Vector3.right, -Vector3.right};
|
||||
var perpDirections = new Vector3[] {-Vector3.right, Vector3.right, Vector3.up, -Vector3.up};
|
||||
Gizmos.color = new Color(0, 1, 0, 0.5f);
|
||||
for (int n = 0; n < 4; ++n)
|
||||
{
|
||||
Vector3 origin = transform.position + transform.rotation*directions[n]*effectWidth*0.5f;
|
||||
|
||||
Vector3 direction =
|
||||
transform.TransformDirection(Quaternion.AngleAxis(effectAngle, perpDirections[n])*Vector3.forward);
|
||||
|
||||
Gizmos.DrawLine(origin, origin + direction*m_Sphere.radius*2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/AfterburnerPhysicsForce.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/AfterburnerPhysicsForce.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d44a238286f6904198ab78e914c229d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class ExplosionFireAndDebris : MonoBehaviour
|
||||
{
|
||||
public Transform[] debrisPrefabs;
|
||||
public Transform firePrefab;
|
||||
public int numDebrisPieces = 0;
|
||||
public int numFires = 0;
|
||||
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
float multiplier = GetComponent<ParticleSystemMultiplier>().multiplier;
|
||||
|
||||
for (int n = 0; n < numDebrisPieces*multiplier; ++n)
|
||||
{
|
||||
var prefab = debrisPrefabs[Random.Range(0, debrisPrefabs.Length)];
|
||||
Vector3 pos = transform.position + Random.insideUnitSphere*3*multiplier;
|
||||
Quaternion rot = Random.rotation;
|
||||
Instantiate(prefab, pos, rot);
|
||||
}
|
||||
|
||||
// wait one frame so these new objects can be picked up in the overlapsphere function
|
||||
yield return null;
|
||||
|
||||
float r = 10*multiplier;
|
||||
var cols = Physics.OverlapSphere(transform.position, r);
|
||||
foreach (var col in cols)
|
||||
{
|
||||
if (numFires > 0)
|
||||
{
|
||||
RaycastHit fireHit;
|
||||
Ray fireRay = new Ray(transform.position, col.transform.position - transform.position);
|
||||
if (col.Raycast(fireRay, out fireHit, r))
|
||||
{
|
||||
AddFire(col.transform, fireHit.point, fireHit.normal);
|
||||
numFires--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float testR = 0;
|
||||
while (numFires > 0 && testR < r)
|
||||
{
|
||||
RaycastHit fireHit;
|
||||
Ray fireRay = new Ray(transform.position + Vector3.up, Random.onUnitSphere);
|
||||
if (Physics.Raycast(fireRay, out fireHit, testR))
|
||||
{
|
||||
AddFire(null, fireHit.point, fireHit.normal);
|
||||
numFires--;
|
||||
}
|
||||
testR += r*.1f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void AddFire(Transform t, Vector3 pos, Vector3 normal)
|
||||
{
|
||||
pos += normal*0.5f;
|
||||
Transform fire = (Transform) Instantiate(firePrefab, pos, Quaternion.identity);
|
||||
fire.parent = t;
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/ExplosionFireAndDebris.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/ExplosionFireAndDebris.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 009fbf49e77db344db366a646868e02d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class ExplosionPhysicsForce : MonoBehaviour
|
||||
{
|
||||
public float explosionForce = 4;
|
||||
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
// wait one frame because some explosions instantiate debris which should then
|
||||
// be pushed by physics force
|
||||
yield return null;
|
||||
|
||||
float multiplier = GetComponent<ParticleSystemMultiplier>().multiplier;
|
||||
|
||||
float r = 10*multiplier;
|
||||
var cols = Physics.OverlapSphere(transform.position, r);
|
||||
var rigidbodies = new List<Rigidbody>();
|
||||
foreach (var col in cols)
|
||||
{
|
||||
if (col.attachedRigidbody != null && !rigidbodies.Contains(col.attachedRigidbody))
|
||||
{
|
||||
rigidbodies.Add(col.attachedRigidbody);
|
||||
}
|
||||
}
|
||||
foreach (var rb in rigidbodies)
|
||||
{
|
||||
rb.AddExplosionForce(explosionForce*multiplier, transform.position, r, 1*multiplier, ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/ExplosionPhysicsForce.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/ExplosionPhysicsForce.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ac1691131a8c844dafe8b6ace6a172a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
65
Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs
Normal file
65
Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityStandardAssets.Utility;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class Explosive : MonoBehaviour
|
||||
{
|
||||
public Transform explosionPrefab;
|
||||
public float detonationImpactVelocity = 10;
|
||||
public float sizeMultiplier = 1;
|
||||
public bool reset = true;
|
||||
public float resetTimeDelay = 10;
|
||||
|
||||
private bool m_Exploded;
|
||||
private ObjectResetter m_ObjectResetter;
|
||||
|
||||
|
||||
// implementing one method from monobehviour to ensure that the enable/disable tickbox appears in the inspector
|
||||
private void Start()
|
||||
{
|
||||
m_ObjectResetter = GetComponent<ObjectResetter>();
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator OnCollisionEnter(Collision col)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
if (col.contacts.Length > 0)
|
||||
{
|
||||
// compare relative velocity to collision normal - so we don't explode from a fast but gentle glancing collision
|
||||
float velocityAlongCollisionNormal =
|
||||
Vector3.Project(col.relativeVelocity, col.contacts[0].normal).magnitude;
|
||||
|
||||
if (velocityAlongCollisionNormal > detonationImpactVelocity || m_Exploded)
|
||||
{
|
||||
if (!m_Exploded)
|
||||
{
|
||||
Instantiate(explosionPrefab, col.contacts[0].point,
|
||||
Quaternion.LookRotation(col.contacts[0].normal));
|
||||
m_Exploded = true;
|
||||
|
||||
SendMessage("Immobilize");
|
||||
|
||||
if (reset)
|
||||
{
|
||||
m_ObjectResetter.DelayedReset(resetTimeDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Exploded = false;
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 433e9c8d0293ac4429eaf19bff2b58cf
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class ExtinguishableParticleSystem : MonoBehaviour
|
||||
{
|
||||
public float multiplier = 1;
|
||||
|
||||
private ParticleSystem[] m_Systems;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_Systems = GetComponentsInChildren<ParticleSystem>();
|
||||
}
|
||||
|
||||
|
||||
public void Extinguish()
|
||||
{
|
||||
foreach (var system in m_Systems)
|
||||
{
|
||||
var emission = system.emission;
|
||||
emission.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/ExtinguishableParticleSystem.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/ExtinguishableParticleSystem.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13e3e45088e68834999c82ca6f025949
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
40
Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs
Normal file
40
Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class FireLight : MonoBehaviour
|
||||
{
|
||||
private float m_Rnd;
|
||||
private bool m_Burning = true;
|
||||
private Light m_Light;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_Rnd = Random.value*100;
|
||||
m_Light = GetComponent<Light>();
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (m_Burning)
|
||||
{
|
||||
m_Light.intensity = 2*Mathf.PerlinNoise(m_Rnd + Time.time, m_Rnd + 1 + Time.time*1);
|
||||
float x = Mathf.PerlinNoise(m_Rnd + 0 + Time.time*2, m_Rnd + 1 + Time.time*2) - 0.5f;
|
||||
float y = Mathf.PerlinNoise(m_Rnd + 2 + Time.time*2, m_Rnd + 3 + Time.time*2) - 0.5f;
|
||||
float z = Mathf.PerlinNoise(m_Rnd + 4 + Time.time*2, m_Rnd + 5 + Time.time*2) - 0.5f;
|
||||
transform.localPosition = Vector3.up + new Vector3(x, y, z)*1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Extinguish()
|
||||
{
|
||||
m_Burning = false;
|
||||
m_Light.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 723274b822865ed4d9ed2a504c0ca79d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
37
Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs
Normal file
37
Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class Hose : MonoBehaviour
|
||||
{
|
||||
public float maxPower = 20;
|
||||
public float minPower = 5;
|
||||
public float changeSpeed = 5;
|
||||
public ParticleSystem[] hoseWaterSystems;
|
||||
public Renderer systemRenderer;
|
||||
|
||||
private float m_Power;
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
m_Power = Mathf.Lerp(m_Power, Input.GetMouseButton(0) ? maxPower : minPower, Time.deltaTime*changeSpeed);
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||||
{
|
||||
systemRenderer.enabled = !systemRenderer.enabled;
|
||||
}
|
||||
|
||||
foreach (var system in hoseWaterSystems)
|
||||
{
|
||||
ParticleSystem.MainModule mainModule = system.main;
|
||||
mainModule.startSpeed = m_Power;
|
||||
var emission = system.emission;
|
||||
emission.enabled = (m_Power > minPower*1.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 915950f1f73ea9e429d92b7226238623
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class ParticleSystemMultiplier : MonoBehaviour
|
||||
{
|
||||
// a simple script to scale the size, speed and lifetime of a particle system
|
||||
|
||||
public float multiplier = 1;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var systems = GetComponentsInChildren<ParticleSystem>();
|
||||
foreach (ParticleSystem system in systems)
|
||||
{
|
||||
ParticleSystem.MainModule mainModule = system.main;
|
||||
mainModule.startSizeMultiplier *= multiplier;
|
||||
mainModule.startSpeedMultiplier *= multiplier;
|
||||
mainModule.startLifetimeMultiplier *= Mathf.Lerp(multiplier, 1, 0.5f);
|
||||
system.Clear();
|
||||
system.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/ParticleSystemMultiplier.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/ParticleSystemMultiplier.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 039587c051912eb4ead9e58344c5f3ce
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class SmokeParticles : MonoBehaviour
|
||||
{
|
||||
public AudioClip[] extinguishSounds;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GetComponent<AudioSource>().clip = extinguishSounds[Random.Range(0, extinguishSounds.Length)];
|
||||
GetComponent<AudioSource>().Play();
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/SmokeParticles.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/SmokeParticles.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4414ab7cd3d674b449d233db0d583605
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityStandardAssets.Effects
|
||||
{
|
||||
public class WaterHoseParticles : MonoBehaviour
|
||||
{
|
||||
public static float lastSoundTime;
|
||||
public float force = 1;
|
||||
|
||||
|
||||
private List<ParticleCollisionEvent> m_CollisionEvents = new List<ParticleCollisionEvent>();
|
||||
private ParticleSystem m_ParticleSystem;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_ParticleSystem = GetComponent<ParticleSystem>();
|
||||
}
|
||||
|
||||
|
||||
private void OnParticleCollision(GameObject other)
|
||||
{
|
||||
int numCollisionEvents = m_ParticleSystem.GetCollisionEvents(other, m_CollisionEvents);
|
||||
int i = 0;
|
||||
|
||||
while (i < numCollisionEvents)
|
||||
{
|
||||
if (Time.time > lastSoundTime + 0.2f)
|
||||
{
|
||||
lastSoundTime = Time.time;
|
||||
}
|
||||
|
||||
var col = m_CollisionEvents[i].colliderComponent;
|
||||
var attachedRigidbody = col.GetComponent<Rigidbody>();
|
||||
if (attachedRigidbody != null)
|
||||
{
|
||||
Vector3 vel = m_CollisionEvents[i].velocity;
|
||||
attachedRigidbody.AddForce(vel*force, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
Assets/Standard Assets/ParticleSystems/Scripts/WaterHoseParticles.cs.meta
generated
Normal file
9
Assets/Standard Assets/ParticleSystems/Scripts/WaterHoseParticles.cs.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d79772cda0b4b6409070163fcab05da
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
Reference in New Issue
Block a user