/// <summary> /// Attempts to identify the kebbit. /// </summary> /// <returns>True if the kebbit is identified as a known species of kebbit. False if the kebbit cannot be identified.</returns> public bool IdentifyKebbit() { int searchRadius = (int)(0.01 * GameScreen.GetLength(1)); int left = Location.Center.X - searchRadius; int right = Location.Center.X + searchRadius; int top = Location.Center.Y - searchRadius; int bottom = Location.Center.Y + searchRadius; List <KebbitType> identifiableKebbits = IdentifiableKebbits; double furMatch; double bestFurMatch = 0.01; //minimum threshold for a valid kebbit _type = KebbitType.Unknown; foreach (KebbitType kebbitType in IdentifiableKebbits) { furMatch = ImageProcessing.FractionalMatchPiece(GameScreen, GetKebbitFilter(kebbitType), left, right, top, bottom); if (furMatch > bestFurMatch) { _type = kebbitType; bestFurMatch = furMatch; } } return(false); }
/// <summary> /// Gets the color filter for the fur of a type of kebbit. /// </summary> /// <param name="kebbitType">The type of kebbit.</param> /// <returns>A color filter for the given kebbit type.</returns> public static ColorFilter GetKebbitFilter(KebbitType kebbitType) { switch (kebbitType) { case KebbitType.Spotted: return(KebbitSpottedFur); case KebbitType.Dark: return(KebbitDarkFur); case KebbitType.Dashing: return(KebbitDashingFur); default: return(new RejectFilter()); } }