// Use this for initialization void Start() { playerFactionSpec = (PlayerFaction)Faction.GetComponent("PlayerFaction"); UnitBody = (GameObject)Instantiate(unitPrefab); UnitBodySpec = ((UnitSpec)UnitBody.GetComponent("UnitSpec")); UnitBodySpec.paintUnit(playerFactionSpec.FactionColor); UnitBodySpec.GenerateBody(); UnitBody.transform.parent = this.transform; UnitBody.transform.position = this.transform.position; switch (UnitBodySpec.getUnitClassSize()) { case UnitSpec.UnitSize.M: UnitBody.transform.localScale = new Vector3(3.5f, 3.5f, 3.5f); break; default: break; } SetRotation(); health = UnitBodySpec.getMaxHealth(); supply = UnitBodySpec.getMaxSupply(); ammo = new int[UnitBodySpec.turrets.Length]; for (int i = 0; i < ammo.Length; i++) { ammo[i] = ((TurretSpec)UnitBodySpec.turrets[i].GetComponent("TurretSpec")).getMaxAmmo(); } }
public float getPercentual100SP() { return(Mathf.Ceil(((float)supply / (float)UnitBodySpec.getMaxSupply()) * 100.0f)); }