Skip to content

Commit

Permalink
V0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
orp1205 committed Apr 15, 2024
1 parent 0f7e76a commit 2320ac6
Show file tree
Hide file tree
Showing 23 changed files with 13,312 additions and 1,521 deletions.
1 change: 0 additions & 1 deletion Assets/CanUseUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ void Update()
public void loadMobCanUse(int type)
{
mobstas = DataMob.GetComponent<ManageMobData>().getListMob();
this.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(40, mobstas.Count * 50);
GameObject buttonTemplate = transform.GetChild(0).gameObject;
transform.GetChild(0).gameObject.SetActive(false);
int count = transform.childCount;
Expand Down
13 changes: 9 additions & 4 deletions Assets/DestroyHouseFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class DestroyHouseFix : MonoBehaviour
// Start is called before the first frame update
private void Start()
{
hp = 700;
maxHp = 700;
hp = 400;
maxHp = 400;
}

// Update is called once per frame
Expand All @@ -32,11 +32,16 @@ public void takeDame(int Damage)
}
public void FixBuilding()
{
Instantiate(nomalHouse, transform.position, Quaternion.identity);
Destroy(this.gameObject);
nomalHouse.SetActive(true);
nomalHouse.GetComponent<HouseStat>().ReBackHouse();
this.gameObject.SetActive(false);
}
public int getHp()
{
return hp;
}
public void ReBackHouse()
{
this.hp = this.maxHp;
}
}
55 changes: 32 additions & 23 deletions Assets/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class GameController : MonoBehaviour
private Button logOut;
public GameObject text;
[SerializeField]
private GameObject lv, exp, wood, gold, meat, clock, spawnEnemy;
private GameObject lv, exp, wood, gold, meat, clock, wave, spawnEnemy;
[SerializeField]
private string json;
private bool startGame;
private int waveCount;
// Start is called before the first frame update

[SerializeField] UnityEvent OnEnter;
Expand All @@ -29,7 +31,7 @@ public class GameController : MonoBehaviour
void Start()
{
//This is Conection to the server call user data
/*RequestAddress();*/
RequestAddress();
//Fake data
/*string json = "{\r\nexp: 0,\r\ngold: 90,\r\nid: \"VN\",\r\nlevel: 1,\r\nmax_exp: 5,\r\nmeat: 90,\r\nwood: 90\r\n}";
ReceiveAddress(json);*/
Expand All @@ -38,32 +40,40 @@ void Start()
logOut.onClick.AddListener(LogOutPrePare);
}

time = 10.0f;

time = 60.0f;
startGame = false;
waveCount = 0;
}

// Update is called once per frame
void Update()
{
if (time > 0.0f)
if(startGame)
{
time -= Time.deltaTime;

// Divide the time by 60
float minutes = Mathf.FloorToInt(time / 60);
if (time > 0.0f)
{
time -= Time.deltaTime;

// Returns the remainder
float seconds = Mathf.FloorToInt(time % 60);
string timeCount = string.Format("{0:00}:{1:00}", minutes, seconds);
clock.GetComponent<TextMeshProUGUI>().SetText(timeCount);
}
else
{
OnEnter.Invoke();
// Divide the time by 60
float minutes = Mathf.FloorToInt(time / 60);

GameObject.FindGameObjectWithTag("MOBDATA").GetComponent<ManageMobData>().saveMob();
spawnEnemy.GetComponent<SpawnController>().SpawnEnemy();
time = 30.0f;
// Returns the remainder
float seconds = Mathf.FloorToInt(time % 60);
string timeCount = string.Format("{0:00}:{1:00}", minutes, seconds);
clock.GetComponent<TextMeshProUGUI>().SetText(timeCount);
}
else
{
waveCount += 1;
//This is code for save player data
PlayerInfoJson player = new PlayerInfoJson(playerInfo);
SavePlayer(JsonConvert.SerializeObject(player));
OnEnter.Invoke();
wave.GetComponent<TextMeshProUGUI>().SetText("Wave: "+waveCount);
GameObject.FindGameObjectWithTag("MOBDATA").GetComponent<ManageMobData>().saveMob();
spawnEnemy.GetComponent<SpawnController>().SpawnEnemy();
time = 30.0f;
}
}
}

Expand Down Expand Up @@ -109,9 +119,7 @@ public void setMaterials(int m, int g, int w)
lv.GetComponent<TextMeshProUGUI>().SetText(playerInfo.getLv().ToString());
exp.GetComponent<Slider>().value = playerInfo.getExp();
exp.GetComponent<Slider>().maxValue = playerInfo.getMaxExp();
//This is code for save player data
PlayerInfoJson player = new PlayerInfoJson(playerInfo);
SavePlayer(JsonConvert.SerializeObject(player));

}
public PlayerInfo getPlayer()
{
Expand Down Expand Up @@ -139,6 +147,7 @@ public void stopLoadingScreen()
if (loadingScreen != null)
{
loadingScreen.SetActive(false);
startGame = true;
}
}
}
Loading

0 comments on commit 2320ac6

Please sign in to comment.