//Functions public override void BroadcastMove(int numSteps, Field comesFrom) { if (numSteps <= 0) //Pawn is trying to stop on this field. Allow if possible { return; //Can't walk to forests } else //This is needed for moving off the forest. { numSteps--; if (comesFrom == null) //Call is originating from the pawn and not an exit { if (_exitN != null) { _exitN.BroadcastMove(numSteps, this); } if (_exitE != null) { _exitE.BroadcastMove(numSteps, this); } if (_exitS != null) { _exitS.BroadcastMove(numSteps, this); } if (_exitW != null) { _exitW.BroadcastMove(numSteps, this); } } } }
//Functions public override void BroadcastMove(int numSteps, Field comesFrom) { if (comesFrom == null || (comesFrom is Model.StartField)) { if (_contains == null || _contains.Type != "barricade") { //Only push through for 1 more, should always end up outside the start and not cause endless loops. //Note: odd Maps that have the exit of the start fields south or west might be problematic. if (comesFrom == null) //Moving off the starting fields is always only 1 step. numSteps--; if (comesFrom != _exitN && _exitN != null) { _exitN.BroadcastMove(numSteps, this); } else if (comesFrom != _exitE && _exitE != null) { _exitE.BroadcastMove(numSteps, this); } else if (comesFrom != _exitW && _exitW != null) { _exitW.BroadcastMove(numSteps, this); } else if (comesFrom != _exitS && _exitS != null) { _exitS.BroadcastMove(numSteps, this); } } } }
public override void BroadcastMove(int numSteps, Field comesFrom) { if (numSteps <= 0) //Pawn is trying to stop on this field. Allow always { EventHandler handler = broadcastMove; if (handler != null) { handler(this, new MyEventArgs.BroadcastMoveArgs(XPos, YPos, this)); } } }
//Constructor public Field(Field exitN, Field exitE, Field exitS, Field exitW, bool barricadeAllowed, int returnTo, int xPos, int yPos) { this.BroadcastedBarricade = false; this.XPos = xPos; this.YPos = yPos; this.ExitN = exitN; this.ExitE = exitE; this.ExitS = exitS; this.ExitW = exitW; this.BarricadeAllowed = barricadeAllowed; this.ReturnTo = returnTo; Debug.Write("Field made. "); if (exitN != null) Debug.Write("ExitN given "); if (exitW != null) Debug.Write("ExitW given "); Debug.WriteLine(""); Debug.WriteLine(""); }
//Functions public override void BroadcastMove(int numSteps, Field comesFrom) { if (numSteps <= 0) //Pawn is trying to stop on this field. Allow if no pawn is on it. { if (this.Contains == null) { EventHandler handler = broadcastMove; if (handler != null) { handler(this, new MyEventArgs.BroadcastMoveArgs(XPos, YPos, this)); } } } else { numSteps--; if (_contains == null || _contains.Type != "barricade") { if (comesFrom != _exitN && _exitN != null) { _exitN.BroadcastMove(numSteps, this); } if (comesFrom != _exitE && _exitE != null) { _exitE.BroadcastMove(numSteps, this); } if (comesFrom != _exitS && _exitS != null) { _exitS.BroadcastMove(numSteps, this); } if (comesFrom != _exitW && _exitW != null) { _exitW.BroadcastMove(numSteps, this); } } } }
//Constructor public Barricade(Field position) { Position = position; this.Type = "barricade"; Debug.WriteLine("Barricade made"); }
//Constructor public Forest(Field exitN, Field exitE, Field exitS, Field exitW, int numForest, int xPos, int yPos) : base(exitN, exitE, exitS, exitW, false, 0, xPos, yPos) { NumForest = numForest; _container = new List<Movable>(); }
//Constructor public GoalField(Field exitN, Field exitE, Field exitS, Field exitW, int xPos, int yPos) : base(exitN, exitE, exitS, exitW, false, 0, xPos, yPos) { }
//Constructor public Pawn(Field position) { this.Position = position; this.Type = "pawn"; }
public void ResetBroadcastedBarricades(Field comesFrom) { if (BroadcastedBarricade) { BroadcastedBarricade = false; if (comesFrom != _exitN && _exitN != null) { _exitN.ResetBroadcastedBarricades(this); } if (comesFrom != _exitE && _exitE != null) { _exitE.ResetBroadcastedBarricades(this); } if (comesFrom != _exitS && _exitS != null) { _exitS.ResetBroadcastedBarricades(this); } if (comesFrom != _exitW && _exitW != null) { _exitW.ResetBroadcastedBarricades(this); } } }
public void BroadcastBarricades(Field comesFrom) { if (!BroadcastedBarricade) { BroadcastedBarricade = true; if (_contains == null && BarricadeAllowed) { EventHandler handler = broadcastMove; if (handler != null) { handler(this, new MyEventArgs.BroadcastMoveArgs(XPos, YPos, this)); } } if (comesFrom != _exitN && _exitN != null) { _exitN.BroadcastBarricades(this); } if (comesFrom != _exitE && _exitE != null) { _exitE.BroadcastBarricades(this); } if (comesFrom != _exitS && _exitS != null) { _exitS.BroadcastBarricades(this); } if (comesFrom != _exitW && _exitW != null) { _exitW.BroadcastBarricades(this); } } }
//Constructor public StartField(Field exitN, Field exitE, Field exitS, Field exitW, string color, int xPos, int yPos) : base(exitN, exitE, exitS, exitW, false, 0, xPos, yPos) { Color = color.ToUpper(); }
//Constructor public BarricadeField(Field exitN, Field exitE, Field exitS, Field exitW, bool barricadeAllowed, int returnTo, int xPos, int yPos) : base(exitN, exitE, exitS, exitW, barricadeAllowed, returnTo, xPos, yPos) { }