本文整理汇总了C#中Modifier.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Modifier.ToString方法的具体用法?C# Modifier.ToString怎么用?C# Modifier.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Modifier
的用法示例。
在下文中一共展示了Modifier.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateScope
public static string GenerateScope(Scope scope, Modifier modifier)
{
return string.Format("{0}:{1}", scope.ToString(), modifier.ToString());
}
示例2: WriteNewModifier
//Writes out a new modifier or a replacement for an existing modifer
//Modifier = the modifier to write out
//replacementIndex = the index of the modifier to replace or -1 if to append
//typeIndex = the index of the type to replace based off the weapon types file
public static bool WriteNewModifier(Modifier modifier, int replacementIndex, int typeIndex)
{
//Append CSV of modifier to the end of the data
//Modify the stat alias data to match the new file
if (!File.Exists(DATA_PATH))
{
Debug.Log("ERROR: Could not find Weapon Modifier Data");
return false;
}
if (!File.Exists(WEP_TYPE_DATA_PATH))
{
Debug.Log("ERROR: Could not find Weapon Type Data");
return false;
}
//Load Data
string allData = File.ReadAllText(DATA_PATH);
string[] dataLines = allData.Replace("\r", "").Split('\n');
//Load Types
string allTypes = File.ReadAllText(WEP_TYPE_DATA_PATH);
string[] typeLines = allTypes.Replace("\r", "").Split('\n');
if (replacementIndex < 0)
{
//Test if a modifier with this name exists already
for (int i = 0; i < dataLines.Length; i++)
{
string line = dataLines[i];
if (line.StartsWith(modifier.Name + ','))
{
if (EditorUtility.DisplayDialog("Conflict", "A Modifier with this name already exists. Do you want to overwrite?", "Yes", "Oops, Cancel"))
replacementIndex = i - 1;
else
return false;
}
}
}
//Determine end point of this type
string lastEndName = typeLines[typeIndex];
string currentEndName = typeLines[typeIndex + 1];
int currentEndIndexInData = 0;
int lastEndIndex = 0;
for (int i = 0; i < dataLines.Length; i++)
{
string line = dataLines[i];
if (line.Contains(currentEndName))
currentEndIndexInData = i - 1;
if (line.Contains(lastEndName))
lastEndIndex = i - 1;
}
//Just insert to the end of this type data
if (replacementIndex < 0)
{
WriteType(typeIndex, modifier.Name);
List<string> dataList = dataLines.ToList();
dataList.Insert(currentEndIndexInData + 2, modifier.ToString());
allData = "";
for (int i = 0; i < dataList.Count; i++)
{
string line = dataList[i];
if (i < dataList.Count - 1)
allData += line + '\n';
else
allData += line;
}
} //Overwrite
else
{
replacementIndex += lastEndIndex;
if (typeIndex > 0)
replacementIndex++;
//If we're replacing the current end name, we need to edit the type data file
if (replacementIndex == currentEndIndexInData)
{
WriteType(typeIndex, modifier.Name);
}
dataLines[replacementIndex + 1] = modifier.ToString();
allData = "";
for (int i = 0; i < dataLines.Length; i++)
{
string line = dataLines[i];
if (i < dataLines.Length - 1)
allData += line + '\n';
//.........这里部分代码省略.........