Ejemplo n.º 1
0
 /// <summary>
 /// 临时添加背包物品数据
 /// </summary>
 private void TempAddBagItem(int num)
 {
     for (int i = 0; i < num; i++)
     {
         BagItemData.AddItem(new Item("物品", i));
     }
 }
Ejemplo n.º 2
0
    public override void Awake(GameObject go)
    {
        transform.Find("Btn_Close").GetComponent <Button>().onClick.AddListener(() =>
        {
            ClosePage <BagUI>();
        });

        //滑动列表相关配置
        TempAddBagItem(20);//给背包添加假数据
        warpContentItem = Resources.Load <GameObject>("UIPrefab/WarpContentItem");
        if (null == warpContentItem)
        {
            Debug.LogError("背包内item预制体不存在或路径错误!!");
            return;
        }
        warpContent = transform.FindChildPlus("Scroll View").GetComponent <UIWarpContent>();
        #region 代码配置滑动列表
        if (null == warpContent)
        {
            warpContent                 = transform.FindChildPlus("Scroll View").gameObject.AddComponent <UIWarpContent>();
            warpContent.arrangement     = UIWarpContent.Arrangement.Vertical;
            warpContent.maxPerLine      = 1;
            warpContent.cellHeight      = 100;
            warpContent.cellWidth       = 160;
            warpContent.cellHeightSpace = 10;
            warpContent.scrollRect      = transform.FindChildPlus("Scroll View").GetComponent <ScrollRect>();
            warpContent.content         = transform.FindChildPlus("Content").GetComponent <RectTransform>();
            warpContent.goItemPrefab    = warpContentItem;
        }
        #endregion
        warpContent.onInitializeItem = onInitializeItem;
        warpContent.Init(BagItemData.GetNum());
    }
Ejemplo n.º 3
0
            /// <summary>
            /// 아이템 판매 할때
            /// 슬롯에 직접 놓는다
            /// </summary>
            /// <param name="eventData"></param>
            public void OnDrop(PointerEventData eventData)
            {
                if (slotType == IconDrag.draggingItem.GetComponent <IconDrag>().ItemType)
                {
                    if (transform.childCount == 0 && !bagStore.IsBuy)
                    {
                        //드래그 중인 아이템의 상위 오브젝트로 잡는다
                        //슬롯에 아이템 장착
                        //IconDrag.draggingItem.transform.SetParent(this.transform);

                        BagItemData data = IconDrag.draggingItem.GetComponent <BagItemData>();

                        data.transform.SetParent(this.transform);

                        //아이템의 개수를 임시 저장 시킨다
                        //  data._BagItem._Count 이것은 원래
                        //파싱 데이터 가져올때 무조건 1이여야 하는 값이지만
                        //판매 시 판매전 수량을 알아야 하기 때문에
                        //이곳에 임시 저장 후
                        //판매가 끝나면 다시 1로 만들어 준다
                        data._BagItem._Count = data.NCount;

                        priceText.text = ((data.NCount * data._BagItem._Price) / Manager.GameManager.INSTANCE.SellPrice).ToString("N0");
                    }
                }
            }
