打算写任务系统,背包系统,战斗系统三部分,但是目前只做过背包系统(跟着siki学的),战斗系统(还不是用FSM写的),决定从背包系统开始,修改下之前的框架。

先做UI:

背包系统是由很多小格子构成,每个格子也就是一个图片,创建一个image,加一个button,把所有格子放到一个空物体下面,为了对小格子进行排序所以要有Grid layout Group组件。grid layout group组件设置排序方式偏移等等。

     

写代码:

     整体框架如下


Item基类:

   

public class Item {public int ID { get; set; }public string Name { get; set; }public ItemType Type{get;set;}public ItemQualitys Quality { get; set; } public string Description { get; set; } public int Capacity { get; set; }//容量public int BuyPrice { get; set; }public int SellPrice { get; set; }public string Sprite { get; set; }public Item(){this.ID = -1;}public Item(int id,string name,ItemType type,ItemQualitys quality,string des,int capacity,int buyPrice,int sellPrice,string sprite ){this.ID = id;this.Name = name;this.Type = type;this.Quality = quality;this.Description = des;this.Capacity = capacity;this.BuyPrice = buyPrice;this.SellPrice = sellPrice;this.Sprite = sprite;}/// <summary>/// 物品类型/// </summary>public enum ItemType{Consumable,//消耗品Equipment,//装备类Weapon,//武器Material//材料}/// <summary>/// 物品品质/// </summary>public enum ItemQualitys{white,//白色yellow,//黄色blue,//蓝色Orange//橙色}/// <summary>/// 得到提示面板应该显示什么样的内容/// </summary>/// <returns></returns>public virtual string GetToolTipText(){string color = "";switch(Quality){case ItemQualitys.white:color = "white";break;case ItemQualitys.blue:color = "blue";break;case ItemQualitys.Orange:color = "orange";break;case ItemQualitys.yellow:color = "yellow";break;}string text = string.Format("<color={4}>{0}</color>\n<size=10>购买价格:{1}出售价格:{2}</size>\n<color=blue>{3}</color>", Name, BuyPrice, SellPrice, Description, color);return text;}

消耗品:

public class Consumable : Item
{public int HP { get; set; }public int MP { get; set; }public Consumable(int id, string name, ItemType type, ItemQualitys quality, string des, int capacity, int buyPrice, int sellPrice, string sprite, int hp,int mp) : base(id, name, type, quality, des, capacity, buyPrice, sellPrice,sprite){this.HP = hp;this.MP = mp;}
}

武器类:

public class Weapon : Item
{public int Damage { get; set; }public Weapon(int id, string name, ItemType type, ItemQualitys quality, string des, int capacity, int buyPrice, int sellPrice,int damage,string sprite) : base(id, name, type, quality, des, capacity, buyPrice, sellPrice,sprite){this.Damage = damage;}public override string GetToolTipText(){string text= base.GetToolTipText();int damage = Damage;string newtext = string.Format("{0}\n<color=green>攻击力:{1}</color>", text, damage);return newtext;}}

装备类:

public class Equipment : Item
{public int Strength { get; set; }//力量public int Intellect { get; set; }//智力public int Agility { get; set; }//敏捷public int Stamina { get; set; }//体力    public EquipmentType equipType { get; set; }public enum EquipmentType{None,Head,Chest,//胸部Leg,//腿Boots,//腿}public Equipment(int id, string name, ItemType type, ItemQualitys quality, string des, int capacity, int buyPrice, int sellPrice,int strength,int intellect,int agility,int stamina,EquipmentType equiptype,string sprite) : base(id, name, type, quality, des, capacity, buyPrice, sellPrice,sprite){this.Strength = strength;this.Intellect = intellect;this.Agility = agility;this.Stamina = stamina;this.equipType = equiptype;}public override string GetToolTipText(){string equipTypeText = "";switch(equipType){case EquipmentType.Head:equipTypeText = "头部";break;case EquipmentType.Chest:equipTypeText = "胸部";break;case EquipmentType.Leg:equipTypeText = "腿";break;case EquipmentType.Boots:equipTypeText = "靴子";break;}string text= base.GetToolTipText();string newText = string.Format("{0}\n<color=blue>装备类型:{5}\n力量:{1}\n智力:{2}\n敏捷:{3}\n体力:{4}</color>", text,Strength,Intellect,Agility,Stamina,equipTypeText);return newText;}
}

毕业设计之背包系统1相关推荐

  1. 【最新计算机、电子毕业设计 本科 大专 设计+源码】

    2022年 - 2023年 最新计算机.电子毕业设计 本科 大专 设计+源码 下载前必看: 纯小白教程,unity两种格式资源的使用方法,1打开现有项目.2导入package 大专毕设源码:数媒专业. ...

  2. 基于颜色特征,形状特征和纹理特征的数字图像的检索(Digital Image Retrieval)MATLAB GUI实现(本科毕业设计)

