Exemple #1
0
        public static void CreateTable()
        {
            PuppetModel[,] puppets = SingletonPuppets.instance.Value.GetInstance();
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < puppets.GetLength(0); j++)
                {
                    if ((i % 2 == 0) && (j % 2 == 0) || (i % 2 == 1) && (j % 2 == 1))
                    {
                        puppets[i, j] = new PuppetModel(PuppetModel.Colour.Red);
                    }
                }
            }

            for (int i = puppets.GetLength(1) - 1; i > puppets.GetLength(1) - 4; i--)
            {
                for (int j = 0; j < puppets.GetLength(0); j++)
                {
                    if ((i % 2 == 0) && (j % 2 == 0) || (i % 2 == 1) && (j % 2 == 1))
                    {
                        puppets[i, j] = new PuppetModel(PuppetModel.Colour.Blue);
                    }
                }
            }
        }
Exemple #2
0
 protected bool CanMove(Position from, Position to, PuppetModel.Colour colour)
 {
     try
     {
         PuppetModel freeSpace = puppets[to.x, to.y];
         if (freeSpace == null)
         {
             return(true);
         }
     }
     catch (Exception)
     {
     }
     return(false);
 }
Exemple #3
0
 /// <summary>
 /// Is valid hit
 /// </summary>
 /// <param name="fromX">from coordinate</param>
 /// <param name="fromY">from coordinate</param>
 /// <param name="xdiff">up or down direction</param>
 /// <param name="colour">puppet colour</param>
 /// <param name="isRight">right or left</param>
 /// <returns>returns true if the hit is valid, false if not</returns>
 protected bool CanHit(Position from, Position to, PuppetModel.Colour colour)
 {
     try
     {
         PuppetModel enemy     = puppets[(from.x + to.x) / 2, (from.y + to.y) / 2];
         PuppetModel freeSpace = puppets[to.x, to.y];
         if (enemy.Color == NegateColour(colour) && freeSpace == null)
         {
             return(true);
         }
     }
     catch (Exception)
     {
     }
     return(false);
 }