Пример #1
0
    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();
    }
Пример #2
0
        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();
        }
Пример #3
0
    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));
    }
Пример #4
0
    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);
            }
        }
    }
Пример #5
0
 public static void CaughtPropertyChanged(this ICatcher <PropertyChangedEventArgs> subCatcher, object sender, string propertyName)
 {
     subCatcher.Received(1).Catch(sender, Arg.Is <PropertyChangedEventArgs>(p => p.PropertyName == propertyName));
 }
Пример #6
0
 public static void DidNotCatch <T>(this ICatcher <T> subCatcher)
 {
     subCatcher.DidNotReceiveWithAnyArgs().Catch(null, default !);
Пример #7
0
 public static void CaughtEmpty(this ICatcher <EventArgs> subCatcher, object sender)
 {
     subCatcher.Received(1).Catch(sender, EventArgs.Empty);
 }
Пример #8
0
 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));
 }
Пример #9
0
 public void Receive(ICatcher catcher)
 {
     catcher.OnCatch(this);
 }