Exemple #1
0
        /// <summary>
        /// Check to see if the dead map hint applies
        /// </summary>
        /// <param name="context"></param>
        public void Check(DeadMapState context)
        {
            foreach (VectorInt checkLocation in checkLocations)
            {
                int cx = checkLocation.X;
                int cy = checkLocation.Y;

                if (CheckMatchAtLocation(context, cx, cy))
                {
                    // All criteria passed
                    // Mark all crates as dead
                    for (int hintY = 0; hintY < hint.GetLength(1); hintY++)
                        for (int hintX = 0; hintX < hint.GetLength(0); hintX++)
                        {
                            if (hint[hintX, hintY] == HintCell.CrateNotGoal) context[cx + hintX, cy + hintY] = true;
                        }

                    // Increase the hints
                    context.DeadMapAnalysis.StaticAnalysis.Controller.Stats.HintsUsed.Increment();
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Perform the full check at a location
 /// </summary>
 /// <param name="context"></param>
 /// <param name="cx"></param>
 /// <param name="cy"></param>
 /// <returns></returns>
 bool CheckMatchAtLocation(DeadMapState context, int cx, int cy)
 {
     for (int hintY = 0; hintY < hint.GetLength(1); hintY++)
         for (int hintX = 0; hintX < hint.GetLength(0); hintX++)
         {
             switch (hint[hintX, hintY])
             {
                 case (HintCell.Floor):
                     if (!context.StaticAnalysis.FloorMap[cx + hintX, cy + hintY]) return false;
                     break;
                 case (HintCell.Wall):
                     if (!context.WallMap[cx + hintX, cy + hintY]) return false;
                     break;
                 case (HintCell.CrateNotGoal):
                     if (!(context.CrateMap[cx + hintX, cy + hintY] && !context.GoalMap[cx + hintX, cy + hintY])) return false;
                     break;
                 case (HintCell.CrateGoalOrCrateNonGoal):
                     if (!(context.CrateMap[cx + hintX, cy + hintY])) return false;
                     break;
                 case (HintCell.DeadStatic):
                     // Dead cannot be in the move map
                     if (context.MoveMap[cx + hintX, cy + hintY]) return false;
                     // Static deadmap or dynamic dead map
                     if (!context.StaticAnalysis.DeadMap[cx + hintX, cy + hintY] &&
                         !context[cx + hintX, cy + hintY]) return false;
                     break;
                 case (HintCell.Ignore):
                     break;
                 default:
                     throw new InvalidDataException("Hint char is invalid:" + hint[hintX, hintY]);
             }
         }
     return true;
 }