using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class CsGameManager : MonoBehaviour
{
private CsGameManager hInstance;
public CsGameManager GetInstance() { return hInstance; }
public Transform hero;
public Transform enemyPrefab;
public Transform floor;
public Text stageText;
public Text monsterCountText;
private float stateTime;
private int monsterCount;
public int stage;
public int heroHP;
public int monsterHP;
public int heroDamage;
public int monsterDamage;
// Use this for initialization
void Start()
{
hInstance = this;
stateTime = 0;
monsterCount = stage;
stageText.text = "STAGE : " + stage;
monsterCountText.text = "Monster : " + monsterCount;
CreateEnemy();
}
// Update is called once per frame
void Update()
{
}
public int GetHeroHP()
{
return heroHP;
}
public int GetMonsterHP()
{
return monsterHP;
}
public int GetHeroDamage()
{
return heroDamage;
}
public int GetMonsterDamage()
{
return monsterDamage;
}
public void DownMonsterCount()
{
monsterCount--;
monsterCountText.text = "Monster : " + monsterCount;
if(monsterCount <= 0)
{
stage++;
monsterCount = stage;
stageText.text = "STAGE : " + stage;
monsterCountText.text = "Monster : " + monsterCount;
ChangeStage();
CreateEnemy();
}
}
void CreateEnemy()
{
for(int i=0; i<stage; i++)
{
float x = Random.Range(-0.3f, 0.4f);
float z = Random.Range(-0.3f, 0.4f);
Instantiate(enemyPrefab, new Vector3(x, 0.1f, z), enemyPrefab.localRotation);
}
}
void ChangeStage()
{
hero.localPosition = new Vector3(0, 0, 0);
floor.GetComponent<Renderer>().material.mainTexture = Resources.Load("floor_" + (stage % 5)) as Texture2D;
}
}