private void CreateMe() { TextBox xpBox1 = new TextBox(transform, TextRef.Create("Xp", "Experiance", false), 28, TextAnchor.UpperLeft); xpBox1.transform.anchoredPosition = new Vector2(5, -4); TextBox xpBox2 = new TextBox(transform, TextRef.Create(() => Player.instance.xp), 28, TextAnchor.UpperRight); xpBox2.transform.anchoredPosition = new Vector2(-5, -4); TextBox coinBox1 = new TextBox(transform, "Coins", 28, TextAnchor.UpperLeft); coinBox1.transform.anchoredPosition = new Vector2(5, -34); TextBox coinBox2 = new TextBox(transform, TextRef.Create(() => Player.instance.coins), 28, TextAnchor.UpperRight); coinBox2.transform.anchoredPosition = new Vector2(-5, -34); TextBox weightBox1 = new TextBox(transform, "Weight", 28, TextAnchor.UpperLeft); weightBox1.transform.anchoredPosition = new Vector2(5, -64); TextBox weightBox2 = new TextBox(transform, TextRef.Create(() => Player.instance.TotalWeight), 28, TextAnchor.UpperRight); weightBox2.transform.anchoredPosition = new Vector2(-5, -64); TextBox hpBox1 = new TextBox(transform, "HP", 28, TextAnchor.UpperLeft); hpBox1.transform.anchoredPosition = new Vector2(5, -94); TextBox hpBox2 = new TextBox(transform, TextRef.Create(() => Player.instance.hitpoints), 28, TextAnchor.UpperRight); hpBox2.transform.anchoredPosition = new Vector2(-5, -94); TextBox armorBox1 = new TextBox(transform, "Armor", 28, TextAnchor.UpperLeft); armorBox1.transform.anchoredPosition = new Vector2(5, -124); TextBox armorBox2 = new TextBox(transform, TextRef.Create(() => Player.instance.equipment.Armor().ToString("00%")), 28, TextAnchor.UpperRight); armorBox2.transform.anchoredPosition = new Vector2(-5, -124); }
private static TextRef GetSpecificDetails(Loot l) { if (l.GetType() == typeof(Loot.Melee)) { Loot.Melee m = (Loot.Melee)l; return(TextRef.Create("d: " + TextRef.ToSI(m.damage) + ", r:" + TextRef.ToSI(m.range), "Damage: " + TextRef.ToSI(m.damage) + "\nRange: " + TextRef.ToSI(m.range), false)); } else if (l.GetType() == typeof(Loot.Ranged)) { Loot.Ranged r = (Loot.Ranged)l; return(TextRef.Create("d: " + TextRef.ToSI(r.damage) + ", r:" + TextRef.ToSI(r.range), "Damage: " + TextRef.ToSI(r.damage) + "\nRange: " + TextRef.ToSI(r.range), false)); } else if (l.GetType() == typeof(Loot.Shield)) { Loot.Shield s = (Loot.Shield)l; return(TextRef.Create("p: " + s.blockChancePassive.ToString("#0%") + ", a:" + s.blockChanceActive.ToString("#0%"), "Passive block chance: " + s.blockChancePassive.ToString("#0%") + "\nActive block chance: " + s.blockChanceActive.ToString("#0%"), false)); } else if (l.GetType() == typeof(Loot.Armor)) { Loot.Armor a = (Loot.Armor)l; return(TextRef.Create("b: " + a.blockChance.ToString("#0%"), "Block chance: " + a.blockChance.ToString("#0%"), false)); } else { throw new Exception("This switsh statement did not acount for: " + l.GetType().ToString()); } }
static public void Create(GameObject canvas) { go = new GameObject("Shop_Screen", typeof(RectTransform)); go.transform.SetParent(canvas.transform); go.AddComponent <Dragable>(); RectTransform tr = (RectTransform)go.transform; tr.sizeDelta = new Vector2(1100, 600); tr.anchorMin = new Vector2(.5f, .5f); tr.anchorMax = new Vector2(.5f, .5f); tr.pivot = new Vector2(.5f, .5f); tr.anchoredPosition = new Vector2(0, 0); Image im = go.AddComponent <Image>(); im.sprite = QuintensUITools.Graphics.GetSprite("Inventory_window"); im.type = Image.Type.Sliced; /// Table with the shops inventory { shopInventoryTable = InfoTable.Create(go.transform, () => inventory, (Loot l) => new List <TextRef>() { l.ToString(), GetSpecificDetails(l), l.weight, l.value, l.slot.ToString() }, 520, new List <TextRef>() { "Inventory", "Specifics", TextRef.Create("w", "Weight", false), TextRef.Create("v", "value", false), "s" }, 24, "Shop"); shopInventoryTable.transform.anchorMin = new Vector2(0, 1); shopInventoryTable.transform.anchorMax = new Vector2(0, 1); shopInventoryTable.transform.pivot = new Vector2(0, 1); shopInventoryTable.transform.anchoredPosition = new Vector2(10, -50); shopInventoryTable.SetColumnWidths(new List <float>() { 160, 80, 60, 60, 160 }); } /// Table with my inventory { myInventoryTable = InfoTable.Create(go.transform, () => Player.instance.inventory, (Loot l) => new List <TextRef>() { l.ToString(), GetSpecificDetails(l), l.weight, l.value, l.slot.ToString() }, 520, new List <TextRef>() { "Inventory", "Specifics", TextRef.Create("w", "Weight", false), TextRef.Create("v", "value", false), "s" }, 24, "Me"); myInventoryTable.transform.anchorMin = new Vector2(1, 1); myInventoryTable.transform.anchorMax = new Vector2(1, 1); myInventoryTable.transform.pivot = new Vector2(1, 1); myInventoryTable.transform.anchoredPosition = new Vector2(-10, -50); myInventoryTable.SetColumnWidths(new List <float>() { 160, 80, 60, 60, 160 }); } /// Bottom buttons { TextBox equipButton = new TextBox(go.transform, TextRef.Create("Buy", "Make sure your product is selected.", false).AddLink(() => BuySelected()), 24); equipButton.transform.anchorMin = new Vector2(0, 0); equipButton.transform.anchorMax = new Vector2(0, 0); equipButton.transform.pivot = new Vector2(0, 0); equipButton.transform.anchoredPosition = new Vector2(40, 40); TextBox dropAllButton = new TextBox(go.transform, TextRef.Create("Sell All", "Sell everything in your inventory.\nBeware! You can't buy it back.", false).AddLink(() => DiscardAll()), 24, TextAnchor.MiddleRight); dropAllButton.transform.anchorMin = new Vector2(1, 0); dropAllButton.transform.anchorMax = new Vector2(1, 0); dropAllButton.transform.pivot = new Vector2(1, 0); dropAllButton.transform.anchoredPosition = new Vector2(-150, 40); TextBox dropButton = new TextBox(go.transform, TextRef.Create("Sell", "-Select an item.\n-Press this button.", false).AddLink(() => DiscardSelected()), 24, TextAnchor.MiddleRight); dropButton.transform.anchorMin = new Vector2(1, 0); dropButton.transform.anchorMax = new Vector2(1, 0); dropButton.transform.pivot = new Vector2(1, 0); dropButton.transform.anchoredPosition = new Vector2(-40, 40); } go.SetActive(false); }
static public void Create(GameObject canvas) { go = new GameObject("Inventory", typeof(RectTransform)); go.transform.SetParent(canvas.transform); go.AddComponent <Dragable>(); RectTransform tr = (RectTransform)go.transform; tr.sizeDelta = new Vector2(800, 600); tr.anchorMin = new Vector2(.5f, .5f); tr.anchorMax = new Vector2(.5f, .5f); tr.pivot = new Vector2(.5f, .5f); tr.anchoredPosition = new Vector2(0, 0); Image im = go.AddComponent <Image>(); im.sprite = QuintensUITools.Graphics.GetSprite("Inventory_window"); im.type = Image.Type.Sliced; /// Equipment { TextBox head = new TextBox(go.transform, TextRef.Create("Head", "Hats and stuff", false), 24, TextAnchor.UpperLeft); head.transform.anchoredPosition = new Vector2(10, -80); TextBox head2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.head.GetItemName(), () => Player.instance.equipment.head.GetItemStats()), 24, TextAnchor.UpperLeft); head2.transform.anchoredPosition = new Vector2(60, -100); MakeEquButton(head); TextBox chest = new TextBox(go.transform, TextRef.Create("Chest", "Upper body protection", false), 24, TextAnchor.UpperLeft); chest.transform.anchoredPosition = new Vector2(10, -130); TextBox chest2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.chest.GetItemName(), () => Player.instance.equipment.chest.GetItemStats()), 24, TextAnchor.UpperLeft); chest2.transform.anchoredPosition = new Vector2(60, -150); MakeEquButton(chest); TextBox rhand = new TextBox(go.transform, TextRef.Create("Right Hand", "The weapon hand", false), 24, TextAnchor.UpperLeft); rhand.transform.anchoredPosition = new Vector2(10, -180); TextBox rhand2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.rHand.GetItemName(), () => Player.instance.equipment.rHand.GetItemStats()), 24, TextAnchor.UpperLeft); rhand2.transform.anchoredPosition = new Vector2(60, -200); MakeEquButton(rhand); TextBox lhand = new TextBox(go.transform, TextRef.Create("Left Hand", "The shield hand", false), 24, TextAnchor.UpperLeft); lhand.transform.anchoredPosition = new Vector2(10, -230); TextBox lhand2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.lHand.GetItemName(), () => Player.instance.equipment.lHand.GetItemStats()), 24, TextAnchor.UpperLeft); lhand2.transform.anchoredPosition = new Vector2(60, -250); MakeEquButton(lhand); TextBox rarm = new TextBox(go.transform, TextRef.Create("Right arm", "Arm protection", false), 24, TextAnchor.UpperLeft); rarm.transform.anchoredPosition = new Vector2(10, -280); TextBox rarm2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.rArm.GetItemName(), () => Player.instance.equipment.rArm.GetItemStats()), 24, TextAnchor.UpperLeft); rarm2.transform.anchoredPosition = new Vector2(60, -300); MakeEquButton(rarm); TextBox larm = new TextBox(go.transform, TextRef.Create("Left arm", "Arm protection", false), 24, TextAnchor.UpperLeft); larm.transform.anchoredPosition = new Vector2(10, -330); TextBox larm2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.lArm.GetItemName(), () => Player.instance.equipment.lArm.GetItemStats()), 24, TextAnchor.UpperLeft); larm2.transform.anchoredPosition = new Vector2(60, -350); MakeEquButton(larm); TextBox rleg = new TextBox(go.transform, TextRef.Create("Right leg", "Leg protection", false), 24, TextAnchor.UpperLeft); rleg.transform.anchoredPosition = new Vector2(10, -380); TextBox rleg2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.rLeg.GetItemName(), () => Player.instance.equipment.rLeg.GetItemStats()), 24, TextAnchor.UpperLeft); rleg2.transform.anchoredPosition = new Vector2(60, -400); MakeEquButton(rleg); TextBox lleg = new TextBox(go.transform, TextRef.Create("Left leg", "Leg protection", false), 24, TextAnchor.UpperLeft); lleg.transform.anchoredPosition = new Vector2(10, -430); TextBox lleg2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.lLeg.GetItemName(), () => Player.instance.equipment.lLeg.GetItemStats()), 24, TextAnchor.UpperLeft); lleg2.transform.anchoredPosition = new Vector2(60, -450); MakeEquButton(lleg); } /// Table with the inventory { inventoryTable = InfoTable.Create(go.transform, () => Player.instance.inventory, (Loot l) => new List <TextRef>() { l.ToString(), GetSpecificDetails(l), l.weight, l.value, l.slot.ToString() }, 520, new List <TextRef>() { "Inventory", "Specifics", TextRef.Create("w", "Weight", false), TextRef.Create("v", "value", false), "Slot" }, 24); inventoryTable.transform.anchorMin = new Vector2(1, 1); inventoryTable.transform.anchorMax = new Vector2(1, 1); inventoryTable.transform.pivot = new Vector2(1, 1); inventoryTable.transform.anchoredPosition = new Vector2(-10, -50); inventoryTable.SetColumnWidths(new List <float>() { 160, 80, 60, 60, 160 }); } /// Bottom buttons { TextBox equipButton = new TextBox(go.transform, TextRef.Create("Equip", "-Select a weapon.\n-Select a slot.\n-Press this button.", false).AddLink(() => EquipSelected()), 24); equipButton.transform.anchorMin = new Vector2(0, 0); equipButton.transform.anchorMax = new Vector2(0, 0); equipButton.transform.pivot = new Vector2(0, 0); equipButton.transform.anchoredPosition = new Vector2(40, 40); TextBox dropAllButton = new TextBox(go.transform, TextRef.Create("Discard All", "Throw away everything in your inventory.\nBeware! All will be lost.", false).AddLink(() => DiscardAll()), 24, TextAnchor.MiddleRight); dropAllButton.transform.anchorMin = new Vector2(1, 0); dropAllButton.transform.anchorMax = new Vector2(1, 0); dropAllButton.transform.pivot = new Vector2(1, 0); dropAllButton.transform.anchoredPosition = new Vector2(-150, 40); TextBox dropButton = new TextBox(go.transform, TextRef.Create("Discard", "-Select an item.\n-Press this button.", false).AddLink(() => DiscardSelected()), 24, TextAnchor.MiddleRight); dropButton.transform.anchorMin = new Vector2(1, 0); dropButton.transform.anchorMax = new Vector2(1, 0); dropButton.transform.pivot = new Vector2(1, 0); dropButton.transform.anchoredPosition = new Vector2(-40, 40); } go.SetActive(false); }