IEnumerator Highlight(Matchable match) { match.Select(); yield return(new WaitForSeconds(highlightDiration)); match.StopSelect(); }
/// <summary> /// Generate the GUI. /// </summary> void OnGUI() { // Initialize the SDK (optional) Matchable.Init(); GUIStyle style; style = new GUIStyle(GUI.skin.box); style.wordWrap = true; style.padding = new RectOffset(5, 5, 5, 5); style.normal.textColor = Color.white; GUI.skin.box = style; int buttonSize = Screen.width / 2 - 10; int buttonHeight = 50; Rect rect = new Rect(10, 10, buttonSize, buttonHeight); if (GUI.Button(rect, "GetRecommendations()")) { StartCoroutine(DemoGetRecommendations()); } rect = new Rect(buttonSize + 10, 10, buttonSize, buttonHeight); if (GUI.Button(rect, "SendAction()")) { StartCoroutine(DemoSendAction()); } rect = new Rect(10, buttonHeight + 20, Screen.width - 20, Screen.height); string text = String.Format("{0}\n\n{1}", _test, _log); GUI.Box(rect, text); }
public static int Compare <T>(this Matchable <T> m, T candidate1, T candidate2) { if (candidate1 == null) { return(1); } if (candidate2 == null) { return(-1); } var score1 = m.GetScore(candidate1); var score2 = m.GetScore(candidate2); if (score1 < score2) { return(-1); } else if (score1 > score2) { return(1); } else { return(0); } }
public IEnumerable <Matchable <TY> > Match <TX, TY>(Matchable <TX> toMatch, IEnumerable <Matchable <TY> > possibleMatches) { foreach (var possibleMatch in possibleMatches) { if (possibleMatch.MatchData.StartsWith(toMatch.MatchData, ComparisonType)) { yield return(possibleMatch); } } }
public ConsumerStatus Match(Matchable <decimal, decimal> payment) { //var leftOfPayment = payment.Input - payment.AccumulatedConsumption; //var toPay = Math.Min(leftOfPayment, monthlyCost - Covered); //Covered += toPay; //var isPaymentComplete = toPay == leftOfPayment; //payment.AddMatch(this, toPay, isPaymentComplete); //if (Covered == monthlyCost) // return ConsumerStatus.Complete; return(ConsumerStatus.Active); }
public ConsumerStatus Match(Matchable <decimal, decimal> payment) { var leftOfPayment = payment.Input - payment.AccumulatedConsumption; var toPay = Math.Min(leftOfPayment, monthlyCost - CoveredByConsumer); CoveredByConsumer += toPay; var isPaymentComplete = toPay == leftOfPayment; payment.AddMatch(this, toPay, isPaymentComplete); return(CoveredByConsumer == monthlyCost ? ConsumerStatus.Complete : ConsumerStatus.Active); }
/// <summary> /// Demo of call the the GetRecommendations SDK method. /// Displays the response JSON string. /// </summary> /// <code> /// StartCoroutine(Matchable.GetRecommendations((response) => /// { /// _log = response.ToJsonString(); /// })); /// </code> public IEnumerator DemoGetRecommendations() { _test = "Matchable.GetRecommendations()"; _log = "Waiting for response..."; // Call GetAdvisor asynchronously as a Coroutine yield return(StartCoroutine(Matchable.GetRecommendations((response) => { // Handle the API response the way you want _log = response.ToJsonString(); // Ex: get the advisor value _log += "\n\nAdvisor: " + response.GetValue("advisor"); }))); }
public IEnumerable <Matchable <TY> > Match <TX, TY>(Matchable <TX> toMatch, IEnumerable <Matchable <TY> > possibleMatches) { var possibleNames = Nicknames.Where(x => x.Value.Contains(toMatch.MatchData)).Select(x => x.Key).ToList(); foreach (var possibleMatch in possibleMatches) { if (possibleNames.Contains(possibleMatch.MatchData, Nicknames.Comparer)) { yield return(possibleMatch); } } }
public IEnumerable <Matchable <TY> > Match <TX, TY>(Matchable <TX> toMatch, IEnumerable <Matchable <TY> > possibleMatches) { var nameSoundex = ExternalCode.Soundex.For(toMatch.MatchData); foreach (var possibleMatch in possibleMatches) { if (nameSoundex == ExternalCode.Soundex.For(possibleMatch.MatchData)) { yield return(possibleMatch); } } }
void MatchWith(Matchable other) { if (matchedObject) { return; } Debug.Log("Matching with " + other.name); matchedObject = other; // disable the matched object so it doesn't also run match behavior matchedObject.enabled = false; SetFreeMovement(true); other.SetFreeMovement(true); }
public static T getFavorite <T>(this Matchable <T> m, List <T> matchees) { T favorite = matchees.First(); var bestScore = Single.PositiveInfinity; foreach (var candidate in matchees) { var score = m.GetScore(candidate); if (score < bestScore) { favorite = candidate; bestScore = score; } } return(favorite); }
/// <summary> /// Demo of call the the SendAction SDK method. /// Displays the response JSON string. /// </summary> /// <code> /// Hashtable parameters = new Hashtable(); /// parameters.Add("game_type", "tactical"); /// parameters.Add("xp", 0); /// parameters.Add("player_lvl", 1); /// parameters.Add("status", 1); /// StartCoroutine(MatchableAction.StartGame(parameters, (response) => /// { /// _log = response.ToJsonString(); /// })); /// </code> public IEnumerator DemoSendAction() { _test = "Matchable.SendAction()"; _log = "Waiting for response..."; Hashtable parameters = new Hashtable(); parameters.Add("game_type", "tactical"); parameters.Add("xp", 0); parameters.Add("player_lvl", 1); parameters.Add("status", 1); // Call any MatchableAction asynchronously as a Coroutine yield return(StartCoroutine(Matchable.SendAction("sample_action_type", parameters, (response) => { // Handle the API response the way you want _log = response.ToJsonString(); }))); }
public Action( int id, string?method, string?uri, string?to, string?mapper, IList <MappedParameter> additionalParameters) { Id = id; _method = Method.From(method); _uri = uri; _to = new ToSpec(to); _originalTo = to; _mapper = mapper == null ? DefaultJsonMapper.Instance : MapperFrom(mapper); _additionalParameters = additionalParameters; _matchable = new Matchable(uri); }
public Action( int id, string method, string uri, string to, string mapper, bool disallowPathParametersWithSlash, IList <MappedParameter> additionalParameters) { _id = id; _method = Method.From(method); _uri = uri; _to = new ToSpec(to); _originalTo = to; _mapper = mapper == null ? DefaultJsonMapper.Instance : MapperFrom(mapper); _disallowPathParametersWithSlash = disallowPathParametersWithSlash; _additionalParameters = additionalParameters; _matchable = new Matchable(uri); }
void MergeWith(Matchable other) { if (AmMaxLevel()) { return; } // get the next level prefab int evolution = level + 1; GameObject evolutionPrefab = matchableInfo.evolutions[evolution]; // instantiate the next level prefab GameObject evolutionInstance = Instantiate(evolutionPrefab, transform.position, transform.rotation); // Check if the haunter should be migrated to the next level evolution. Check both matchers for a haunter Haunter haunter = GetHaunter(); if (!haunter) { haunter = other.GetHaunter(); } if (haunter) { Hauntable evolutionHauntable = evolutionInstance.GetComponent <Hauntable>(); if (evolutionHauntable) { haunter.MigrateHaunt(evolutionHauntable); } else { haunter.EndHaunt(evolutionInstance); } } // destroy Destroy(other.gameObject); Destroy(gameObject); }
public void Process <T>(Matchable <T> input) { input.MatchData = input.MatchData.Trim(); }
public void Process <T>(Matchable <T> input) { input.MatchData = Regex.Replace(input.MatchData, @"\p{C}+", string.Empty); }
public MatchStruct(Matchable <T> i = null, float s = Single.PositiveInfinity) { score = s; indivdual = i; }