Exemple #1
0
 void Show()
 {
     info.gameObject.SetActive(true);
     Debug.Log(info.gameObject.name);
     OkBtn     = info.Find("UseBtn").GetComponent <Button>();
     CancelBtn = info.Find("Cancel").GetComponent <Button>();
     CancelBtn.onClick.AddListener(() => { info.gameObject.SetActive(false); });
     OkBtn.onClick.AddListener(() => {
         if (gameObject.name != "Image(Clone)")
         {
             ID            = int.Parse(gameObject.name);
             GoodsModel gm = Save.Equiplist.Find(x => x.Id == ID);
             Save.BuyItem(Read.GedInstance().GetItemId(ID), false);
             if (gm != null)
             {
                 Save.UseItem(Read.GedInstance().GetItemId(ID), true);
             }
             //GetComponent<Image>().sprite = Resources.Load<Sprite>("Icon/Slotlayout");
             //if (gameObject.name==ID.ToString())
             //{
             //    gameObject.name = "Image";
             //}
         }
         info.gameObject.SetActive(false);
         TTUIPage.ShowPage <EquiPanel>();
     });
 }
Exemple #2
0
 void Start()
 {
     for (int i = 0; i < Read.GedInstance().itemList.Count; i++)
     {
         items.Add(Read.GedInstance().itemList[i].description);
     }
     buy = transform.parent.Find("ButtonBuy").GetComponent <Button>();
     buy.onClick.AddListener(() => { Save.BuyItem(item, false); });
 }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        buttonBuy = transform.Find("ButtonBuy").GetComponent <Button>();
        toggle    = transform.Find("ImageSlot").GetComponent <Toggle>();
        buttonBuy.onClick.AddListener(() =>
        {
            Save.BuyItem(itemInfo);
            //SoundManager.instance.PlayingSound("BuyItem");
            TTUIPage.ShowPage <TipPanel>("购买成功!");
        });
        toggle.onValueChanged.AddListener(x => { SelectItem(); });

        Debug.LogWarning("记住调用Init方法,对物品信息进行初始化");
    }
Exemple #4
0
    /// <summary>
    /// 得到要锻造的物品
    /// </summary>
    public void GetNeedDZ()
    {
        //判断两个锻造槽是否都有东西
        if (Save.Currformulas.Count >= 2)
        {
            List <int> CaiLia = new List <int>();
            int        a      = 0;//所有锻造材料的总和
            //foreach (GoodsModel item in Save.Currformulas)
            //{
            //    a += item.Num;
            //}
            for (int i = 0; i < Save.Currformulas.Count; i++)
            {
                a += Save.Currformulas[i].Num;
            }
            //得到当前所有的锻造材料
            for (int i = 0; i < a; i++)
            {
                if (i + 1 <= Save.Currformulas[0].Num)
                {
                    CaiLia.Add(Save.Currformulas[0].Id);
                }
                else
                {
                    CaiLia.Add(Save.Currformulas[1].Id);
                }
            }

            Formula matchedFormula = null;
            foreach (Formula formula in formulaList)
            {
                bool isMatch = formula.Match(CaiLia);
                //Debug.Log(isMatch);
                if (isMatch)
                {
                    matchedFormula = formula;
                    break;
                }
            }
            if (matchedFormula != null)
            {
                Save.BuyItem(Read.GedInstance().GetItemId(matchedFormula.ResID), false);
                Save.SuccessDZ(formulaList.Find(x => x.ResID == matchedFormula.ResID));
                TTUIPage.ShowPage <BagPanel>();
                Clear();
            }
        }
        ShowItem();
    }
