public static void Load() { if (!File.Exists(savePath)) { return; } string line; StreamReader file = new StreamReader(savePath); while ((line = file.ReadLine()) != null) { string[] exp = line.Split(';'); if (exp[0] == "gold") { PlayerCoin.Set(int.Parse(exp[1])); } else if (exp[0] == "monster") { PlayerMonster.Add(exp[1], int.Parse(exp[2])); } else if (exp[0] == "item") { PlayerItems.Add(exp[1], int.Parse(exp[2])); } else if (exp[0] == "field") { if (exp[2] == "0") { PlayerField.Add(int.Parse(exp[1]), FieldStatus.FIELD_FAILED); } else if (exp[2] == "1") { PlayerField.Add(int.Parse(exp[1]), FieldStatus.FIELD_1STAR); } else if (exp[2] == "2") { PlayerField.Add(int.Parse(exp[1]), FieldStatus.FIELD_2STAR); } else if (exp[2] == "3") { PlayerField.Add(int.Parse(exp[1]), FieldStatus.FIELD_3STAR); } else { PlayerField.Add(int.Parse(exp[1]), FieldStatus.FIELD_EMPTY); } } PlayerMonster.Load(); } file.Close(); }
private void ShowGameEnd() { if (!messageBox.activeSelf) { int bonusMin = (PlayerMonster.IndexEnemy + 1) * 9; int bonusMax = (PlayerMonster.IndexEnemy + 1) * 12; if (playerHealth <= 0) { bonusMin = (PlayerMonster.IndexEnemy + 1) * 1; bonusMax = (PlayerMonster.IndexEnemy + 1) * 3; } int goldBonus = Random.Range(bonusMin, bonusMax); PlayerCoin.Add(goldBonus); GameObject gold = messageBox.transform.FindChild("GoldDisplay").gameObject; gold.GetComponent <TextMesh>().text = "+" + goldBonus; // Apply database foreach (GameObject go in activeMonster) { PlayerMonster.Get(go.GetComponent <Monster>().StorageIndex).exp = go.GetComponent <Monster>().Exp; } List <GameObject> dropItem = new List <GameObject>(); foreach (GameObject item in Reference.Asset.itemTemplate) { int rand = Random.Range(0, 100); if (rand <= item.GetComponent <Item>().DropWeight) { PlayerItems.Add(item.name, 1); dropItem.Add(item); } } int count = 0; foreach (GameObject go in dropItem) { GameObject item = (GameObject)Instantiate(go, new Vector3(count, 0, 0), Quaternion.identity); item.GetComponent <SpriteRenderer>().sortingOrder = 2; count++; } switch (defeatedEnemy) { case 0: if (PlayerField.Get(PlayerMonster.IndexEnemy) != FieldStatus.FIELD_3STAR && PlayerField.Get(PlayerMonster.IndexEnemy) != FieldStatus.FIELD_2STAR && PlayerField.Get(PlayerMonster.IndexEnemy) != FieldStatus.FIELD_1STAR) { PlayerField.Add(PlayerMonster.IndexEnemy, FieldStatus.FIELD_FAILED); } break; case 1: if (PlayerField.Get(PlayerMonster.IndexEnemy) != FieldStatus.FIELD_3STAR && PlayerField.Get(PlayerMonster.IndexEnemy) != FieldStatus.FIELD_2STAR) { PlayerField.Add(PlayerMonster.IndexEnemy, FieldStatus.FIELD_1STAR); } break; case 2: if (PlayerField.Get(PlayerMonster.IndexEnemy) != FieldStatus.FIELD_3STAR) { PlayerField.Add(PlayerMonster.IndexEnemy, FieldStatus.FIELD_2STAR); } break; case 3: PlayerField.Add(PlayerMonster.IndexEnemy, FieldStatus.FIELD_3STAR); break; } messageBox.SetActive(true); } GameObject title = messageBox.transform.FindChild("TextHelper").gameObject; if (playerHealth > 0) { title.GetComponent <TextMesh>().text = "Victory"; title.GetComponent <TextMesh>().color = new Color(255, 226, 0); } else { title.GetComponent <TextMesh>().text = "Defeated"; title.GetComponent <TextMesh>().color = new Color(233, 0, 0); } }