IEnumerator Throwroutine(Contestant a, ICatcher b, float chanceToThrow, float time) { float randomVal = UnityEngine.Random.value; if (randomVal <= chanceToThrow) { yield return(StartCoroutine(Launch(a.BallHolderObject.position, b.BallHolderObject.position, time))); Receive(b); } else { List <Hex> hexesAroundMissed = GridManager.Instance.Grid.HexesInRangeAccountingObstacles(b.CurrentHex, 1 + ((randomVal - chanceToThrow) * 10f)); Debug.Log(hexesAroundMissed.Count + " collected from range: " + (1 + ((randomVal - chanceToThrow) * 10f))); Hex hex = hexesAroundMissed [UnityEngine.Random.Range(1, hexesAroundMissed.Count)]; yield return(StartCoroutine(Launch(a.transform.GetChild(0).GetChild(0).position, hex.Position, time))); CurrentHex = hex; } onFinishedLaunch(); }
private void btnBegin_Click(object sender, EventArgs e) { CatcherConfig config = StaticCacheManager.GetConfig <CatcherConfig>(); object obj = ReflectHelper.CreateInstance(config.CatcherClassName); ICatcher catcher = obj as ICatcher; catcher.Parse(); }
public void ThrowToCatcher(Contestant a, ICatcher b, float chanceToThrow, float time) { if (a.Ball == null) { Debug.LogError("Trying to throw a ball you don't have"); } Release(a); StartCoroutine(Throwroutine(a, b, chanceToThrow, time)); }
public void ThrowToTarget(float time) { TargetSelectorMode <ICatcher> tsm = ((TargetSelectorMode <ICatcher>)currentControlMode); ICatcher currentTarget = tsm.CurrentTarget; List <ICatcher> targets = tsm.Targets; if (currentTarget != null) { ICatcher catcher = (ICatcher)currentTarget; if (targets.Contains(catcher)) { selected.Ball.RegisterOnFinishedLaunch(() => { ControlModeType = ControlModeEnum.Move; }); selected.Ball.ThrowToCatcher(selected, catcher, tsm.TargetProbabilities[catcher], time); } } }
public static void CaughtPropertyChanged(this ICatcher <PropertyChangedEventArgs> subCatcher, object sender, string propertyName) { subCatcher.Received(1).Catch(sender, Arg.Is <PropertyChangedEventArgs>(p => p.PropertyName == propertyName)); }
public static void DidNotCatch <T>(this ICatcher <T> subCatcher) { subCatcher.DidNotReceiveWithAnyArgs().Catch(null, default !);
public static void CaughtEmpty(this ICatcher <EventArgs> subCatcher, object sender) { subCatcher.Received(1).Catch(sender, EventArgs.Empty); }
public static void DidNotCatchPropertyChanged(this ICatcher <PropertyChangedEventArgs> subCatcher, object sender, string propertyName) { subCatcher.DidNotReceive().Catch(sender, Arg.Is <PropertyChangedEventArgs>(e => e != null && e.PropertyName == propertyName)); }
public void Receive(ICatcher catcher) { catcher.OnCatch(this); }