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

相关文章

python常见环境管理工具超全解析

《python常见环境管理工具超全解析》在Python开发中,管理多个项目及其依赖项通常是一个挑战,下面:本文主要介绍python常见环境管理工具的相关资料,文中通过代码介绍的非常详细,需要的朋友... 目录1. conda2. pip3. uvuv 工具自动创建和管理环境的特点4. setup.py5.

C++中零拷贝的多种实现方式

《C++中零拷贝的多种实现方式》本文主要介绍了C++中零拷贝的实现示例,旨在在减少数据在内存中的不必要复制,从而提高程序性能、降低内存使用并减少CPU消耗,零拷贝技术通过多种方式实现,下面就来了解一下... 目录一、C++中零拷贝技术的核心概念二、std::string_view 简介三、std::stri

C++高效内存池实现减少动态分配开销的解决方案

《C++高效内存池实现减少动态分配开销的解决方案》C++动态内存分配存在系统调用开销、碎片化和锁竞争等性能问题,内存池通过预分配、分块管理和缓存复用解决这些问题,下面就来了解一下... 目录一、C++内存分配的性能挑战二、内存池技术的核心原理三、主流内存池实现:TCMalloc与Jemalloc1. TCM

OpenCV实现实时颜色检测的示例

《OpenCV实现实时颜色检测的示例》本文主要介绍了OpenCV实现实时颜色检测的示例,通过HSV色彩空间转换和色调范围判断实现红黄绿蓝颜色检测,包含视频捕捉、区域标记、颜色分析等功能,具有一定的参考... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间

全面解析HTML5中Checkbox标签

《全面解析HTML5中Checkbox标签》Checkbox是HTML5中非常重要的表单元素之一,通过合理使用其属性和样式自定义方法,可以为用户提供丰富多样的交互体验,这篇文章给大家介绍HTML5中C... 在html5中,Checkbox(复选框)是一种常用的表单元素,允许用户在一组选项中选择多个项目。本

Python并行处理实战之如何使用ProcessPoolExecutor加速计算

《Python并行处理实战之如何使用ProcessPoolExecutor加速计算》Python提供了多种并行处理的方式,其中concurrent.futures模块的ProcessPoolExecu... 目录简介完整代码示例代码解释1. 导入必要的模块2. 定义处理函数3. 主函数4. 生成数字列表5.

Python实现精准提取 PDF中的文本,表格与图片

《Python实现精准提取PDF中的文本,表格与图片》在实际的系统开发中,处理PDF文件不仅限于读取整页文本,还有提取文档中的表格数据,图片或特定区域的内容,下面我们来看看如何使用Python实... 目录安装 python 库提取 PDF 文本内容:获取整页文本与指定区域内容获取页面上的所有文本内容获取

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1

Python包管理工具核心指令uvx举例详细解析

《Python包管理工具核心指令uvx举例详细解析》:本文主要介绍Python包管理工具核心指令uvx的相关资料,uvx是uv工具链中用于临时运行Python命令行工具的高效执行器,依托Rust实... 目录一、uvx 的定位与核心功能二、uvx 的典型应用场景三、uvx 与传统工具对比四、uvx 的技术实

Java使用HttpClient实现图片下载与本地保存功能

《Java使用HttpClient实现图片下载与本地保存功能》在当今数字化时代,网络资源的获取与处理已成为软件开发中的常见需求,其中,图片作为网络上最常见的资源之一,其下载与保存功能在许多应用场景中都... 目录引言一、Apache HttpClient简介二、技术栈与环境准备三、实现图片下载与保存功能1.