    该程序实现的功能为:检索出指定的图像文件,并从检索出的图像中检索出指定的物体 . 1,主程序为Recognition和Recognition. 2.颜色特征,形状特征,纹理特征为对应的各子程序. 3. ...

  3. 24/4毕业设计小记

    折腾了很久了,关于我的毕业设计,一直就没有时间来写博客,今天感冒了,趁着思路不太好的时候就写一篇博客吧!写什么好呢,就写基于vlc sdk的播放器开发吧! 我的项目是关于windows和linux两个 ...

  4. 基于jsp的图书管理系统_计算机毕业设计基于JSP书籍租阅管理系统的设计与实现...

    系统总业务流程图: 普通用户业务流程图: 管理员业务流程图: 系统功能需求设计: 1.系统用户管理:超级管理员和普通管理员都需要对系统用户进行管理,包括添加.删除.修改和查询普通管理员,修改管理员密码 ...

  5. qpsk调制解调matlab_本科毕业设计课题—QPSK相干解调的MATLAB仿真(3)

    继续讲解! 给出参考文章! <全数字BPSKQPSK接收机同步技术研究> 模拟中频信号经过模数转换后形成数字中频信号,解调时首先经数字下变频器DDC(digita down-convert ...

  6. 计算机论文工作进程记录,毕业设计进程记录

    本频道涵盖与毕业设计和进程和记录有关的论文范例,免费给你学习毕业设计进程记录怎么写提供相关文献资料. [摘要]结合中国矿业大学工程技术学院应用型人才的培养目标,针对安全专业的特点,通过分析近年毕业设计 ...

  7. qudpsocket 丢包 线程解决_服装毕业设计一站式解决方案——线下amp;线上辅导课程...

    毕业季来了!真的来了! 服装人准备好了嘛? 勤勤恳恳努努力力做着毕业设计的你是否会遇到以下问题: 1.有设计想法,可是不知道该怎么实现? 2.有效果图,但不知道怎么与自己的设计灵感扯上关系? 3.想法 ...

  8. python爬虫怎么做毕业设计_python语言爬虫做成毕业设计的话,怎样答辩演示,或者怎样把爬虫复杂化?...

    作为一名IT行业的从业者,同时也是一名计算机专业的教育工作者,我来回答一下这个问题. 对于计算机专业的学生来说,如果想把毕业设计定位在爬虫上,虽然从技术选型上是完全可以的,但是通过爬虫来获取数据本身还 ...

  9. linux界面设计论文,毕业设计(论文)-基于linux的云校园桌面虚拟化系统的设计与实现.doc...

    毕业设计(论文)-基于linux的云校园桌面虚拟化系统的设计与实现.doc 还剩 67页未读, 继续阅读 下载文档到电脑,马上远离加班熬夜! 亲,很抱歉,此页已超出免费预览范围啦! 如果喜欢就下载吧, ...

最新文章

  1. 莱芜市公安局交警支队智能交通项目集成及容灾公开招标公告
  2. TinyML 机器学习简介
  3. oracle统计一个班男生女生,一条sql统计一个班级的男女人数
  4. 数字谋定农村建设-农业大健康·万祥军:农业人工智能应用
  5. 关于函数,对象以及闭包的一些理解
  6. internal java compiler error_java字节码注入AOP作业心得
  7. 找上海或深圳塑胶模具工作
  8. 破B操作系统:(1)显示桌面图标
  9. 【转载】财务主管的ERP实施之路
  10. 「图像处理」C#+AForge.Net+DlibDotNet实现人脸识别
  11. 增广拉格朗日函数的三种统一公式
  12. 在一张图片的某个特定位置添加另外一张图片
  13. 通过 TensorFlow 实现 AI 语音降噪提升 QQ 音视频通话质量
  14. 大家都在学Python,你和别人的差距在哪?
  15. windows7彻底删除流氓软件的操作方法
  16. AjaxFileUpload组件结合Struts2异步图片上传
  17. 详解 PerformanceResourceTiming API,咦,这货真的干!
  18. 站点主机安全档案(转)
  19. 《第6讲 非线性优化 》读书笔记
  20. Web自动化测试(二)

热门文章

  1. CTFHub信息泄露
  2. 土木工程转专业,上岸趣头条、今日头条后端开发,学习历程分享
  3. 网页服务器,小公司是应该自己买服务器去托管还是租用服务器
  4. MySQL数据库三大范式和反范式
  5. java里面取余什么意思_java中%是取余运算符。
  6. 【转载】详细制作form的方法
  7. 编译cc1:all warnings being treated as errors
  8. 虚拟机安装与ubuntu安装
  9. 华盛顿大学 计算机语言学 费用,华盛顿大学获得计算机语言学硕士专业
  10. IBM AIX 入门培训