本文整理汇总了C#中MatchState类的典型用法代码示例。如果您正苦于以下问题:C# MatchState类的具体用法?C# MatchState怎么用?C# MatchState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MatchState类属于命名空间,在下文中一共展示了MatchState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestStateClone
public void TestStateClone()
{
MatchState state = new MatchState(new PhysicsEngine(new GameWorld(null)));
IEntity e = new IEntity(IDGenerator.GenerateID(), new Vec2(100f, -99f), 1f, 1f, 1f);
state.AddEntity(e);
Assert.True(state.ContainsEntity(e.ID), "entity1 added to match");
IEntity e2 = new IEntity(IDGenerator.GenerateID(), new Vec2(42f, 24f), 1f, 1f, 1f);
state.AddEntity(e2);
Assert.True(state.ContainsEntity(e2.ID), "entity2 added to match");
MatchState clone = state.Clone() as MatchState;
Assert.True(clone.ContainsEntity(e.ID), "clone contains entity1");
Assert.True(clone.ContainsEntity(e2.ID), "clone contains entity2");
IEntity clonedE = clone.GetEntity(e.ID);
TestClonedEntityValues(e, clonedE, true, "after clone (e1)");
ChangeClonedEntity(clonedE, new Vec2(11f, 111f), new Vec2(22f, 222f), 1000f, 2000f, 333f);
TestClonedEntityValues(e, clonedE, false, "after clone modif (e1)");
IEntity clonedE2 = clone.GetEntity(e2.ID);
TestClonedEntityValues(e2, clonedE2, true, "after clone (e2)");
ChangeClonedEntity(clonedE2, new Vec2(87f, 78f), new Vec2(52f, 25f), 76f, 88f, 2121f);
TestClonedEntityValues(e2, clonedE2, false, "after clone modif (e2)");
}
开发者ID:DrPandemic,项目名称:EraParadox,代码行数:32,代码来源:MatchTest.cs
示例2: ClassEnd
private static int ClassEnd( MatchState ms, int p )
{
var lua = ms.Lua;
switch( ms.Pattern[p++] )
{
case L_ESC:
{
if( p == ms.PatternEnd )
lua.L_Error( "malformed pattern (ends with '%')" );
return p+1;
}
case '[':
{
if( ms.Pattern[p] == '^' ) p++;
do {
if( p == ms.PatternEnd )
lua.L_Error( "malformed pattern (missing ']')" );
if( ms.Pattern[p++] == L_ESC && p < ms.PatternEnd )
p++; // skip escapes (e.g. `%]')
} while( ms.Pattern[p] != ']' );
return p+1;
}
default: return p;
}
}
开发者ID:bharath1097,项目名称:UniLua,代码行数:25,代码来源:LuaStrLib.cs
示例3: ClassEnd
private static int ClassEnd( ref MatchState ms, int pPos )
{
var pat = ms.Pat;
switch( pat[pPos++] )
{
case (byte)'%':
if( pPos == pat.Length )
throw new ArgumentException( "Malformed pattern (ends with %%)" );
return pPos + 1;
case (byte)'[':
if( pat[pPos] == (byte)'^' )
pPos++;
do
{
if( pPos == pat.Length )
throw new ArgumentException( "Malformed pattern (missing ']')" );
if( pat[pPos++] == (byte)'%' && pPos < pat.Length )
pPos++;
} while( pat[pPos] != (byte)']' );
return pPos + 1;
default:
return pPos;
}
}
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:30,代码来源:StringLib.cs
示例4: CheckCapture
private static int CheckCapture( MatchState ms, char l )
{
var lua = ms.Lua;
int i = (int)(l - '1');
if( i < 0 || i >= ms.Level || ms.Capture[i].Len == CAP_UNFINISHED )
return lua.L_Error( "invalid capture index %d", i+1 );
return i;
}
开发者ID:bharath1097,项目名称:UniLua,代码行数:8,代码来源:LuaStrLib.cs
示例5: Start
public void Start()
{
if (State == MatchState.Ready)
{
_broadcastHandler.BroadcastConfiguration(_mode.GetConfiguration());
State = MatchState.Loading;
}
}
开发者ID:pksorensen,项目名称:CycleR,代码行数:8,代码来源:Match.cs
示例6: GG
private void GG(int winning_player_num)
{
state = MatchState.PostMatch;
//match_audio.PlayGameOver();
TimeScaleManager.Instance.AddMultiplier("GG_slow", 0.3f);
this.winner_player_num = winning_player_num;
StartCoroutine(TranInGGPage());
}
开发者ID:RPITeamTree,项目名称:Spelleo_RGS2015,代码行数:9,代码来源:MatchManager.cs
示例7: Match
public Match()
{
Id = Guid.NewGuid();
_matchState = MatchState.NotStarted;
// TODO: set up teams based on docuDB
Team1 = new Team(0, "red team");
Team2 = new Team(1, "blue team");
}
开发者ID:chow-land,项目名称:GriddyBackend,代码行数:9,代码来源:Match.cs
示例8: CaptureToClose
private static int CaptureToClose( MatchState ms )
{
var lua = ms.Lua;
int level=ms.Level;
for( level--; level>=0; level-- )
{
if( ms.Capture[level].Len == CAP_UNFINISHED )
return level;
}
return lua.L_Error( "invalid pattern capture" );
}
开发者ID:rokyado,项目名称:UniLua,代码行数:11,代码来源:LuaStrLib.cs
示例9: GameMatch
public GameMatch(string mapPath)
{
World = new GameWorld(mapPath);
Physics = new PhysicsEngine(World);
CurrentState = new MatchState(Physics);
LeftStructures = new TeamStructures(Teams.Left,
World.Map.Meta.LeftMeta.BaseTileIds,
World.Map.Meta.LeftMeta.BaseTowerTileIds,
World.Map.Meta.LeftMeta.TopTowerTileIds,
World.Map.Meta.LeftMeta.BottomTowerTileIds);
RightStructures = new TeamStructures(Teams.Right,
World.Map.Meta.RightMeta.BaseTileIds,
World.Map.Meta.RightMeta.BaseTowerTileIds,
World.Map.Meta.RightMeta.TopTowerTileIds,
World.Map.Meta.RightMeta.BottomTowerTileIds);
Structures = new List<IStructure>();
LeftStructures.Structures.ForEach(Structures.Add);
RightStructures.Structures.ForEach(Structures.Add);
}
开发者ID:DrPandemic,项目名称:EraParadox,代码行数:21,代码来源:GameMatch.cs
示例10: AdvanceState
private void AdvanceState(Side side)
{
if (side == Side.One)
{
sideOneScore++;
}
if (side == Side.Two)
{
sideTwoScore++;
}
if (sideOneScore >= 2)
{
state = MatchState.MatchWonBySideOne;
}
if (sideTwoScore >= 2)
{
state = MatchState.MatchWonBySideTwo;
}
}
开发者ID:dtryon,项目名称:tennis,代码行数:22,代码来源:Match.cs
示例11: MinExpand
private static int MinExpand( MatchState ms, int s, int p, int ep )
{
for(;;)
{
int res = Match( ms, s, ep+1 );
if( res >= 0 )
return res;
else if( s < ms.SrcEnd && SingleMatch( ms, ms.Src[s], p, ep ) )
s++; // try with one more repetition
else return -1;
}
}
开发者ID:Jornason,项目名称:UniLua,代码行数:12,代码来源:LuaStrLib.cs
示例12: MaxExpand
private static int MaxExpand( MatchState ms, int s, int p, int ep )
{
int i = 0; // counts maximum expand for item
while( (s+i) < ms.SrcEnd && SingleMatch( ms, ms.Src[s+i], p, ep ) )
i++;
// keeps trying to match with the maximum repetitions
while( i >= 0 )
{
int res = Match( ms, (s+i), (ep+1) );
if( res >= 0 ) return res;
i--; // else didn't match; reduce 1 repetition to try again
}
return -1;
}
开发者ID:Jornason,项目名称:UniLua,代码行数:14,代码来源:LuaStrLib.cs
示例13: Str_Gsub
private static int Str_Gsub( ILuaState lua )
{
string src = lua.L_CheckString(1);
int srcl = src.Length;
string p = lua.L_CheckString(2);
LuaType tr = lua.Type(3);
int max_s = lua.L_OptInt(4, srcl + 1);
int anchor = 0;
if (p[0] == '^')
{
p = p.Substring(1);
anchor = 1;
}
int n = 0;
MatchState ms = new MatchState();
StringBuilder b = new StringBuilder(srcl);
lua.L_ArgCheck(tr == LuaType.LUA_TNUMBER || tr == LuaType.LUA_TSTRING ||
tr == LuaType.LUA_TFUNCTION || tr == LuaType.LUA_TTABLE, 3,
"string/function/table expected");
ms.Lua = lua;
ms.Src = src;
ms.SrcInit = 0;
ms.SrcEnd = srcl;
ms.Pattern = p;
ms.PatternEnd = p.Length;
int s = 0;
while (n < max_s) {
ms.Level = 0;
int e = Match(ms, s, 0);
if (e != -1) {
n++;
Add_Value(ms, b, s, e);
}
if ((e != -1) && e > s) /* non empty match? */
s = e; /* skip it */
else if (s < ms.SrcEnd)
{
char c = src[s];
++s;
b.Append(c);
}
else break;
if (anchor != 0) break;
}
b.Append(src.Substring(s, ms.SrcEnd - s));
lua.PushString(b.ToString());
lua.PushInteger(n); /* number of substitutions */
return 2;
}
开发者ID:Jornason,项目名称:UniLua,代码行数:50,代码来源:LuaStrLib.cs
示例14: Add_S
private static void Add_S (MatchState ms, StringBuilder b, int s, int e) {
string news = ms.Lua.ToString(3);
for (int i = 0; i < news.Length; i++) {
if (news[i] != L_ESC)
b.Append(news[i]);
else {
i++; /* skip ESC */
if (!Char.IsDigit((news[i])))
b.Append(news[i]);
else if (news[i] == '0')
b.Append(ms.Src.Substring(s, (e - s)));
else {
PushOneCapture(ms, news[i] - '1', s, e);
b.Append(ms.Lua.ToString(-1)); /* add capture to accumulated result */
}
}
}
}
开发者ID:Jornason,项目名称:UniLua,代码行数:18,代码来源:LuaStrLib.cs
示例15: StrFindAux
private static int StrFindAux( ILuaState lua, bool find )
{
string s = lua.L_CheckString( 1 );
string p = lua.L_CheckString( 2 );
int init = PosRelative( lua.L_OptInt(3, 1), s.Length );
if( init < 1 ) init = 1;
else if( init > s.Length + 1 ) // start after string's end?
{
lua.PushNil(); // cannot find anything
return 1;
}
// explicit request or no special characters?
if( find && (lua.ToBoolean(4) || NoSpecials(p)) )
{
// do a plain search
int pos = s.IndexOf( p, init-1 );
if( pos >= 0 )
{
lua.PushInteger( pos+1 );
lua.PushInteger( pos+p.Length );
return 2;
}
}
else
{
int s1 = init-1;
int ppos = 0;
bool anchor = p[ppos] == '^';
if( anchor )
ppos++; // skip anchor character
MatchState ms = new MatchState();
ms.Lua = lua;
ms.Src = s;
ms.SrcInit = s1;
ms.SrcEnd = s.Length;
ms.Pattern = p;
ms.PatternEnd = p.Length;
do
{
ms.Level = 0;
int res = Match( ms, s1, ppos );
if( res != -1 )
{
if(find)
{
lua.PushInteger( s1+1 ); // start
lua.PushInteger( res ); // end
return PushCaptures(lua, ms, -1, 0) + 2;
}
else return PushCaptures(lua, ms, s1, res);
}
} while( s1++ < ms.SrcEnd && !anchor );
}
lua.PushNil(); // not found
return 1;
}
开发者ID:Jornason,项目名称:UniLua,代码行数:58,代码来源:LuaStrLib.cs
示例16:
private static void PushOneCapture
( MatchState ms
, int i
, int start
, int end
)
{
var lua = ms.Lua;
if( i >= ms.Level )
{
if( i == 0 ) // ms.Level == 0, too
lua.PushString( ms.Src.Substring( start, end-start ) );
else
lua.L_Error( "invalid capture index" );
}
else
{
int l = ms.Capture[i].Len;
if( l == CAP_UNFINISHED )
lua.L_Error( "unfinished capture" );
if( l == CAP_POSITION )
lua.PushInteger( ms.Capture[i].Init - ms.SrcInit + 1 );
else
lua.PushString( ms.Src.Substring( ms.Capture[i].Init, l ) );
}
}
开发者ID:Jornason,项目名称:UniLua,代码行数:26,代码来源:LuaStrLib.cs
示例17: MatchCapture
private static int MatchCapture( MatchState ms, int s, char l )
{
int i = CheckCapture( ms, l );
int len = ms.Capture[i].Len;
if( ms.SrcEnd - s >= len &&
string.Compare(ms.Src, ms.Capture[i].Init, ms.Src, s, len) == 0 )
return s + len;
else
return -1;
}
开发者ID:Jornason,项目名称:UniLua,代码行数:10,代码来源:LuaStrLib.cs
示例18: StartCapture
private static int StartCapture( MatchState ms, int s, int p, int what )
{
var lua = ms.Lua;
int level = ms.Level;
if( level >= LUA_MAXCAPTURES )
lua.L_Error( "too many captures" );
ms.Capture[level].Init = s;
ms.Capture[level].Len = what;
ms.Level = level + 1;
int res = Match( ms, s, p );
if( res == -1 ) // match failed?
ms.Level--;
return res;
}
开发者ID:Jornason,项目名称:UniLua,代码行数:14,代码来源:LuaStrLib.cs
示例19: EndCapture
private static int EndCapture( MatchState ms, int s, int p )
{
int l = CaptureToClose( ms );
ms.Capture[l].Len = s - ms.Capture[l].Init; // close capture
int res = Match( ms, s, p );
if( res == -1 ) // match failed?
ms.Capture[l].Len = CAP_UNFINISHED; // undo capture
return res;
}
开发者ID:Jornason,项目名称:UniLua,代码行数:9,代码来源:LuaStrLib.cs
示例20: start_capture
private static CharPtr start_capture(MatchState ms, CharPtr s,
CharPtr p, int what)
{
CharPtr res;
int level = ms.level;
if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, "too many captures");
ms.capture[level].init = s;
ms.capture[level].len = what;
ms.level = level+1;
if ((res=match(ms, s, p)) == null) /* match failed? */
ms.level--; /* undo capture */
return res;
}
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:13,代码来源:lstrlib.cs
注:本文中的MatchState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论