public void UpdateMenu() { foreach (GameObject menuItem in menuItems) { if (menuItem == null) { break; } UpgradeTypes itemType = menuItem.GetComponent <GUIMenuItem>().type; Upgrade ownedUpgrade = upgrades.GetOwnedUpgrade(itemType); Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[1]; double hvalue = ownedUpgrade.health; double mhvalue = ownedUpgrade.GetCurrentLevelHealth(); string hunit = ""; string mhunit = ""; UnitsConverter.Convert(ref hvalue, ref hunit); UnitsConverter.Convert(ref mhvalue, ref mhunit); txt.text = "Health: " + hvalue.ToString("f" + healthDecimals) + hunit + "/" + mhvalue.ToString("f" + healthDecimals) + mhunit; txt = comps[2]; double repairCost = ownedUpgrade.GetRepairCost(); string runit = ""; UnitsConverter.Convert(ref repairCost, ref runit); txt.text = "Repair: $" + repairCost.ToString("f" + priceDecimals) + runit; } }
// Update is called once per frame void Update() { float currentTime = Time.time; if (currentTime > lastTime + updateInterval) { float seconds = Mathf.Floor((float)speed.ETA % 60.0f); float minutes = Mathf.Floor(((float)speed.ETA / 60.0f) % 60.0f); float hours = Mathf.Floor(((float)speed.ETA / 3600.0f) % 24.0f); float days = Mathf.Floor((float)speed.ETA / 86400); double val = (double)days; string vunit = ""; UnitsConverter.Convert(ref val, ref vunit); if (vunit == " Infinity") { displayText.text = "ETA: N/A"; } else { displayText.text = "ETA: " + val.ToString("f0") + vunit + " d " + hours + "h " + minutes + "m " + seconds + "s"; } lastTime = currentTime; } }
public void Repair(GameObject menuItem) { AudioManager.Instance.AudioSources["Tap"].Play(); UpgradeTypes itemType = menuItem.GetComponent <GUIMenuItem>().type; Upgrade ownedUpgrade = instance.upgrades.GetOwnedUpgrade(itemType); float healthBefore = ownedUpgrade.health; double repairCost = ownedUpgrade.GetRepairCost(); instance.speed.points -= repairCost; instance.upgradesController.RepairUpgrade(itemType); Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[1]; double hvalue = ownedUpgrade.health; string hunit = ""; UnitsConverter.Convert(ref hvalue, ref hunit); txt.text = "Health: " + hvalue.ToString("f" + instance.healthDecimals) + hunit; txt = comps[2]; double rvalue = ownedUpgrade.GetRepairCost(); string runit = ""; UnitsConverter.Convert(ref rvalue, ref runit); txt.text = "Repair: $" + rvalue.ToString("f" + instance.priceDecimals) + runit; //rather than updating values of all items we just fix the value for the repaired item and update total with difference float healthAfter = ownedUpgrade.health; instance.totalHealth += (healthAfter - healthBefore); instance.totalRepairPrice -= repairCost; }
// Update is called once per frame void Update() { double value = (double)(entity.GetComponent <Speed>().GetType().GetField(var).GetValue(entity.GetComponent <Speed>())); string unit = ""; UnitsConverter.Convert(ref value, ref unit); text.text = "" + value.ToString("f" + numberOfDecimals) + unit + " " + postfix; }
// Update is called once per frame void Update() { double value = speed.currentPlanet.distanceToTravel; string unit = ""; UnitsConverter.Convert(ref value, ref unit); text.text = "" + value.ToString("f" + numberOfDecimals) + unit + " " + postfix; }
void BuildMenu() { totalRepairPrice = 0; totalHealth = 0; totalMaxHealth = 0; int j = 0; foreach (KeyValuePair <UpgradeTypes, Upgrade> upgradeItem in ownedUpgrades) { if (upgradeItem.Key != UpgradeTypes.Clicker && upgradeItem.Key != UpgradeTypes.AutoPilot1h && upgradeItem.Key != UpgradeTypes.AutoPilot6h && upgradeItem.Key != UpgradeTypes.AutoPilot12h && upgradeItem.Key != UpgradeTypes.AutoPilot3d && upgradeItem.Key != UpgradeTypes.AutoPilot1w) { Upgrade upgrade = upgradeItem.Value; string name = upgrade.type.ToString(); float health = upgrade.health; double repaircost = upgrade.GetRepairCost(); float maxhealth = upgrade.GetCurrentLevelHealth(); totalRepairPrice += repaircost; totalHealth += health; totalMaxHealth += maxhealth; GameObject menuItem = GameObject.Instantiate(Resources.Load("Prefabs/RepairMenuItem")) as GameObject; menuItem.GetComponentInChildren <UpdateItemHealthBar> ().SetItemUpgrade(upgrade); menuItem.GetComponent <GUIMenuItem>().type = upgrade.type; Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[0]; txt.text = name.ToUpper(); txt = comps[1]; double hvalue = (double)health; double mhvalue = (double)maxhealth; string hunit = ""; string mhunit = ""; UnitsConverter.Convert(ref hvalue, ref hunit); UnitsConverter.Convert(ref mhvalue, ref mhunit); txt.text = "Health: " + hvalue.ToString("f" + healthDecimals) + hunit + "/" + mhvalue.ToString("f" + healthDecimals) + mhunit; txt = comps[2]; string runit = ""; UnitsConverter.Convert(ref repaircost, ref runit); txt.text = "Repair: $" + repaircost.ToString("f" + priceDecimals) + runit; menuItem.transform.SetParent(transform, false); menuItems[j] = menuItem; //parent = menuItems[i].transform; j++; } } //menuItems [3].transform.SetSiblingIndex (0); }
void UpdateAutoPilotItems() { foreach (GameObject menuItem in menuItems) { UpgradeTypes itemType = menuItem.GetComponent <GUIMenuItem> ().type;; Upgrade upgrade = allUpgrades[itemType]; Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[2]; txt.color = Color.magenta; double cost = upgrade.GetCost(); string unit = ""; UnitsConverter.Convert(ref cost, ref unit); txt.text = "$ " + cost.ToString("f" + priceDecimals) + unit; txt = comps[3]; } }
private void InitializeSetWithScreenData(PsaParametersSet set, PeugeotScreen screen) { set.Type = PsaParametersSetTypeMapper.Get(screen.Name); set.OriginalName = screen.Name; foreach (PeugeotRawParameterPoint p in screen.Points) { PsaParameterData parameter = new PsaParameterData(p.ParameterName); // passed original type ID parameter.Type = DataTypeResolver2.GetType(p.ParameterName); parameter.OriginalName = p.ParameterName; parameter.HasTimestamps = false; parameter.Values.Add(p.Value); parameter.Units = UnitsConverter.Convert(p.Units); parameter.AdditionalSourceInfo = GenerateAdditionalSourceInfo(parameter.OriginalTypeId); set.Parameters.Add(parameter); } }
public void UpdateRepairAllButton() { Text[] texts = instance.repairAllItem.GetComponentsInChildren <Text>(); Text rtxt = texts[1]; double hvalue = instance.totalHealth; double mhvalue = instance.totalMaxHealth; string hunit = ""; string mhunit = ""; UnitsConverter.Convert(ref hvalue, ref hunit); UnitsConverter.Convert(ref mhvalue, ref mhunit); rtxt.text = "Health: " + hvalue.ToString("f" + instance.healthDecimals) + hunit + "/" + mhvalue.ToString("f" + instance.healthDecimals) + mhunit; rtxt = texts[2]; double totalRepairValue = instance.totalRepairPrice; string runit = ""; UnitsConverter.Convert(ref totalRepairValue, ref runit); rtxt.text = "Repair: $" + totalRepairValue.ToString("f" + instance.priceDecimals) + runit; }
public void RepairAll() { AudioManager.Instance.AudioSources["Tap"].Play(); instance.totalRepairPrice = 0; instance.totalHealth = 0; instance.totalMaxHealth = 0; foreach (GameObject menuItem in instance.menuItems) { if (menuItem == null) { break; } UpgradeTypes itemType = menuItem.GetComponent <GUIMenuItem>().type; Upgrade ownedUpgrade = instance.upgrades.GetOwnedUpgrade(itemType); instance.speed.points -= ownedUpgrade.GetRepairCost(); instance.upgradesController.RepairUpgrade(itemType); double repairCost = ownedUpgrade.GetRepairCost(); float health = ownedUpgrade.health; float maxHealth = ownedUpgrade.GetCurrentLevelHealth(); instance.totalRepairPrice += repairCost; instance.totalHealth += health; instance.totalMaxHealth += ownedUpgrade.GetCurrentLevelHealth(); Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[1]; double hvalue = (double)health; double mhvalue = (double)maxHealth; string hunit = ""; string mhunit = ""; UnitsConverter.Convert(ref hvalue, ref hunit); UnitsConverter.Convert(ref mhvalue, ref mhunit); txt.text = "Health: " + hvalue.ToString("f" + instance.healthDecimals) + hunit + "/" + mhvalue.ToString("f" + instance.healthDecimals) + mhunit; txt = comps[2]; string runit = ""; UnitsConverter.Convert(ref repairCost, ref runit); txt.text = "Repair: $" + repairCost.ToString("f" + instance.priceDecimals) + runit; } }
public void TapPoints(float points) { GameObject text = textsPool.Enqueue(); if (text) { text.transform.position = new Vector3(Random.Range(-3.0f, 1.0f), Random.Range(1.0f, 4.0f), 0); text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); TextMesh tMesh = text.GetComponent <TextMesh> (); tMesh.color = Color.white; double value = (double)points; string unit = ""; UnitsConverter.Convert(ref value, ref unit); tMesh.text = "+" + value.ToString("f1") + unit; tMesh.characterSize = 0.08f; ClickPoints cp = text.GetComponent <ClickPoints> (); cp.floatUpSpeed = 1f; cp.fadeTime = 0.5f; text.GetComponent <ClickPoints> ().Animate(); } }
public void UpdateMenu() { foreach (GameObject menuItem in menuItems) { UpgradeTypes itemType = menuItem.GetComponent <GUIMenuItem> ().type;; if (ownedUpgrades.ContainsKey(itemType)) { Upgrade upgrade = ownedUpgrades[itemType]; Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[1]; double value = upgrade.GetCurrentLevelValue(); string unit = ""; UnitsConverter.Convert(ref value, ref unit); txt.text = value.ToString("f" + speedDecimals) + unit + " m/s"; txt = comps[2]; txt.color = Color.magenta; double cost = upgrade.GetCost(); unit = ""; UnitsConverter.Convert(ref cost, ref unit); txt.text = "$ " + cost.ToString("f" + priceDecimals) + unit; txt = comps[3]; double val = upgrade.GetNextLevelValue() - value; unit = ""; UnitsConverter.Convert(ref val, ref unit); float bonus = upgrade.percentValueIncrease * 100.0f; txt.text = "+ " + bonus + "%" + " " + val.ToString("f" + speedDecimals) + unit; txt.color = Color.cyan; txt = comps[4]; txt.text = "Level\n" + upgrade.level; Selectable selectableButton = menuItem.GetComponent <Selectable>(); ColorBlock colors = menuItem.GetComponent <Selectable>().colors; colors.normalColor = new Color(0.06f, 0.08f, 0.16f, 1.0f); colors.disabledColor = new Color(0.2f, 0.2f, 0.2f, 1.0f); colors.highlightedColor = new Color(0.09f, 0.12f, 0.31f, 1.0f); selectableButton.colors = colors; } } }
public void AddItem(UpgradeTypes itemType) { GameObject menuItem = GameObject.Instantiate(Resources.Load("Prefabs/RepairMenuItem")) as GameObject; Upgrade ownedUpgrade = upgrades.GetOwnedUpgrade(itemType); menuItem.GetComponentInChildren <UpdateItemHealthBar> ().SetItemUpgrade(ownedUpgrade); double health = (double)ownedUpgrade.health; string name = ownedUpgrade.type.ToString(); double repaircost = ownedUpgrade.GetRepairCost(); Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[0]; txt.text = name.ToUpper(); txt = comps[1]; string hunit = ""; UnitsConverter.Convert(ref health, ref hunit); txt.text = "Health: " + health.ToString("f" + healthDecimals) + hunit; txt = comps[2]; string runit = ""; UnitsConverter.Convert(ref repaircost, ref runit); txt.text = "Repair: $" + repaircost.ToString("f" + priceDecimals) + runit; menuItem.GetComponent <GUIMenuItem> ().type = itemType; menuItem.transform.SetParent(transform, false); //as soon i make it inot the dictionary we can use add for (int i = 0; i < menuItems.Length; i++) { if (menuItems[i] == null) { menuItems[i] = menuItem; break; } } }
private static PsaParameterData Convert(LexiaChannelRawData channel) { PsaParameterData parameter = new PsaParameterData(channel.Header.Mnemocode) // Passed original type id { HasTimestamps = true, // for Graph it is true AdditionalSourceInfo = GenerateAdditionalSourceInfo(channel.Header.Mnemocode), Type = ConvertType(channel.Header.Mnemocode), OriginalName = channel.Header.Mnemocode, Units = UnitsConverter.Convert(channel.Header.DataUnit) }; foreach (LexiaRawDataPoint p in channel.ChannelDataPoints.Points) { int ts; Int32.TryParse(p.TimeStamp, NumberStyles.Integer, CultureInfo.InvariantCulture, out ts); parameter.Timestamps.Add(ts); parameter.Values.Add(p.Value); } return(parameter); }
public object ConvertBack(object value, Type targetType, object parameter, string language) { double fromValue = System.Convert.ToDouble(value); Tuple <ISensorItem, IGaugeItem> tuple = (Tuple <ISensorItem, IGaugeItem>)parameter; if (tuple.Item2.GaugeType == GaugeTypeEnum.TextControl) { return(fromValue); } Units fromUnits = (Units)tuple.Item1.SensorUnits; Units toUnits = (Units)tuple.Item2.Units; if (fromUnits == toUnits) { return(fromValue); } UnitItem fromUnitItem = UnitsConverter.Find(fromUnits); UnitItem toUnitItem = UnitsConverter.Find(toUnits); return(UnitsConverter.Convert(toUnitItem, fromUnitItem, fromValue)); }
void BuildMenu() { GameObject autopilotitem = GameObject.Instantiate(Resources.Load("Prefabs/AutoPilot1h")) as GameObject; autopilotitem.transform.SetParent(transform, false); autopilotitem.GetComponent <GUIMenuItem> ().type = UpgradeTypes.AutoPilot1h; menuItems.Add(autopilotitem); autopilotitem = GameObject.Instantiate(Resources.Load("Prefabs/AutoPilot6h")) as GameObject; autopilotitem.transform.SetParent(transform, false); autopilotitem.GetComponent <GUIMenuItem> ().type = UpgradeTypes.AutoPilot6h; menuItems.Add(autopilotitem); autopilotitem = GameObject.Instantiate(Resources.Load("Prefabs/AutoPilot12h")) as GameObject; autopilotitem.transform.SetParent(transform, false); autopilotitem.GetComponent <GUIMenuItem> ().type = UpgradeTypes.AutoPilot12h; menuItems.Add(autopilotitem); autopilotitem = GameObject.Instantiate(Resources.Load("Prefabs/AutoPilot3d")) as GameObject; autopilotitem.transform.SetParent(transform, false); autopilotitem.GetComponent <GUIMenuItem> ().type = UpgradeTypes.AutoPilot3d; menuItems.Add(autopilotitem); autopilotitem = GameObject.Instantiate(Resources.Load("Prefabs/AutoPilot1w")) as GameObject; autopilotitem.transform.SetParent(transform, false); autopilotitem.GetComponent <GUIMenuItem> ().type = UpgradeTypes.AutoPilot1w; menuItems.Add(autopilotitem); UpdateAutoPilotItems(); foreach (KeyValuePair <UpgradeTypes, Upgrade> upgradeItem in allUpgrades) { Upgrade upgrade = upgradeItem.Value; if (upgrade.type == UpgradeTypes.AutoPilot1h || upgrade.type == UpgradeTypes.AutoPilot6h || upgrade.type == UpgradeTypes.AutoPilot12h || upgradeItem.Key == UpgradeTypes.AutoPilot3d || upgradeItem.Key == UpgradeTypes.AutoPilot1w) { continue; } else { double value = upgrade.GetCurrentLevelValue(); string vunit = ""; UnitsConverter.Convert(ref value, ref vunit); string name = upgrade.type.ToString(); double cost = upgrade.GetCost(); string cunit = ""; UnitsConverter.Convert(ref cost, ref cunit); int level = upgrade.level; float bonus = upgrade.percentValueIncrease * 100.0f; GameObject item = GameObject.Instantiate(Resources.Load("Prefabs/UpgradeMenuItem")) as GameObject; item.GetComponent <GUIMenuItem> ().type = upgrade.type; Text[] comps = item.GetComponentsInChildren <Text>(); Text txt = comps[0]; txt.text = name.ToUpper(); if (ownedUpgrades.ContainsKey(upgrade.type)) { txt = comps[1]; txt.text = value.ToString("f" + speedDecimals) + vunit + " m/s"; txt = comps[2]; txt.text = "$ " + cost.ToString("f" + priceDecimals) + cunit; txt = comps[3]; double val = upgrade.GetNextLevelValue() - value; vunit = ""; UnitsConverter.Convert(ref val, ref vunit); txt.text = "+ " + bonus + "%" + " " + val.ToString("f" + speedDecimals) + vunit; txt = comps[4]; txt.text = "Level\n" + level; } else { Selectable selectableButton = item.GetComponent <Selectable>(); ColorBlock colors = item.GetComponent <Selectable>().colors; colors.normalColor = new Color(0.91f, 0.55f, 0.0f, 1.0f); colors.disabledColor = new Color(0.68f, 0.48f, 0.16f, 1.0f); colors.highlightedColor = new Color(1.0f, 0.68f, 0.0f, 1.0f); selectableButton.colors = colors; txt = comps[1]; double bvalue = upgrade.baseValue; vunit = ""; UnitsConverter.Convert(ref bvalue, ref vunit); txt.text = bvalue.ToString("f" + speedDecimals) + vunit + " m/s"; txt = comps[2]; txt.text = "$ " + cost.ToString("f" + priceDecimals) + cunit; txt.color = Color.black; txt = comps[3]; double val = upgrade.GetNextLevelValue() - bvalue; vunit = ""; UnitsConverter.Convert(ref val, ref vunit); txt.text = "+ " + bonus + "%" + " " + val.ToString("f" + speedDecimals) + vunit; txt.color = Color.black; txt = comps[4]; txt.text = "NEW"; } item.transform.SetParent(transform, false); menuItems.Add(item); } //parent = menuItems[i].transform; } //menuItems [3].transform.SetSiblingIndex (0); }
public void BuyUpgrade(GameObject menuItem) { AudioManager.Instance.AudioSources["Tap"].Play(); UpgradeTypes itemType = menuItem.GetComponent <GUIMenuItem> ().type; if (instance.ownedUpgrades.ContainsKey(itemType)) { Upgrade upgrade = instance.ownedUpgrades[itemType]; SpawnText(menuItem, upgrade); instance.speed.points -= upgrade.GetCost(); instance.upgradesController.LevelUpUpgrade(itemType); } else { Upgrade upgrade = instance.allUpgrades[itemType]; SpawnText(menuItem, upgrade); instance.speed.points -= upgrade.GetCost(); instance.upgradesController.AddUpgrade(itemType); instance.upgradesController.LevelUpUpgrade(itemType); Text[] comps = menuItem.GetComponentsInChildren <Text>(); Text txt = comps[2]; txt.color = Color.magenta; txt = comps[3]; txt.color = Color.cyan; Selectable selectableButton = menuItem.GetComponent <Selectable>(); ColorBlock colors = menuItem.GetComponent <Selectable>().colors; colors.normalColor = new Color(0.06f, 0.08f, 0.16f, 1.0f); colors.disabledColor = new Color(0.2f, 0.2f, 0.2f, 1.0f); colors.highlightedColor = new Color(0.09f, 0.12f, 0.31f, 1.0f); selectableButton.colors = colors; RepairsMenuManager.Instance.AddItem(itemType); } Upgrade ownedUpgrade = instance.ownedUpgrades [itemType]; Text[] texts = menuItem.GetComponentsInChildren <Text>(); Text txtx = texts[1]; double value = ownedUpgrade.GetCurrentLevelValue(); string unit = ""; UnitsConverter.Convert(ref value, ref unit); txtx.text = value.ToString("f" + instance.speedDecimals) + unit + " m/s"; txtx = texts[2]; double cost = ownedUpgrade.GetCost(); unit = ""; UnitsConverter.Convert(ref cost, ref unit); txtx.text = "$ " + cost.ToString("f" + instance.priceDecimals) + unit; txtx = texts[3]; double val = ownedUpgrade.GetNextLevelValue() - value; unit = ""; UnitsConverter.Convert(ref val, ref unit); float bonus = ownedUpgrade.percentValueIncrease * 100.0f; txtx.text = "+ " + bonus + "%" + " " + val.ToString("f" + speedDecimals) + unit; txtx = texts[4]; txtx.text = "Level\n" + ownedUpgrade.level; }
void SpawnText(GameObject menuItem, Upgrade upgrade) { GameObject text = instance.textsPool.Enqueue(); if (text) { text.transform.position = menuItem.transform.position; text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); text.transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f)); text.transform.Translate(new Vector3(0.0f, 0.0f, -0.1f)); TextMesh tMesh = text.GetComponent <TextMesh> (); double value = upgrade.GetCost(); string unit = ""; UnitsConverter.Convert(ref value, ref unit); tMesh.text = "-" + value.ToString("f" + priceDecimals) + unit; tMesh.color = Color.magenta; tMesh.characterSize = 0.003f; ClickPoints cp = text.GetComponent <ClickPoints>(); cp.floatUpSpeed = -0.06f; cp.fadeTime = 0.8f; cp.Animate(); } text = instance.textsPool.Enqueue(); if (text) { text.transform.position = menuItem.transform.position; text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); text.transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f)); text.transform.Translate(new Vector3(-0.05f, -0.02f, -0.1f)); TextMesh tMesh = text.GetComponent <TextMesh> (); double valueDifference = upgrade.GetNextLevelValue() - upgrade.GetCurrentLevelValue(); string unit = ""; UnitsConverter.Convert(ref valueDifference, ref unit); tMesh.text = "+" + valueDifference.ToString("f" + speedDecimals) + unit; tMesh.characterSize = 0.003f; tMesh.color = Color.cyan; ClickPoints cp = text.GetComponent <ClickPoints> (); cp.floatUpSpeed = 0.06f; cp.fadeTime = 0.8f; cp.Animate(); } text = instance.textsPool.Enqueue(); if (text) { text.transform.position = menuItem.transform.position; text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); text.transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f)); text.transform.Translate(new Vector3(-0.05f, 0.0f, -0.1f)); TextMesh tMesh = text.GetComponent <TextMesh> (); double healthDifference = (double)upgrade.GetNextLevelHealth() - upgrade.GetCurrentLevelHealth(); string unit = ""; UnitsConverter.Convert(ref healthDifference, ref unit); tMesh.text = "+" + healthDifference.ToString("f" + RepairsMenuManager.Instance.healthDecimals) + unit; tMesh.characterSize = 0.003f; tMesh.color = Color.green; ClickPoints cp = text.GetComponent <ClickPoints> (); cp.floatUpSpeed = 0.06f; cp.fadeTime = 0.8f; cp.Animate(); } }