This commit is contained in:
xixu-me committed 2025-04-11 09:56:51 +08:00
1 parent 24ccea0748
commit 15fe1e4ce1
26 files changed
+290 -304

No files matched your search

+14 -10
View File
@@ -1,8 +1,9 @@
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (AudioSource))]
public class CoconutThrower : MonoBehaviour {
[RequireComponent(typeof(AudioSource))]
public class CoconutThrower : MonoBehaviour
{
public AudioClip throwSound;
public Rigidbody coconutPrefab;
@@ -10,21 +11,24 @@ public class CoconutThrower : MonoBehaviour {
public static bool canThrow = false;
// Use this for initialization
void Start () {
void Start()
{
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("Fire1") && canThrow) {
void Update()
{
if (Input.GetButtonDown("Fire1") && canThrow)
{
audio.PlayOneShot(throwSound);
Rigidbody newCoconut = Instantiate(coconutPrefab,
transform.position, transform.rotation) as Rigidbody;
transform.position, transform.rotation) as Rigidbody;
newCoconut.name = "coconut";
newCoconut.velocity = transform.forward * throwSpeed;
Physics.IgnoreCollision(transform.root.collider,
newCoconut.collider, true);
}
newCoconut.collider, true);
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 85cba2d465ac9ab4d8064e0b99aaa7dd
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+15 -11
View File
@@ -1,30 +1,34 @@
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (AudioSource))]
public class CoconutWin : MonoBehaviour {
[RequireComponent(typeof(AudioSource))]
public class CoconutWin : MonoBehaviour
{
public static int targets = 0;
public static bool haveWon = false;
public AudioClip winSound;
public GameObject cellPrefab;
// Use this for initialization
void Start () {
void Start()
{
}
// Update is called once per frame
void Update () {
if (targets == 3 && haveWon == false) {
void Update()
{
if (targets == 3 && haveWon == false)
{
targets = 0;
audio.PlayOneShot(winSound);
GameObject winCell = transform.Find ("powerCell").
GameObject winCell = transform.Find("powerCell").
gameObject;
winCell.transform.Translate(-1, 0, 0);
Instantiate(cellPrefab, winCell.transform.position,
transform.rotation);
Destroy (winCell);
transform.rotation);
Destroy(winCell);
haveWon = true;
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e4ccbd406b9ee9a4dbf41adad9400abe
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+30 -22
View File
@@ -1,42 +1,50 @@
using UnityEngine;
using System.Collections;
public class DoorManager : MonoBehaviour {
public class DoorManager : MonoBehaviour
{
bool doorIsOpen = false;
float doorTimer= 0.0f;
float doorTimer = 0.0f;
public float doorOpenTime = 3.0f;
public AudioClip doorOpenSound;
public AudioClip doorShutSound;
// Use this for initialization
void Start () {
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 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 DoorCheck()
{
if (!doorIsOpen)
{
Door(doorOpenSound, true, "dooropen");
}
}
void Door(AudioClip aClip,bool openCheck, string animName){
audio.PlayOneShot (aClip);
void Door(AudioClip aClip, bool openCheck, string animName)
{
audio.PlayOneShot(aClip);
doorIsOpen = openCheck;
transform.parent.animation.Play (animName);
transform.parent.animation.Play(animName);
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 80af9609c13cf5648aa46809aaec8e8c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+41 -27
View File
@@ -1,9 +1,10 @@
using UnityEngine;
using System.Collections;
public class Inventory : MonoBehaviour {
public class Inventory : MonoBehaviour
{
public static int charge=0;
public static int charge = 0;
public AudioClip collectSound;
public Texture2D[] hudCharge;
public GUITexture chargeHudGUI;
@@ -18,58 +19,71 @@ public class Inventory : MonoBehaviour {
bool fireIsLit = false;
// Use this for initialization
void Start () {
void Start()
{
charge = 0;
}
// Update is called once per frame
void Update () {
void Update()
{
}
void CellPickup(){
HUDon ();
AudioSource .PlayClipAtPoint (collectSound, transform.position);
void CellPickup()
{
HUDon();
AudioSource.PlayClipAtPoint(collectSound, transform.position);
charge++;
chargeHudGUI.texture = hudCharge [charge];
meter.material.mainTexture = meterCharge [charge];
chargeHudGUI.texture = hudCharge[charge];
meter.material.mainTexture = meterCharge[charge];
}
void HUDon(){
if (!chargeHudGUI.enabled) {
chargeHudGUI.enabled =true;
void HUDon()
{
if (!chargeHudGUI.enabled)
{
chargeHudGUI.enabled = true;
}
}
void MatchPickup() {
void MatchPickup()
{
haveMatches = true;
//AudioSource.PlayClipAtPoint (collectSound, transform.position);
GUITexture matchHUD = Instantiate (matchGUIprefab,
new Vector3 (0.15f, 0.1f, 0), transform.rotation) as GUITexture;
GUITexture matchHUD = Instantiate(matchGUIprefab,
new Vector3(0.15f, 0.1f, 0), transform.rotation) as GUITexture;
matchGUI = matchHUD;
}
void OnControllerColliderHit(ControllerColliderHit col) {
if (col.gameObject.name == "campfire") {
if (haveMatches && !fireIsLit) {
void OnControllerColliderHit(ControllerColliderHit col)
{
if (col.gameObject.name == "campfire")
{
if (haveMatches && !fireIsLit)
{
LightFire(col.gameObject);
} else if (!haveMatches && !fireIsLit) {
}
else if (!haveMatches && !fireIsLit)
{
textHints.SendMessage("ShowHint",
"I could use this campfire to signal for help... " +
"if only I could light it...");
"I could use this campfire to signal for help... " +
"if only I could light it...");
}
}
}
void LightFire(GameObject campfire) {
void LightFire(GameObject campfire)
{
ParticleSystem[] pSystems;
pSystems = campfire.GetComponentsInChildren<ParticleSystem> ();
foreach (ParticleSystem pSystem in pSystems) {
pSystems = campfire.GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem pSystem in pSystems)
{
pSystem.Play();
}
//campfire.audio.Play ();
Destroy (matchGUI);
Destroy(matchGUI);
haveMatches = false;
fireIsLit = true;
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 41ee0d51a80bc614cbc4c2fc637cb996
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+31 -21
View File
@@ -1,8 +1,9 @@
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (AudioSource))]
public class MainMenuBtns : MonoBehaviour {
[RequireComponent(typeof(AudioSource))]
public class MainMenuBtns : MonoBehaviour
{
public string levelToLoad;
public Texture2D normalTexture;
@@ -13,35 +14,44 @@ public class MainMenuBtns : MonoBehaviour {
public GUIText textHints;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
void Start()
{
}
void OnMouseEnter() {
// Update is called once per frame
void Update()
{
}
void OnMouseEnter()
{
guiTexture.texture = rollOverTexture;
}
void OnMouseExit() {
void OnMouseExit()
{
guiTexture.texture = normalTexture;
}
IEnumerator OnMouseUp() {
audio.PlayOneShot (beep);
IEnumerator OnMouseUp()
{
audio.PlayOneShot(beep);
yield return new WaitForSeconds(0.35f);
if (quitButton) {
Application.Quit ();
} else if (instructionsButton) {
textHints.SendMessage("ShowHint",
"You awake on a mysterious island..." +
"Find a way to signal for help or face certain doom!");
if (quitButton)
{
Application.Quit();
}
else {
Application.LoadLevel (levelToLoad);
else if (instructionsButton)
{
textHints.SendMessage("ShowHint",
"You awake on a mysterious island..." +
"Find a way to signal for help or face certain doom!");
}
else
{
Application.LoadLevel(levelToLoad);
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 782d7955bf27e2244acf3aa18fa8d58e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+16 -11
View File
@@ -1,22 +1,27 @@
using UnityEngine;
using System.Collections;
public class Matches : MonoBehaviour {
public class Matches : MonoBehaviour
{
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
void Start()
{
}
void OnTriggerEnter(Collider col) {
if (col.gameObject.tag == "Player") {
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
col.gameObject.SendMessage("MatchPickup");
Destroy (gameObject);
Destroy(gameObject);
}
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3ff7e1803b15b4f4c8c16b28071afc58
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
@@ -1,28 +1,33 @@
using UnityEngine;
using System.Collections;
public class PlayerCollisions : MonoBehaviour {
public class PlayerCollisions : MonoBehaviour
{
//bool doorIsOpen = false;
//float doorTimer= 0.0f;
//public float doorOpenTime = 3.0f;
//public AudioClip doorOpenSound;
//public AudioClip doorShutSound;
GameObject currentDoor;
// Use this for initialization
void Start () {
void Start()
{
}
// Update is called once per frame
void Update () {
void Update()
{
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 (Physics.Raycast(transform.position, transform.forward, out hit, 3))
{
if (hit.collider.gameObject.tag == "playerDoor")
{
currentDoor = hit.collider.gameObject;
currentDoor.SendMessage("DoorCheck");
}
}
/*if (doorIsOpen) {
@@ -37,7 +42,7 @@ public class PlayerCollisions : MonoBehaviour {
}*/
}
/*void OnControllerColliderHit(ControllerColliderHit hit){
if (hit.gameObject.tag == "playerDoor" && doorIsOpen == false) {
currentDoor =hit.gameObject;
@@ -45,14 +50,14 @@ public class PlayerCollisions : MonoBehaviour {
//OpenDoor(hit.gameObject);
}
}*/
/*void Door(AudioClip aClip,bool openCheck, string animName,GameObject thisDoor){
thisDoor.audio.PlayOneShot (aClip);
doorIsOpen = openCheck;
thisDoor.transform.parent.animation.Play (animName);
}*/
/*void OpenDoor(GameObject door){
doorIsOpen = true;
door.audio.PlayOneShot (doorOpenSound);
@@ -66,5 +71,5 @@ public class PlayerCollisions : MonoBehaviour {
door.audio.PlayOneShot (doorShutSound);
door.transform.parent.animation.Play ("doorshut");
}*/
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e4996adab0d5ae548ae6ef51830da0f2
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+15 -10
View File
@@ -1,25 +1,30 @@
using UnityEngine;
using System.Collections;
public class PowerCell : MonoBehaviour {
public class PowerCell : MonoBehaviour
{
public float rotationSpeed=100.0f;
public float rotationSpeed = 100.0f;
// Use this for initialization
void Start () {
void Start()
{
}
void OnTriggerEnter(Collider col){
if (col.gameObject .tag == "Player") {
col.gameObject .SendMessage ("CellPickup");
Destroy (gameObject );
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
col.gameObject.SendMessage("CellPickup");
Destroy(gameObject);
}
}
// Update is called once per frame
void Update () {
transform.Rotate (
new Vector3 (0, rotationSpeed * Time .deltaTime, 0));
void Update()
{
transform.Rotate(
new Vector3(0, rotationSpeed * Time.deltaTime, 0));
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e564b3f50537083478ebea99a84920c0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
@@ -1,8 +1,9 @@
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (AudioSource))]
public class TargetCollision : MonoBehaviour {
[RequireComponent(typeof(AudioSource))]
public class TargetCollision : MonoBehaviour
{
bool beenHit = false;
Animation targetRoot;
@@ -11,35 +12,40 @@ public class TargetCollision : MonoBehaviour {
public float resetTime = 3.0f;
// Use this for initialization
void Start () {
void Start()
{
targetRoot = transform.parent.transform.parent.animation;
}
void OnCollisionEnter(Collision col) {
void OnCollisionEnter(Collision col)
{
if (beenHit == false &&
col.gameObject.name == "coconut") {
col.gameObject.name == "coconut")
{
StartCoroutine("targetHit");
}
}
IEnumerator targetHit() {
audio.PlayOneShot (hitSound);
targetRoot.Play ("down");
IEnumerator targetHit()
{
audio.PlayOneShot(hitSound);
targetRoot.Play("down");
beenHit = true;
CoconutWin.targets++;
yield return new WaitForSeconds(resetTime);
audio.PlayOneShot (resetSound);
targetRoot.Play ("up");
audio.PlayOneShot(resetSound);
targetRoot.Play("up");
beenHit = false;
CoconutWin.targets--;
}
// Update is called once per frame
void Update () {
void Update()
{
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 81348036fe326a44aabe9dd92dad9412
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+21 -14
View File
@@ -1,30 +1,37 @@
using UnityEngine;
using System.Collections;
public class TextHints : MonoBehaviour {
public class TextHints : MonoBehaviour
{
float timer =0.0f;
float timer = 0.0f;
// Use this for initialization
void Start () {
void Start()
{
}
// Update is called once per frame
void Update () {
if (guiText.enabled) {
timer+=Time.deltaTime;
if(timer>=4){
guiText.enabled=false;
timer=0.0f;
void Update()
{
if (guiText.enabled)
{
timer += Time.deltaTime;
if (timer >= 4)
{
guiText.enabled = false;
timer = 0.0f;
}
}
}
void ShowHint(string message){
void ShowHint(string message)
{
guiText.text = message;
if (!guiText.enabled) {
guiText.enabled=true;
if (!guiText.enabled)
{
guiText.enabled = true;
}
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: ce0e2ee8905a73d4ca6006d8924194e6
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+26 -18
View File
@@ -1,37 +1,45 @@
using UnityEngine;
using System.Collections;
public class ThrowTrigger : MonoBehaviour {
public GUITexture crosshair;
public class ThrowTrigger : MonoBehaviour
{
public GUITexture crosshair;
public GUIText textHints;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
void Start()
{
}
void OnTriggerEnter(Collider col) {
if (col.gameObject.tag == "Player") {
crosshair.enabled = true;
if (!CoconutWin.haveWon) {
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
crosshair.enabled = true;
if (!CoconutWin.haveWon)
{
textHints.SendMessage("ShowHint",
"\n\n\n\n\n There's a power cell attached to this game, \n" +
"maybe I'll win it if I can knock down all the targets...");
}
CoconutThrower.canThrow = true;
}
}
}
void OnTriggerExit(Collider col) {
if (col.gameObject.tag == "Player") {
crosshair.enabled = false;
void OnTriggerExit(Collider col)
{
if (col.gameObject.tag == "Player")
{
crosshair.enabled = false;
CoconutThrower.canThrow = false;
}
}
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3ef851c593da8cd4d8fbf46996e72817
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+9 -6
View File
@@ -1,16 +1,19 @@
using UnityEngine;
using System.Collections;
public class TidyObject : MonoBehaviour {
public class TidyObject : MonoBehaviour
{
public float removeTime = 3.0f;
// Use this for initialization
void Start () {
Destroy (gameObject, removeTime);
void Start()
{
Destroy(gameObject, removeTime);
}
// Update is called once per frame
void Update () {
void Update()
{
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 59dcc2d1f955c094fbee06fc38a0f423
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
+34 -23
View File
@@ -1,30 +1,39 @@
using UnityEngine;
using System.Collections;
public class TriggerZone : MonoBehaviour {
public class TriggerZone : MonoBehaviour
{
public AudioClip lockedSound;
public Light doorLight;
public GUIText textHints;
void OnTriggerEnter(Collider col){
if (col.gameObject.tag == "Player") {
if(Inventory .charge ==4){
transform.FindChild("door").SendMessage ("DoorCheck");
if(GameObject.Find ("PowerGUI")){
Destroy (GameObject .Find ("PowerGUI"));
doorLight.color=Color.green;
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
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...");
}
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...");
}
}
}
@@ -32,12 +41,14 @@ public class TriggerZone : MonoBehaviour {
// Use this for initialization
void Start () {
void Start()
{
}
// Update is called once per frame
void Update () {
void Update()
{
}
}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 749d278a94f759c4bb676c433e07044e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: