自由幻想UI之宠物界面
来源:互联网 发布:拼豆转图软件手机 编辑:程序博客网 时间:2024/04/29 15:14
using System.Collections.Generic;using UnityEngine;using UnityEngine.Events;using UnityEngine.UI;public class PetView : MonoBehaviour { [System.Serializable] public struct AttributeRelation { public Text value; public Button button; } public Button help; public Button close; [Tooltip("品质")] public Text quality; public InputField petName; public Text hp; public Text mp; public Text level; [Tooltip("食物类型")] public Image foodType; [Tooltip("性别")] public Image gender; [Tooltip("饥渴")] public Text hunger; [Tooltip("信赖")] public Text trust; [Tooltip("所有装备")] public LatticeView[] equips; [Tooltip("最小攻击")] public Text minAttack; [Tooltip("最大攻击")] public Text maxAttack; [Tooltip("防御")] public Text defense; [Tooltip("魔攻")] public Text magicAttack; [Tooltip("命中")] public Text hit; [Tooltip("魔防")] public Text magicDefense; [Tooltip("六维属性")] public AttributeRelation[] attributeRelation; [Tooltip("剩余点数")] public Text surplus; [Tooltip("资质")] public Button aptitude; [Tooltip("已用数量")] public Text used; [Tooltip("经验")] public Text exp; [Tooltip("所有宠物")] public LatticeView[] pets; [Tooltip("所有技能")] public Toggle showPet; public LatticeView[] skills; public class IntEvent : UnityEvent<int> { } public IntEvent onLeftClick = new IntEvent(); public IntEvent onRightClick = new IntEvent(); public IntEvent onDoubleClick = new IntEvent(); public class StringEvent : UnityEvent<string> { } public StringEvent onAddAttribute = new StringEvent(); public StringEvent onLeftClickEquip = new StringEvent(); public StringEvent onRightClickEquip = new StringEvent(); private Dictionary<string, LatticeView> equipDic = new Dictionary<string, LatticeView>(); public void InitWindow() { InitEquipLattice(); InitAttribute(); InitPetLattice(); InitSkillLattice(); } public void SetEquip(string name, Sprite icon, int count) { equipDic[name].Icon = icon; equipDic[name].Count = count; } private void InitEquipLattice() { int length = equips.Length; for (int i = 0; i < length; i++) { var go = equips[i].gameObject; var name = go.name; EventListener.Get(go).onLeftClick += () => { onLeftClickEquip.Invoke(name); }; EventListener.Get(go).onRightClick += () => { onRightClickEquip.Invoke(name); }; equipDic.Add(name,equips[i]); } } private void InitAttribute() { int length = attributeRelation.Length; for(int i = 0; i < length; i++) { var index = i; var name = attributeRelation[i].button.name; attributeRelation[i].button.onClick.AddListener(() => { int value; if (int.TryParse(attributeRelation[index].value.text,out value)) { onAddAttribute.Invoke(name); attributeRelation[index].value.text = (value + 1).ToString(); } }); } } private void InitPetLattice() { int length = pets.Length; for (int i = 0; i < length; i++) { var index = i; var go = pets[i].gameObject; EventListener.Get(go).onLeftClick += () => { onLeftClick.Invoke(index); }; EventListener.Get(go).onRightClick += () => { onRightClick.Invoke(index); }; EventListener.Get(go).onLeftDoubleClick += () => { onDoubleClick.Invoke(index); }; } } private void InitSkillLattice() { int length = skills.Length; for (int i = 0; i < length; i++) { var index = i; var go = skills[i].gameObject; EventListener.Get(go).onLeftClick += () => { onLeftClick.Invoke(index); }; EventListener.Get(go).onRightClick += () => { onRightClick.Invoke(index); }; } }}
阅读全文
0 0
- 自由幻想UI之宠物界面
- 自由幻想UI之数量选择界面
- 自由幻想UI之角色界面
- 自由幻想UI之成就界面
- 自由幻想UI之幻神界面
- 自由幻想UI之任务界面
- 自由幻想UI之格子
- 自由幻想UI之背包
- 自由幻想UI之鼠标跟随图标
- 自由幻想UI之信息显示
- 自由幻想UI之技能面板
- 自由幻想UI之切换成就列表
- 《QQ自由幻想》我所钟爱的可爱宠物
- 《QQ自由幻想》我所钟爱的可爱宠物
- 《QQ自由幻想》我所钟爱的可爱宠物
- 宠物之家UI设计
- 恶搞《卖拐》之QQ自由幻想版
- QQ自由幻想之都是月亮惹的祸
- 超声波测距仪
- [数论][二项式定理][矩阵乘法] BZOJ 3328: PYXFIB
- 单链表逆序问题
- fedora服务器网站搭建
- 象形识字隐私用户数据声明
- 自由幻想UI之宠物界面
- 理解字节序
- bzoj 1019: [SHOI2008]汉诺塔(打表)
- bzoj 1036: [ZJOI2008]树的统计Count(树链剖分)
- top和ps取长补短续篇3之进程定位
- 伪类
- 剑指offer 顺时针打印矩阵
- WIN7 64位系统安装JDK并配置环境变量
- 成员变量和静态变量的区别