本文整理汇总了C#中FSM.getCurrentState方法的典型用法代码示例。如果您正苦于以下问题:C# FSM.getCurrentState方法的具体用法?C# FSM.getCurrentState怎么用?C# FSM.getCurrentState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSM
的用法示例。
在下文中一共展示了FSM.getCurrentState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: guardWallsMove
/*
private Action guardWallsMove (FSM<BomberAgent> fsm)
{
State<BomberAgent> current = fsm.getCurrentState ();
Action move = null;
State<BomberAgent> nextState = null;
if (current is PredictDestinationState) {
if (current.fail (this)) {
nextState = new BlastWallState (this.gs, false);
} else if (current.complete(this)) {
nextState = new BombState(this.gs);
}
} else if (current is BlastWallState) {
if (current.fail (this) || current.complete (this)) {
nextState = new EvadeExplosionState(this.gs);
}
} else if (current is BombState) {
if (current.fail (this) || current.complete (this)) {
nextState = new EvadeExplosionState(this.gs);
}
} else if (current is EvadeExplosionState) {
if (current.fail (this) || current.complete (this)) {
nextState = new PredictDestinationState(this.gs, this.isBombPassable);
}
}
if (nextState != null) {
Console.WriteLine ("Agent " + this.agentId + " switching to " + nextState.GetType ().ToString ());
fsm.changeState (nextState);
}
move = fsm.getCurrentState ().getAction (this);
Console.WriteLine ("Agent " + this.agentId + ", state " + fsm.getCurrentState ().GetType ().ToString () + ", move " + move);
return move;
}
*/
private Action surroundPlayerFSM(FSM<BomberAgent> fsm)
{
State<BomberAgent> current = fsm.getCurrentState();
Action move = null;
//check if blowing up stuff and we need to evade bombs!!
//if (current is BlastWallState) {
//for (int i = 0; i < this.gs.NumberAIBombermen; i++) {
Coords botCoords = this.gs.GetAgentCoords(this.agentId + 1);
bool shouldMove = this.gs.isOnExplosionPath(botCoords);
if (shouldMove)
{
State<BomberAgent> newState = new EvadeExplosionState(this.gs);
Console.WriteLine("Agent " + this.agentId + " switching to EvadeExplosionState");
fsm.changeState(newState);
move = fsm.getCurrentState().getAction(this);
Console.WriteLine("Agent " + this.agentId + ", state " + fsm.getCurrentState().GetType().ToString() + ", move " + move);
return move;
}
//}
//}
if (current.fail(this))
{
Console.WriteLine("Failed strategy " + current.GetType());
if (current is SurroundState)
{
//Chaaarrge!! Blow our way to the player!!!
Console.WriteLine("Switching to BlastWallState");
BlastWallState newState = new BlastWallState(this.gs, false);
fsm.changeState(newState);
}
else if (current is BombState)
{
Console.WriteLine("Switching to SurroundState");
//this.current = new Surround(this.gs, this.surroundIgnoreBombs);
//this.current = new Surround(this.gs, this.isBombPassable);
SurroundState newState = new SurroundState(this.gs, this.isBombPassable);
fsm.changeState(newState);
}
else if (current is BlastWallState)
{
//map fail.... ruh roh
Console.WriteLine("AI can't move... map fail");
//switch to BombState as last-ditch resort...
Console.WriteLine("Switching to BombState");
BombState newState = new BombState(this.gs);
fsm.changeState(newState);
}
}
if (current.complete(this))
{
Console.WriteLine("Agent " + this.agentId + " completed strategy " + current.GetType());
if (current is SurroundState)
{
//this.current = new KillPlayer(this.gs);
Console.WriteLine("Switching to BombState");
BombState newState = new BombState(this.gs);
fsm.changeState(newState);
}
else
{
//.........这里部分代码省略.........
示例2: blockEscapeMove
private Action blockEscapeMove(FSM<BomberAgent> fsm)
{
State<BomberAgent> current = fsm.getCurrentState();
Action move = null;
State<BomberAgent> nextState = null;
if (current is PursueState)
{
if (current.fail(this))
{
nextState = new BlastWallState(this.gs, false);
}
else
{
//check for four adjacent locations open near player
Coords playerCoords = this.gs.GetAgentCoords(0);
List<Coords> adj = this.gs.GetAdjacentAccessibleTiles(playerCoords.getTileNum(), this.isBombPassable, false);
if (adj.Count == 4)
{
nextState = new SurroundState(this.gs, this.isBombPassable);
}
else
{
Coords choke = this.chokepoints.findChokePoint(this.isBombPassable, this);
if (choke != null)
{
nextState = new CutOffChokePointState(this.gs, this.isBombPassable, choke);
}
}
}
}
else if (current is BlastWallState)
{
if (current.fail(this) || current.complete(this))
{
nextState = new EvadeExplosionState(this.gs);
}
}
else if (current is CutOffChokePointState)
{
//Coords choke = this.chokepoints.findChokePoint(this.isBombPassable, this);
//if ((choke == null) || current.fail(this)) {
if (current.fail(this))
{
nextState = new PursueState(this.gs, this.isBombPassable);
}
else if (current.complete(this))
{
nextState = new BombState(this.gs);
}
}
else if (current is BombState)
{
if (current.fail(this) || current.complete(this))
{
nextState = new EvadeExplosionState(this.gs);
}
}
else if (current is EvadeExplosionState)
{
if (current.fail(this) || current.complete(this))
{
Coords choke = this.chokepoints.findChokePoint(this.isBombPassable, this);
if (choke == null)
{
nextState = new PursueState(this.gs, this.isBombPassable);
}
else
{
nextState = new CutOffChokePointState(this.gs, this.isBombPassable, choke);
}
}
}
else if (current is SurroundState)
{
if (current.fail(this))
{
nextState = new PursueState(this.gs, this.isBombPassable); //move to default state
}
else if (current.complete(this))
{
nextState = new BombState(this.gs);
}
}
if (nextState != null)
{
Console.WriteLine("Agent " + this.agentId + " switching to " + nextState.GetType().ToString());
fsm.changeState(nextState);
}
move = fsm.getCurrentState().getAction(this);
Console.WriteLine("Agent " + this.agentId + ", state " + fsm.getCurrentState().GetType().ToString() + ", move " + move);
return move;
}