Example #1
0
 public void MoveToInventory(ShopCell shopCell)
 {
     if (_inventoryHero.transform.childCount < 5)
     {
         shopCell.transform.SetParent(_inventoryHero.transform, false);
         shopCell.PlaceToHero = PlaceToHero.INVENTORY;
     }
 }
    public void onDrop(ShopCell shopCell)
    {
        Vector3    mouseWorldPos  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector3Int tileCoordinate = _tilemap.WorldToCell(mouseWorldPos);
        Texture2D  t = shopCell.HeroImpl.icon.texture;

        tileHero.sprite = Sprite.Create(t, new Rect(0, 0, t.width, t.height), new Vector2(0.5f, 0.5f), 256f);
        _tilemap.SetTile(tileCoordinate, tileHero);
        Debug.Log(shopCell);
    }
    private void ConfirmItem()
    {
        ShopCell itemWTB = seleObj.GetComponentInParent <ShopCell>();

        if (itemWTB.ifCanBuy())
        {
            string itemName = GameDataMgr.Instance.GetItemInfo(itemWTB.GetShopCellInfo().itemInfo.id).name;
            //点击购买后,弹出确认提示面板
            UIMgr.Instance.ShowConfirmPanel("是否确认购买" + itemName, ConfirmType.TwoBtn, () =>
            {
                itemWTB.BuyItem();
                waitToBuy = false;
            });
        }
    }
Example #4
0
    public override void ShowMe()
    {
        base.ShowMe();
        //根据数据进行初始化
        for (int i = 0; i < GameDataMgr.GetInstance().shopInfos.Count; i++)
        {
            //实例化出来shopcell对象
            ShopCell cell = ResMgr.GetInstance().Load <GameObject>("UI/ShopCell").GetComponent <ShopCell>();
            //设置父对象
            cell.transform.SetParent(content);
            //设置相对大小
            cell.transform.localScale = Vector3.one;

            cell.InitInfo(GameDataMgr.GetInstance().shopInfos[i]);
        }
    }