From fb3ab3c2bd5be5a2d0362e1a6503afd975a1958b Mon Sep 17 00:00:00 2001 From: Nyghor Date: Mon, 23 Apr 2018 23:20:38 +0200 Subject: [PATCH] Added sparks when enemy is damaged --- .../Prefabs/PlayerNew.prefab | 3 +++ .../Prefabs/Weapons/Sparks.prefab | 21 +++++++++++++++---- ShowPT/Assets/Scripts/DestroyByTime.cs | 12 +++++++++++ ShowPT/Assets/Scripts/DestroyByTime.cs.meta | 13 ++++++++++++ ShowPT/Assets/Scripts/GunController.cs | 3 +++ ShowPT/Assets/Scripts/RifleController.cs | 3 +++ ShowPT/Assets/Scripts/WeaponController.cs | 3 +++ 7 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 ShowPT/Assets/Scripts/DestroyByTime.cs create mode 100644 ShowPT/Assets/Scripts/DestroyByTime.cs.meta diff --git a/ShowPT/Assets/Graphical Resources/Prefabs/PlayerNew.prefab b/ShowPT/Assets/Graphical Resources/Prefabs/PlayerNew.prefab index 6ffb723c..be8fb7e9 100644 --- a/ShowPT/Assets/Graphical Resources/Prefabs/PlayerNew.prefab +++ b/ShowPT/Assets/Graphical Resources/Prefabs/PlayerNew.prefab @@ -11885,6 +11885,7 @@ MonoBehaviour: esferaRoja: {fileID: 1875600123601928, guid: f9e53e24f85fa9549adb0b70849208db, type: 2} explosion: {fileID: 1538796440401936, guid: dc2e349666b67b147abf2bb01918ffd3, type: 2} shootEffect: {fileID: 198198216888127518} + sparks: {fileID: 1149727948857286, guid: 81170b26490e59a45b57295281371104, type: 2} numDrons: 0 typeAmmo: 0 wazPuntuation: {fileID: 0} @@ -11992,6 +11993,7 @@ MonoBehaviour: esferaRoja: {fileID: 1875600123601928, guid: a59f92463ea9a2b41aa7288b86acfeda, type: 2} explosion: {fileID: 1538796440401936, guid: 02e088ba12ebc334f9c9f06de13f267b, type: 2} shootEffect: {fileID: 198878964317542246} + sparks: {fileID: 1149727948857286, guid: 81170b26490e59a45b57295281371104, type: 2} numDrons: 0 typeAmmo: 2 wazPuntuation: {fileID: 0} @@ -12041,6 +12043,7 @@ MonoBehaviour: esferaRoja: {fileID: 1875600123601928, guid: a59f92463ea9a2b41aa7288b86acfeda, type: 2} explosion: {fileID: 1538796440401936, guid: 02e088ba12ebc334f9c9f06de13f267b, type: 2} shootEffect: {fileID: 198008672147419078} + sparks: {fileID: 1149727948857286, guid: 81170b26490e59a45b57295281371104, type: 2} numDrons: 0 typeAmmo: 1 shot: {fileID: 8300000, guid: eba2a5b7be178b042b2477624eccde55, type: 3} diff --git a/ShowPT/Assets/Graphical Resources/Prefabs/Weapons/Sparks.prefab b/ShowPT/Assets/Graphical Resources/Prefabs/Weapons/Sparks.prefab index c4410f93..d1f11670 100644 --- a/ShowPT/Assets/Graphical Resources/Prefabs/Weapons/Sparks.prefab +++ b/ShowPT/Assets/Graphical Resources/Prefabs/Weapons/Sparks.prefab @@ -21,6 +21,7 @@ GameObject: - component: {fileID: 4372771240180146} - component: {fileID: 198110048108992374} - component: {fileID: 199749373231686412} + - component: {fileID: 114616735894447762} m_Layer: 0 m_Name: Sparks m_TagString: Untagged @@ -72,6 +73,18 @@ Transform: m_Father: {fileID: 4372771240180146} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &114616735894447762 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1149727948857286} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f24be192f2e312242b4b492a7d0aaa6e, type: 3} + m_Name: + m_EditorClassIdentifier: + lifetime: 2 --- !u!198 &198110048108992374 ParticleSystem: m_ObjectHideFlags: 1 @@ -84,7 +97,7 @@ ParticleSystem: stopAction: 0 looping: 0 prewarm: 0 - playOnAwake: 0 + playOnAwake: 1 useUnscaledTime: 0 autoRandomSeed: 1 useRigidbodyForVelocity: 1 @@ -132,7 +145,7 @@ ParticleSystem: moveWithTransform: 0 moveWithCustomTransform: {fileID: 0} scalingMode: 2 - randomSeed: 2119211827 + randomSeed: 1083692332 InitialModule: serializedVersion: 3 enabled: 1 @@ -3490,7 +3503,7 @@ ParticleSystem: stopAction: 0 looping: 0 prewarm: 0 - playOnAwake: 0 + playOnAwake: 1 useUnscaledTime: 0 autoRandomSeed: 1 useRigidbodyForVelocity: 1 @@ -3538,7 +3551,7 @@ ParticleSystem: moveWithTransform: 0 moveWithCustomTransform: {fileID: 0} scalingMode: 1 - randomSeed: -1102321603 + randomSeed: -151327990 InitialModule: serializedVersion: 3 enabled: 1 diff --git a/ShowPT/Assets/Scripts/DestroyByTime.cs b/ShowPT/Assets/Scripts/DestroyByTime.cs new file mode 100644 index 00000000..45d32964 --- /dev/null +++ b/ShowPT/Assets/Scripts/DestroyByTime.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class DestroyByTime : MonoBehaviour { + + public float lifetime = 2f; + void Start() + { + Destroy(gameObject, lifetime); + } +} diff --git a/ShowPT/Assets/Scripts/DestroyByTime.cs.meta b/ShowPT/Assets/Scripts/DestroyByTime.cs.meta new file mode 100644 index 00000000..034d9aa3 --- /dev/null +++ b/ShowPT/Assets/Scripts/DestroyByTime.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f24be192f2e312242b4b492a7d0aaa6e +timeCreated: 1524518336 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ShowPT/Assets/Scripts/GunController.cs b/ShowPT/Assets/Scripts/GunController.cs index b737eb79..e3aac567 100644 --- a/ShowPT/Assets/Scripts/GunController.cs +++ b/ShowPT/Assets/Scripts/GunController.cs @@ -33,6 +33,7 @@ public class GunController : MonoBehaviour { public GameObject esferaRoja; public GameObject explosion; public ParticleSystem shootEffect; + public GameObject sparks; public int numDrons = 0; @@ -161,6 +162,8 @@ void decreaseAmmo() { hitInfo.collider.gameObject.GetComponent().getHit(damage); ScoreController.gunHit(); + GameObject spark = Instantiate(sparks, hitInfo.point, Quaternion.Euler(0f, 0f, 0f)); + spark.transform.up = hitInfo.normal; } } diff --git a/ShowPT/Assets/Scripts/RifleController.cs b/ShowPT/Assets/Scripts/RifleController.cs index efec669f..ef1e6b9a 100644 --- a/ShowPT/Assets/Scripts/RifleController.cs +++ b/ShowPT/Assets/Scripts/RifleController.cs @@ -34,6 +34,7 @@ public class RifleController : MonoBehaviour public GameObject esferaRoja; public GameObject explosion; public ParticleSystem shootEffect; + public GameObject sparks; public int numDrons = 0; @@ -181,6 +182,8 @@ void decreaseAmmo() { hitInfo.collider.gameObject.GetComponent().getHit(damage); ScoreController.rifleHit(); + GameObject spark = Instantiate(sparks, hitInfo.point, Quaternion.Euler(0f, 0f, 0f)); + spark.transform.up = hitInfo.normal; } } diff --git a/ShowPT/Assets/Scripts/WeaponController.cs b/ShowPT/Assets/Scripts/WeaponController.cs index e5eedc1e..532fbc15 100644 --- a/ShowPT/Assets/Scripts/WeaponController.cs +++ b/ShowPT/Assets/Scripts/WeaponController.cs @@ -39,6 +39,7 @@ public class WeaponController : MonoBehaviour public GameObject esferaRoja; public GameObject explosion; public ParticleSystem shootEffect; + public GameObject sparks; public int numDrons = 0; @@ -209,6 +210,8 @@ void decreaseAmmo() { hitInfo.collider.gameObject.GetComponent().getHit(damage); ScoreController.weaponHit(); + GameObject spark = Instantiate(sparks, hitInfo.point, Quaternion.Euler(0f, 0f, 0f)); + spark.transform.up = hitInfo.normal; } }