Files
unity-vr-development/SurvivalIsland/Assets/Scripts/CoconutWin.cs
T
2025-04-10 19:05:55 +08:00

34 lines
722 B
C#

using UnityEngine;
using System.Collections;
[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 () {
}
// Update is called once per frame
void Update () {
if (targets == 3 && haveWon == false) {
targets = 0;
audio.PlayOneShot(winSound);
GameObject winCell = transform.Find ("powerCell").
gameObject;
winCell.transform.Translate(-1, 0, 0);
Instantiate(cellPrefab, winCell.transform.position,
transform.rotation);
Destroy (winCell);
haveWon = true;
}
}
}