示例#1
0
        /// <summary>
        /// Bruuuuuuuuuteforce!
        /// </summary>
        /// <param name="length">The length of plain text.</param>
        /// <param name="match">The hash to look for.</param>
        /// <param name="callback">An <see cref="OnMatchFound"/> callback that is called when a match is found.</param>
        public void Bruteforce(int length, uint match, OnMatchFound callback)
        {
            Initialize(length);
            while (true)
            {
                var depth = _bytes.Length - 1;
                while (_bytes.Increment(depth))
                {
                    depth--;
                    if (depth == -1)
                    {
                        return;                 // all permutations at this length are done
                    }
                }

                _hashes.ZeroFrom(depth);    // throw away stale hash caches

                byte lastByte = 0x2f;
                uint tempHash = Hash(_bytes, _hashes, _bytes.Length) * Prime;
                while (!lastByte.Increment(out var nextByte))
                {
                    lastByte = nextByte;
                    uint result = tempHash;
                    result ^= lastByte;

                    if (result == match)
                    {
                        callback(length, Encoding.ASCII.GetString(_bytes) + Convert.ToChar(lastByte));
                    }
                }
            }
        }
示例#2
0
        public ImageGestureImage CheckForImageMatch()
        {
            if (matchedImage == null)
            {
                if (MatchText != null)
                {
                    //MatchText.text = "No match found!";
                }
            }
            else
            {
                if (MatchText != null)
                {
                    //MatchText.text = "You drew a " + matchedImage.Name;
                    print("1");
                    if (OnMatchFound != null)
                    {
                        print("1");
                        OnMatchFound.Invoke(matchedImage.Name);
                        StopAnimation();
                        //  print("2");
                    }
                }

                // image gesture must be manually reset when a shape is recognized
                Gesture.Reset();
                matchedImage = null;

                // clear out lines with animation
                BeginAnimateOutLines();
            }

            return(matchedImage);
        }
 public virtual void OnMatchFoundInvoke(MatchFoundMessage x)
 {
     if (GameSparksManager.Instance().IsDebug)
     {
         var subs     = OnMatchFound?.GetInvocationList();
         var debugStr = "OnMatchFound InvokationList: ";
         subs?.ToList().ForEach(m => debugStr += "\n" + m.Method.Name);
         Debug.Log(debugStr);
     }
     OnMatchFound?.Invoke(x);
 }
示例#4
0
    void OnMatchMakerMatched(IMatchmakerMatched matched)
    {
        ServerSessionManager.Instance.Socket.ReceivedMatchmakerMatched -= OnMatchMakerMatched;
        _pendingMatch = matched;

        ChooseHost();

        UnityMainThreadDispatcher.Instance().Enqueue(() => {
            OnMatchFound?.Invoke(matched);
        });
    }
示例#5
0
        private void CombineConnectionsWithMatches()
        {
            Request[] combination;
            while ((combination = Matchmaking.Matches.Read()) != null)
            {
                MatchData matchData = GenerateMatchData(combination);
                if (matchData == null)
                {
                    continue;
                }

                RemoveConnectionsFromQueue(matchData);
                OnMatchFound?.Invoke(this, matchData);
            }
        }
示例#6
0
        public List <MatchResult> FindAllMatches(List <Person> personList = null)
        {
            Matches.Clear();

            if (personList == null && Persons == null)
            {
                return(new List <MatchResult>());
            }
            else if (personList == null && Persons != null)
            {
                personList = Persons;
            }

            for (int i = 0; i < personList.Count(); i++)
            {
                for (int j = i + 1; j < personList.Count(); j++)
                {
                    int equalsFound   = 0;
                    int inequalsFound = 0;

                    foreach (BasePattern pattern in MatchingPatterns)
                    {
                        BasePattern.MATCH_RESULT result = pattern.Compare(personList[i], personList[j]);
                        if (result == BasePattern.MATCH_RESULT.NOT_EQUAL)
                        {
                            inequalsFound++;
                            break;
                        }
                        else if (result == BasePattern.MATCH_RESULT.EQUAL)
                        {
                            equalsFound++;
                        }
                    }

                    if (inequalsFound == 0 && equalsFound > 0)
                    {
                        MatchResult newMatch = new MatchResult(personList[i], personList[j]);
                        Logger.Info($"New Match! -> {newMatch.ToString()}");
                        Matches.Add(newMatch);
                        OnMatchFound?.Invoke(newMatch);
                    }
                }
            }

            return(Matches);
        }