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

本文主要是介绍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;}#endregionpublic 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;    }
}

这篇关于Unity实战案例全解析 之 背包/贩卖/锻造系统(左侧类图实现)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1125393

相关文章

MySQL 中的 JSON 查询案例详解

《MySQL中的JSON查询案例详解》:本文主要介绍MySQL的JSON查询的相关知识,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录mysql 的 jsON 路径格式基本结构路径组件详解特殊语法元素实际示例简单路径复杂路径简写操作符注意MySQL 的 J

pandas中位数填充空值的实现示例

《pandas中位数填充空值的实现示例》中位数填充是一种简单而有效的方法,用于填充数据集中缺失的值,本文就来介绍一下pandas中位数填充空值的实现,具有一定的参考价值,感兴趣的可以了解一下... 目录什么是中位数填充?为什么选择中位数填充?示例数据结果分析完整代码总结在数据分析和机器学习过程中,处理缺失数

Golang HashMap实现原理解析

《GolangHashMap实现原理解析》HashMap是一种基于哈希表实现的键值对存储结构,它通过哈希函数将键映射到数组的索引位置,支持高效的插入、查找和删除操作,:本文主要介绍GolangH... 目录HashMap是一种基于哈希表实现的键值对存储结构,它通过哈希函数将键映射到数组的索引位置,支持

Pandas使用AdaBoost进行分类的实现

《Pandas使用AdaBoost进行分类的实现》Pandas和AdaBoost分类算法,可以高效地进行数据预处理和分类任务,本文主要介绍了Pandas使用AdaBoost进行分类的实现,具有一定的参... 目录什么是 AdaBoost?使用 AdaBoost 的步骤安装必要的库步骤一:数据准备步骤二:模型

使用Pandas进行均值填充的实现

《使用Pandas进行均值填充的实现》缺失数据(NaN值)是一个常见的问题,我们可以通过多种方法来处理缺失数据,其中一种常用的方法是均值填充,本文主要介绍了使用Pandas进行均值填充的实现,感兴趣的... 目录什么是均值填充?为什么选择均值填充?均值填充的步骤实际代码示例总结在数据分析和处理过程中,缺失数

Java对象转换的实现方式汇总

《Java对象转换的实现方式汇总》:本文主要介绍Java对象转换的多种实现方式,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录Java对象转换的多种实现方式1. 手动映射(Manual Mapping)2. Builder模式3. 工具类辅助映

Go语言开发实现查询IP信息的MCP服务器

《Go语言开发实现查询IP信息的MCP服务器》随着MCP的快速普及和广泛应用,MCP服务器也层出不穷,本文将详细介绍如何在Go语言中使用go-mcp库来开发一个查询IP信息的MCP... 目录前言mcp-ip-geo 服务器目录结构说明查询 IP 信息功能实现工具实现工具管理查询单个 IP 信息工具的实现服

SpringBoot基于配置实现短信服务策略的动态切换

《SpringBoot基于配置实现短信服务策略的动态切换》这篇文章主要为大家详细介绍了SpringBoot在接入多个短信服务商(如阿里云、腾讯云、华为云)后,如何根据配置或环境切换使用不同的服务商,需... 目录目标功能示例配置(application.yml)配置类绑定短信发送策略接口示例:阿里云 & 腾

Python Transformers库(NLP处理库)案例代码讲解

《PythonTransformers库(NLP处理库)案例代码讲解》本文介绍transformers库的全面讲解,包含基础知识、高级用法、案例代码及学习路径,内容经过组织,适合不同阶段的学习者,对... 目录一、基础知识1. Transformers 库简介2. 安装与环境配置3. 快速上手示例二、核心模

Python使用getopt处理命令行参数示例解析(最佳实践)

《Python使用getopt处理命令行参数示例解析(最佳实践)》getopt模块是Python标准库中一个简单但强大的命令行参数处理工具,它特别适合那些需要快速实现基本命令行参数解析的场景,或者需要... 目录为什么需要处理命令行参数?getopt模块基础实际应用示例与其他参数处理方式的比较常见问http