ATC522-011\IGDA 7 years ago
parent
commit
fe5a00a0b6
12 changed files with 130 additions and 12 deletions
  1. +9
    -0
      IronToad_UnityProject/Assets/Animations.meta
  2. +4
    -4
      IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs
  3. +15
    -0
      IronToad_UnityProject/Assets/Scripts/HeavyObject.cs
  4. +12
    -0
      IronToad_UnityProject/Assets/Scripts/HeavyObject.cs.meta
  5. +5
    -1
      IronToad_UnityProject/Assets/Scripts/PlayerController.cs
  6. +6
    -4
      IronToad_UnityProject/Assets/Scripts/WaterController.cs
  7. +3
    -3
      IronToad_UnityProject/Assets/Scripts/WaterObject.cs
  8. +37
    -0
      IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs
  9. +12
    -0
      IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs.meta
  10. +9
    -0
      IronToad_UnityProject/Assets/Sound/Music.meta
  11. +9
    -0
      IronToad_UnityProject/Assets/Sound/SFX.meta
  12. +9
    -0
      IronToad_UnityProject/Assets/Textures.meta

+ 9
- 0
IronToad_UnityProject/Assets/Animations.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 653e5549e4b277c4facae79f936bb3e6
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 4
- 4
IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs View File

@ -28,7 +28,7 @@ public class BuoyantObject : WaterObject {
#endregion Unity Functions #endregion Unity Functions
public override void OnWaterStay(GameObject water,float waveHeight) {
public override void OnWaterStay(WaterController water,float waveHeight) {
Vector3 waterEntryPoint = transform.position; Vector3 waterEntryPoint = transform.position;
waterEntryPoint.y = water.transform.position.y + waveHeight; waterEntryPoint.y = water.transform.position.y + waveHeight;
@ -42,16 +42,16 @@ public class BuoyantObject : WaterObject {
rb.AddForce(force); rb.AddForce(force);
Vector3 dragVel = rb.velocity; Vector3 dragVel = rb.velocity;
dragVel.y *= 0.98f;
dragVel.y *= 0.9f;
rb.velocity = dragVel; rb.velocity = dragVel;
} }
public override void OnWaterEnter(GameObject water) {
public override void OnWaterEnter(WaterController water) {
//rb.drag = 1; //rb.drag = 1;
} }
public override void OnWaterExit(GameObject water) {
public override void OnWaterExit(WaterController water) {
// rb.drag = airDrag; // rb.drag = airDrag;
} }

+ 15
- 0
IronToad_UnityProject/Assets/Scripts/HeavyObject.cs View File

@ -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)
}
}

+ 12
- 0
IronToad_UnityProject/Assets/Scripts/HeavyObject.cs.meta View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9fd6f6961a3776a4182416c3c917f017
timeCreated: 1484987123
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 5
- 1
IronToad_UnityProject/Assets/Scripts/PlayerController.cs View File

@ -4,6 +4,10 @@ using UnityEngine;
public class PlayerController : MonoBehaviour { public class PlayerController : MonoBehaviour {
public float power;
public float radius;
public float time;
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
@ -22,7 +26,7 @@ public class PlayerController : MonoBehaviour {
Debug.Log("I hit: " + hit.transform.name); Debug.Log("I hit: " + hit.transform.name);
if (waterScript != null) if (waterScript != null)
waterScript.CreateWave(hit.point, 10, 5);
waterScript.CreateWave(hit.point, radius, power);
} }

+ 6
- 4
IronToad_UnityProject/Assets/Scripts/WaterController.cs View File

@ -40,6 +40,8 @@ public class WaterController : MonoBehaviour {
public void CreateWave(Vector3 point, float radius, float power){ public void CreateWave(Vector3 point, float radius, float power){
//find all colliders within the wave distance //find all colliders within the wave distance
point.y = transform.position.y;
StartCoroutine(waveController(point, radius, power, 2)); StartCoroutine(waveController(point, radius, power, 2));
@ -48,7 +50,7 @@ public class WaterController : MonoBehaviour {
#region Helper Functions #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; 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 //calls appropriate function if the object should interact with the water on enter
WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>(); WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>();
if (waterInteraction != null) { 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); 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 //calls appropriate function if the object should interact with the water on exit
WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>(); WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>();
if (waterInteraction != null) { if (waterInteraction != null) {
waterInteraction.OnWaterExit(gameObject);
waterInteraction.OnWaterExit(this);
} }
} }

+ 3
- 3
IronToad_UnityProject/Assets/Scripts/WaterObject.cs View File

@ -7,17 +7,17 @@ public abstract class WaterObject : MonoBehaviour {
/// <summary> /// <summary>
/// Called when object intersects water plane /// Called when object intersects water plane
/// </summary> /// </summary>
public abstract void OnWaterEnter(GameObject water);
public abstract void OnWaterEnter(WaterController water);
/// <summary> /// <summary>
/// Called while objects stays in water /// Called while objects stays in water
/// </summary> /// </summary>
public abstract void OnWaterStay(GameObject water,float waveHeight);
public abstract void OnWaterStay(WaterController water,float waveHeight);
/// <summary> /// <summary>
/// Called when object leaves water /// Called when object leaves water
/// </summary> /// </summary>
public abstract void OnWaterExit(GameObject water);
public abstract void OnWaterExit(WaterController water);
} }

+ 37
- 0
IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs View File

@ -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<Renderer>().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<Renderer>().material.SetTextureOffset("_Diffuse", texOffset);
// waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Normals", texOffset);
// waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Perlin", texOffset);
// waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Perlin_copy", texOffset);
}
}
Debug.Log("blah");
}
}

+ 12
- 0
IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs.meta View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2c43fce4399eca2488874b64aef6786c
timeCreated: 1484981374
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Sound/Music.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1715d56e0d2b68246a82993db31014ab
folderAsset: yes
timeCreated: 1484979777
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Sound/SFX.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: de5a3adcedb96f64183518ac89622ade
folderAsset: yes
timeCreated: 1484979777
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Textures.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2a6e699820a38a544acfc0015eb679a2
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save