当前位置: 首页 > article >正文

Unity实战案例全解析 之 背包/贩卖/锻造系统(左侧类图实现)

物品类

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Item 
{
    #region 物品类的基础属性
    public int ID { get; set; }
    public string Name { get; set; }
    public Typeitem typeitem { get; set; }//物品类型
    public Qualityitem qualityitem { get; set; }
    public string Desctiption { get; set; }
    public int Capacity { get; set; }
    public int Buyprice { get; set; }
    public int Sellprice { get; set; }

    public Item() {
        ID = -1;
    }
    #endregion
    public Item(int id,string name,Typeitem t,Qualityitem q,string desctiption,int capacity,int buyprice,int sellprice)
    {
        this.ID = id;
        this.Name = name;
        this.typeitem = t;
        this.qualityitem = q;
        this.Desctiption = desctiption;
        this.Capacity = capacity;
        this.Buyprice = buyprice;
        this.Sellprice = sellprice;
    }
}
/// <summary>
/// 物品类型
/// </summary>
public enum Typeitem
{ 
    Cosumable,//消耗品
    Equipment,//装备
    Weapon,//武器
    Material//材料
}
/// <summary>
/// 品质
/// </summary>
public enum Qualityitem
{ 
    Common,
    Uncommon,
    Rare,
    Epic,
    Legendary,
    Artifact
}

 其子类:

装备

using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using static UnityEditor.Experimental.GraphView.Port;

public class Equipment : Item
{
    //力量
    public int Strength { get; set; }
    /// <summary>
    /// 智力
    /// </summary>
    public int Intellect { get; set; }
    /// <summary>
    /// /敏捷
    /// </summary>
    public int Agility { get; set; }
    /// <summary>
    /// 体力
    /// </summary>
    public int Stamina { get; set; }
    public Equipment(int id, string name, Typeitem t, Qualityitem q, string desctiption, int capacity, int buyprice, int sellprice
        ,int strength,int intellect, int agility,int stamina)
        : base(id, name, t, q, desctiption, capacity, buyprice, sellprice)
    { 
    this.Strength = strength;
    this.Intellect = intellect;
     this.Agility = agility;
     this.Stamina = stamina;
    }
}

public enum equipType
{ 
    head,
    neck,
    chest,//胸部
    ring,//戒指
    leg,//腿
    bracer,//护腕
    boots,//靴子
    shuoulder,//肩膀
    belt,//腰带
    offHand//副手
}

材质

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Material : Item
{
 
}

武器

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Weapon : Item
{
    public float Damage { get; set; }
    public weaponType weaponType;
    public Weapon(int id, string name, Typeitem t, Qualityitem q, string desctiption, int capacity, int buyprice, int sellprice, float damnage, weaponType w) 
        :base(id, name, t, q, desctiption, capacity, buyprice, sellprice)
    {
        this.Damage = damnage;
        this.weaponType = w;
    }
}
public enum weaponType
{ 
      offHand,
      mainHand,
}

消耗品

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Consumable : Item
{
   public float  Hp { get; set; }
    public float Mp { get; set; }
    public Consumable(int id, string name, Typeitem t, Qualityitem q, string desctiption, int capacity, int buyprice, int sellprice,float hp,float mp) 
        : base(id,name,  t,  q,  desctiption,  capacity,  buyprice,  sellprice)
    { 
    this.Hp = hp;
    this.Mp = mp;    
    }
}


http://www.kler.cn/news/284825.html

相关文章:

  • 如何在JPG文件中隐写数据
  • 类实例化和构造函数
  • 【Go语言成长之路】使用 Go 和 Gin 开发 RESTful API
  • 五,Spring Boot中的 Spring initializr 的使用
  • go.uber.org/ratelimit 源码分析
  • MyBatis一级缓存和二级缓存以及 mybatis架构
  • .net开发日常笔记(持续更新)
  • 续:MySQL的并行复制
  • XtQuant是什么?哪家券商支持miniQMT,XtQuant?
  • 使用SQLite进行Python简单数据存储的线程安全解决方案
  • Centos服务器配置使用密钥登录
  • 【C++题解】1722 - 输出两位的巧数
  • Docker 部署 Kafka 可视化 Kafka-UI
  • Arco Voucher - 不知道有什么用的凭证单据录入表单插件
  • 简易STL实现 | Deque的实现
  • PyMOL的开源版和商业版如何选择 PyMOL开源版安装 PyMOL商业版安装 PyMOL安装教程 远程安装PyMOL正式版 官网版
  • PDF文本指令解析与文本水印去除
  • 【IDEA】一键重启多个服务
  • 游戏出海,燃动全球,“安全”如何通关?
  • 【C++】有关vector迭代器失效问题
  • 快速了解Git服务器端基础及基本操作命令(一)
  • mysql的group by怎么用
  • disk manager操作教程 如何使用Disk Manager组件 Mac如何打开ntfs格式文件
  • Open WebUI官方库:解锁人工智能服务的官方通道
  • git常见命令行及分支规范
  • MATLAB智能优化算法-学习笔记(1)——遗传算法求解0-1背包问题【过程+代码】
  • 通过css,js html结合实现第一个页面
  • 网络安全实训六(靶机实例DC-3)
  • 迭代器模式
  • TWRP 使用帮助 第三方Recovery