Ejemplo n.º 4
0
    void ReadItemConfig(string csvname)
    {
        bagitemsdata_.Clear();

        List <string[]> strList;

        CReadCsvBase.ReaderCsvDataFromAB(GameDefine.CsvAssetbundleName, csvname, out strList);

        int columnCount = strList.Count;

        for (int i = 2; i < columnCount; i++)
        {
            BagItemData data = new BagItemData();

            uint.TryParse(strList[i][0], out data.itemid);
            data.itemName = strList[i][1];
            data.itemIcon = strList[i][2];
            data.itemInfo = strList[i][3];
            uint.TryParse(strList[i][4], out data.repeatNumber);
            int isgiven = 0;
            int.TryParse(strList[i][5], out isgiven);
            data.isgiven = isgiven == 1;
            int usetype = 0;
            int.TryParse(strList[i][6], out usetype);
            data.usetype = (ItemUseType)usetype;
            uint.TryParse(strList[i][7], out data.itemScriptid);
            uint.TryParse(strList[i][8], out data.itemWorkTime);
            data.workEndTime = strList[i][9];

            bagitemsdata_.Add(data.itemid, data);
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 显示兑换物品界面
    /// </summary>
    /// <param name="itemId">兑换物品Id</param>
    public void ShowExchangeItemPanel(ushort itemId)
    {
        CurItemData = BagDataManager.GetBagDataInstance().GetItemData(itemId);
        if (CurItemData == null)
        {
            CRollTextUI.Instance.AddVerticalRollText("兑换物品不存在!");
            return;
        }

        if (ExchangeItemPanelGameObject == null)
        {
            LoadExchangeItemPanelResource();
        }

        UnityEngine.Transform ItemPopTransform = ExchangeItemPanelGameObject.transform.Find("pop_up");
        UnityEngine.Transform ItemTransform    = ItemPopTransform.Find("Exchange_Gouwuka");

        AssetBundle assetBundle = AssetBundleManager.GetAssetBundle(GameDefine.HallBagIconAssetBundleName);

        if (assetBundle)
        {
            Sprite goodsicon = assetBundle.LoadAsset <Sprite>(CurItemData.itemIcon);
            Image  goods     = ItemTransform.Find("Image").gameObject.GetComponent <Image>();
            goods.sprite = goodsicon;
        }

        ItemPopTransform.gameObject.SetActive(true);
        ItemTransform.gameObject.SetActive(true);
        ExchangeItemPanelGameObject.SetActive(true);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 显示兑换物品历史记录界面
    /// </summary>
    public void ShowExchangeItemRecordPanel()
    {
        if (ExchangeItemPanelGameObject == null)
        {
            LoadExchangeItemPanelResource();
        }
        CurItemData = null;
        UnityEngine.Transform ItemPopTransform    = ExchangeItemPanelGameObject.transform.Find("pop_up");
        UnityEngine.Transform ItemRecordTransform = ItemPopTransform.Find("Exchange_Record");

        ItemRecordTransform.gameObject.SetActive(true);
        ItemPopTransform.gameObject.SetActive(true);
        ExchangeItemPanelGameObject.SetActive(true);

        if (!ExChangeRecordDataFlag)
        {
            ExChangeRecordDataFlag = true;
            //请求兑换记录数据
            UMessage recordMsg = new UMessage((uint)GameCity.EMSG_ENUM.CrazyCityMsg_PLAYERGETTRADEINFO);
            recordMsg.Add(GameMain.hall_.GetPlayerId());
            NetWorkClient.GetInstance().SendMsg(recordMsg);

            CCustomDialog.OpenCustomWaitUI("正在进行兑换记录查询...");
        }
    }
Ejemplo n.º 7
0
    public void AddItem(BagItemData data)
    {
        var grid = Grids[data.bag_index].transform;

        if (data.itemtype == ItemType.武器)
        {
            GameStaticData.WeaponUI.Copy(grid.GetChild(0).GetComponent <RectTransform>());
        }
        else
        {
            GameStaticData.EquipmentUI.Copy(grid.GetChild(0).GetComponent <RectTransform>());
        }
        grid.GetComponent <ItemUI>().SetConfig(data);
    }
Ejemplo n.º 8
0
    private void onInitializeItem(GameObject go, int index)
    {
        Item tempItem = BagItemData.GetItem(index);

        go.transform.Find("Name").GetComponent <Text>().text = tempItem.Name + ":" + index;

        Button tempInformationButton = go.transform.Find("Information").GetComponent <Button>();

        tempInformationButton.onClick.RemoveAllListeners();
        tempInformationButton.onClick.AddListener(() =>
        {
            ShowPage <NoticeUI>(new NoticeInfo("详细信息", tempItem.Name + tempItem.Index));
        });
    }
Ejemplo n.º 9
0
 /// <summary>
 /// 关闭兑换界面
 /// </summary>
 void CloseExchangeEvent()
 {
     if (null == ExchangeItemPanelGameObject)
     {
         return;
     }
     CurItemData = null;
     UnityEngine.Transform ItemPopTransform     = ExchangeItemPanelGameObject.transform.Find("pop_up");
     UnityEngine.Transform ItemRecordTransform  = ItemPopTransform.Find("Exchange_Record");
     UnityEngine.Transform ItemTransform        = ItemPopTransform.Find("Exchange_Gouwuka");
     UnityEngine.Transform ItemConfirmTransform = ItemPopTransform.Find("Tips_Confirm");
     ItemConfirmTransform.gameObject.SetActive(false);
     ItemRecordTransform.gameObject.SetActive(false);
     ItemTransform.gameObject.SetActive(false);
     ExchangeItemPanelGameObject.SetActive(false);
 }
Ejemplo n.º 10
0
            /// <summary>
            /// Q = 0
            /// W = 1
            /// E = 2
            /// 키 입력 시 사용
            /// </summary>
            /// <param name="index"></param>
            public void UseItem(int index)
            {
                //회복 아이템
                if (quickSlots[index].GetComponentInChildren <BagItemData>() != null)
                {
                    //Debug.Log("BagItem");
                    BagItemData data = quickSlots[index].GetComponentInChildren <BagItemData>();

                    //각 아이템에 맞는 데이터 처리 및 애니메이션
                    //회복 되는 데이터(HP, STA.....)
                    bagItemUse.UseItemApply(data); //아아템 사용

                    // data.NCount--; //수량을 감소 시킨다 (나중에 아이템에 수량이 붙일수 있다)
                    if (data.NCount <= 0) //수량이 0이 되면 삭제한다
                    {
                        Destroy(data.gameObject);
                    }
                }
                //보조 무기(수류탄 등)
                else if (quickSlots[index].GetComponentInChildren <SubItemData>() != null)
                {
                    //마우스 방향을 바라본다
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;

                    if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                    {
                        transform.LookAt(new Vector3(hit.point.x, transform.position.y, hit.point.z));
                    }

                    //Debug.Log("SubItem");
                    SubItemData data = quickSlots[index].GetComponentInChildren <SubItemData>();

                    //각 아이템에 맞는 데이터 처리 및 애니메이션
                    //수류탄 던지는 애니 등
                    UseSubItemApply(data);

                    data.NCount--;
                    if (data.NCount <= 0)
                    {
                        Destroy(data.gameObject);
                    }
                }
            }
Ejemplo n.º 11
0
            public void OnDrop(PointerEventData eventData)
            {
                if (transform.childCount == 0)
                {
                    if (itemSlot == IconDrag.draggingItem.GetComponent <IconDrag>().ItemType)
                    {
                        IconDrag.draggingItem.transform.SetParent(this.transform);

                        //소모 아이템인 경우 무게를 늘린다
                        BagItemData data = IconDrag.draggingItem.GetComponent <BagItemData>();
                        player.FWeight += (data.NCount * data._BagItem._Weight);

                        playerInven.WeightTextPrint();
                    }

                    if (subItemSlot == IconDrag.draggingItem.GetComponent <IconDrag>().ItemType)
                    {
                        IconDrag.draggingItem.transform.SetParent(this.transform);
                    }
                }
            }
Ejemplo n.º 12
0
 public void ShowItem(BagItemData data)
 {
     Grids[data.bag_index].transform.GetChild(0).gameObject.SetActive(true);
 }
Ejemplo n.º 13
0
    void SetItemInfo(ushort itemid)
    {
        AssetBundle bagbundle = AssetBundleManager.GetAssetBundle(GameDefine.HallBagIconAssetBundleName);

        if (bagbundle == null)
        {
            return;
        }

        BagItemData bagItemData = BagDataManager.GetBagDataInstance().GetItemData(itemid);

        if (bagItemData == null)
        {
            return;
        }

        GameObject iteminfo = root_.transform.Find("Pop-up").Find("iteminfo").Find("ImageBG").gameObject;

        Image infoicon = iteminfo.transform.Find("bag_icon").Find("Imageicon").gameObject.GetComponent <Image>();

        infoicon.sprite = bagbundle.LoadAsset <Sprite>(bagItemData.itemIcon);
        Text itemName = iteminfo.transform.Find("Textname").gameObject.GetComponent <Text>();

        itemName.text = bagItemData.itemName;
        Text itemNumber = iteminfo.transform.Find("Textnum").gameObject.GetComponent <Text>();

        itemNumber.text = BagDataManager.GetBagDataInstance().currentItems_[itemid].itemNumber.ToString();
        Text itemWorkTime = iteminfo.transform.Find("Texttime").gameObject.GetComponent <Text>();

        if (bagItemData.itemWorkTime > 0)
        {
            uint minutes = bagItemData.itemWorkTime / 60;
            uint hours   = minutes / 60;
            minutes = minutes % 60;
            uint days = hours / 24;
            hours = hours % 24;
            string timeTx = "";
            if (days > 0)
            {
                timeTx += days.ToString() + "天";
            }
            if (hours > 0)
            {
                timeTx += hours.ToString() + "小时";
            }
            if (minutes > 0)
            {
                timeTx += minutes.ToString() + "分钟";
            }
            itemWorkTime.text = timeTx;
        }
        else
        {
            itemWorkTime.gameObject.SetActive(false);
        }

        Text itemcontent = iteminfo.transform.Find("Textinfo").gameObject.GetComponent <Text>();

        itemcontent.text = bagItemData.itemInfo;

        GameObject givetype = iteminfo.transform.Find("ButtonBG").Find("Button_Give").gameObject;

        givetype.SetActive(false);
        GameObject usetype = iteminfo.transform.Find("ButtonBG").Find("Button_shiyong").gameObject;

        usetype.SetActive(false);
        GameObject switchtype = iteminfo.transform.Find("ButtonBG").Find("Button_duihuan").gameObject;

        switchtype.SetActive(false);

        switch (bagItemData.usetype)
        {
        case ItemUseType.Type1:
            givetype.SetActive(true);
            XPointEvent.AutoAddListener(givetype, OnGiveItem, itemid);
            break;

        case ItemUseType.Type2:
            usetype.SetActive(true);
            XPointEvent.AutoAddListener(usetype, OnUseTicket, itemid);
            break;

        case ItemUseType.Type3:
            switchtype.SetActive(true);
            XPointEvent.AutoAddListener(switchtype, OnSwitchGoods, itemid);
            break;

        case ItemUseType.Type4:
            break;

        case ItemUseType.Type5:
            break;
        }
    }
Ejemplo n.º 14
0
    public void SetConfig(BagItemData data, bool ispickup = false)
    {
        this.data = data;
        var id  = this.data.config_id;
        var typ = this.data.itemtype;

        switch (typ)
        {
        case ItemType.鞋子:
            icon.sprite = FootConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + FootConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[FootConfig.Get(id).物品阶级]);
            }
            break;

        case ItemType.裤子:
            icon.sprite = PelvisConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + PelvisConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[PelvisConfig.Get(id).物品阶级]);
            }
            break;

        case ItemType.肩膀:
            icon.sprite = ArmConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + ArmConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[ArmConfig.Get(id).物品阶级]);
            }
            break;

        case ItemType.手链:
            icon.sprite = SleeveConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + SleeveConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[SleeveConfig.Get(id).物品阶级]);
            }
            break;

        case ItemType.武器:
            icon.sprite = WeaponConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + WeaponConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[WeaponConfig.Get(id).物品阶级]);
            }

            break;

        case ItemType.衣:
            icon.sprite = TorsoConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + TorsoConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[TorsoConfig.Get(id).物品阶级]);
            }
            break;

        case ItemType.消耗品:
            icon.sprite = ConsumablesConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + ConsumablesConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[ConsumablesConfig.Get(id).物品阶级]);
            }
            break;

        case ItemType.盾牌:
            icon.sprite = ShieldConfig.Get(id).GetSprite();
            if (ispickup)
            {
                View.CurrentScene.GetView <GameInfoView>().SetPopText("拾取 " + ShieldConfig.Get(id).物品名字 + "*1", GameStaticData.ITEM_COLOR_DICT[ShieldConfig.Get(id).物品阶级]);
            }
            break;

        default:
            break;
        }
    }