void OnMouseUp() { if (currentItem != null) { PlayerCoin.Add((int)(currentItem.GetComponent <Item>().Cost *quantity * 0.1f)); PlayerItems.Add(currentItem.name, -quantity); SetItem(currentItem.name); } }
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); } }