Browse Source

Fixed some inheritance and added Heavyobject class

master
Joshua Reason 8 years ago
parent
commit
deabf49ab8
13 changed files with 130 additions and 12 deletions
  1. +9
    -0
      IronToad_UnityProject/Assets/Animations.meta
  2. BIN
      IronToad_UnityProject/Assets/Art/terrainTextures/ToonLit 1.mat
  3. +4
    -4
      IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs
  4. +15
    -0
      IronToad_UnityProject/Assets/Scripts/HeavyObject.cs
  5. +12
    -0
      IronToad_UnityProject/Assets/Scripts/HeavyObject.cs.meta
  6. +5
    -1
      IronToad_UnityProject/Assets/Scripts/PlayerController.cs
  7. +6
    -4
      IronToad_UnityProject/Assets/Scripts/WaterController.cs
  8. +3
    -3
      IronToad_UnityProject/Assets/Scripts/WaterObject.cs
  9. +37
    -0
      IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs
  10. +12
    -0
      IronToad_UnityProject/Assets/Scripts/WaterSetUp.cs.meta
  11. +9
    -0
      IronToad_UnityProject/Assets/Sound/Music.meta
  12. +9
    -0
      IronToad_UnityProject/Assets/Sound/SFX.meta
  13. +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:

BIN
IronToad_UnityProject/Assets/Art/terrainTextures/ToonLit 1.mat View File


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

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

+ 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 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);
}

+ 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){
//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<WaterObject>();
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<WaterObject>();
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>
/// Called when object intersects water plane
/// </summary>
public abstract void OnWaterEnter(GameObject water);
public abstract void OnWaterEnter(WaterController water);
/// <summary>
/// Called while objects stays in water
/// </summary>
public abstract void OnWaterStay(GameObject water,float waveHeight);
public abstract void OnWaterStay(WaterController water,float waveHeight);
/// <summary>
/// Called when object leaves water
/// </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