Update SurvivalIsland
This commit is contained in:
1 parent
d33bc2d31c
commit
388161e953
18 files changed
+105
-23
No files matched your search
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class DoorManager : MonoBehaviour
|
||||
{
|
||||
bool doorIsOpen = false;
|
||||
float doorTimer = 0.0f;
|
||||
public float doorOpenTime = 3.0f;
|
||||
public AudioClip doorOpenSound;
|
||||
public AudioClip doorShutSound;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
doorTimer = 0.0f;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (doorIsOpen)
|
||||
{
|
||||
doorTimer += Time.deltaTime;
|
||||
if (doorTimer > doorOpenTime)
|
||||
{
|
||||
Door(doorShutSound, false, "doorshut");
|
||||
doorTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoorCheck()
|
||||
{
|
||||
if (!doorIsOpen)
|
||||
{
|
||||
Door(doorOpenSound, true, "dooropen");
|
||||
}
|
||||
}
|
||||
|
||||
void Door(AudioClip aClip, bool openCheck, string animName)
|
||||
{
|
||||
audio.PlayOneShot(aClip);
|
||||
doorIsOpen = openCheck;
|
||||
transform.parent.animation.Play(animName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28c1dfaf4ab0da34590fb036ccc994c1
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -2,11 +2,11 @@
|
||||
using System.Collections;
|
||||
|
||||
public class PlayerCollisions : MonoBehaviour {
|
||||
bool doorIsOpen = false;
|
||||
float doorTimer = 0.0f;
|
||||
public float doorOpenTime = 3.0f;
|
||||
public AudioClip doorOpenSound;
|
||||
public AudioClip doorShutSound;
|
||||
// bool doorIsOpen = false;
|
||||
// float doorTimer = 0.0f;
|
||||
// public float doorOpenTime = 3.0f;
|
||||
// public AudioClip doorOpenSound;
|
||||
// public AudioClip doorShutSound;
|
||||
|
||||
GameObject currentDoor;
|
||||
|
||||
@@ -17,26 +17,33 @@ public class PlayerCollisions : MonoBehaviour {
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if (doorIsOpen) {
|
||||
doorTimer += Time.deltaTime;
|
||||
|
||||
if (doorTimer > doorOpenTime) {
|
||||
Door (doorShutSound, false, "doorshut",currentDoor);
|
||||
doorTimer = 0.0f;
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast (transform.position, transform.forward, out hit, 3)) {
|
||||
if (hit.collider.gameObject.tag == "playerDoor") {
|
||||
currentDoor = hit.collider.gameObject;
|
||||
currentDoor.SendMessage ("DoorCheck");
|
||||
}
|
||||
}
|
||||
// if (doorIsOpen) {
|
||||
// doorTimer += Time.deltaTime;
|
||||
|
||||
// if (doorTimer > doorOpenTime) {
|
||||
// Door (doorShutSound, false, "doorshut",currentDoor);
|
||||
// doorTimer = 0.0f;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void OnControllerColliderHit(ControllerColliderHit hit) {
|
||||
if (hit.gameObject.tag == "playerDoor" && doorIsOpen == false) {
|
||||
currentDoor = hit.gameObject;
|
||||
Door (doorOpenSound, true, "dooropen",currentDoor);
|
||||
}
|
||||
}
|
||||
// void OnControllerColliderHit(ControllerColliderHit hit) {
|
||||
// if (hit.gameObject.tag == "playerDoor" && doorIsOpen == false) {
|
||||
// currentDoor = hit.gameObject;
|
||||
// Door (doorOpenSound, true, "dooropen",currentDoor);
|
||||
// }
|
||||
// }
|
||||
|
||||
void Door(AudioClip aClip, bool openCheck, string animName,GameObject thisDoor) {
|
||||
thisDoor.audio.PlayOneShot (aClip);
|
||||
doorIsOpen = openCheck;
|
||||
thisDoor.transform.parent.animation.Play (animName);
|
||||
}
|
||||
// void Door(AudioClip aClip, bool openCheck, string animName,GameObject thisDoor) {
|
||||
// thisDoor.audio.PlayOneShot (aClip);
|
||||
// doorIsOpen = openCheck;
|
||||
// thisDoor.transform.parent.animation.Play (animName);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class TriggerZone : MonoBehaviour
|
||||
{
|
||||
void OnTriggerEnter(Collider col)
|
||||
{
|
||||
if (col.gameObject.tag == "Player")
|
||||
{
|
||||
transform.FindChild("door").SendMessage("DoorCheck");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96b2117e72a038e41acc5be055c9c5f9
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Reference in new issue
Block a user