Beispiel #1
0
 private void Update()
 {
     if (mType != FireworkController.LaunchType.None)
     {
         FireworkController.Launch(mType);
         mType = FireworkController.LaunchType.None;
     }
 }
Beispiel #2
0
            private void Update()
            {
                // Use keyboard keys to test launch types
#if UNITY_EDITOR
                if (Input.GetKeyUp(KeyCode.Alpha1))
                {
                    FireworkController.Launch(FireworkController.LaunchType.Single);
                }
                else if (Input.GetKeyUp(KeyCode.Alpha2))
                {
                    FireworkController.Launch(FireworkController.LaunchType.Dud);
                }
                else if (Input.GetKeyUp(KeyCode.Alpha3))
                {
                    FireworkController.Launch(FireworkController.LaunchType.Finale);
                }
                else if (Input.GetKeyUp(KeyCode.Alpha4))
                {
                    FireworkController.Launch(FireworkController.LaunchType.Fuse);
                }
#endif

                // Time to launch!
                float e = Time.realtimeSinceStartup;
                if (mLaunchTime > 0.0f && e - mLaunchTime > launchDelay)
                {
                    switch (mType)
                    {
                    case LaunchType.Dud:

                        // Fire the dud
                        if (dudPrefab != null)
                        {
                            ARScene.Append(dudPrefab);
                        }

                        break;

                    case LaunchType.Finale:

                        // Record the original delay values
                        mFinaleMaxDelay = finaleMaxDelay;
                        mFinaleMinDelay = finaleMinDelay;

                        // Choose a random number of fireworks and start the finale
                        mFinaleCount     = finaleMinCount + (int)(Random.value * Mathf.Abs((float)finaleMaxCount - (float)finaleMinCount));
                        mFinaleStartTime = Time.realtimeSinceStartup;

                        break;

                    case LaunchType.Fuse:

                        // Start the fuse animation
                        ARScene.Append(fusePrefab);
                        break;

                    case LaunchType.Single:

                        // Shoot off a firework
                        ARScene.Append(fireworkPrefab);

                        break;
                    }

                    // Ready for next launch
                    mLaunchTime = 0.0f;
                    mType       = LaunchType.None;
                }

                // Grand finale timing logic
                if (mFinaleStartTime > 0.0f && e - mFinaleStartTime > mFinaleDelay)
                {
                    Launch(LaunchType.Single);
                    mFinaleDelay     = finaleMinDelay + Random.value * (Mathf.Abs(finaleMaxDelay - finaleMinDelay));
                    finaleMaxDelay  *= finaleDelayDecay;
                    finaleMinDelay  *= finaleDelayDecay;
                    mFinaleStartTime = e;
                    --mFinaleCount;
                }

                // Restore delay values when the finale is complete
                if (mFinaleCount <= 0)
                {
                    finaleMaxDelay   = mFinaleMaxDelay;
                    finaleMinDelay   = mFinaleMinDelay;
                    mFinaleStartTime = 0.0f;
                }
            }