public void resetUnitStats(UiUnitType ut) { // NOTE: if property stats are changed in the prefabs, these must be changed as well level = 1; switch (ut.UnitName) { case "Shepherd": // bow maxHealth = 60; attack = 4; break; case "Evangelist": // spear maxHealth = 50; attack = 10; break; case "Elder": // staff maxHealth = 60; attack = 4; break; case "Teacher": // sword maxHealth = 50; attack = 10; break; case "Orator": // wand maxHealth = 60; attack = 4; break; } }
// Update is called once per frame void Update() { if (selection != null) { GomUnit gom = selection.GetComponent <GomUnit>(); Ability ab = selection.GetComponent <Ability>(); if (gom != null) { PropertyStats stats; UiUnitType uut = world.GetComponent <WorldController>().unitTypes[gom.getType(gom.unitType)].GetComponent <UiUnitType>(); if (gom.faction == GomObject.Faction.Player) { stats = uut.getPlayerStats(); } else { stats = uut.getEnemyStats(); } nameText.GetComponent <TextMesh>().text = "Name: " + gom.unitType; upgradeText.GetComponent <TextMesh>().text = "To Upgrade: " + stats.upgradeCost; expText.GetComponent <TextMesh>().text = "Lvl: " + stats.level; attackText.GetComponent <TextMesh>().text = "x" + stats.attack; defenseText.GetComponent <TextMesh>().text = "x" + stats.defense; spiritText.GetComponent <TextMesh>().text = "x" + stats.spirit; speedText.GetComponent <TextMesh>().text = "x" + stats.speed; } else if (ab != null) { nameText.GetComponent <TextMesh>().text = "Ability: " + ab.abilityName; upgradeText.GetComponent <TextMesh>().text = "Lvl: " + ab.level; switch (ab.abilityType) { case Ability._type.rowDamage: expText.GetComponent <TextMesh>().text = "Damage: " + ab.getDamage(); break; case Ability._type.radiusDamage: expText.GetComponent <TextMesh>().text = "Damage: " + ab.getDamage(); expText.GetComponent <TextMesh>().text += "\nRadius: " + ab.getAreaOfEffect(); break; case Ability._type.freezeEnemyUnit: expText.GetComponent <TextMesh>().text = "Duration: " + ab.getDuration(); break; case Ability._type.ShieldUnit: expText.GetComponent <TextMesh>().text = "Duration: " + ab.getDuration(); break; } } } }
UiUnitType getUnitByType(string unitType, List <GameObject> unitTypes) { UiUnitType ret = null; foreach (GameObject ut in unitTypes) { if (ut.GetComponent <UiUnitType>().UnitName == unitType) { ret = ut.GetComponent <UiUnitType>(); } } return(ret); }
static public void upgradeUnit(UiUnitType upgradeUnit) { for (int i = 0; i < unitTypes.Count; i++) { if (unitTypes[i].GetComponent <UiUnitType>().UnitName == upgradeUnit.UnitName) { UiUnitType uiUnit; uiUnit = unitTypes[i].GetComponent <UiUnitType>(); PlayerPrefs.SetInt(uiUnit.UnitName + "level", uiUnit.getPlayerStats().maxLevel); break; } } PlayerPrefs.Save(); }