Exemple #5
0
    public void Show()
    {
        Vector3 worldPos;

        CurrentGoodsId = int.Parse(transform.parent.name);
        GoodsInfo.gameObject.SetActive(true);//物品信息显示框设为显示
        nameText.text = Read.GedInstance().GetItemId(CurrentGoodsId).item_Name;
        desText.text  = Read.GedInstance().GetItemId(CurrentGoodsId).description;
        //点击使用按钮执行的方法
        usebtn.onClick.AddListener(() => {
            GoodsInfo.gameObject.SetActive(false);//物品信息显示框设为隐藏
            //判断装备类型是不是药品,不是就存起来
            if (Read.GedInstance().GetItemId(CurrentGoodsId).equipment_Type.ToString() != "Null")
            {
                Save.UseItem(Read.GedInstance().GetItemId(CurrentGoodsId), false);
                //Save.GoodList.Add();
            }
            //根据传入的值来判断是买东西存入,还是使用减少数组元素
            Save.BuyItem(Read.GedInstance().GetItemId(CurrentGoodsId), true);
            //刷新背包页面
            TTUIPage.ShowPage <BagPanel>();
            if (!TTUIPage.allPages.ContainsKey("EquipPanel"))
            {
                TTUIPage.ShowPage <EquiPanel>();
            }
        });
        //锻造按钮
        DZBtn.onClick.AddListener(() => {
            //Save.BuyItem(Read.GedInstance().GetItemId(CurrentGoodsId), true);
            TTUIPage.ShowPage <DZ>();
            Save.CurrCaiLiao(Read.GedInstance().GetItemId(CurrentGoodsId));
        });

        if (RectTransformUtility.ScreenPointToWorldPointInRectangle(
                TTUIRoot.Instance.root.transform as RectTransform,
                Input.mousePosition, TTUIRoot.Instance.uiCamera, out worldPos
                ))
        {
            GoodsInfo.transform.position = worldPos;
        }
    }
Exemple #6
0
    public void Chuan(Item _item)
    {
        game   = transform.Find("BG/" + _item.equipment_Type.ToString()).GetChild(0).gameObject;
        sprite = Resources.Load <Sprite>("Icon/" + _item.item_ID.ToString());

        if (game.name != "Image(Clone)" && game.name != _item.item_ID.ToString())
        {
            GoodsModel gm = Save.Equiplist.Find(x => x.Id == int.Parse(game.name));
            Save.BuyItem(Read.GedInstance().GetItemId(int.Parse(game.name)), false);
            if (gm != null)
            {
                Save.Equiplist.Remove(gm);
            }
        }
        switch (_item.equipment_Type)
        {
        case Equipment_Type.Null:
            Debug.Log("Null");
            break;

        case Equipment_Type.Head_Gear:
            Debug.Log("Head_Gear");
            game.name = _item.item_ID.ToString();
            game.transform.GetComponent <Image>().sprite = sprite;
            break;

        case Equipment_Type.Armor:
            Debug.Log("Armor");
            game.name = _item.item_ID.ToString();
            game.transform.GetComponent <Image>().sprite = sprite;
            break;

        case Equipment_Type.Shoes:
            Debug.Log("Shoes");
            game.name = _item.item_ID.ToString();
            game.transform.GetComponent <Image>().sprite = sprite;
            break;

        case Equipment_Type.Accessory:
            Debug.Log("Accessory");
            game.name = _item.item_ID.ToString();
            game.transform.GetComponent <Image>().sprite = sprite;
            break;

        case Equipment_Type.Left_Hand:
            Debug.Log("Left_Hand");
            game.name = _item.item_ID.ToString();
            game.transform.GetComponent <Image>().sprite = sprite;
            break;

        case Equipment_Type.Right_Hand:
            Debug.Log("Right_Hand");
            game.name = _item.item_ID.ToString();
            game.transform.GetComponent <Image>().sprite = sprite;
            break;

        case Equipment_Type.Two_Hand:
            Debug.Log("Two_Hand");
            game.name = _item.item_ID.ToString();
            game.transform.GetComponent <Image>().sprite = sprite;
            break;

        default:
            //Debug.Log("药品");
            //image.sprite = Resources.Load<Sprite>(_item.item_ID.ToString());
            break;
        }
    }
Exemple #7
0
    // Use this for initialization
    void Start()
    {
        transform.parent.GetChild(4).GetComponent <Button>().onClick.AddListener(() => { Save.BuyItem(itt); });
        ti = GameObject.Find("UICamera").GetComponent <Camera>();

        T = GameObject.Find("ttttt(Clone)");
    }