Пример #1
0
    public static bool UseProp(PropsConf propsConf)
    {
        switch (propsConf.type)
        {
        case PropType.GOODS:
            Buff buff = GetBuff(propsConf.buff)[0];
            GameManage.Instance.role.CalculateBuff(buff);
            GameManage.Instance.role.buffList.Add(buff);
            UIManage.CreateTips("使用物品成功!");
            MainView.Instance.Change();
            return(true);

        case PropType.SKILL:
            if (GameManage.Instance.userData.skills.Find(a => a.id == int.Parse(propsConf.buff)) == null)
            {
                Skill skill = new Skill(int.Parse(propsConf.buff), 1);
                GameManage.Instance.userData.skills.Add(skill);
                UIManage.CreateTips("学习技能成功!");
                return(true);
            }
            else
            {
                UIManage.CreateTips("该技能已学习!");
                return(false);
            }
        }
        return(false);
    }
Пример #2
0
    public void OnClickItem(GameObject go)
    {
        id = (int)UIEventListener.Get(go).parameter;
        PropsConf conf = XMLData.PropsConfs.Find(a => a.id == id);

        //Debug.LogError(id);
        propName.text   = conf.propsName;
        des.text        = conf.introduction;
        icon.spriteName = "" + conf.id;
        propName.gameObject.SetActive(true);
        des.gameObject.SetActive(true);
        icon.gameObject.SetActive(true);
        useItem.SetActive(true);
    }
Пример #3
0
    public void OnClickUse()
    {
        PropsConf conf = XMLData.PropsConfs.Find(a => a.id == id);

        if (GameTools.UseProp(conf))
        {
            Prop prop = GameManage.Instance.userData.props.Find(a => a.conf.id == conf.id);
            if (prop.num == 1)
            {
                GameManage.Instance.userData.props.Remove(prop);
                propName.gameObject.SetActive(false);
                des.gameObject.SetActive(false);
                icon.gameObject.SetActive(false);
                useItem.SetActive(false);
            }
            else
            {
                prop.num--;
            }
            CreateItem();
        }
    }