Пример #1
0
    void Update()
    {
        //鼠标悬停其上时显示物品属性展示栏
        if (isHover)
        {
            ShowItemInfoById(id);
            //一般情况下只有鼠标悬停于item上才可右击使用药品
            if (Input.GetMouseButtonDown(1))
            {
                switch (ObjectsInfo.Instance().GetObjectInfoById(id).type)
                {
                case ObjectInfo.ObjectType.Drug: gridOfItem.UseDrug(); break;

                //装备栏中和物品栏中右击装备的操作是不一样的
                case ObjectInfo.ObjectType.Equip: if (!equiping)
                    {
                        gridOfItem.WearEquip();
                    }
                    else
                    {
                        this.GetComponentInParent <GridOfEquip>().UnloadThisGridEquip();
                    }
                    break;
                }
            }
        }
        else
        {
            infoFrame.SetActive(false);
        }
    }
Пример #2
0
    /// <summary>
    /// 设置当前Grid中的item(记录了id和ObjectInfo即物品全部信息)
    /// </summary>
    /// <param name="id">item的id</param>
    /// <param name="num">item的数量</param>
    public void SetThisGridItemById(int id, int num = 1)
    {
        this.id   = id;
        this.num  = num;
        this.info = ObjectsInfo.Instance().GetObjectInfoById(id);
        Item item = this.GetComponentInChildren <Item>();

        item.SetIconAndId(id, this.info.icon_name);
        numLabel.enabled = true;
        numLabel.text    = this.num.ToString();
    }
Пример #3
0
    /// <summary>
    /// 显示id对应的物品信息和展示栏
    /// </summary>
    /// <param name="id">item的id</param>
    public void ShowItemInfoById(int id)
    {
        infoFrame.SetActive(true);
        ObjectInfo info    = ObjectsInfo.Instance().GetObjectInfoById(id);
        string     message = "";

        switch (info.type)
        {
        case ObjectInfo.ObjectType.Drug: message = GetDrugMessage(info); break;

        case ObjectInfo.ObjectType.Equip: message = GetEquipMessage(info); break;
        }
        infoText.text = message;
    }
Пример #4
0
    /// <summary>
    /// 随机掉落一个物品
    /// </summary>
    /// <param name="pos">掉落位置</param>
    public void CreateRandomDropItem(Vector3 pos)
    {
        int kind = Random.Range(1, 3);
        int id   = 0;

        switch (kind)
        {
        case 1: id = Random.Range(1001, 1004); break;

        case 2: id = Random.Range(2001, 2023); break;
        }
        item.SetIconAndId(id, ObjectsInfo.Instance().GetObjectInfoById(id).icon_name);
        Instantiate(item.gameObject, pos + Vector3.up * 0.3f, Quaternion.identity);
    }
Пример #5
0
    /// <summary>
    /// Buy按钮回调
    /// </summary>
    public void BuyButtonClick()
    {
        int price = ObjectsInfo.Instance().GetObjectInfoById(id).price_buy;

        Debug.Log("价格为" + price);
        if (CoinManager.Instance().ReduceCoin(price))
        {
            //添加进背包
            BagBoard.Instance().PickOneItemById(id);
        }
        else
        {
            Debug.Log("金币不足");
        }
    }
Пример #6
0
    /// <summary>
    /// 设置对应物品信息
    /// </summary>
    /// <param name="id"></param>
    public void SetThisShopItemById(int id)
    {
        this.id = id;
        ObjectInfo info = ObjectsInfo.Instance().GetObjectInfoById(id);

        icon.spriteName = info.icon_name;
        string message = "";

        switch (info.type)
        {
        case ObjectInfo.ObjectType.Drug: message = GetDrugMessage(info); break;

        case ObjectInfo.ObjectType.Equip: message = GetEquipMessage(info); break;
        }
        infoText.text = message;
    }
Пример #7
0
    /// <summary>
    /// 穿戴情况处理
    /// </summary>
    /// <param name="id">要穿戴装备id</param>
    /// <returns>成功穿戴return true</returns>
    public bool WearEquipmentById(int id)
    {
        ObjectInfo info = ObjectsInfo.Instance().GetObjectInfoById(id);

        if (info.suittype != PlayerStatusInfo.Instance().playertype)
        {
            return(false);
        }
        GridOfEquip tempGrid = null;

        switch (info.weartype)
        {
        case ObjectInfo.WearType.Headgear:  tempGrid = headgear;                                                                                                break;

        case ObjectInfo.WearType.Armor:         tempGrid = armor;                                                                                                       break;

        case ObjectInfo.WearType.Hand:          tempGrid = hand;    AppearChange.Instance().SwitchWeaponAppear(id); break;                  //目前只有武器可更换外观

        case ObjectInfo.WearType.Accessory: tempGrid = accessory;                                                                                               break;

        case ObjectInfo.WearType.Shoe:          tempGrid = shoe;                                                                                                break;
        }
        //对应装备栏已经有装备的情况,先卸下装备,使装备栏空且物品栏加入改装备
        if (tempGrid.id != 0)
        {
            tempGrid.UnloadThisGridEquip();
            Debug.Log("脱");
        }
        //向空的装备栏中添加装备
        Debug.Log("穿");
        GameObject equipNewItem = NGUITools.AddChild(tempGrid.gameObject, newEquip);

        equipNewItem.transform.localPosition         = Vector3.zero;
        equipNewItem.GetComponent <UISprite>().depth = 2;
        tempGrid.SetThisGridEquipById(id, info);
        return(true);
    }