using UnityEngine; using System.Collections; using UnityEngine.UI; public class GameManager : MonoBehaviour { //manager public static GameManager manager; //player public GameObject player; //texts public GameObject scoreText; public GameObject welcome; public GameObject ammotext; //bullet public GameObject bullet; //ammo public int bullets = 0; public int maxbullets = 0; //gun damage public int damage = 0; //score public int score; //can shoot or not //public bool canShoot = false; //is started? or Over? public bool isStart = false; public bool isOver = false; //max score public const int MAXSCORE = 100; // Before Start()... void OnEnable() { manager = this; } // Use this for initialization void Start () { bullets = 0; maxbullets = 0; } // Update is called once per frame void Update () { if(!welcome.GetComponent<Text>().enabled && !isStart) { //welcome.GetComponent<Text>().text = "You Win!"; //미리 텍스트 변경 //Debug.Log("a"); isStart = true; scoreText.SetActive(true); //스코어 텍스트 켜기 ammotext.GetComponent<Text>().enabled = true; } if(score >= MAXSCORE && !isOver) { welcome.GetComponent<Text>().enabled = true; scoreText.SetActive(false); isOver = true; } if(Input.GetButtonDown("Fire1") && bullets > 0) { Debug.Log("Ammo " + bullets + " Max " + maxbullets); Debug.Log("남은 총알" + (--bullets)); ammotext.GetComponent<Text>().text = "ammo:" + bullets; GameObject ins = Instantiate(bullet, player.transform.position, player.transform.rotation) as GameObject; ins.GetComponent<Rigidbody>().AddForce(player.transform.forward * 5000f); } } }