From deabf49ab85be838f50c0f49ee961b683c860b9e Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Sat, 21 Jan 2017 19:34:09 +1100 Subject: [PATCH] Fixed some inheritance and added Heavyobject class --- IronToad_UnityProject/Assets/Animations.meta | 9 +++++ .../Assets/Art/terrainTextures/ToonLit 1.mat | Bin 2070 -> 4576 bytes .../Assets/Scripts/BuoyantObject.cs | 8 ++-- .../Assets/Scripts/HeavyObject.cs | 15 +++++++ .../Assets/Scripts/HeavyObject.cs.meta | 12 ++++++ .../Assets/Scripts/PlayerController.cs | 6 ++- .../Assets/Scripts/WaterController.cs | 10 +++-- .../Assets/Scripts/WaterObject.cs | 6 +-- .../Assets/Scripts/WaterSetUp.cs | 37 ++++++++++++++++++ .../Assets/Scripts/WaterSetUp.cs.meta | 12 ++++++ IronToad_UnityProject/Assets/Sound/Music.meta | 9 +++++ IronToad_UnityProject/Assets/Sound/SFX.meta | 9 +++++ IronToad_UnityProject/Assets/Textures.meta | 9 +++++ 13 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 IronToad_UnityProject/Assets/Animations.meta create mode 100644 IronToad_UnityProject/Assets/Scripts/HeavyObject.cs create mode 100644 IronToad_UnityProject/Assets/Scripts/HeavyObject.cs.meta create mode 100644 IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs create mode 100644 IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs.meta create mode 100644 IronToad_UnityProject/Assets/Sound/Music.meta create mode 100644 IronToad_UnityProject/Assets/Sound/SFX.meta create mode 100644 IronToad_UnityProject/Assets/Textures.meta diff --git a/IronToad_UnityProject/Assets/Animations.meta b/IronToad_UnityProject/Assets/Animations.meta new file mode 100644 index 0000000..b2e446b --- /dev/null +++ b/IronToad_UnityProject/Assets/Animations.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 653e5549e4b277c4facae79f936bb3e6 +folderAsset: yes +timeCreated: 1484972317 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Art/terrainTextures/ToonLit 1.mat b/IronToad_UnityProject/Assets/Art/terrainTextures/ToonLit 1.mat index 84c2369b37ad33c53b72b022548d2094c4d11a05..0f5053be64eee047e86ceeb132827e150291ffda 100644 GIT binary patch literal 4576 zcmeH~-)|IE6vxl(ul_)V6%-JV1+n$#iq`tGwv~1(mDVn_8smfONT<7Fc4s#;v)CGA z#)M$x(Z~~+NP@f&4Z*|+(Ki#r11}g88x(ml5aWY{2NTnDJ>Pq0FLT%W2bk<_PWRr= zocZ4KV`uj+QCE&AeTDcR(Heds>d*FPch2?Ea--2OVhrv8Z8VNty1HfQ>W2AiZ%kc3 zzVX=lNv1J_D22;Bo+JwRmWEgaLtoZ&O^x`2w#I z&uV_9K=^BMqKhlVnFbf8$9cQrvR|+A8hNc{!$2QV&l1nU*8%bXzs~$!o+BRdHVMG> zy4?w9!S%YW2j_u$Zsk6rZqV5P7=R~4Uyg=+qvA;|-@BO0d{bIqHh~LEX?@wOxYY0F zK4RZ3%;mni{@w5&hL*06_vuRdnUKf$>W4f(#s>Xu{3`WhqHbS=e7oXtEw6hNPiT4V z0Ox`FMC*1hU;v(^!#r!&tw-^csOQ(bMm)WWcWC?KIg|NzYWv;~F050l=L3o->06$o zo~ZGIY#6B9Y3}cNp5wj$5FihOI)r}nd4E_i$)oT8tl}y9nYDl5HJ;H&*oZPh=Q!tk ziB}1>oxle^NvJ3Kh`Ql(3j?25c;4AWzC(b) zzw;edT+jD;a2~Ds?g9+J^?XMZ*Yh1!T+f%k$X3jE3|yF=FFr>lPtq$K0rJIX=WaHl z3|~u$I{eKm)M1>>i14M5zu3Z;L%yelV>9SXgnZKUE!Q^7l+XL_KyKFdt8Q-Iw;a!| zI)hXxjM-&te3U17(=YKv_)VA0S z_E`?!xwmfBE%JQVc8W7*anh{O%Z}|Y5D+B<*MtEOGSEOD1}-;H4TZr5dl)%Hj~g4w+RM<#q)+Jhp|bxel@D1s%Nb z+R?@Imp`THt8=3t_3uDLMCadGvvx6k<6@c`XK&II`JQ#z-is3_dwUMQSG)0v^u7Go za&|HOJuCcn@TRYjY5!|ipk0A>1=?ii0s{3Wzv6fy+42b)uOSZ#n&m-#V>l?z+16CNpiG}F>6ExH` zXreZST*dZqR^xf=z;FLTm}6mjhF5wV_^n?EV+glskqCxlTs3RIa%gJESD~Tumb F^AD@i2rB>p literal 2070 zcmcgtTW`}a6n^io@E*ofTg6V&T;9g$U}9xst&k8xkrSV6Mu}4;&S;tV?;JZ_Y1d9_ zL7E?|I6mk5&fTY9&n8!d4r%XncJ`i}v?oOKySP4nzRKDle9h=~`9jQeR6 z2}<2G#NBa5DNj9*MZW8?KGDlLV!E9H9o$D){;X<&rhofxSVe6Q(?MOr!4;<=J8;P9RNaT66KN5z;tTLHqyfCPXn9x31;%*}Kv@qLw z-hl1|94laRX#@^)?rmGnCw#sJZQu~+)+C1L6|6KhXN%)VJHu$J960;3M^nuWZsAeY{Ym7ffKm7h_)K7^XtDnE0c?& z;`+!=n%+w#6*SHBG?L*cvMUT%SBF*ab*l>m+=X+T&>TQ3+VR)%duvr`MYH#zN|<9xpT~ O6Y$G&{?fxe>iq$#Y8Dg# diff --git a/IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs b/IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs index 1e9f72c..2b2d04d 100644 --- a/IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs +++ b/IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs @@ -28,7 +28,7 @@ public class BuoyantObject : WaterObject { #endregion Unity Functions - public override void OnWaterStay(GameObject water,float waveHeight) { + public override void OnWaterStay(WaterController water,float waveHeight) { Vector3 waterEntryPoint = transform.position; waterEntryPoint.y = water.transform.position.y + waveHeight; @@ -42,16 +42,16 @@ public class BuoyantObject : WaterObject { rb.AddForce(force); Vector3 dragVel = rb.velocity; - dragVel.y *= 0.98f; + dragVel.y *= 0.9f; rb.velocity = dragVel; } - public override void OnWaterEnter(GameObject water) { + public override void OnWaterEnter(WaterController water) { //rb.drag = 1; } - public override void OnWaterExit(GameObject water) { + public override void OnWaterExit(WaterController water) { // rb.drag = airDrag; } diff --git a/IronToad_UnityProject/Assets/Scripts/HeavyObject.cs b/IronToad_UnityProject/Assets/Scripts/HeavyObject.cs new file mode 100644 index 0000000..486e53d --- /dev/null +++ b/IronToad_UnityProject/Assets/Scripts/HeavyObject.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class HeavyObject : WaterObject { + + public float splashRadius; + public float splashPower; + + public override void OnWaterEnter(WaterController water) { + water.CreateWave(transform.position,splashRadius,splashPower) + } + +} diff --git a/IronToad_UnityProject/Assets/Scripts/HeavyObject.cs.meta b/IronToad_UnityProject/Assets/Scripts/HeavyObject.cs.meta new file mode 100644 index 0000000..3db3c19 --- /dev/null +++ b/IronToad_UnityProject/Assets/Scripts/HeavyObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9fd6f6961a3776a4182416c3c917f017 +timeCreated: 1484987123 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Scripts/PlayerController.cs b/IronToad_UnityProject/Assets/Scripts/PlayerController.cs index 5efcfcb..47ba936 100644 --- a/IronToad_UnityProject/Assets/Scripts/PlayerController.cs +++ b/IronToad_UnityProject/Assets/Scripts/PlayerController.cs @@ -4,6 +4,10 @@ using UnityEngine; public class PlayerController : MonoBehaviour { + public float power; + public float radius; + public float time; + // Update is called once per frame void Update () { @@ -22,7 +26,7 @@ public class PlayerController : MonoBehaviour { Debug.Log("I hit: " + hit.transform.name); if (waterScript != null) - waterScript.CreateWave(hit.point, 10, 5); + waterScript.CreateWave(hit.point, radius, power); } diff --git a/IronToad_UnityProject/Assets/Scripts/WaterController.cs b/IronToad_UnityProject/Assets/Scripts/WaterController.cs index 79b5105..d967128 100644 --- a/IronToad_UnityProject/Assets/Scripts/WaterController.cs +++ b/IronToad_UnityProject/Assets/Scripts/WaterController.cs @@ -40,6 +40,8 @@ public class WaterController : MonoBehaviour { public void CreateWave(Vector3 point, float radius, float power){ //find all colliders within the wave distance + + point.y = transform.position.y; StartCoroutine(waveController(point, radius, power, 2)); @@ -48,7 +50,7 @@ public class WaterController : MonoBehaviour { #region Helper Functions - public IEnumerator waveController (Vector3 point, float radius, float power, float rippleTime) { + private IEnumerator waveController (Vector3 point, float radius, float power, float rippleTime) { float elapsedTime = 0.0f; @@ -89,7 +91,7 @@ public class WaterController : MonoBehaviour { //calls appropriate function if the object should interact with the water on enter WaterObject waterInteraction = other.gameObject.GetComponent(); if (waterInteraction != null) { - waterInteraction.OnWaterEnter(gameObject); + waterInteraction.OnWaterEnter(this); } } @@ -105,7 +107,7 @@ public class WaterController : MonoBehaviour { float waveHeight = Mathf.PerlinNoise(waveCoords.x, waveCoords.y + waveOffset); - waterInteraction.OnWaterStay(gameObject,waveHeight * maxWaveHeight); + waterInteraction.OnWaterStay(this,waveHeight * maxWaveHeight); } } @@ -114,7 +116,7 @@ public class WaterController : MonoBehaviour { //calls appropriate function if the object should interact with the water on exit WaterObject waterInteraction = other.gameObject.GetComponent(); if (waterInteraction != null) { - waterInteraction.OnWaterExit(gameObject); + waterInteraction.OnWaterExit(this); } } diff --git a/IronToad_UnityProject/Assets/Scripts/WaterObject.cs b/IronToad_UnityProject/Assets/Scripts/WaterObject.cs index a15a621..85720ad 100644 --- a/IronToad_UnityProject/Assets/Scripts/WaterObject.cs +++ b/IronToad_UnityProject/Assets/Scripts/WaterObject.cs @@ -7,17 +7,17 @@ public abstract class WaterObject : MonoBehaviour { /// /// Called when object intersects water plane /// - public abstract void OnWaterEnter(GameObject water); + public abstract void OnWaterEnter(WaterController water); /// /// Called while objects stays in water /// - public abstract void OnWaterStay(GameObject water,float waveHeight); + public abstract void OnWaterStay(WaterController water,float waveHeight); /// /// Called when object leaves water /// - public abstract void OnWaterExit(GameObject water); + public abstract void OnWaterExit(WaterController water); } diff --git a/IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs b/IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs new file mode 100644 index 0000000..6ff9da1 --- /dev/null +++ b/IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs @@ -0,0 +1,37 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class WaterSetUp : MonoBehaviour { + + // Use this for initialization + void Start () { + Vector3 originalScale = transform.localScale; + + Vector2 texScale = Vector3.one;// GetComponent().material.GetTextureScale("_Perlin"); + + + + transform.localScale = Vector3.one; + + for (float x = -originalScale.x/2; x < originalScale.x / 2; x++) { + for (float z = -originalScale.z / 2; z < originalScale.z/2; z++) { + //Debug.Log("blah"); + + Vector3 pos = transform.position; + pos.x += transform.lossyScale.x * x; + pos.z += transform.lossyScale.z * z; + + Vector2 texOffset = new Vector2(texScale.x * x, texScale.y * z); + + GameObject waterClone = Instantiate(gameObject, pos, transform.rotation, transform); + // waterClone.GetComponent().material.SetTextureOffset("_Diffuse", texOffset); + // waterClone.GetComponent().material.SetTextureOffset("_Normals", texOffset); + // waterClone.GetComponent().material.SetTextureOffset("_Perlin", texOffset); + // waterClone.GetComponent().material.SetTextureOffset("_Perlin_copy", texOffset); + } + } + Debug.Log("blah"); + } + +} diff --git a/IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs.meta b/IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs.meta new file mode 100644 index 0000000..3f71e55 --- /dev/null +++ b/IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2c43fce4399eca2488874b64aef6786c +timeCreated: 1484981374 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Sound/Music.meta b/IronToad_UnityProject/Assets/Sound/Music.meta new file mode 100644 index 0000000..a4f829c --- /dev/null +++ b/IronToad_UnityProject/Assets/Sound/Music.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1715d56e0d2b68246a82993db31014ab +folderAsset: yes +timeCreated: 1484979777 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Sound/SFX.meta b/IronToad_UnityProject/Assets/Sound/SFX.meta new file mode 100644 index 0000000..0c3fd08 --- /dev/null +++ b/IronToad_UnityProject/Assets/Sound/SFX.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: de5a3adcedb96f64183518ac89622ade +folderAsset: yes +timeCreated: 1484979777 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/IronToad_UnityProject/Assets/Textures.meta b/IronToad_UnityProject/Assets/Textures.meta new file mode 100644 index 0000000..ffdd440 --- /dev/null +++ b/IronToad_UnityProject/Assets/Textures.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2a6e699820a38a544acfc0015eb679a2 +folderAsset: yes +timeCreated: 1484972317 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: