// Update is called once per frame void Update() { if (initialized) { if (lastCredits != player.GetCredits()) { int diff = player.GetCredits() - lastCredits; marker.DisplayText(diff); } lastCredits = player.GetCredits(); var texts = GetComponentsInChildren <UnityEngine.UI.Text>(); texts[1].text = player.GetPower() + ""; texts[3].text = player.unitsCommanding.Count + "/" + player.GetTotalCommandLimit(); texts[5].text = GetCreditString(player.GetCredits()) + ""; var rect = texts[5].rectTransform.rect; rect.center = texts[5].rectTransform.position; tooltipManager.AddBounds(rect, $"CREDITS: {player.GetCredits()}"); UpdatePrimaryTargetInfo(); foreach (var infos in secondaryInfosByEntity) { UpdateInfo(infos.Key ? infos.Key.gameObject : null, infos.Value); } } }
public void onButtonPressed(int index) { if (player.GetPower() >= blueprint.items[index].cost && player.faction == vendor.GetFaction() && player.unitsCommanding.Count < player.GetTotalCommandLimit()) { BuyItem(player, index, vendor); if (GetActive()) { CloseUI(); } ClearVendor(); } else if (player as PlayerCore && player.GetUnitsCommanding().Count >= player.GetTotalCommandLimit()) { player.alerter.showMessage("Unit limit reached!", "clip_alert"); } }
public void onButtonPressed(int index) { // TODO: this is invalid for non ownable items, so must be changed later on if (player.GetPower() >= blueprint.items[index].cost && player.faction == vendor.GetFaction() && player.unitsCommanding.Count < player.GetTotalCommandLimit()) { GameObject creation = new GameObject(); switch (blueprint.items[index].entityBlueprint.intendedType) { case EntityBlueprint.IntendedType.Turret: Turret tur = creation.AddComponent <Turret>(); tur.blueprint = blueprint.items[index].entityBlueprint; tur.SetOwner(player); break; case EntityBlueprint.IntendedType.Tank: Tank tank = creation.AddComponent <Tank>(); tank.blueprint = blueprint.items[index].entityBlueprint; tank.enginePower = 250; tank.SetOwner(player); break; default: break; } creation.name = blueprint.items[index].entityBlueprint.name; player.sectorMngr.InsertPersistentObject(blueprint.items[index].entityBlueprint.name, creation); creation.transform.position = vendor.GetPosition(); creation.GetComponent <Entity>().spawnPoint = vendor.GetPosition(); if (blueprint.items[index].entityBlueprint.intendedType != EntityBlueprint.IntendedType.Tank) { player.SetTractorTarget(creation.GetComponent <Draggable>()); } player.AddPower(-blueprint.items[index].cost); if (GetActive()) { CloseUI(); } ClearVendor(); } else if (player as PlayerCore && player.GetUnitsCommanding().Count >= player.GetTotalCommandLimit()) { player.alerter.showMessage("Unit limit reached!", "clip_alert"); } }
// Update is called once per frame void Update() { if (initialized) { if (lastCredits != player.credits) { int diff = player.credits - lastCredits; marker.DisplayText(diff); } lastCredits = player.credits; var texts = GetComponentsInChildren <UnityEngine.UI.Text>(); texts[1].text = player.GetPower() + ""; texts[3].text = player.unitsCommanding.Count + "/" + player.GetTotalCommandLimit(); texts[5].text = GetCreditString(player.credits) + ""; UpdatePrimaryTargetInfo(); foreach (var infos in secondaryInfosByEntity) { UpdateInfo(infos.Key ? infos.Key.gameObject : null, infos.Value); } } }