本文整理汇总了C#中Script.Free方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Free方法的具体用法?C# Script.Free怎么用?C# Script.Free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Script
的用法示例。
在下文中一共展示了Script.Free方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameScript
public GameScript(string scriptFile)
{
//--// Debug.Log("GameScript: Load " + scriptFile);
script = new Script(scriptFile, true);
if (script == null) {
_error = true;
return;
} else if (script.error) {
_error = true;
script.Free();
return;
}
variables = new Dictionary<string,GameObject>();
functions = new Dictionary<string,Function>();
if (variables == null || functions == null) {
_error = true;
script.Free();
return;
}
Script.TokenType tokentType = Script.TokenType.Null;
List<string> line = new List<string>();
string[] a = null;
string token = null;
int bc = 0, fc = 0, vc = 0, sc = 0;
Function function = null;
bool force_nowait = false;
bool force_wait = false;
bool scriptError = false;
do {
tokentType = script.ReadToken();
switch (tokentType) {
case Script.TokenType.Null:
scriptError = true;
break;
case Script.TokenType.Empty:
line.Add("null");
break;
case Script.TokenType.String:
token = script.GetToken();
if (token == "wait")
force_wait = true;
else if (token == "nowait")
force_nowait = true;
else
line.Add(token);
break;
case Script.TokenType.SemiColon:
a = line.ToArray(); line.Clear();
if (a[0] == "var") {
variables.Add(a[1], null);
vc++;
} else {
// statement
Statement statement = new Statement(this, a);
if (function != null) {
if (statement != null) {
if (force_wait)
statement.wait = true;
if (force_nowait)
statement.wait = false;
if (a[0] == "delay")
statement.wait = true;
function.statements.Add(statement);
}
}
if (bc == 0) {
//--// Debug.Log("GameScript::ERROR: Statement out of scope at line " + script.line + " (statement must be inside a function)");
scriptError = true;
}
sc++;
}
force_wait = false;
force_nowait = false;
break;
case Script.TokenType.OpenBrace:
bc++;
if (bc > 1) {
//--// Debug.Log("GameScript::ERROR: Excessive { at line " + script.line + " (might be missing } somewhere before)");
scriptError = true;
}
a = line.ToArray(); line.Clear();
if (a[0] == "function") {
function = new Function(this, a[1]);
if (function != null) {
function.id = functions.Count;
functions.Add(a[1], function);
}
fc++;
}
break;
//.........这里部分代码省略.........
示例2: SaveScript
public SaveScript(string scriptFile)
{
//--// Debug.Log("SaveScript::Load: " + scriptFile);
script = new Script(scriptFile, true);
if (script == null) {
_error = true;
return;
} else if (script.error) {
_error = true;
script.Free();
return;
}
objects = new Dictionary<string,Function>();
if (objects == null) {
_error = true;
script.Free();
return;
}
Script.TokenType tokentType = Script.TokenType.Null;
List<string> line = new List<string>();
string[] a = null;
string token = null;
int bc = 0, oc = 0, sc = 0;
Function obj = null;
bool scriptError = false;
do {
tokentType = script.ReadToken();
switch (tokentType) {
case Script.TokenType.Null:
scriptError = true;
break;
case Script.TokenType.Empty:
line.Add("null");
break;
case Script.TokenType.String:
token = script.GetToken();
line.Add(token);
break;
case Script.TokenType.SemiColon:
a = line.ToArray(); line.Clear();
Statement s = new Statement(null, a);
if (obj != null) {
if (s != null)
obj.statements.Add(s);
}
if (bc == 0) {
//--// Debug.Log("SaveScript::ERROR: Statement out of scope at line " + script.line);
scriptError = true;
}
sc++;
break;
case Script.TokenType.OpenBrace:
bc++;
if (bc > 1) {
scriptError = true;
}
a = line.ToArray(); line.Clear();
if (a[0] == "$actor") {
obj = new Function(null, a[1]);
if (obj != null) {
obj.id = objects.Count;
if(!objects.ContainsKey(a[1]))
objects.Add(a[1], obj);
}
oc++;
}
break;
case Script.TokenType.CloseBrace:
bc--;
if (bc < 0) {
scriptError = true;
}
break;
case Script.TokenType.EOF:
break;
}
if (scriptError)
break;
} while (!script.eof);
script.Free();
line.Clear();
if (scriptError)
_error = true;
//.........这里部分代码省略.........