|
@@ -266,19 +266,32 @@ namespace GFGGame
|
|
}
|
|
}
|
|
//SetNameToIdList();
|
|
//SetNameToIdList();
|
|
}
|
|
}
|
|
|
|
+
|
|
public int GetIDByString(string name)
|
|
public int GetIDByString(string name)
|
|
{
|
|
{
|
|
int id = 0;
|
|
int id = 0;
|
|
//使用正则表达式分割字符串
|
|
//使用正则表达式分割字符串
|
|
string[] parts = Regex.Split(name, "_");
|
|
string[] parts = Regex.Split(name, "_");
|
|
- if(parts.Length > 0)
|
|
|
|
|
|
+ if (parts.Length > 0)
|
|
{
|
|
{
|
|
- if(parts[0] == "Role")
|
|
|
|
|
|
+ string vl = parts[0];
|
|
|
|
+ bool isNumeric = int.TryParse(vl, out _);
|
|
|
|
+ if (vl == "Role")
|
|
{
|
|
{
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+ else if (vl == "Border")
|
|
|
|
+ {
|
|
|
|
+ return -2;
|
|
|
|
+ }
|
|
|
|
+ else if (!isNumeric)
|
|
|
|
+ {
|
|
|
|
+ return -3;
|
|
|
|
+ }
|
|
|
|
+
|
|
id = int.Parse(parts[0]);
|
|
id = int.Parse(parts[0]);
|
|
}
|
|
}
|
|
|
|
+
|
|
return id;
|
|
return id;
|
|
}
|
|
}
|
|
public List<int> GetIDListByString(string name)
|
|
public List<int> GetIDListByString(string name)
|