当前位置: 首页 > 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/a/284825.html

相关文章:

  • Vue常用加密方式
  • 力扣 LeetCode 142. 环形链表II(Day2:链表)
  • 【数理哲学】决定论与混沌理论
  • WebStorm 如何调试 Vue 项目
  • 【考研数学:高数2】数列极限
  • 项目模块详细说明
  • 如何在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迭代器失效问题