本文整理汇总了C#中ObjectData.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectData.Reset方法的具体用法?C# ObjectData.Reset怎么用?C# ObjectData.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectData
的用法示例。
在下文中一共展示了ObjectData.Reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadObjects
void LoadObjects(string fileName)
{
List<Base_Object> data = new List<Base_Object>();
try
{
string line;
StreamReader file = new StreamReader(fileName, Encoding.Default);
ObjectData objectTemp = new ObjectData();
using (file)
{
do
{
line = file.ReadLine();
if (line != null)
{
if(line[0] == '{')
{
objectTemp.Reset();
bool done = false;
//string[] elements;
do
{
line = file.ReadLine();
if(line == null)
done = true;
else if(line[0] == '}')
done = true;
else
{
string[] elements = line.Split('=');
if(elements.Length < 2)
done = true;
else
{
elements[0] = elements[0].Trim(); // gets rid of leading whitespace
switch(elements[0])
{
case "name":
objectTemp.Name = elements[1];
break;
case "desc":
objectTemp.Desc = elements[1];
break;
case "collectable":
string t = elements[1].ToLower();
if(t.CompareTo("true") == 0 || t.CompareTo("1") == 0)
objectTemp.isCollectable = true;
break;
case "icon":
objectTemp.IconFileName = elements[1];
break;
case "combinable":
string s = elements[1].ToLower();
if(s.CompareTo("true") == 0 || s.CompareTo("1") == 0)
objectTemp.isCombinable = true;
break;
case "combines_with":
objectTemp.CombinesWith = int.Parse(elements[1]);
break;
}
}
}
}
while (!done);
Base_Object b;
if(objectTemp.isCollectable)
{
Texture2D texture = null; //Resources.Load(objectTemp.IconFileName)
b = new Collectable(objectTemp.Name, objectTemp.Desc, texture);
if(objectTemp.isCombinable)
{
((Collectable)b).combinable = true;
((Collectable)b).combines_with = objectTemp.CombinesWith;
}
}
else
{
b = new Base_Object(objectTemp.Name, objectTemp.Desc);
}
data.Add(b);
}
}
}
while (line != null);
file.Close();
// PRINT TEST
string msg = "";
foreach(Base_Object obj in data)
{
msg = obj.name + "; " + obj.desc;
if(obj.type == Object_Type.OBJ_COLLECT)
{
msg += " [COLLECTABLE]";
//.........这里部分代码省略.........