예제 #1
0
    public override void Awake(GameObject go)
    {
        propItem = this.transform.Find("Storehouse/Scroll View/Viewport/Content/Item").gameObject;
        propItem.SetActive(false);
        itemHeight = propItem.GetComponent <RectTransform>().rect.height;

        btnItem = this.transform.Find("Storehouse/Scroll View/Viewport/Content/Btn").gameObject.AddComponent <aSongUI_PropListItem>();
        btnItem.gameObject.SetActive(false);
        btnItem.transform.Find("PutOn").GetComponent <Button>().onClick.AddListener(BackpackListButton_PutOn);
        btnItem.transform.Find("Discard").GetComponent <Button>().onClick.AddListener(Discard);

        usingItem = this.transform.Find("Storehouse/Scroll View/Viewport/Content/Using").gameObject.AddComponent <aSongUI_PropListItem>();
        usingItem.gameObject.SetActive(false);
        usingItem.transform.Find("PutOn").GetComponent <Button>().onClick.AddListener(BackpackListButton_PutOn);

        content = this.transform.Find("Storehouse/Scroll View/Viewport/Content").GetComponent <RectTransform>();

        weightText = transform.Find("Storehouse/Instruction/Weight").GetComponent <Text>();
        transform.Find("Storehouse/Instruction/Back").GetComponent <Button>().onClick.AddListener(() => {
            TTUIPage.ClosePage <aSongUI_Backpack>();
        });

        leftWeapon  = transform.Find("Weapons/LeftWeapon").gameObject.AddComponent <aSongUI_BackpackWeapon>();
        rightWeapon = transform.Find("Weapons/RightWeapon").gameObject.AddComponent <aSongUI_BackpackWeapon>();
        leftWeapon.Init();
        rightWeapon.Init();
    }
예제 #2
0
    /// <summary>
    /// 背包list中的装备配件功能
    /// </summary>
    /// <param name="_prop"></param>
    void PutOnParts(aSong_PlayerData.Prop _prop)
    {
        aSongUI_BackpackWeapon curentBackpackWeapon = GetCurrent_aSongUI_BackpackWeapon();

        if (!curentBackpackWeapon)
        {
            return;
        }
        //当前没拿武器
        if (!curentBackpackWeapon.CanPartsOn())
        {
            curentBackpackWeapon.Reset();
            return;
        }
        //先从数据中背包List删除
        //再将道具引用放到aSongUI_BackpackWeapon对应的槽中
        //aSongUI_Contact.m_instance

        PropBaseModel _model = aSongUI_Controller.Instance.playerData.GetBagProp(_prop.propID);

        Debug.Log("装配件_model = " + _model.prop.name);
        aSongUI_Controller.Instance.RemovePropFromBag(_model);
        _model = curentBackpackWeapon.PutOnParts(_model);
        if (_model)
        {
            Debug.Log("卸下来的道具 = " + _model.prop.name);
            aSongUI_Controller.Instance.AddPropToBag(_model);
        }
        HideBtnItem();
    }
예제 #3
0
    aSongUI_BackpackWeapon GetCurrent_aSongUI_BackpackWeapon()
    {
        aSongUI_BackpackWeapon backpackWeapon = null;

        if (rightWeapon.CanPartsOn() && rightWeapon.GetWeaponModel() == aSongUI_Controller.Instance.CurrentModel)
        {
            backpackWeapon = rightWeapon;
        }

        if (leftWeapon.CanPartsOn() && leftWeapon.GetWeaponModel() == aSongUI_Controller.Instance.CurrentModel)
        {
            backpackWeapon = leftWeapon;
        }
        return(backpackWeapon);
    }