Update SurvivalIsland
This commit is contained in:
1 parent
83adad7d01
commit
c404a1c315
46 files changed
+210
-42
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Inventory : MonoBehaviour
|
||||
{
|
||||
public static int charge = 0;
|
||||
public AudioClip collectSound;
|
||||
public Texture2D[] hudCharge;
|
||||
public GUITexture chargeHudGUI;
|
||||
|
||||
public Texture2D[] meterCharge;
|
||||
public Renderer meter;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
charge = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CellPickup()
|
||||
{
|
||||
HUDon();
|
||||
AudioSource.PlayClipAtPoint(collectSound, transform.position);
|
||||
charge++;
|
||||
chargeHudGUI.texture = hudCharge[charge];
|
||||
meter.material.mainTexture = meterCharge [charge];
|
||||
}
|
||||
|
||||
void HUDon()
|
||||
{
|
||||
if (!chargeHudGUI.enabled)
|
||||
{
|
||||
chargeHudGUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68f5e2be7df12d64a88637557de0017f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class PowerCell : MonoBehaviour {
|
||||
public float rotationSpeed = 100.0f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
transform.Rotate (new Vector3 (0, rotationSpeed * Time.deltaTime, 0));
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider col) {
|
||||
if (col.gameObject.tag == "Player") {
|
||||
col.gameObject.SendMessage ("CellPickup");
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84973f37da8c1b64491db40ade6b4948
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class TextHints : MonoBehaviour
|
||||
{
|
||||
float timer = 0.0f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (guiText.enabled)
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
if (timer >= 4)
|
||||
{
|
||||
guiText.enabled = false;
|
||||
timer = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShowHint(string message)
|
||||
{
|
||||
guiText.text = message;
|
||||
if (!guiText.enabled)
|
||||
{
|
||||
guiText.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74894e00c3f33fe4eaaacc1394c80eef
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -3,11 +3,43 @@ using System.Collections;
|
||||
|
||||
public class TriggerZone : MonoBehaviour
|
||||
{
|
||||
public AudioClip lockedSound;
|
||||
public Light doorLight;
|
||||
public GUIText textHints;
|
||||
|
||||
void OnTriggerEnter(Collider col)
|
||||
{
|
||||
if (col.gameObject.tag == "Player")
|
||||
{
|
||||
transform.FindChild("door").SendMessage("DoorCheck");
|
||||
if (Inventory.charge == 4)
|
||||
{
|
||||
transform.FindChild("door").
|
||||
SendMessage("DoorCheck");
|
||||
if (GameObject.Find("PowerGUI"))
|
||||
{
|
||||
Destroy(GameObject.Find("PowerGUI"));
|
||||
doorLight.color = Color.green;
|
||||
}
|
||||
}
|
||||
else if (Inventory.charge > 0 && Inventory.charge < 4)
|
||||
{
|
||||
textHints.SendMessage("ShowHint",
|
||||
"This door won't budge.. " +
|
||||
"guess it needs fully charging - " +
|
||||
"maybe more power cells will help...");
|
||||
transform.FindChild("door").audio.
|
||||
PlayOneShot(lockedSound);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.FindChild("door").audio.
|
||||
PlayOneShot(lockedSound);
|
||||
col.gameObject.SendMessage("HUDon");
|
||||
textHints.SendMessage("ShowHint",
|
||||
"This door seems locked.. maybe that " +
|
||||
"generator needs power...");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user