public void loadCombatData(unitScript attacker, unitScript defender, float AttackerChanceToHit, float defenderChanceToHit) { Transform combatPanel = transform.Find("CombatPanel"); Transform EnemyPanel = combatPanel.Find("EnemyPanel"); var targetText = EnemyPanel.Find("Target").GetComponent <UnityEngine.UI.Text>(); targetText.text = defender.getName(); var classText = EnemyPanel.Find("Class").GetComponent <UnityEngine.UI.Text>(); classText.text = defender.getClass(); var healthText = EnemyPanel.Find("Health").GetComponent <UnityEngine.UI.Text>(); healthText.text = defender.getHealth().ToString() + " : " + defender.getMaxHealth().ToString(); var strikeBack = EnemyPanel.Find("StrikeBack").GetComponent <Text>(); strikeBack.text = (!defender.getStrikeback()).ToString(); var strikebackChanceText = EnemyPanel.Find("ChanceText").GetComponent <Text>(); var strikebackDamageText = EnemyPanel.Find("DamageText").GetComponent <Text>(); var strikebackChance = EnemyPanel.Find("Chance").GetComponent <Text>(); var strikebackDamage = EnemyPanel.Find("Damage").GetComponent <Text>(); if (!defender.getStrikeback()) { strikebackChance.enabled = true; strikebackDamage.enabled = true; strikebackChanceText.enabled = true; strikebackDamageText.enabled = true; strikebackChance.text = defenderChanceToHit.ToString(); strikebackDamage.text = defender.getCurrentWeapon().damage.ToString(); } else { strikebackChance.enabled = false; strikebackDamage.enabled = false; strikebackChanceText.enabled = false; strikebackDamageText.enabled = false; } int chance = (int)Mathf.Max(0, Mathf.Min(100, AttackerChanceToHit * 100)); combatPanel.Find("ChanceToHit").GetComponent <UnityEngine.UI.Text>().text = (chance).ToString() + "%"; combatPanel.Find("Damage").GetComponent <UnityEngine.UI.Text>().text = unit.getCurrentWeapon().damage.ToString(); }
public void loadCharacter(unitScript u, bool ally = true) { if (ally) { unit = u; } Transform characterPanel = transform; Transform statPannel = characterPanel.Find(ally?"StatPanel":"EnemyStatPanel"); UnityEngine.UI.Text nameText = statPannel.Find("Name").GetComponent <UnityEngine.UI.Text>(); nameText.text = u.getName(); statPannel.FindChild("Image").GetComponent <Image>().sprite = u.getPortrait(); var strengthText = statPannel.Find("Strength").GetComponent <UnityEngine.UI.Text>(); strengthText.text = u.getStrength().ToString(); var skillText = statPannel.Find("Skill").GetComponent <UnityEngine.UI.Text>(); skillText.text = u.getSkill().ToString(); var speedText = statPannel.Find("Speed").GetComponent <UnityEngine.UI.Text>(); speedText.text = u.getSpeed().ToString(); var smartsText = statPannel.Find("Smarts").GetComponent <UnityEngine.UI.Text>(); smartsText.text = u.getSmarts().ToString(); loadHealth(u.getHealth(), u.getMaxHealth(), statPannel); if (ally) { if (unit.doorsWithinRange.Count > 0) { transform.FindChild("CharacterPanel").FindChild("DoorButton").GetComponent <Button>().interactable = true; } else { transform.FindChild("CharacterPanel").FindChild("DoorButton").GetComponent <Button>().interactable = false; } } loadWeaponData(u, ally); }