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); }