28 lines
695 B
C#
28 lines
695 B
C#
|
|
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}";
|
||
|
|
}
|
||
|
|
}
|