NG_/Assets/Scripts/Data/Entity/RoleData.cs

28 lines
695 B
C#
Raw Normal View History

2024-12-13 19:40:05 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 角色数据类
[System.Serializable]
public class RoleData:IEquatable<RoleData>
{
public string roleName; // 角色名称
// 实现IEquatable接口的Equals方法以及重写GetHashCode方法以及ToString方法
public bool Equals(RoleData other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return roleName == other.roleName;
}
public override int GetHashCode()
{
return HashCode.Combine(roleName);
}
public override string ToString()
{
return $"角色名称: {roleName}";
}
}