added sfx, minor fixes
This commit is contained in:
parent
94fcee00f6
commit
e63c863167
8
Assets/Resources/1/VFX/Protectior.meta
Normal file
8
Assets/Resources/1/VFX/Protectior.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2656568c40f6c2341b05e5c8be6d0b76
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
23796
Assets/Resources/1/VFX/Protectior/Bomb.prefab
Normal file
23796
Assets/Resources/1/VFX/Protectior/Bomb.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Resources/1/VFX/Protectior/Bomb.prefab.meta
Normal file
7
Assets/Resources/1/VFX/Protectior/Bomb.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 109337c9ec6dfa24db2a7261444e92f0
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
38485
Assets/Resources/1/VFX/Protectior/HitBomb.prefab
Normal file
38485
Assets/Resources/1/VFX/Protectior/HitBomb.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Resources/1/VFX/Protectior/HitBomb.prefab.meta
Normal file
7
Assets/Resources/1/VFX/Protectior/HitBomb.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: abe47e4cb0fa73545b7b24dceb3fa5f1
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/Resources/1/VFX/Scripts.meta
Normal file
8
Assets/Resources/1/VFX/Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1472edf1a2be5ab479942a6bc3a1a825
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
39
Assets/Resources/1/VFX/Scripts/ETFXLightFade.cs
Normal file
39
Assets/Resources/1/VFX/Scripts/ETFXLightFade.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace EpicToonFX
|
||||||
|
{
|
||||||
|
public class ETFXLightFade : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("Seconds to dim the light")]
|
||||||
|
public float life = 0.2f;
|
||||||
|
public bool killAfterLife = true;
|
||||||
|
|
||||||
|
private Light li;
|
||||||
|
private float initIntensity;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
if (gameObject.GetComponent<Light>())
|
||||||
|
{
|
||||||
|
li = gameObject.GetComponent<Light>();
|
||||||
|
initIntensity = li.intensity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
print("No light object found on " + gameObject.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (gameObject.GetComponent<Light>())
|
||||||
|
{
|
||||||
|
li.intensity -= initIntensity * (Time.deltaTime / life);
|
||||||
|
if (killAfterLife && li.intensity <= 0)
|
||||||
|
//Destroy(gameObject);
|
||||||
|
Destroy(gameObject.GetComponent<Light>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Assets/Resources/1/VFX/Scripts/ETFXLightFade.cs.meta
Normal file
12
Assets/Resources/1/VFX/Scripts/ETFXLightFade.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2f54e17d705a2894d88787e24190ebfa
|
||||||
|
timeCreated: 1499439792
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
17
Assets/Resources/1/VFX/Scripts/ETFXPitchRandomizer.cs
Normal file
17
Assets/Resources/1/VFX/Scripts/ETFXPitchRandomizer.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace EpicToonFX
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ETFXPitchRandomizer : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public float randomPercent = 10;
|
||||||
|
|
||||||
|
void Start ()
|
||||||
|
{
|
||||||
|
transform.GetComponent<AudioSource>().pitch *= 1 + Random.Range(-randomPercent / 100, randomPercent / 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Assets/Resources/1/VFX/Scripts/ETFXPitchRandomizer.cs.meta
Normal file
12
Assets/Resources/1/VFX/Scripts/ETFXPitchRandomizer.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 628ef9b0c7e4fd24db54868035e11237
|
||||||
|
timeCreated: 1499558257
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
30
Assets/Resources/1/VFX/Scripts/ETFXRotation.cs
Normal file
30
Assets/Resources/1/VFX/Scripts/ETFXRotation.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace EpicToonFX
|
||||||
|
{
|
||||||
|
public class ETFXRotation : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
[Header("Rotate axises by degrees per second")]
|
||||||
|
public Vector3 rotateVector = Vector3.zero;
|
||||||
|
|
||||||
|
public enum spaceEnum { Local, World };
|
||||||
|
public spaceEnum rotateSpace;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (rotateSpace == spaceEnum.Local)
|
||||||
|
transform.Rotate(rotateVector * Time.deltaTime);
|
||||||
|
if (rotateSpace == spaceEnum.World)
|
||||||
|
transform.Rotate(rotateVector * Time.deltaTime, Space.World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Assets/Resources/1/VFX/Scripts/ETFXRotation.cs.meta
Normal file
12
Assets/Resources/1/VFX/Scripts/ETFXRotation.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7faa64a828219b44cb0eb5bfbfa83524
|
||||||
|
timeCreated: 1494264015
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
10
Assets/Resources/1/VFX/Scripts/ParticleSystemController.meta
Normal file
10
Assets/Resources/1/VFX/Scripts/ParticleSystemController.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 23780763d0d3e6045960b5bb0b39e12b
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1549844774
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,666 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace GAP_ParticleSystemController{
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class ParticleSystemOriginalSettings
|
||||||
|
{
|
||||||
|
public SerializableMinMaxGradient _startColor;
|
||||||
|
public SerializableMinMaxGradient _colorOverLifetimeC;
|
||||||
|
public SerializableMinMaxCurve _startSize;
|
||||||
|
public SerializableMinMaxCurve _startSizeX;
|
||||||
|
public SerializableMinMaxCurve _startSizeY;
|
||||||
|
public SerializableMinMaxCurve _startSizeZ;
|
||||||
|
public SerializableMinMaxCurve _startSpeed;
|
||||||
|
public SerializableMinMaxCurve _startDelay;
|
||||||
|
public SerializableMinMaxCurve _startLifetime;
|
||||||
|
public SerializableMinMaxCurve _velocityOverLifetimeX;
|
||||||
|
public SerializableMinMaxCurve _velocityOverLifetimeY;
|
||||||
|
public SerializableMinMaxCurve _velocityOverLifetimeZ;
|
||||||
|
public SerializableVector3 _localPosition;
|
||||||
|
public SerializableGradient _trailGradient;
|
||||||
|
public float _duration;
|
||||||
|
public float _shapeRadius;
|
||||||
|
public float _trailWidthMultiplier;
|
||||||
|
public float _trailTime;
|
||||||
|
public bool _active;
|
||||||
|
public bool _loop;
|
||||||
|
public bool _prewarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class ParticleSystemController : MonoBehaviour {
|
||||||
|
|
||||||
|
public float size = 1;
|
||||||
|
public float speed = 1;
|
||||||
|
public float duration = 1;
|
||||||
|
public bool loop;
|
||||||
|
public bool prewarm;
|
||||||
|
public bool lights;
|
||||||
|
public bool trails;
|
||||||
|
public bool changeColor;
|
||||||
|
public Color newMaxColor = new Color (0,0,0,1);
|
||||||
|
public Color newMinColor = new Color (0,0,0,1);
|
||||||
|
public List<GameObject> ParticleSystems = new List<GameObject>();
|
||||||
|
public List<bool> ActiveParticleSystems = new List<bool>();
|
||||||
|
|
||||||
|
private List<ParticleSystemOriginalSettings> psOriginalSettingsList = new List<ParticleSystemOriginalSettings> ();
|
||||||
|
|
||||||
|
public void UpdateParticleSystem(){
|
||||||
|
//Enables or Disbales Particle Systems you choose in inspector
|
||||||
|
for(int i = 0; i< ParticleSystems.Count; i++){
|
||||||
|
if (ActiveParticleSystems.Count == ParticleSystems.Count) {
|
||||||
|
if (ActiveParticleSystems [i] == true)
|
||||||
|
ParticleSystems [i].SetActive (true);
|
||||||
|
else
|
||||||
|
ParticleSystems [i].SetActive (false);
|
||||||
|
} else {
|
||||||
|
Debug.Log ("Make sure the ActiveParticleSystems list has the same amount as the ParticleSystems list.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ParticleSystems.Count > 0) {
|
||||||
|
for (int i = 0; i < ParticleSystems.Count; i ++) {
|
||||||
|
var ps = ParticleSystems [i].GetComponent<ParticleSystem> ();
|
||||||
|
if (ps != null) {
|
||||||
|
var main = ps.main;
|
||||||
|
var shape = ps.shape;
|
||||||
|
var psLights = ps.lights;
|
||||||
|
var psTrails = ps.trails;
|
||||||
|
var colorOverLifetime = ps.colorOverLifetime;
|
||||||
|
var colorOverLifetimeC = colorOverLifetime.color;
|
||||||
|
var startColor = main.startColor;
|
||||||
|
var startSize = main.startSize;
|
||||||
|
var startSizeX = main.startSizeX;
|
||||||
|
var startSizeY = main.startSizeY;
|
||||||
|
var startSizeZ = main.startSizeZ;
|
||||||
|
var startSpeed = main.startSpeed;
|
||||||
|
var startDelay = main.startDelay;
|
||||||
|
var startLifetime = main.startLifetime;
|
||||||
|
var velocityOverLifetime = ps.velocityOverLifetime;
|
||||||
|
var velocityOverLifetimeX = velocityOverLifetime.x;
|
||||||
|
var velocityOverLifetimeY = velocityOverLifetime.y;
|
||||||
|
var velocityOverLifetimeZ = velocityOverLifetime.z;
|
||||||
|
var localPos = ParticleSystems [i].transform.localPosition;
|
||||||
|
|
||||||
|
//KEEP ORIGINAL VALUES
|
||||||
|
if (!SaveParticleSystemScript.CheckExistingFile (gameObject)) {
|
||||||
|
ParticleSystemOriginalSettings psOriginalSettings = new ParticleSystemOriginalSettings () {
|
||||||
|
_startColor = new SerializableMinMaxGradient (startColor),
|
||||||
|
_colorOverLifetimeC = new SerializableMinMaxGradient (colorOverLifetimeC),
|
||||||
|
_startSize = new SerializableMinMaxCurve (startSize),
|
||||||
|
_startSizeX = new SerializableMinMaxCurve (startSizeX),
|
||||||
|
_startSizeY = new SerializableMinMaxCurve (startSizeY),
|
||||||
|
_startSizeZ = new SerializableMinMaxCurve (startSizeZ),
|
||||||
|
_startSpeed = new SerializableMinMaxCurve (startSpeed),
|
||||||
|
_startDelay = new SerializableMinMaxCurve (startDelay),
|
||||||
|
_startLifetime = new SerializableMinMaxCurve (startLifetime),
|
||||||
|
_velocityOverLifetimeX = new SerializableMinMaxCurve (velocityOverLifetimeX),
|
||||||
|
_velocityOverLifetimeY = new SerializableMinMaxCurve (velocityOverLifetimeY),
|
||||||
|
_velocityOverLifetimeZ = new SerializableMinMaxCurve (velocityOverLifetimeZ),
|
||||||
|
_localPosition = new SerializableVector3 (ParticleSystems [i].transform.localPosition),
|
||||||
|
_duration = main.duration,
|
||||||
|
_shapeRadius = shape.radius,
|
||||||
|
_active = ps.gameObject.activeSelf,
|
||||||
|
_loop = main.loop,
|
||||||
|
_prewarm = main.prewarm
|
||||||
|
};
|
||||||
|
psOriginalSettingsList.Add (psOriginalSettings);
|
||||||
|
} else {
|
||||||
|
List<ParticleSystemOriginalSettings> listOriginalSettings = new List<ParticleSystemOriginalSettings> ();
|
||||||
|
listOriginalSettings = SaveParticleSystemScript.LoadVFX (gameObject);
|
||||||
|
|
||||||
|
startColor = listOriginalSettings [i]._startColor.GetMinMaxGradient();
|
||||||
|
colorOverLifetimeC = listOriginalSettings [i]._colorOverLifetimeC.GetMinMaxGradient();
|
||||||
|
startSize = listOriginalSettings [i]._startSize.GetMinMaxCurve();
|
||||||
|
startSizeX = listOriginalSettings [i]._startSizeX.GetMinMaxCurve();
|
||||||
|
startSizeY = listOriginalSettings [i]._startSizeY.GetMinMaxCurve();
|
||||||
|
startSizeZ = listOriginalSettings [i]._startSizeZ.GetMinMaxCurve();
|
||||||
|
startSpeed = listOriginalSettings [i]._startSpeed.GetMinMaxCurve();
|
||||||
|
startDelay = listOriginalSettings [i]._startDelay.GetMinMaxCurve();
|
||||||
|
startLifetime = listOriginalSettings [i]._startLifetime.GetMinMaxCurve();
|
||||||
|
velocityOverLifetimeX = listOriginalSettings [i]._velocityOverLifetimeX.GetMinMaxCurve ();
|
||||||
|
velocityOverLifetimeY = listOriginalSettings [i]._velocityOverLifetimeY.GetMinMaxCurve ();
|
||||||
|
velocityOverLifetimeZ = listOriginalSettings [i]._velocityOverLifetimeZ.GetMinMaxCurve ();
|
||||||
|
localPos = listOriginalSettings [i]._localPosition.GetVector3();
|
||||||
|
main.duration = listOriginalSettings [i]._duration;
|
||||||
|
shape.radius = listOriginalSettings [i]._shapeRadius;
|
||||||
|
ps.gameObject.SetActive (listOriginalSettings [i]._active);
|
||||||
|
loop = listOriginalSettings [i]._loop;
|
||||||
|
prewarm = listOriginalSettings [i]._prewarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
//LOOP
|
||||||
|
if(!main.loop)
|
||||||
|
main.loop = loop;
|
||||||
|
|
||||||
|
//PREWARM
|
||||||
|
main.prewarm = prewarm;
|
||||||
|
|
||||||
|
//LIGHTS
|
||||||
|
if (!lights && psLights.enabled)
|
||||||
|
psLights.enabled = false;
|
||||||
|
|
||||||
|
//TRAILS
|
||||||
|
if (!trails && psTrails.enabled)
|
||||||
|
psTrails.enabled = false;
|
||||||
|
|
||||||
|
//POSITION
|
||||||
|
if (i > 0) {
|
||||||
|
if (localPos.x != 0 || localPos.y != 0 || localPos.z != 0) {
|
||||||
|
localPos.x *= size;
|
||||||
|
localPos.y *= size;
|
||||||
|
localPos.z *= size;
|
||||||
|
ParticleSystems [i].transform.localPosition = localPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//DURATION
|
||||||
|
if(duration != 1){
|
||||||
|
main.duration *= duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SIZE
|
||||||
|
if (main.startSize3D) {
|
||||||
|
if (startSize.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startSizeX.constantMax *= size;
|
||||||
|
startSizeX.constantMin *= size;
|
||||||
|
|
||||||
|
startSizeY.constantMax *= size;
|
||||||
|
startSizeY.constantMin *= size;
|
||||||
|
|
||||||
|
startSizeZ.constantMax *= size;
|
||||||
|
startSizeZ.constantMin *= size;
|
||||||
|
} else {
|
||||||
|
startSizeX.constant *= size;
|
||||||
|
startSizeY.constant *= size;
|
||||||
|
startSizeZ.constant *= size;
|
||||||
|
}
|
||||||
|
main.startSizeX = startSizeX;
|
||||||
|
main.startSizeY = startSizeY;
|
||||||
|
main.startSizeZ = startSizeZ;
|
||||||
|
} else {
|
||||||
|
if (startSize.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startSize.constantMax *= size;
|
||||||
|
startSize.constantMin *= size;
|
||||||
|
} else {
|
||||||
|
startSize.constant *= size;
|
||||||
|
}
|
||||||
|
main.startSize = startSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
//START_SPEED (affected by size)
|
||||||
|
if (startSpeed.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startSpeed.constantMax *= size;
|
||||||
|
startSpeed.constantMin *= size;
|
||||||
|
main.startSpeed = startSpeed;
|
||||||
|
} else {
|
||||||
|
startSpeed.constant *= size;
|
||||||
|
main.startSpeed = startSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//START_SPEED (affected by speed)
|
||||||
|
if (startSpeed.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startSpeed.constantMax *= speed;
|
||||||
|
startSpeed.constantMin *= speed;
|
||||||
|
main.startSpeed = startSpeed;
|
||||||
|
} else {
|
||||||
|
startSpeed.constant *= speed;
|
||||||
|
main.startSpeed = startSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//LIFETIME
|
||||||
|
if (main.startLifetime.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startLifetime.constantMax *= 1 / speed;
|
||||||
|
startLifetime.constantMin *= 1 / speed;
|
||||||
|
main.startLifetime = startLifetime;
|
||||||
|
} else {
|
||||||
|
startLifetime.constant *= 1 / speed;
|
||||||
|
main.startLifetime = startLifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
//START_DELAY
|
||||||
|
if (startDelay.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startDelay.constantMax *= 1 / speed;
|
||||||
|
startDelay.constantMin *= 1 / speed;
|
||||||
|
main.startDelay = startDelay;
|
||||||
|
} else {
|
||||||
|
startDelay.constant *= 1 / speed;
|
||||||
|
main.startDelay = startDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
//VELOCITY OVERLIFETIME
|
||||||
|
if(velocityOverLifetime.enabled){
|
||||||
|
float amount = 1;
|
||||||
|
if(size != 1)
|
||||||
|
amount = size;
|
||||||
|
if(speed != 1)
|
||||||
|
amount = speed;
|
||||||
|
if(size != 1 && speed != 1)
|
||||||
|
amount = (size + speed)/2;
|
||||||
|
|
||||||
|
if (velocityOverLifetime.x.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
velocityOverLifetimeX.constantMax *= amount;
|
||||||
|
velocityOverLifetimeX.constantMin *= amount;
|
||||||
|
|
||||||
|
velocityOverLifetimeY.constantMax *= amount;
|
||||||
|
velocityOverLifetimeY.constantMin *= amount;
|
||||||
|
|
||||||
|
velocityOverLifetimeZ.constantMax *= amount;
|
||||||
|
velocityOverLifetimeZ.constantMin *= amount;
|
||||||
|
} else {
|
||||||
|
velocityOverLifetimeX.constant *= amount;
|
||||||
|
velocityOverLifetimeY.constant *= amount;
|
||||||
|
velocityOverLifetimeZ.constant *= amount;
|
||||||
|
}
|
||||||
|
velocityOverLifetime.x = velocityOverLifetimeX;
|
||||||
|
velocityOverLifetime.y = velocityOverLifetimeY;
|
||||||
|
velocityOverLifetime.z = velocityOverLifetimeZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//RADIUS
|
||||||
|
if (shape.enabled) {
|
||||||
|
shape.radius *= size;
|
||||||
|
}
|
||||||
|
|
||||||
|
//COLOR
|
||||||
|
if (changeColor) {
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.Color) {
|
||||||
|
startColor.color = ChangeHUE (startColor.color, newMaxColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.TwoColors) {
|
||||||
|
startColor.colorMax = ChangeHUE (startColor.colorMax, newMaxColor);
|
||||||
|
startColor.colorMin = ChangeHUE (startColor.colorMin, newMinColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.Gradient) {
|
||||||
|
startColor.gradient = ChangeGradientColor (startColor.gradient, newMaxColor, newMinColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.TwoGradients) {
|
||||||
|
startColor.gradientMax = ChangeGradientColor (startColor.gradientMax, newMaxColor, newMinColor);
|
||||||
|
startColor.gradientMin = ChangeGradientColor (startColor.gradientMin, newMinColor, newMaxColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//COLOR OVERLIFETIME
|
||||||
|
if (colorOverLifetime.enabled) {
|
||||||
|
if (colorOverLifetime.color.mode == ParticleSystemGradientMode.Gradient) {
|
||||||
|
colorOverLifetimeC.gradient = ChangeGradientColor (colorOverLifetimeC.gradient, newMaxColor, newMinColor);
|
||||||
|
}
|
||||||
|
if (colorOverLifetime.color.mode == ParticleSystemGradientMode.TwoGradients) {
|
||||||
|
colorOverLifetimeC.gradientMax = ChangeGradientColor (colorOverLifetimeC.gradientMax, newMaxColor, newMinColor);
|
||||||
|
colorOverLifetimeC.gradientMin = ChangeGradientColor (colorOverLifetimeC.gradientMin, newMinColor, newMaxColor);
|
||||||
|
}
|
||||||
|
colorOverLifetime.color = colorOverLifetimeC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//TRAIL RENDERER
|
||||||
|
var trail = ParticleSystems [i].GetComponent<TrailRenderer> ();
|
||||||
|
if (trail != null) {
|
||||||
|
if (!SaveParticleSystemScript.CheckExistingFile (gameObject)) {
|
||||||
|
ParticleSystemOriginalSettings psOriginalSettings = new ParticleSystemOriginalSettings {
|
||||||
|
_trailGradient = new SerializableGradient (trail.colorGradient),
|
||||||
|
_localPosition = new SerializableVector3 (trail.transform.localPosition),
|
||||||
|
_trailWidthMultiplier = trail.widthMultiplier,
|
||||||
|
_trailTime = trail.time
|
||||||
|
};
|
||||||
|
psOriginalSettingsList.Add (psOriginalSettings);
|
||||||
|
} else {
|
||||||
|
List<ParticleSystemOriginalSettings> listOriginalSettings = new List<ParticleSystemOriginalSettings> ();
|
||||||
|
listOriginalSettings = SaveParticleSystemScript.LoadVFX (gameObject);
|
||||||
|
|
||||||
|
trail.colorGradient = listOriginalSettings [i]._trailGradient.GetGradient();
|
||||||
|
trail.transform.localPosition = listOriginalSettings [i]._localPosition.GetVector3 ();
|
||||||
|
trail.widthMultiplier = listOriginalSettings [i]._trailWidthMultiplier;
|
||||||
|
trail.time = listOriginalSettings [i]._trailTime;
|
||||||
|
}
|
||||||
|
trail.colorGradient = ChangeGradientColor (trail.colorGradient, newMaxColor, newMinColor);
|
||||||
|
trail.widthMultiplier *= size;
|
||||||
|
|
||||||
|
float amount = 1;
|
||||||
|
if(size != 1)
|
||||||
|
amount = size;
|
||||||
|
if(speed != 1)
|
||||||
|
amount = speed;
|
||||||
|
if(size != 1 && speed != 1)
|
||||||
|
amount = (size + speed)/2;
|
||||||
|
if(amount > 1)
|
||||||
|
trail.time *= 1 / amount;
|
||||||
|
else
|
||||||
|
trail.time *= amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!SaveParticleSystemScript.CheckExistingFile (gameObject)) {
|
||||||
|
SaveParticleSystemScript.SaveVFX (gameObject, psOriginalSettingsList);
|
||||||
|
}
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SaveParticleSystemScript.SaveNestedPrefab(gameObject);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Debug.Log("No Particle Systems added to the Particle Systems list");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeColorOnly () {
|
||||||
|
if (ParticleSystems.Count == 0) {
|
||||||
|
FillLists ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ParticleSystems.Count > 0) {
|
||||||
|
for (int i = 0; i < ParticleSystems.Count; i++) {
|
||||||
|
var ps = ParticleSystems [i].GetComponent<ParticleSystem> ();
|
||||||
|
if (ps != null) {
|
||||||
|
var main = ps.main;
|
||||||
|
var colorOverLifetime = ps.colorOverLifetime;
|
||||||
|
var colorOverLifetimeC = colorOverLifetime.color;
|
||||||
|
var startColor = main.startColor;
|
||||||
|
//COLOR
|
||||||
|
if (changeColor) {
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.Color) {
|
||||||
|
startColor.color = ChangeHUE (startColor.color, newMaxColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.TwoColors) {
|
||||||
|
startColor.colorMax = ChangeHUE (startColor.colorMax, newMaxColor);
|
||||||
|
startColor.colorMin = ChangeHUE (startColor.colorMin, newMinColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.Gradient) {
|
||||||
|
startColor.gradient = ChangeGradientColor (startColor.gradient, newMaxColor, newMinColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
if (main.startColor.mode == ParticleSystemGradientMode.TwoGradients) {
|
||||||
|
startColor.gradientMax = ChangeGradientColor (startColor.gradientMax, newMaxColor, newMinColor);
|
||||||
|
startColor.gradientMin = ChangeGradientColor (startColor.gradientMin, newMinColor, newMaxColor);
|
||||||
|
main.startColor = startColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//COLOR OVERLIFETIME
|
||||||
|
if (colorOverLifetime.enabled) {
|
||||||
|
if (colorOverLifetime.color.mode == ParticleSystemGradientMode.Gradient) {
|
||||||
|
colorOverLifetimeC.gradient = ChangeGradientColor (colorOverLifetimeC.gradient, newMaxColor, newMinColor);
|
||||||
|
}
|
||||||
|
if (colorOverLifetime.color.mode == ParticleSystemGradientMode.TwoGradients) {
|
||||||
|
colorOverLifetimeC.gradientMax = ChangeGradientColor (colorOverLifetimeC.gradientMax, newMaxColor, newMinColor);
|
||||||
|
colorOverLifetimeC.gradientMin = ChangeGradientColor (colorOverLifetimeC.gradientMin, newMinColor, newMaxColor);
|
||||||
|
}
|
||||||
|
colorOverLifetime.color = colorOverLifetimeC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//TRAIL RENDERER
|
||||||
|
var trail = ParticleSystems [i].GetComponent<TrailRenderer> ();
|
||||||
|
if (trail != null) {
|
||||||
|
if (!SaveParticleSystemScript.CheckExistingFile (gameObject)) {
|
||||||
|
ParticleSystemOriginalSettings psOriginalSettings = new ParticleSystemOriginalSettings {
|
||||||
|
_trailGradient = new SerializableGradient (trail.colorGradient),
|
||||||
|
_localPosition = new SerializableVector3 (trail.transform.localPosition),
|
||||||
|
_trailWidthMultiplier = trail.widthMultiplier,
|
||||||
|
_trailTime = trail.time
|
||||||
|
};
|
||||||
|
psOriginalSettingsList.Add (psOriginalSettings);
|
||||||
|
} else {
|
||||||
|
List<ParticleSystemOriginalSettings> listOriginalSettings = new List<ParticleSystemOriginalSettings> ();
|
||||||
|
listOriginalSettings = SaveParticleSystemScript.LoadVFX (gameObject);
|
||||||
|
|
||||||
|
trail.colorGradient = listOriginalSettings [i]._trailGradient.GetGradient ();
|
||||||
|
trail.transform.localPosition = listOriginalSettings [i]._localPosition.GetVector3 ();
|
||||||
|
trail.widthMultiplier = listOriginalSettings [i]._trailWidthMultiplier;
|
||||||
|
trail.time = listOriginalSettings [i]._trailTime;
|
||||||
|
}
|
||||||
|
trail.colorGradient = ChangeGradientColor (trail.colorGradient, newMaxColor, newMinColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResizeOnly () {
|
||||||
|
if (ParticleSystems.Count == 0) {
|
||||||
|
FillLists ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ParticleSystems.Count > 0) {
|
||||||
|
for (int i = 0; i < ParticleSystems.Count; i ++) {
|
||||||
|
var ps = ParticleSystems [i].GetComponent<ParticleSystem> ();
|
||||||
|
if (ps != null) {
|
||||||
|
var main = ps.main;
|
||||||
|
var shape = ps.shape;
|
||||||
|
var startSize = main.startSize;
|
||||||
|
var startSizeX = main.startSizeX;
|
||||||
|
var startSizeY = main.startSizeY;
|
||||||
|
var startSizeZ = main.startSizeZ;
|
||||||
|
var startSpeed = main.startSpeed;
|
||||||
|
var velocityOverLifetime = ps.velocityOverLifetime;
|
||||||
|
var velocityOverLifetimeX = velocityOverLifetime.x;
|
||||||
|
var velocityOverLifetimeY = velocityOverLifetime.y;
|
||||||
|
var velocityOverLifetimeZ = velocityOverLifetime.z;
|
||||||
|
var localPos = ParticleSystems [i].transform.localPosition;
|
||||||
|
|
||||||
|
//POSITION
|
||||||
|
if (i > 0) {
|
||||||
|
if (localPos.x != 0 || localPos.y != 0 || localPos.z != 0) {
|
||||||
|
localPos.x *= size;
|
||||||
|
localPos.y *= size;
|
||||||
|
localPos.z *= size;
|
||||||
|
ParticleSystems [i].transform.localPosition = localPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//SIZE
|
||||||
|
if (main.startSize3D) {
|
||||||
|
if (startSize.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startSizeX.constantMax *= size;
|
||||||
|
startSizeX.constantMin *= size;
|
||||||
|
|
||||||
|
startSizeY.constantMax *= size;
|
||||||
|
startSizeY.constantMin *= size;
|
||||||
|
|
||||||
|
startSizeZ.constantMax *= size;
|
||||||
|
startSizeZ.constantMin *= size;
|
||||||
|
} else {
|
||||||
|
startSizeX.constant *= size;
|
||||||
|
startSizeY.constant *= size;
|
||||||
|
startSizeZ.constant *= size;
|
||||||
|
}
|
||||||
|
main.startSizeX = startSizeX;
|
||||||
|
main.startSizeY = startSizeY;
|
||||||
|
main.startSizeZ = startSizeZ;
|
||||||
|
} else {
|
||||||
|
if (startSize.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startSize.constantMax *= size;
|
||||||
|
startSize.constantMin *= size;
|
||||||
|
} else {
|
||||||
|
startSize.constant *= size;
|
||||||
|
}
|
||||||
|
main.startSize = startSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
//START_SPEED (affected by size)
|
||||||
|
if (startSpeed.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
startSpeed.constantMax *= size;
|
||||||
|
startSpeed.constantMin *= size;
|
||||||
|
main.startSpeed = startSpeed;
|
||||||
|
} else {
|
||||||
|
startSpeed.constant *= size;
|
||||||
|
main.startSpeed = startSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//VELOCITY OVERLIFETIME
|
||||||
|
if(velocityOverLifetime.enabled){
|
||||||
|
float amount = 1;
|
||||||
|
if(size != 1)
|
||||||
|
amount = size;
|
||||||
|
if(speed != 1)
|
||||||
|
amount = speed;
|
||||||
|
if(size != 1 && speed != 1)
|
||||||
|
amount = (size + speed)/2;
|
||||||
|
|
||||||
|
if (velocityOverLifetime.x.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
velocityOverLifetimeX.constantMax *= amount;
|
||||||
|
velocityOverLifetimeX.constantMin *= amount;
|
||||||
|
|
||||||
|
velocityOverLifetimeY.constantMax *= amount;
|
||||||
|
velocityOverLifetimeY.constantMin *= amount;
|
||||||
|
|
||||||
|
velocityOverLifetimeZ.constantMax *= amount;
|
||||||
|
velocityOverLifetimeZ.constantMin *= amount;
|
||||||
|
} else {
|
||||||
|
velocityOverLifetimeX.constant *= amount;
|
||||||
|
velocityOverLifetimeY.constant *= amount;
|
||||||
|
velocityOverLifetimeZ.constant *= amount;
|
||||||
|
}
|
||||||
|
velocityOverLifetime.x = velocityOverLifetimeX;
|
||||||
|
velocityOverLifetime.y = velocityOverLifetimeY;
|
||||||
|
velocityOverLifetime.z = velocityOverLifetimeZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//RADIUS
|
||||||
|
if (shape.enabled) {
|
||||||
|
shape.radius *= size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//TRAIL RENDERER
|
||||||
|
var trail = ParticleSystems [i].GetComponent<TrailRenderer> ();
|
||||||
|
if (trail != null) {
|
||||||
|
trail.widthMultiplier *= size;
|
||||||
|
|
||||||
|
float amount = 1;
|
||||||
|
if(size != 1)
|
||||||
|
amount = size;
|
||||||
|
if(speed != 1)
|
||||||
|
amount = speed;
|
||||||
|
if(size != 1 && speed != 1)
|
||||||
|
amount = (size + speed)/2;
|
||||||
|
if(amount > 1)
|
||||||
|
trail.time *= 1 / amount;
|
||||||
|
else
|
||||||
|
trail.time *= amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetParticleSystem (){
|
||||||
|
|
||||||
|
List<ParticleSystemOriginalSettings> listOriginalSettings = new List<ParticleSystemOriginalSettings> ();
|
||||||
|
listOriginalSettings = SaveParticleSystemScript.LoadVFX (gameObject);
|
||||||
|
|
||||||
|
if (listOriginalSettings != null) {
|
||||||
|
for (int i = 0; i < ParticleSystems.Count; i++) {
|
||||||
|
var ps = ParticleSystems [i].GetComponent<ParticleSystem> ();
|
||||||
|
if (ps != null) {
|
||||||
|
var main = ps.main;
|
||||||
|
var shape = ps.shape;
|
||||||
|
var colorOverLifetime = ps.colorOverLifetime;
|
||||||
|
var velocityOverLifetime = ps.velocityOverLifetime;
|
||||||
|
main.startColor = listOriginalSettings [i]._startColor.GetMinMaxGradient ();
|
||||||
|
colorOverLifetime.color = listOriginalSettings [i]._colorOverLifetimeC.GetMinMaxGradient ();
|
||||||
|
main.startSize = listOriginalSettings [i]._startSize.GetMinMaxCurve ();
|
||||||
|
main.startSizeX = listOriginalSettings [i]._startSizeX.GetMinMaxCurve ();
|
||||||
|
main.startSizeY = listOriginalSettings [i]._startSizeY.GetMinMaxCurve ();
|
||||||
|
main.startSizeZ = listOriginalSettings [i]._startSizeZ.GetMinMaxCurve ();
|
||||||
|
main.startSpeed = listOriginalSettings [i]._startSpeed.GetMinMaxCurve ();
|
||||||
|
main.startDelay = listOriginalSettings [i]._startDelay.GetMinMaxCurve ();
|
||||||
|
main.startLifetime = listOriginalSettings [i]._startLifetime.GetMinMaxCurve ();
|
||||||
|
velocityOverLifetime.x = listOriginalSettings [i]._velocityOverLifetimeX.GetMinMaxCurve ();
|
||||||
|
velocityOverLifetime.y = listOriginalSettings [i]._velocityOverLifetimeY.GetMinMaxCurve ();
|
||||||
|
velocityOverLifetime.z = listOriginalSettings [i]._velocityOverLifetimeZ.GetMinMaxCurve ();
|
||||||
|
ParticleSystems [i].transform.localPosition = listOriginalSettings [i]._localPosition.GetVector3 ();
|
||||||
|
main.duration = listOriginalSettings [i]._duration;
|
||||||
|
shape.radius = listOriginalSettings [i]._shapeRadius;
|
||||||
|
ps.gameObject.SetActive (listOriginalSettings [i]._active);
|
||||||
|
main.loop = listOriginalSettings [i]._loop;
|
||||||
|
main.prewarm = listOriginalSettings [i]._prewarm;
|
||||||
|
} else {
|
||||||
|
var trail = ParticleSystems [i].GetComponent<TrailRenderer> ();
|
||||||
|
if (trail != null) {
|
||||||
|
trail.colorGradient = listOriginalSettings [i]._trailGradient.GetGradient ();
|
||||||
|
trail.widthMultiplier = listOriginalSettings [i]._trailWidthMultiplier;
|
||||||
|
trail.time = listOriginalSettings [i]._trailTime;
|
||||||
|
ParticleSystems [i].transform.localPosition = listOriginalSettings [i]._localPosition.GetVector3 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
SaveParticleSystemScript.SaveNestedPrefab(gameObject);
|
||||||
|
#endif
|
||||||
|
Debug.Log ( gameObject.name + " reseted to default.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color ChangeHUE (Color oldColor, Color newColor){
|
||||||
|
float newHue;
|
||||||
|
float newSaturation;
|
||||||
|
float newValue;
|
||||||
|
float oldHue;
|
||||||
|
float oldSaturation;
|
||||||
|
float oldValue;
|
||||||
|
float originalAlpha = oldColor.a;
|
||||||
|
Color.RGBToHSV (newColor, out newHue, out newSaturation, out newValue);
|
||||||
|
Color.RGBToHSV (oldColor, out oldHue, out oldSaturation, out oldValue);
|
||||||
|
var updatedColor = Color.HSVToRGB (newHue, oldSaturation, oldValue);
|
||||||
|
updatedColor.a = originalAlpha;
|
||||||
|
return updatedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gradient ChangeGradientColor (Gradient oldGradient, Color newMaxColor, Color newMinColor){
|
||||||
|
GradientColorKey[] colorKeys = new GradientColorKey[oldGradient.colorKeys.Length];
|
||||||
|
for(int j = 0; j < oldGradient.colorKeys.Length; j++){
|
||||||
|
colorKeys [j].time = oldGradient.colorKeys [j].time;
|
||||||
|
if(j%2 == 0)
|
||||||
|
colorKeys [j].color = ChangeHUE (oldGradient.colorKeys[j].color, newMaxColor);
|
||||||
|
if(j%2 == 1)
|
||||||
|
colorKeys [j].color = ChangeHUE (oldGradient.colorKeys[j].color, newMinColor);
|
||||||
|
}
|
||||||
|
oldGradient.SetKeys (colorKeys, oldGradient.alphaKeys);
|
||||||
|
return oldGradient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FillLists (){
|
||||||
|
if (ParticleSystems.Count == 0) {
|
||||||
|
var ps = GetComponent<ParticleSystem> ();
|
||||||
|
var trail = GetComponent<TrailRenderer> ();
|
||||||
|
if (ps != null || trail != null)
|
||||||
|
ParticleSystems.Add (gameObject);
|
||||||
|
|
||||||
|
AddChildRecurvsively (transform);
|
||||||
|
|
||||||
|
for (int i = 0; i < ParticleSystems.Count; i++) {
|
||||||
|
ActiveParticleSystems.Add (true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Debug.Log ("Lists already have GameObjects. For automatic filling consider emptying the lists and try again.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EmptyLists (){
|
||||||
|
ParticleSystems.Clear();
|
||||||
|
ActiveParticleSystems.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddChildRecurvsively (Transform transf){
|
||||||
|
foreach (Transform t in transf) {
|
||||||
|
var child = t.gameObject;
|
||||||
|
var psChild = child.GetComponent<ParticleSystem> ();
|
||||||
|
var trailChild = child.GetComponent<TrailRenderer> ();
|
||||||
|
if (psChild != null || trailChild != null)
|
||||||
|
ParticleSystems.Add (child);
|
||||||
|
if (child.transform.childCount > 0)
|
||||||
|
AddChildRecurvsively (child.transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b9e272d634f40434b85fbf756732714d
|
||||||
|
timeCreated: 1519590398
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,37 @@
|
|||||||
|
namespace GAP_ParticleSystemController{
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
[CustomEditor(typeof(ParticleSystemController))]
|
||||||
|
public class ParticleSystemControllerEditor : Editor
|
||||||
|
{
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
DrawDefaultInspector();
|
||||||
|
|
||||||
|
ParticleSystemController psCtrl = (ParticleSystemController)target;
|
||||||
|
|
||||||
|
if (GUILayout.Button ("Fill Lists"))
|
||||||
|
{
|
||||||
|
psCtrl.FillLists ();
|
||||||
|
}
|
||||||
|
if (GUILayout.Button ("Empty Lists"))
|
||||||
|
{
|
||||||
|
psCtrl.EmptyLists ();
|
||||||
|
}
|
||||||
|
if(GUILayout.Button("Apply"))
|
||||||
|
{
|
||||||
|
psCtrl.UpdateParticleSystem();
|
||||||
|
}
|
||||||
|
if(GUILayout.Button("Reset"))
|
||||||
|
{
|
||||||
|
psCtrl.ResetParticleSystem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 45d4e8a998e88754d8ce3fc6827b2912
|
||||||
|
timeCreated: 1523291927
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,110 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace GAP_ParticleSystemController
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class SaveParticleSystemScript{
|
||||||
|
|
||||||
|
public static void SaveVFX (GameObject prefabVFX, List<ParticleSystemOriginalSettings> psOriginalSettingsList) {
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
var prefabFolderPath = GetPrefabFolder2018_3 (prefabVFX);
|
||||||
|
#else
|
||||||
|
var prefabFolderPath = GetPrefabFolder (prefabVFX);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Directory.Exists (prefabFolderPath + "/OriginalSettings")) {
|
||||||
|
UnityEditor.AssetDatabase.CreateFolder (prefabFolderPath, "OriginalSettings");
|
||||||
|
Debug.Log ("Created folder: " + prefabFolderPath + "/OriginalSettings");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
BinaryFormatter bf = new BinaryFormatter ();
|
||||||
|
FileStream stream = new FileStream (prefabFolderPath + "/OriginalSettings/" + prefabVFX.name + ".dat", FileMode.Create);
|
||||||
|
|
||||||
|
bf.Serialize (stream, psOriginalSettingsList);
|
||||||
|
stream.Close ();
|
||||||
|
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
SaveNestedPrefab(prefabVFX);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Debug.Log ("Original Settings of '" + prefabVFX.name + "' saved to: " + prefabFolderPath + "/OriginalSettings");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ParticleSystemOriginalSettings> LoadVFX (GameObject prefabVFX) {
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
var prefabFolderPath = GetPrefabFolder2018_3 (prefabVFX);
|
||||||
|
#else
|
||||||
|
var prefabFolderPath = GetPrefabFolder(prefabVFX);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (File.Exists (prefabFolderPath + "/OriginalSettings/" + prefabVFX.name + ".dat")) {
|
||||||
|
BinaryFormatter bf = new BinaryFormatter ();
|
||||||
|
FileStream stream = new FileStream (prefabFolderPath + "/OriginalSettings/" + prefabVFX.name + ".dat", FileMode.Open);
|
||||||
|
|
||||||
|
List<ParticleSystemOriginalSettings> originalSettingsList = new List<ParticleSystemOriginalSettings> ();
|
||||||
|
originalSettingsList = bf.Deserialize (stream) as List<ParticleSystemOriginalSettings>;
|
||||||
|
|
||||||
|
stream.Close ();
|
||||||
|
return originalSettingsList;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Debug.Log ("No saved VFX data found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckExistingFile (GameObject prefabVFX){
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
var prefabFolderPath = GetPrefabFolder2018_3 (prefabVFX);
|
||||||
|
#else
|
||||||
|
var prefabFolderPath = GetPrefabFolder(prefabVFX);
|
||||||
|
#endif
|
||||||
|
if (prefabFolderPath != null) {
|
||||||
|
if (File.Exists (prefabFolderPath + "/OriginalSettings/" + prefabVFX.name + ".dat"))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetPrefabFolder (GameObject prefabVFX){
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
string prefabPath = UnityEditor.AssetDatabase.GetAssetPath (prefabVFX);
|
||||||
|
string prefabFolderPath = Path.GetDirectoryName (prefabPath);
|
||||||
|
return prefabFolderPath;
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
static string GetPrefabFolder2018_3 (GameObject prefabVFX)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
string prefabPath = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(prefabVFX).prefabAssetPath;
|
||||||
|
string prefabFolderPath = Path.GetDirectoryName (prefabPath);
|
||||||
|
return prefabFolderPath;
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
public static void SaveNestedPrefab(GameObject prefab)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(prefab);
|
||||||
|
UnityEditor.PrefabUtility.SaveAsPrefabAsset(prefabStage.prefabContentsRoot, prefabStage.prefabAssetPath);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ebcd90b1eae99d848ad993f40990f336
|
||||||
|
timeCreated: 1532255172
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,473 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GAP_ParticleSystemController{
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableMinMaxGradient{
|
||||||
|
public SerializableColor color;
|
||||||
|
public SerializableColor colorMax;
|
||||||
|
public SerializableColor colorMin;
|
||||||
|
public SerializableAlphaKeys gradientAlphaKeys;
|
||||||
|
public SerializableColorKeys gradientColorKeys;
|
||||||
|
public SerializableAlphaKeys gradientMaxAlphaKeys;
|
||||||
|
public SerializableColorKeys gradientMaxColorKeys;
|
||||||
|
public SerializableAlphaKeys gradientMinAlphaKeys;
|
||||||
|
public SerializableColorKeys gradientMinColorKeys;
|
||||||
|
public SerializablePSGradientMode gradientMode;
|
||||||
|
|
||||||
|
public SerializableMinMaxGradient (ParticleSystem.MinMaxGradient minMaxGradient){
|
||||||
|
|
||||||
|
gradientMode = new SerializablePSGradientMode (minMaxGradient.mode);
|
||||||
|
|
||||||
|
if (minMaxGradient.mode == ParticleSystemGradientMode.Color)
|
||||||
|
color = new SerializableColor (minMaxGradient.color);
|
||||||
|
|
||||||
|
if (minMaxGradient.mode == ParticleSystemGradientMode.TwoColors) {
|
||||||
|
colorMax = new SerializableColor (minMaxGradient.colorMax);
|
||||||
|
colorMin = new SerializableColor (minMaxGradient.colorMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minMaxGradient.mode == ParticleSystemGradientMode.Gradient) {
|
||||||
|
gradientAlphaKeys = new SerializableAlphaKeys (minMaxGradient.gradient.alphaKeys);
|
||||||
|
gradientColorKeys = new SerializableColorKeys (minMaxGradient.gradient.colorKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minMaxGradient.mode == ParticleSystemGradientMode.TwoGradients) {
|
||||||
|
gradientMaxAlphaKeys = new SerializableAlphaKeys (minMaxGradient.gradientMax.alphaKeys);
|
||||||
|
gradientMaxColorKeys = new SerializableColorKeys (minMaxGradient.gradientMax.colorKeys);
|
||||||
|
gradientMinAlphaKeys = new SerializableAlphaKeys (minMaxGradient.gradientMin.alphaKeys);
|
||||||
|
gradientMinColorKeys = new SerializableColorKeys (minMaxGradient.gradientMin.colorKeys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticleSystem.MinMaxGradient GetMinMaxGradient (){
|
||||||
|
ParticleSystem.MinMaxGradient minMaxGradient = new ParticleSystem.MinMaxGradient ();
|
||||||
|
if (gradientMode.GetGradientMode () == ParticleSystemGradientMode.Color) {
|
||||||
|
if (minMaxGradient.color == null)
|
||||||
|
minMaxGradient.color = new Color ();
|
||||||
|
minMaxGradient.color = color.GetColor ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gradientMode.GetGradientMode() == ParticleSystemGradientMode.TwoColors) {
|
||||||
|
if (minMaxGradient.colorMax == null)
|
||||||
|
minMaxGradient.colorMax = new Color ();
|
||||||
|
minMaxGradient.colorMax = colorMax.GetColor ();
|
||||||
|
|
||||||
|
if (minMaxGradient.colorMin == null)
|
||||||
|
minMaxGradient.colorMin = new Color ();
|
||||||
|
minMaxGradient.colorMin = colorMin.GetColor ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gradientMode.GetGradientMode() == ParticleSystemGradientMode.Gradient) {
|
||||||
|
if (minMaxGradient.gradient == null)
|
||||||
|
minMaxGradient.gradient = new Gradient ();
|
||||||
|
minMaxGradient.gradient.alphaKeys = gradientAlphaKeys.GetAlphaKeys ();
|
||||||
|
minMaxGradient.gradient.colorKeys = gradientColorKeys.GetColorKeys ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gradientMode.GetGradientMode() == ParticleSystemGradientMode.TwoGradients) {
|
||||||
|
if (minMaxGradient.gradientMax == null)
|
||||||
|
minMaxGradient.gradientMax = new Gradient ();
|
||||||
|
minMaxGradient.gradientMax.alphaKeys = gradientMaxAlphaKeys.GetAlphaKeys ();
|
||||||
|
minMaxGradient.gradientMax.colorKeys = gradientMaxColorKeys.GetColorKeys ();
|
||||||
|
|
||||||
|
if (minMaxGradient.gradientMin == null)
|
||||||
|
minMaxGradient.gradientMin = new Gradient ();
|
||||||
|
minMaxGradient.gradientMin.alphaKeys = gradientMinAlphaKeys.GetAlphaKeys ();
|
||||||
|
minMaxGradient.gradientMin.colorKeys = gradientMinColorKeys.GetColorKeys ();
|
||||||
|
}
|
||||||
|
|
||||||
|
minMaxGradient.mode = gradientMode.GetGradientMode ();
|
||||||
|
|
||||||
|
return minMaxGradient;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableMinMaxCurve{
|
||||||
|
public float constant;
|
||||||
|
public float constantMax;
|
||||||
|
public float constantMin;
|
||||||
|
public SerializableAnimationCurve curve;
|
||||||
|
public SerializableAnimationCurve curveMax;
|
||||||
|
public SerializableAnimationCurve curveMin;
|
||||||
|
public float curveMultiplier;
|
||||||
|
public SerializablePSCurveMode curveMode;
|
||||||
|
|
||||||
|
public SerializableMinMaxCurve (ParticleSystem.MinMaxCurve minMaxCurve){
|
||||||
|
|
||||||
|
curveMode = new SerializablePSCurveMode (minMaxCurve.mode);
|
||||||
|
|
||||||
|
if (minMaxCurve.mode == ParticleSystemCurveMode.Constant)
|
||||||
|
constant = minMaxCurve.constant;
|
||||||
|
|
||||||
|
if (minMaxCurve.mode == ParticleSystemCurveMode.Curve)
|
||||||
|
curve = new SerializableAnimationCurve (minMaxCurve.curve);
|
||||||
|
|
||||||
|
if (minMaxCurve.mode == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
constantMax = minMaxCurve.constantMax;
|
||||||
|
constantMin = minMaxCurve.constantMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minMaxCurve.mode == ParticleSystemCurveMode.TwoCurves) {
|
||||||
|
curveMax = new SerializableAnimationCurve (minMaxCurve.curveMax);
|
||||||
|
curveMin = new SerializableAnimationCurve (minMaxCurve.curve);
|
||||||
|
}
|
||||||
|
|
||||||
|
curveMultiplier = minMaxCurve.curveMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticleSystem.MinMaxCurve GetMinMaxCurve (){
|
||||||
|
ParticleSystem.MinMaxCurve minMaxCurve = new ParticleSystem.MinMaxCurve ();
|
||||||
|
|
||||||
|
if (curveMode.GetCurveMode() == ParticleSystemCurveMode.Constant)
|
||||||
|
minMaxCurve.constant = constant;
|
||||||
|
|
||||||
|
if (curveMode.GetCurveMode() == ParticleSystemCurveMode.TwoConstants) {
|
||||||
|
minMaxCurve.constantMax = constantMax;
|
||||||
|
minMaxCurve.constantMin = constantMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curveMode.GetCurveMode () == ParticleSystemCurveMode.Curve) {
|
||||||
|
if (minMaxCurve.curve == null)
|
||||||
|
minMaxCurve.curve = new AnimationCurve ();
|
||||||
|
minMaxCurve.curve = curve.GetAnimationCurve ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curveMode.GetCurveMode() == ParticleSystemCurveMode.TwoCurves) {
|
||||||
|
if (minMaxCurve.curveMax == null)
|
||||||
|
minMaxCurve.curveMax = new AnimationCurve ();
|
||||||
|
minMaxCurve.curveMax = curveMax.GetAnimationCurve();
|
||||||
|
|
||||||
|
if (minMaxCurve.curveMin == null)
|
||||||
|
minMaxCurve.curveMin = new AnimationCurve ();
|
||||||
|
minMaxCurve.curveMin = curveMin.GetAnimationCurve();
|
||||||
|
}
|
||||||
|
|
||||||
|
minMaxCurve.curveMultiplier = curveMultiplier;
|
||||||
|
minMaxCurve.mode = curveMode.GetCurveMode ();
|
||||||
|
|
||||||
|
return minMaxCurve;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableAnimationCurve {
|
||||||
|
public SerializableKeyFrames[] keys;
|
||||||
|
public SerializableWrapMode postWrapMode;
|
||||||
|
public SerializableWrapMode preWrapMode;
|
||||||
|
|
||||||
|
public SerializableAnimationCurve (AnimationCurve animCurve){
|
||||||
|
SerializableKeyFrames[] keys_ = new SerializableKeyFrames[animCurve.keys.Length];
|
||||||
|
for (int i = 0; i < animCurve.length; i++) {
|
||||||
|
keys_[i] = new SerializableKeyFrames (animCurve.keys[i]);
|
||||||
|
}
|
||||||
|
keys = keys_;
|
||||||
|
postWrapMode = new SerializableWrapMode(animCurve.postWrapMode);
|
||||||
|
preWrapMode = new SerializableWrapMode(animCurve.preWrapMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnimationCurve GetAnimationCurve (){
|
||||||
|
AnimationCurve animCurv = new AnimationCurve ();
|
||||||
|
animCurv.keys = new Keyframe[keys.Length];
|
||||||
|
for(int i = 0; i < keys.Length; i++){
|
||||||
|
animCurv.keys[i] = keys[i].GetKeyFrames();
|
||||||
|
}
|
||||||
|
animCurv.postWrapMode = postWrapMode.GetWrapMode();
|
||||||
|
animCurv.preWrapMode = preWrapMode.GetWrapMode();
|
||||||
|
|
||||||
|
return animCurv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableKeyFrames{
|
||||||
|
public float inTangent;
|
||||||
|
public float outTangent;
|
||||||
|
public int tangentMode;
|
||||||
|
public float time;
|
||||||
|
public float value;
|
||||||
|
|
||||||
|
public SerializableKeyFrames (Keyframe keyFrame){
|
||||||
|
inTangent = keyFrame.inTangent;
|
||||||
|
outTangent = keyFrame.outTangent;
|
||||||
|
tangentMode = keyFrame.tangentMode;
|
||||||
|
time = keyFrame.time;
|
||||||
|
value = keyFrame.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Keyframe GetKeyFrames (){
|
||||||
|
Keyframe kf = new Keyframe();
|
||||||
|
|
||||||
|
kf.inTangent = inTangent;
|
||||||
|
kf.outTangent = outTangent;
|
||||||
|
kf.tangentMode = tangentMode;
|
||||||
|
kf.time = time;
|
||||||
|
kf.value = value;
|
||||||
|
|
||||||
|
return kf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableAlphaKeys{
|
||||||
|
public float[] alpha;
|
||||||
|
public float[] time;
|
||||||
|
|
||||||
|
public SerializableAlphaKeys (GradientAlphaKey[] gradAlphaKeys){
|
||||||
|
float[] alpha_ = new float[gradAlphaKeys.Length];
|
||||||
|
float[] time_ = new float[gradAlphaKeys.Length];
|
||||||
|
for (int i = 0; i < gradAlphaKeys.Length; i++) {
|
||||||
|
alpha_[i] = gradAlphaKeys[i].alpha;
|
||||||
|
time_[i] = gradAlphaKeys[i].time;
|
||||||
|
}
|
||||||
|
alpha = alpha_;
|
||||||
|
time = time_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GradientAlphaKey[] GetAlphaKeys (){
|
||||||
|
GradientAlphaKey[] gak = new GradientAlphaKey[alpha.Length];
|
||||||
|
for (int i = 0; i < alpha.Length; i++) {
|
||||||
|
gak [i].alpha = alpha [i];
|
||||||
|
gak [i].time = time [i];
|
||||||
|
}
|
||||||
|
return gak;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableColorKeys{
|
||||||
|
public SerializableColor[] color;
|
||||||
|
public float[] time;
|
||||||
|
|
||||||
|
public SerializableColorKeys (GradientColorKey[] gradColorKeys){
|
||||||
|
SerializableColor[] color_ = new SerializableColor[gradColorKeys.Length];
|
||||||
|
float[] time_ = new float[gradColorKeys.Length];
|
||||||
|
for (int i = 0; i < gradColorKeys.Length; i++) {
|
||||||
|
color_[i] = new SerializableColor (gradColorKeys[i].color);
|
||||||
|
time_[i] = gradColorKeys[i].time;
|
||||||
|
}
|
||||||
|
color = color_;
|
||||||
|
time = time_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GradientColorKey[] GetColorKeys (){
|
||||||
|
GradientColorKey[] gck = new GradientColorKey[color.Length];
|
||||||
|
for (int i = 0; i < color.Length; i++) {
|
||||||
|
gck [i].color = color [i].GetColor();
|
||||||
|
gck [i].time = time [i];
|
||||||
|
}
|
||||||
|
return gck;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableColor {
|
||||||
|
public float R;
|
||||||
|
public float G;
|
||||||
|
public float B;
|
||||||
|
public float A;
|
||||||
|
|
||||||
|
public SerializableColor (Color color){
|
||||||
|
R = color.r;
|
||||||
|
G = color.g;
|
||||||
|
B = color.b;
|
||||||
|
A = color.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color GetColor (){
|
||||||
|
return new Color (R,G,B,A);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableVector3 {
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float z;
|
||||||
|
|
||||||
|
public SerializableVector3 (Vector3 v3){
|
||||||
|
x = v3.x;
|
||||||
|
y = v3.y;
|
||||||
|
z = v3.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 GetVector3 (){
|
||||||
|
return new Vector3 (x,y,z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableGradient{
|
||||||
|
public SerializableAlphaKeys gradientAlphaKeys;
|
||||||
|
public SerializableColorKeys gradientColorKeys;
|
||||||
|
public SerializableGradientMode gradientMode;
|
||||||
|
|
||||||
|
public SerializableGradient (Gradient gradient){
|
||||||
|
gradientMode = new SerializableGradientMode (gradient.mode);
|
||||||
|
gradientAlphaKeys = new SerializableAlphaKeys (gradient.alphaKeys);
|
||||||
|
gradientColorKeys = new SerializableColorKeys (gradient.colorKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gradient GetGradient (){
|
||||||
|
Gradient gradient = new Gradient ();
|
||||||
|
gradient.alphaKeys = gradientAlphaKeys.GetAlphaKeys ();
|
||||||
|
gradient.colorKeys = gradientColorKeys.GetColorKeys ();
|
||||||
|
gradient.mode = gradientMode.GetGradientMode ();
|
||||||
|
|
||||||
|
return gradient;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializablePSGradientMode{
|
||||||
|
public string mode;
|
||||||
|
|
||||||
|
public SerializablePSGradientMode (ParticleSystemGradientMode psGradientMode){
|
||||||
|
mode = psGradientMode.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticleSystemGradientMode GetGradientMode (){
|
||||||
|
ParticleSystemGradientMode psGradientMode = new ParticleSystemGradientMode ();
|
||||||
|
switch (mode) {
|
||||||
|
case "Color":
|
||||||
|
{
|
||||||
|
psGradientMode = ParticleSystemGradientMode.Color;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Gradient":
|
||||||
|
{
|
||||||
|
psGradientMode = ParticleSystemGradientMode.Gradient;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "RandomColor":
|
||||||
|
{
|
||||||
|
psGradientMode = ParticleSystemGradientMode.RandomColor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "TwoColors":
|
||||||
|
{
|
||||||
|
psGradientMode = ParticleSystemGradientMode.TwoColors;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "TwoGradients":
|
||||||
|
{
|
||||||
|
psGradientMode = ParticleSystemGradientMode.TwoGradients;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return psGradientMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableGradientMode{
|
||||||
|
public string mode;
|
||||||
|
|
||||||
|
public SerializableGradientMode (GradientMode gradientMode){
|
||||||
|
mode = gradientMode.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GradientMode GetGradientMode (){
|
||||||
|
GradientMode gradientMode = new GradientMode ();
|
||||||
|
switch (mode) {
|
||||||
|
case "Blend":
|
||||||
|
{
|
||||||
|
gradientMode = GradientMode.Blend;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Fixed":
|
||||||
|
{
|
||||||
|
gradientMode = GradientMode.Fixed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gradientMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializablePSCurveMode{
|
||||||
|
public string mode;
|
||||||
|
|
||||||
|
public SerializablePSCurveMode (ParticleSystemCurveMode psCurveMode){
|
||||||
|
mode = psCurveMode.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticleSystemCurveMode GetCurveMode (){
|
||||||
|
ParticleSystemCurveMode psCurveMode = new ParticleSystemCurveMode ();
|
||||||
|
switch (mode) {
|
||||||
|
case "Constant":
|
||||||
|
{
|
||||||
|
psCurveMode = ParticleSystemCurveMode.Constant;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Curve":
|
||||||
|
{
|
||||||
|
psCurveMode = ParticleSystemCurveMode.Curve;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "TwoConstants":
|
||||||
|
{
|
||||||
|
psCurveMode = ParticleSystemCurveMode.TwoConstants;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "TwoCurves":
|
||||||
|
{
|
||||||
|
psCurveMode = ParticleSystemCurveMode.TwoCurves;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return psCurveMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableWrapMode {
|
||||||
|
public string mode;
|
||||||
|
|
||||||
|
public SerializableWrapMode (WrapMode wrapMode){
|
||||||
|
mode = wrapMode.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrapMode GetWrapMode (){
|
||||||
|
WrapMode wrapMode = new WrapMode ();
|
||||||
|
switch (mode) {
|
||||||
|
case "Clamp":
|
||||||
|
{
|
||||||
|
wrapMode = WrapMode.Clamp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "ClampForever":
|
||||||
|
{
|
||||||
|
wrapMode = WrapMode.ClampForever;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Default":
|
||||||
|
{
|
||||||
|
wrapMode = WrapMode.Default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Loop":
|
||||||
|
{
|
||||||
|
wrapMode = WrapMode.Loop;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Once":
|
||||||
|
{
|
||||||
|
wrapMode = WrapMode.Once;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "PingPong":
|
||||||
|
{
|
||||||
|
wrapMode = WrapMode.PingPong;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wrapMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 06137310f20d06f4eb859f958f491cc1
|
||||||
|
timeCreated: 1532254155
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
10
Assets/Resources/1/VFX/Scripts/UniqueProjectiles.meta
Normal file
10
Assets/Resources/1/VFX/Scripts/UniqueProjectiles.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 45ac3517469314040972a89240788486
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1549844767
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,55 @@
|
|||||||
|
//
|
||||||
|
//NOTES:
|
||||||
|
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
|
||||||
|
//This is just a basic example.
|
||||||
|
//
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CameraShakeSimpleScript : MonoBehaviour {
|
||||||
|
|
||||||
|
private bool isRunning = false;
|
||||||
|
private Animation anim;
|
||||||
|
|
||||||
|
void Start () {
|
||||||
|
anim = GetComponent<Animation> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShakeCamera() {
|
||||||
|
if (anim != null)
|
||||||
|
anim.Play (anim.clip.name);
|
||||||
|
else
|
||||||
|
ShakeCaller (0.25f, 0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
//other shake option
|
||||||
|
public void ShakeCaller (float amount, float duration){
|
||||||
|
StartCoroutine (Shake(amount, duration));
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator Shake (float amount, float duration){
|
||||||
|
isRunning = true;
|
||||||
|
|
||||||
|
Vector3 originalPos = transform.localPosition;
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
while (duration > 0.01f) {
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
var x = Random.Range (-1f, 1f) * (amount/counter);
|
||||||
|
var y = Random.Range (-1f, 1f) * (amount/counter);
|
||||||
|
|
||||||
|
transform.localPosition = Vector3.Lerp (transform.localPosition, new Vector3 (originalPos.x + x, originalPos.y + y, originalPos.z), 0.5f);
|
||||||
|
|
||||||
|
duration -= Time.deltaTime;
|
||||||
|
|
||||||
|
yield return new WaitForSeconds (0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
transform.localPosition = originalPos;
|
||||||
|
|
||||||
|
isRunning = false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1561ad5ecde53f84bae260b308e51a2f
|
||||||
|
timeCreated: 1529402807
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,169 @@
|
|||||||
|
//
|
||||||
|
//NOTES:
|
||||||
|
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
|
||||||
|
//This is just a basic example.
|
||||||
|
//
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ProjectileMoveScript : MonoBehaviour {
|
||||||
|
|
||||||
|
public bool bounce = false;
|
||||||
|
public float bounceForce = 10;
|
||||||
|
public float speed;
|
||||||
|
[Tooltip("From 0% to 100%")]
|
||||||
|
public float accuracy;
|
||||||
|
public float fireRate;
|
||||||
|
public GameObject muzzlePrefab;
|
||||||
|
public GameObject hitPrefab;
|
||||||
|
public AudioClip shotSFX;
|
||||||
|
public AudioClip hitSFX;
|
||||||
|
public List<GameObject> trails;
|
||||||
|
|
||||||
|
private Vector3 startPos;
|
||||||
|
private float speedRandomness;
|
||||||
|
private Vector3 offset;
|
||||||
|
private bool collided;
|
||||||
|
private Rigidbody rb;
|
||||||
|
private RotateToMouseScript rotateToMouse;
|
||||||
|
private GameObject target;
|
||||||
|
|
||||||
|
void Start () {
|
||||||
|
startPos = transform.position;
|
||||||
|
rb = GetComponent <Rigidbody> ();
|
||||||
|
|
||||||
|
//used to create a radius for the accuracy and have a very unique randomness
|
||||||
|
if (accuracy != 100) {
|
||||||
|
accuracy = 1 - (accuracy / 100);
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
var val = 1 * Random.Range (-accuracy, accuracy);
|
||||||
|
var index = Random.Range (0, 2);
|
||||||
|
if (i == 0) {
|
||||||
|
if (index == 0)
|
||||||
|
offset = new Vector3 (0, -val, 0);
|
||||||
|
else
|
||||||
|
offset = new Vector3 (0, val, 0);
|
||||||
|
} else {
|
||||||
|
if (index == 0)
|
||||||
|
offset = new Vector3 (0, offset.y, -val);
|
||||||
|
else
|
||||||
|
offset = new Vector3 (0, offset.y, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (muzzlePrefab != null) {
|
||||||
|
var muzzleVFX = Instantiate (muzzlePrefab, transform.position, Quaternion.identity);
|
||||||
|
muzzleVFX.transform.forward = gameObject.transform.forward + offset;
|
||||||
|
var ps = muzzleVFX.GetComponent<ParticleSystem>();
|
||||||
|
if (ps != null)
|
||||||
|
Destroy (muzzleVFX, ps.main.duration);
|
||||||
|
else {
|
||||||
|
var psChild = muzzleVFX.transform.GetChild(0).GetComponent<ParticleSystem>();
|
||||||
|
Destroy (muzzleVFX, psChild.main.duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shotSFX != null && GetComponent<AudioSource>()) {
|
||||||
|
GetComponent<AudioSource> ().PlayOneShot (shotSFX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedUpdate () {
|
||||||
|
if (target != null)
|
||||||
|
rotateToMouse.RotateToMouse (gameObject, target.transform.position);
|
||||||
|
if (speed != 0 && rb != null)
|
||||||
|
rb.position += (transform.forward + offset) * (speed * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnCollisionEnter (Collision co) {
|
||||||
|
if (!bounce)
|
||||||
|
{
|
||||||
|
if (co.gameObject.tag != "Bullet" && !collided)
|
||||||
|
{
|
||||||
|
collided = true;
|
||||||
|
|
||||||
|
if (shotSFX != null && GetComponent<AudioSource>())
|
||||||
|
{
|
||||||
|
GetComponent<AudioSource>().PlayOneShot(hitSFX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trails.Count > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < trails.Count; i++)
|
||||||
|
{
|
||||||
|
trails[i].transform.parent = null;
|
||||||
|
var ps = trails[i].GetComponent<ParticleSystem>();
|
||||||
|
if (ps != null)
|
||||||
|
{
|
||||||
|
ps.Stop();
|
||||||
|
Destroy(ps.gameObject, ps.main.duration + ps.main.startLifetime.constantMax);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
speed = 0;
|
||||||
|
GetComponent<Rigidbody>().isKinematic = true;
|
||||||
|
|
||||||
|
ContactPoint contact = co.contacts[0];
|
||||||
|
Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
|
||||||
|
Vector3 pos = contact.point;
|
||||||
|
|
||||||
|
if (hitPrefab != null)
|
||||||
|
{
|
||||||
|
var hitVFX = Instantiate(hitPrefab, pos, rot) as GameObject;
|
||||||
|
|
||||||
|
var ps = hitVFX.GetComponent<ParticleSystem>();
|
||||||
|
if (ps == null)
|
||||||
|
{
|
||||||
|
var psChild = hitVFX.transform.GetChild(0).GetComponent<ParticleSystem>();
|
||||||
|
Destroy(hitVFX, psChild.main.duration);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Destroy(hitVFX, ps.main.duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
StartCoroutine(DestroyParticle(0f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rb.useGravity = true;
|
||||||
|
rb.drag = 0.5f;
|
||||||
|
ContactPoint contact = co.contacts[0];
|
||||||
|
rb.AddForce (Vector3.Reflect((contact.point - startPos).normalized, contact.normal) * bounceForce, ForceMode.Impulse);
|
||||||
|
Destroy ( this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator DestroyParticle (float waitTime) {
|
||||||
|
|
||||||
|
if (transform.childCount > 0 && waitTime != 0) {
|
||||||
|
List<Transform> tList = new List<Transform> ();
|
||||||
|
|
||||||
|
foreach (Transform t in transform.GetChild(0).transform) {
|
||||||
|
tList.Add (t);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (transform.GetChild(0).localScale.x > 0) {
|
||||||
|
yield return new WaitForSeconds (0.01f);
|
||||||
|
transform.GetChild(0).localScale -= new Vector3 (0.1f, 0.1f, 0.1f);
|
||||||
|
for (int i = 0; i < tList.Count; i++) {
|
||||||
|
tList[i].localScale -= new Vector3 (0.1f, 0.1f, 0.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds (waitTime);
|
||||||
|
Destroy (gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTarget (GameObject trg, RotateToMouseScript rotateTo)
|
||||||
|
{
|
||||||
|
target = trg;
|
||||||
|
rotateToMouse = rotateTo;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12ba759cd568c0e47a7018ab70867a0d
|
||||||
|
timeCreated: 1498482809
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,74 @@
|
|||||||
|
//
|
||||||
|
//NOTES:
|
||||||
|
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
|
||||||
|
//This is just a basic example.
|
||||||
|
//
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class RotateToMouseScript : MonoBehaviour {
|
||||||
|
|
||||||
|
public float maximumLenght;
|
||||||
|
|
||||||
|
private bool use2D;
|
||||||
|
private Ray rayMouse;
|
||||||
|
private Vector3 pos;
|
||||||
|
private Vector3 direction;
|
||||||
|
private Quaternion rotation;
|
||||||
|
private Camera cam;
|
||||||
|
private WaitForSeconds updateTime = new WaitForSeconds (0.01f);
|
||||||
|
|
||||||
|
|
||||||
|
public void StartUpdateRay (){
|
||||||
|
StartCoroutine (UpdateRay());
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator UpdateRay (){
|
||||||
|
if (cam != null) {
|
||||||
|
if (use2D) {
|
||||||
|
Vector2 direction = Camera.main.ScreenToWorldPoint (Input.mousePosition) - transform.position;
|
||||||
|
float angle = Mathf.Atan2 (direction.y, direction.x) * Mathf.Rad2Deg;
|
||||||
|
if (angle > 180) angle -= 360;
|
||||||
|
rotation.eulerAngles = new Vector3 (-angle, 90, 0); // use different values to lock on different axis
|
||||||
|
transform.rotation = rotation;
|
||||||
|
} else {
|
||||||
|
RaycastHit hit;
|
||||||
|
var mousePos = Input.mousePosition;
|
||||||
|
rayMouse = cam.ScreenPointToRay (mousePos);
|
||||||
|
if (Physics.Raycast (rayMouse.origin, rayMouse.direction, out hit, maximumLenght)) {
|
||||||
|
RotateToMouse (gameObject, hit.point);
|
||||||
|
} else {
|
||||||
|
var pos = rayMouse.GetPoint (maximumLenght);
|
||||||
|
RotateToMouse (gameObject, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield return updateTime;
|
||||||
|
StartCoroutine (UpdateRay ());
|
||||||
|
} else
|
||||||
|
Debug.Log ("Camera not set");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RotateToMouse (GameObject obj, Vector3 destination ) {
|
||||||
|
direction = destination - obj.transform.position;
|
||||||
|
rotation = Quaternion.LookRotation (direction);
|
||||||
|
obj.transform.localRotation = Quaternion.Lerp (obj.transform.rotation, rotation, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set2D (bool state){
|
||||||
|
use2D = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCamera (Camera camera){
|
||||||
|
cam = camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 GetDirection () {
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion GetRotation () {
|
||||||
|
return rotation;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b471b1df235ed774e9063eb5be974d7b
|
||||||
|
timeCreated: 1529269730
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,211 @@
|
|||||||
|
//
|
||||||
|
//NOTES:
|
||||||
|
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
|
||||||
|
//This is just a basic example.
|
||||||
|
//
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class SpawnProjectilesScript : MonoBehaviour {
|
||||||
|
|
||||||
|
public bool useTarget;
|
||||||
|
public bool use2D;
|
||||||
|
public bool cameraShake;
|
||||||
|
public Text effectName;
|
||||||
|
public RotateToMouseScript rotateToMouse;
|
||||||
|
public GameObject firePoint;
|
||||||
|
public GameObject cameras;
|
||||||
|
public GameObject target;
|
||||||
|
public List<GameObject> VFXs = new List<GameObject> ();
|
||||||
|
|
||||||
|
private int count = 0;
|
||||||
|
private float timeToFire = 0f;
|
||||||
|
private GameObject effectToSpawn;
|
||||||
|
private List<Camera> camerasList = new List<Camera> ();
|
||||||
|
private Camera singleCamera;
|
||||||
|
|
||||||
|
void Start () {
|
||||||
|
|
||||||
|
if (cameras.transform.childCount > 0) {
|
||||||
|
for (int i = 0; i < cameras.transform.childCount; i++) {
|
||||||
|
camerasList.Add (cameras.transform.GetChild (i).gameObject.GetComponent<Camera> ());
|
||||||
|
}
|
||||||
|
if(camerasList.Count == 0){
|
||||||
|
Debug.Log ("Please assign one or more Cameras in inspector");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
singleCamera = cameras.GetComponent<Camera> ();
|
||||||
|
if (singleCamera != null)
|
||||||
|
camerasList.Add (singleCamera);
|
||||||
|
else
|
||||||
|
Debug.Log ("Please assign one or more Cameras in inspector");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(VFXs.Count>0)
|
||||||
|
effectToSpawn = VFXs[0];
|
||||||
|
else
|
||||||
|
Debug.Log ("Please assign one or more VFXs in inspector");
|
||||||
|
|
||||||
|
if (effectName != null) effectName.text = effectToSpawn.name;
|
||||||
|
|
||||||
|
if (camerasList.Count > 0) {
|
||||||
|
rotateToMouse.SetCamera (camerasList [camerasList.Count - 1]);
|
||||||
|
if(use2D)
|
||||||
|
rotateToMouse.Set2D (true);
|
||||||
|
rotateToMouse.StartUpdateRay ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Debug.Log ("Please assign one or more Cameras in inspector");
|
||||||
|
|
||||||
|
if (useTarget && target != null)
|
||||||
|
{
|
||||||
|
var collider = target.GetComponent<BoxCollider>();
|
||||||
|
if (!collider)
|
||||||
|
{
|
||||||
|
target.AddComponent<BoxCollider>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update () {
|
||||||
|
if (Input.GetKey (KeyCode.Space) && Time.time >= timeToFire || Input.GetMouseButton (0) && Time.time >= timeToFire) {
|
||||||
|
timeToFire = Time.time + 1f / effectToSpawn.GetComponent<ProjectileMoveScript>().fireRate;
|
||||||
|
SpawnVFX ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown (KeyCode.D))
|
||||||
|
Next ();
|
||||||
|
if (Input.GetKeyDown (KeyCode.A))
|
||||||
|
Previous ();
|
||||||
|
if (Input.GetKeyDown (KeyCode.C))
|
||||||
|
SwitchCamera ();
|
||||||
|
if (Input.GetKeyDown (KeyCode.Alpha1))
|
||||||
|
CameraShake ();
|
||||||
|
if (Input.GetKeyDown (KeyCode.X))
|
||||||
|
ZoomIn ();
|
||||||
|
if (Input.GetKeyDown (KeyCode.Z))
|
||||||
|
ZoomOut ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SpawnVFX () {
|
||||||
|
GameObject vfx;
|
||||||
|
|
||||||
|
var cameraShakeScript = cameras.GetComponent<CameraShakeSimpleScript> ();
|
||||||
|
|
||||||
|
if (cameraShake && cameraShakeScript != null)
|
||||||
|
cameraShakeScript.ShakeCamera ();
|
||||||
|
|
||||||
|
if (firePoint != null) {
|
||||||
|
vfx = Instantiate (effectToSpawn, firePoint.transform.position, Quaternion.identity);
|
||||||
|
if (!useTarget)
|
||||||
|
{
|
||||||
|
if (rotateToMouse != null)
|
||||||
|
{
|
||||||
|
vfx.transform.localRotation = rotateToMouse.GetRotation();
|
||||||
|
}
|
||||||
|
else Debug.Log("No RotateToMouseScript found on firePoint.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
vfx.GetComponent<ProjectileMoveScript>().SetTarget(target, rotateToMouse);
|
||||||
|
rotateToMouse.RotateToMouse(vfx, target.transform.position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Destroy(vfx);
|
||||||
|
Debug.Log("No target assigned.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vfx = Instantiate (effectToSpawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Next () {
|
||||||
|
count++;
|
||||||
|
|
||||||
|
if (count > VFXs.Count)
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < VFXs.Count; i++){
|
||||||
|
if (count == i) effectToSpawn = VFXs [i];
|
||||||
|
if (effectName != null) effectName.text = effectToSpawn.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Previous () {
|
||||||
|
count--;
|
||||||
|
|
||||||
|
if (count < 0)
|
||||||
|
count = VFXs.Count;
|
||||||
|
|
||||||
|
for (int i = 0; i < VFXs.Count; i++) {
|
||||||
|
if (count == i) effectToSpawn = VFXs [i];
|
||||||
|
if (effectName != null) effectName.text = effectToSpawn.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CameraShake () {
|
||||||
|
cameraShake = !cameraShake;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ZoomIn () {
|
||||||
|
if (camerasList.Count > 0) {
|
||||||
|
if (!camerasList [0].orthographic) {
|
||||||
|
if (camerasList [0].fieldOfView < 101) {
|
||||||
|
for (int i = 0; i < camerasList.Count; i++) {
|
||||||
|
camerasList [i].fieldOfView += 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (camerasList [0].orthographicSize < 10) {
|
||||||
|
for (int i = 0; i < camerasList.Count; i++) {
|
||||||
|
camerasList [i].orthographicSize += 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ZoomOut () {
|
||||||
|
if (camerasList.Count > 0) {
|
||||||
|
if (!camerasList [0].orthographic) {
|
||||||
|
if (camerasList [0].fieldOfView > 20) {
|
||||||
|
for (int i = 0; i < camerasList.Count; i++) {
|
||||||
|
camerasList [i].fieldOfView -= 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (camerasList [0].orthographicSize > 4) {
|
||||||
|
for (int i = 0; i < camerasList.Count; i++) {
|
||||||
|
camerasList [i].orthographicSize -= 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SwitchCamera () {
|
||||||
|
if (camerasList.Count > 0) {
|
||||||
|
for (int i = 0; i < camerasList.Count; i++) {
|
||||||
|
if (camerasList [i].gameObject.activeSelf) {
|
||||||
|
camerasList [i].gameObject.SetActive (false);
|
||||||
|
if ((i + 1) == camerasList.Count) {
|
||||||
|
camerasList [0].gameObject.SetActive (true);
|
||||||
|
rotateToMouse.SetCamera (camerasList [0]);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
camerasList [i + 1].gameObject.SetActive (true);
|
||||||
|
rotateToMouse.SetCamera (camerasList [i + 1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d2eb83ec655d71b498b43c9ebccd8066
|
||||||
|
timeCreated: 1515515037
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/Resources/1/VFX/_GeneralPrefab.meta
Normal file
8
Assets/Resources/1/VFX/_GeneralPrefab.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0c13863c6fbc4f4498ff062ca1b75f83
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
17251
Assets/Resources/1/VFX/_GeneralPrefab/EnergyNovaMuzzleBlue.prefab
Normal file
17251
Assets/Resources/1/VFX/_GeneralPrefab/EnergyNovaMuzzleBlue.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 985cf11bc3430314c828a892f897a79a
|
||||||
|
timeCreated: 1499639222
|
||||||
|
licenseType: Store
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
13598
Assets/Resources/1/VFX/_GeneralPrefab/LightningFloorBlueTrail.prefab
Normal file
13598
Assets/Resources/1/VFX/_GeneralPrefab/LightningFloorBlueTrail.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7ba66345f3cd7bc438d039e7153110c9
|
||||||
|
timeCreated: 1529457602
|
||||||
|
licenseType: Store
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 340b511e7e2a1cf459933fa71bbedaf9
|
||||||
|
timeCreated: 1521307224
|
||||||
|
licenseType: Store
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
10381
Assets/Resources/1/VFX/_GeneralPrefab/MagicBuffBlue.prefab
Normal file
10381
Assets/Resources/1/VFX/_GeneralPrefab/MagicBuffBlue.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: afe338d7e6d0c694287972439de8b3eb
|
||||||
|
timeCreated: 1447692206
|
||||||
|
licenseType: Store
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
17263
Assets/Resources/1/VFX/_GeneralPrefab/SwordHitBlueCritical.prefab
Normal file
17263
Assets/Resources/1/VFX/_GeneralPrefab/SwordHitBlueCritical.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2ae9c010e1803a641a6d5d5301ec4bd0
|
||||||
|
timeCreated: 1494262925
|
||||||
|
licenseType: Store
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -20,3 +20,9 @@ MonoBehaviour:
|
|||||||
- {fileID: 8300000, guid: db2b24c43cc41514b85fb4a4950c1299, type: 3}
|
- {fileID: 8300000, guid: db2b24c43cc41514b85fb4a4950c1299, type: 3}
|
||||||
- {fileID: 8300000, guid: 14662fc30f12b7847929c0d90295de95, type: 3}
|
- {fileID: 8300000, guid: 14662fc30f12b7847929c0d90295de95, type: 3}
|
||||||
- {fileID: 8300000, guid: ed81a29d95a7c6843855e95917ff40ed, type: 3}
|
- {fileID: 8300000, guid: ed81a29d95a7c6843855e95917ff40ed, type: 3}
|
||||||
|
captures:
|
||||||
|
- {fileID: 8300000, guid: d657487da1404a34f835a7631432b835, type: 3}
|
||||||
|
- {fileID: 8300000, guid: 5481b8f08252dd7499af6b48ad6c5354, type: 3}
|
||||||
|
- {fileID: 8300000, guid: 2b1056532f20f3248910d138da8358b9, type: 3}
|
||||||
|
hardCapture: {fileID: 8300000, guid: 72cf5153f4959df4eb30db3dc01d4e24, type: 3}
|
||||||
|
death: {fileID: 8300000, guid: 158e2b6cd6cdcba49bc9f9c1cb29d84b, type: 3}
|
||||||
|
220660
Assets/Scenes/_MainMenu.unity
Normal file
220660
Assets/Scenes/_MainMenu.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/_MainMenu.unity.meta
Normal file
7
Assets/Scenes/_MainMenu.unity.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3bb4ad973e7dfdd438c1338417226bea
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -37,7 +37,6 @@ namespace Controller
|
|||||||
controllers.Add(cameraControl);
|
controllers.Add(cameraControl);
|
||||||
player.onPlayerSpawned += cameraControl.InitCameraControl;
|
player.onPlayerSpawned += cameraControl.InitCameraControl;
|
||||||
player.onPlayerSpawned += MusicController.Instance.AddAudioListener;
|
player.onPlayerSpawned += MusicController.Instance.AddAudioListener;
|
||||||
player.onPlayerSpawned += MusicController.Instance.AddAudioSource;
|
|
||||||
units.Add(player);
|
units.Add(player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -27,7 +27,12 @@ namespace Data
|
|||||||
public struct SFXMusic
|
public struct SFXMusic
|
||||||
{
|
{
|
||||||
[SerializeField] private List<AudioClip> steps;
|
[SerializeField] private List<AudioClip> steps;
|
||||||
|
[SerializeField] private List<AudioClip> captures;
|
||||||
|
[SerializeField] private AudioClip hardCapture;
|
||||||
|
[SerializeField] private AudioClip death;
|
||||||
|
public List<AudioClip> Captures => captures;
|
||||||
public List<AudioClip> Step => steps;
|
public List<AudioClip> Step => steps;
|
||||||
|
public AudioClip HardCapture => hardCapture;
|
||||||
|
public AudioClip Death => death;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace HexFiled
|
namespace HexFiled
|
||||||
{
|
{
|
||||||
@ -13,12 +14,13 @@ namespace HexFiled
|
|||||||
private UnitColor _color;
|
private UnitColor _color;
|
||||||
private MeshRenderer _renderer;
|
private MeshRenderer _renderer;
|
||||||
private Dictionary<UnitColor, CellColor> _cellColor;
|
private Dictionary<UnitColor, CellColor> _cellColor;
|
||||||
|
|
||||||
public UnitColor Color => _color;
|
public UnitColor Color => _color;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_renderer = GetComponent<MeshRenderer>();
|
_renderer = GetComponent<MeshRenderer>();
|
||||||
|
MusicController.Instance.AddAudioSource(gameObject);
|
||||||
_color = UnitColor.GREY;
|
_color = UnitColor.GREY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,16 +43,19 @@ namespace HexFiled
|
|||||||
public void PaintHex(UnitColor color)
|
public void PaintHex(UnitColor color)
|
||||||
{
|
{
|
||||||
if (color == _color) return;
|
if (color == _color) return;
|
||||||
if(color == UnitColor.GREY)
|
if (color == UnitColor.GREY)
|
||||||
{
|
{
|
||||||
_renderer.material.mainTexture = _cellColor[color].Texture;
|
_renderer.material.mainTexture = _cellColor[color].Texture;
|
||||||
_color = color;
|
_color = color;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderer.material.mainTexture = _cellColor[color].Texture;
|
_renderer.material.mainTexture = _cellColor[color].Texture;
|
||||||
onHexPainted?.Invoke(this);
|
onHexPainted?.Invoke(this);
|
||||||
_color = color;
|
_color = color;
|
||||||
Instantiate(_cellColor[color].VFXPrefab, transform);
|
Instantiate(_cellColor[color].VFXPrefab, transform);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ using HexFiled;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Weapons;
|
using Weapons;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
|
|
||||||
namespace Units
|
namespace Units
|
||||||
@ -30,7 +31,7 @@ namespace Units
|
|||||||
private Vector2 _direction;
|
private Vector2 _direction;
|
||||||
private BarCanvas _barCanvas;
|
private BarCanvas _barCanvas;
|
||||||
private bool _isHardToCapture;
|
private bool _isHardToCapture;
|
||||||
|
private bool _isCapturing;
|
||||||
|
|
||||||
|
|
||||||
public bool IsBusy => _isBusy;
|
public bool IsBusy => _isBusy;
|
||||||
@ -46,6 +47,7 @@ namespace Units
|
|||||||
_hexGrid = hexGrid;
|
_hexGrid = hexGrid;
|
||||||
_isBusy = false;
|
_isBusy = false;
|
||||||
_isHardToCapture = false;
|
_isHardToCapture = false;
|
||||||
|
_isCapturing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Move(HexDirection direction)
|
public void Move(HexDirection direction)
|
||||||
@ -62,10 +64,9 @@ namespace Units
|
|||||||
_unitView.RegenMana(_mana);
|
_unitView.RegenMana(_mana);
|
||||||
DoTransit(direction);
|
DoTransit(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (_mana - _hexGrid.HexCaptureCost >= 0)
|
else if (_mana - _hexGrid.HexCaptureCost >= 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
_mana -= _hexGrid.HexCaptureCost;
|
_mana -= _hexGrid.HexCaptureCost;
|
||||||
_unitView.RegenMana(_mana);
|
_unitView.RegenMana(_mana);
|
||||||
UpdateBarCanvas();
|
UpdateBarCanvas();
|
||||||
@ -76,8 +77,10 @@ namespace Units
|
|||||||
private void DoTransit(HexDirection direction)
|
private void DoTransit(HexDirection direction)
|
||||||
{
|
{
|
||||||
_isBusy = true;
|
_isBusy = true;
|
||||||
|
_isCapturing = _data.color != _cell.GetNeighbor(direction).Color;
|
||||||
_cell = _cell.GetNeighbor(direction);
|
_cell = _cell.GetNeighbor(direction);
|
||||||
RotateUnit(new Vector2((_cell.transform.position - _instance.transform.position).normalized.x, (_cell.transform.position - _instance.transform.position).normalized.z));
|
RotateUnit(new Vector2((_cell.transform.position - _instance.transform.position).normalized.x,
|
||||||
|
(_cell.transform.position - _instance.transform.position).normalized.z));
|
||||||
_animator.SetTrigger("Move");
|
_animator.SetTrigger("Move");
|
||||||
_animator.SetBool("isMoving", _isBusy);
|
_animator.SetBool("isMoving", _isBusy);
|
||||||
_instance.transform.DOMove(_cell.transform.position, _animLength.Move);
|
_instance.transform.DOMove(_cell.transform.position, _animLength.Move);
|
||||||
@ -87,7 +90,7 @@ namespace Units
|
|||||||
{
|
{
|
||||||
_cell.PaintHex(_data.color);
|
_cell.PaintHex(_data.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetAnimLength()
|
private void SetAnimLength()
|
||||||
{
|
{
|
||||||
AnimationClip[] clips = _animator.runtimeAnimatorController.animationClips;
|
AnimationClip[] clips = _animator.runtimeAnimatorController.animationClips;
|
||||||
@ -127,10 +130,10 @@ namespace Units
|
|||||||
_barCanvas = _unitView.BarCanvas.GetComponent<BarCanvas>();
|
_barCanvas = _unitView.BarCanvas.GetComponent<BarCanvas>();
|
||||||
_unitView.SetUp(_barCanvas.SpawnShotUI(_weapon.shots), _weapon, RegenMana, _data.manaRegen, CaptureHex);
|
_unitView.SetUp(_barCanvas.SpawnShotUI(_weapon.shots), _weapon, RegenMana, _data.manaRegen, CaptureHex);
|
||||||
SetAnimLength();
|
SetAnimLength();
|
||||||
|
MusicController.Instance.AddAudioSource(_instance);
|
||||||
_mana = _data.maxMana;
|
_mana = _data.maxMana;
|
||||||
_hp = _data.maxHP;
|
_hp = _data.maxHP;
|
||||||
SetUpActions();
|
SetUpActions();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,14 +147,23 @@ namespace Units
|
|||||||
{
|
{
|
||||||
_isBusy = false;
|
_isBusy = false;
|
||||||
_animator.SetBool("isMoving", _isBusy);
|
_animator.SetBool("isMoving", _isBusy);
|
||||||
|
if(!_isCapturing)
|
||||||
|
{
|
||||||
|
_isHardToCapture = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_isHardToCapture)
|
if (_isHardToCapture)
|
||||||
{
|
{
|
||||||
_unitView.HardCaptureHex();
|
_unitView.HardCaptureHex(_cell);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var capturesMusic = MusicController.Instance.MusicData.SfxMusic.Captures;
|
||||||
|
MusicController.Instance.PlayerAudioClip(capturesMusic[Random.Range(0, capturesMusic.Count - 1)],
|
||||||
|
_cell.gameObject);
|
||||||
CaptureHex();
|
CaptureHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
_isHardToCapture = false;
|
_isHardToCapture = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +227,8 @@ namespace Units
|
|||||||
_unitView.OnHit -= Damage;
|
_unitView.OnHit -= Damage;
|
||||||
_isAlive = false;
|
_isAlive = false;
|
||||||
_animator.SetTrigger("Death");
|
_animator.SetTrigger("Death");
|
||||||
|
MusicController.Instance.PlayerAudioClip(MusicController.Instance.MusicData.SfxMusic.Death, _instance);
|
||||||
|
MusicController.Instance.RemoveAudioSource(_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,14 +239,13 @@ namespace Units
|
|||||||
_isBusy = true;
|
_isBusy = true;
|
||||||
if (!_direction.Equals(Vector2.zero))
|
if (!_direction.Equals(Vector2.zero))
|
||||||
RotateUnit(_direction);
|
RotateUnit(_direction);
|
||||||
|
|
||||||
_animator.SetTrigger("Attack");
|
_animator.SetTrigger("Attack");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RotateUnit(Vector2 direction)
|
private void RotateUnit(Vector2 direction)
|
||||||
{
|
{
|
||||||
|
|
||||||
_unitView.transform.DOLookAt(new Vector3(direction.x, 0, direction.y) + _unitView.transform.position,
|
_unitView.transform.DOLookAt(new Vector3(direction.x, 0, direction.y) + _unitView.transform.position,
|
||||||
0.1f);
|
0.1f);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Data;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using HexFiled;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Weapons;
|
using Weapons;
|
||||||
@ -44,7 +46,7 @@ public class UnitView : MonoBehaviour
|
|||||||
_capureHex = captureHex;
|
_capureHex = captureHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HardCaptureHex()
|
public void HardCaptureHex(HexCell cell)
|
||||||
{
|
{
|
||||||
captureBar.gameObject.SetActive(true);
|
captureBar.gameObject.SetActive(true);
|
||||||
_sequence = DOTween.Sequence();
|
_sequence = DOTween.Sequence();
|
||||||
@ -53,8 +55,11 @@ public class UnitView : MonoBehaviour
|
|||||||
_capureHex.Invoke();
|
_capureHex.Invoke();
|
||||||
captureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);
|
captureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);
|
||||||
captureBar.gameObject.SetActive(false);
|
captureBar.gameObject.SetActive(false);
|
||||||
|
MusicController.Instance.PlayerAudioClip(MusicController.Instance.MusicData.SfxMusic.HardCapture,
|
||||||
|
cell.gameObject);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void StopHardCature()
|
public void StopHardCature()
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,13 @@ public class WeaponSelection : MonoBehaviour
|
|||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
var dataPah = Application.persistentDataPath + "/" + dataFilePath;
|
||||||
|
if (!File.Exists(dataPah))
|
||||||
|
{
|
||||||
|
FileStream stream = new FileStream(dataPah, FileMode.Create);
|
||||||
|
using StreamWriter writer = new StreamWriter(stream);
|
||||||
|
writer.Write(JsonUtility.ToJson(data.WeaponsList[0]));
|
||||||
|
}
|
||||||
_buttons = new List<Button>();
|
_buttons = new List<Button>();
|
||||||
data.WeaponsList.ForEach(x =>
|
data.WeaponsList.ForEach(x =>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user