Exemplo n.º 1
0
        public void Load(Tune loadData)
        {
            AssembledData = loadData;

            //Materials
            for (int i = 0; i < MaterialSlots.Count; i++)
            {
                Destroy(MaterialSlots[i].gameObject);
            }
            MaterialSlots.Clear();

            for (int i = 0; i < AssembledData.CraftMaterials.Count; i++)
            {
                CraftMaterialSlot craftMaterialSlot = Instantiate(MaterialSlotTemplate, MaterialTemplate.transform);
                craftMaterialSlot.gameObject.SetActive(true);
                craftMaterialSlot.NameInputField.SetTextWithoutNotify(AssembledData.CraftMaterials[i].Name);
                craftMaterialSlot.AmountInputField.SetTextWithoutNotify(AssembledData.CraftMaterials[i].Amount.ToString());
                craftMaterialSlot.GetComponent <RectTransform>().anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count);
                MaterialSlots.Add(craftMaterialSlot);
            }
            MaterialAddButton.anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count);
            RecalculateContent();

            //Event callback
            OnRedraw?.Invoke(AssembledData);
        }
Exemplo n.º 2
0
        public void UpdateMaterialName(CraftMaterialSlot craftMaterialSlot, string text)
        {
            if (IgnoreEvents)
            {
                return;
            }
            int index = MaterialSlots.IndexOf(craftMaterialSlot);

            AssembledData.CraftMaterials[index].Name = text;
        }
Exemplo n.º 3
0
        public void UpdateMaterialAmount(CraftMaterialSlot craftMaterialSlot, string text)
        {
            if (IgnoreEvents)
            {
                return;
            }
            int index = MaterialSlots.IndexOf(craftMaterialSlot);

            int.TryParse(text, out int amount);
            AssembledData.CraftMaterials[index].Amount = amount;
        }
Exemplo n.º 4
0
        public void AddMaterialSlot()
        {
            CraftMaterialSlot craftMaterialSlot = Instantiate(MaterialSlotTemplate, MaterialTemplate.transform);

            craftMaterialSlot.gameObject.SetActive(true);
            craftMaterialSlot.GetComponent <RectTransform>().anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count);
            MaterialSlots.Add(craftMaterialSlot);
            AssembledData.CraftMaterials.Add(new Tune.CraftMaterial());

            MaterialAddButton.anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count);
            RecalculateContent();
        }
Exemplo n.º 5
0
        public void RemoveMaterialSlot(CraftMaterialSlot craftMaterialSlot)
        {
            int index = MaterialSlots.IndexOf(craftMaterialSlot);

            MaterialSlots.RemoveAt(index);
            AssembledData.CraftMaterials.RemoveAt(index);
            Destroy(craftMaterialSlot.gameObject);
            for (int i = index; i < MaterialSlots.Count; i++)
            {
                RectTransform slotTransform = MaterialSlots[i].GetComponent <RectTransform>();
                slotTransform.anchoredPosition = new Vector2(slotTransform.anchoredPosition.x, slotTransform.anchoredPosition.y - MaterialOffset.y);
            }

            MaterialAddButton.anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count);
            RecalculateContent();
        }