コード例 #1
0
        //public static int getHorizontalDigitOffsetForPlayer(PlayerIndex playerIndex, DigitPosition digitPos )
        //{
        //    // We might have casted it from an int, check if it's inside enum range
        //    Dbg.assertPlayerIndexIsInRangeAndNotInvalid( playerIndex );
        //    Dbg.assertDigitPosEnumIsInRangeAndNotInvalid( digitPos );

        //    string resolution = ScreenCapture.getScreenshotResolutionAsString();

        //    //horizontalDigitOffset[ ( int )DigitPosition.DigitPos0 ] = 661;   // Left-most digit
        //    //horizontalDigitOffset[ ( int )DigitPosition.DigitPos1 ] = 683;
        //    //horizontalDigitOffset[ ( int )DigitPosition.DigitPos2 ] = 715;
        //    //horizontalDigitOffset[ ( int )DigitPosition.DigitPos3 ] = 738;
        //    //horizontalDigitOffset[ ( int )DigitPosition.DigitPos4 ] = 760;   // Right-most digit

        //    switch ( playerIndex )
        //    {
        //        case PlayerIndex.Survivor1:
        //        case PlayerIndex.Survivor2:
        //        case PlayerIndex.Survivor3:
        //        case PlayerIndex.Survivor4:
        //            return horizontalDigitOffset[ resolution ][( int )digitPos ];

        //        case PlayerIndex.Killer:
        //            // All digits except for the first one are moved by 1 pixel for killer
        //            if ( digitPos == DigitPosition.DigitPos0 )
        //                return horizontalDigitOffset[ resolution ][ ( int )digitPos ];

        //            return horizontalDigitOffset[ resolution ][ ( int )digitPos ] + 1;

        //        default:
        //            Dbg.onError( "Invalid player" );
        //            break;
        //    }

        //    Dbg.onError( "Error" );

        //    return 0;
        //}

        /// <summary>
        /// digitIndex is 0 based
        /// </summary>
        public bool recognize(PlayerIndex playerIndex, DigitPosition digitPos, bool bDebug = false)
        {
            // We might have casted it from an int, check if it's inside enum range
            Dbg.assertPlayerIndexIsInRangeAndNotInvalid(playerIndex);
            Dbg.assertDigitPosEnumIsInRangeAndNotInvalid(digitPos);

            string resolution = ScreenCapture.getScreenshotResolutionAsString();

            //int verticalBeginningOfDigits = verticalPosOfFirstSurvivorBPDigit[ resolution ];

            int horizontalOffset = horizontalDigitOffset[resolution][playerIndex][( int )digitPos];
            int verticalOffset   = verticalOffsetBetweenEndscorePlayerBpDigits[resolution][( int )playerIndex];

            //// For killer it is moved 5 pixels down
            //if ( playerIndex == PlayerIndex.Killer )
            //    verticalOffset = verticalOffset + 5;

            return(base.recognize(horizontalOffset, verticalOffset, bDebug));
        }
コード例 #2
0
        /// <summary>
        /// Take player index and index of a digit in BP score and return the digit.
        /// E.g. digit at index '2' from BP score "14 356" will be '3'
        /// </summary>
        public static DigitEnum recognizeDigitAtDigitPosForPlayer(PlayerIndex playerIndex, DigitPosition digitPos)
        {
            // We might have casted it from an int, check if it's inside enum range
            Dbg.assertPlayerIndexIsInRangeAndNotInvalid(playerIndex);
            Dbg.assertDigitPosEnumIsInRangeAndNotInvalid(digitPos);


            List <bool> boolDigitList = new List <bool>();

            // Try to recognize ALL possible digits at that place
            for (int d = 0; d <= 9; d++)
            {
                boolDigitList.Add(digit[d].recognize(playerIndex, digitPos));
            }

            Dbg.ensureMaxOneBoolIsTrue(boolDigitList);

            // see which one is true, if any
            DigitEnum recognizedDigit = DigitEnum.Error;

            for (int d = (int)DigitEnum.Digit0; d <= (int)DigitEnum.Digit9; d++)
            {
                // Already set it before, so we have more than 1 value => error
                if (boolDigitList[d] && recognizedDigit != DigitEnum.Error)
                {
                    return(DigitEnum.Error);
                }

                if (boolDigitList[d])
                {
                    recognizedDigit = ( DigitEnum )d;
                }
            }

            Dbg.assertDigitEnumIsInRange(recognizedDigit);

            return(recognizedDigit);
        }