예제 #1
0
 //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);
             }
         }
     }
 }
예제 #2
0
        //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);
                    }
                }
            }
        }
예제 #3
0
 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));
         }
     }
 }
예제 #4
0
 //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("");
 }
예제 #5
0
 //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);
             }
         }
     }
 }
예제 #6
0
 //Constructor
 public Barricade(Field position)
 {
     Position = position;
     this.Type = "barricade";
     Debug.WriteLine("Barricade made");
 }
예제 #7
0
 //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>();
 }
예제 #8
0
 //Constructor
 public GoalField(Field exitN, Field exitE, Field exitS, Field exitW, int xPos, int yPos)
     : base(exitN, exitE, exitS, exitW, false, 0, xPos, yPos)
 {
 }
예제 #9
0
        //Constructor
        public Pawn(Field position)
        {
            this.Position = position;

            this.Type = "pawn";
        }
예제 #10
0
 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);
         }
     }
 }
예제 #11
0
        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);
                }
            }
        }
예제 #12
0
 //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();
 }
예제 #13
0
 //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)
 {
 }