Exemple #1
0
 public UShooter AddStage(IShootStage newStage)
 {
     newStage.SetShooter(this);              // Remember to set shooter so it could be accessed in stage object
     this.stages.Add(newStage);
     return(this);
 }
Exemple #2
0
        private IEnumerator _ShootCoroutine()
        {
            int stageLen = this.stages.Count;

            switch (this._loopType)
            {
            case EShooterLoopType.NONE:
            {
                if (stageLen == 1)                           // optimize for single staged shooter
                {
                    StartCoroutine(this.stages [0].StartStage());
                }
                else
                {
                    // Loop through each stage, call their own coroutines, and wait till complete
                    for (int i = 0; i < stageLen; i++)
                    {
                        IShootStage currStage = this.stages [i];
                        // currStage.SetShooter (this); // Set before during adding
                        StartCoroutine(currStage.StartStage());
                        yield return(new WaitUntil(() => currStage.IsComplete()));
                    }
                }
                break;
            }

            case EShooterLoopType.FORTH:
            {
                while (true)
                {
                    for (int i = 0; i < stageLen; i++)
                    {
                        IShootStage currStage = this.stages [i];
                        // currStage.SetShooter (this); // Set before during adding
                        StartCoroutine(currStage.StartStage());
                        yield return(new WaitUntil(() => currStage.IsComplete()));

                        // BUGFIX: forcefully set incomplete to allow normal running (else WaitUntil in next loop will NOT work)
                        currStage.SetComplete(false);
                    }
                }
                break;
            }

            case EShooterLoopType.BACKFORTH:
            {
                while (true)
                {
                    for (int i = 0; i < stageLen; i++)
                    {
                        IShootStage currStage = this.stages [i];
                        // currStage.SetShooter (this); // Set before during adding
                        StartCoroutine(currStage.StartStage());
                        yield return(new WaitUntil(() => currStage.IsComplete()));

                        // BUGFIX: forcefully set incomplete to allow normal running (else WaitUntil in next loop will NOT work)
                        currStage.SetComplete(false);
                    }
                    for (int i = stageLen - 1; i >= 0; i--)
                    {
                        IShootStage currStage = this.stages [i];
                        // currStage.SetShooter (this); // Set before during adding
                        StartCoroutine(currStage.StartStage());
                        yield return(new WaitUntil(() => currStage.IsComplete()));

                        // BUGFIX: forcefully set incomplete to allow normal running (else WaitUntil in next loop will NOT work)
                        currStage.SetComplete(false);
                    }
                }
                break;
            }

            case EShooterLoopType.BOUNCE:
            {
                if (stageLen == 1)                           // optimize for single staged shooter
                {
                    IShootStage onlyStage = this.stages [0];
                    while (true)
                    {
                        // currStage.SetShooter (this); // Set before during adding
                        StartCoroutine(onlyStage.StartStage());
                        yield return(new WaitUntil(() => onlyStage.IsComplete()));
                    }
                }
                else
                {
                    while (true)
                    {
                        for (int i = 0; i < stageLen - 1; i++)                                   // exclude last
                        {
                            IShootStage currStage = this.stages [i];
                            // currStage.SetShooter (this); // Set before during adding
                            StartCoroutine(currStage.StartStage());
                            yield return(new WaitUntil(() => currStage.IsComplete()));

                            // BUGFIX: forcefully set incomplete to allow normal running (else WaitUntil in next loop will NOT work)
                            currStage.SetComplete(false);
                        }
                        for (int i = stageLen - 1; i > 0; i--)                                   // exclude first
                        {
                            IShootStage currStage = this.stages [i];
                            // currStage.SetShooter (this); // Set before during adding
                            StartCoroutine(currStage.StartStage());
                            yield return(new WaitUntil(() => currStage.IsComplete()));

                            // BUGFIX: forcefully set incomplete to allow normal running (else WaitUntil in next loop will NOT work)
                            currStage.SetComplete(false);
                        }
                    }
                }
                break;
            }

            default:
            {
                // Placeholder
                break;
            }
            }

            yield break;
        }