Example #1
0
        // ====================================================================================================================
        // Race start countdown

        private IEnumerator Start()
        {
            yield return(new WaitForSeconds(2f));

            startText.text = "3";
            startAudio.PlayOneShot(startClips[0]);
            yield return(new WaitForSeconds(1f));

            startText.text = "2";
            startAudio.PlayOneShot(startClips[0]);
            yield return(new WaitForSeconds(1f));

            startText.text = "1";
            startAudio.PlayOneShot(startClips[0]);
            yield return(new WaitForSeconds(1f));

            state          = State.Play;
            Time.timeScale = 1f;
            startText.text = "GO";
            startAudio.PlayOneShot(startClips[1]);
            MusicManager.Play(MusicTrack.Race);
            yield return(new WaitForSecondsRealtime(1f));

            startText.text = "";
        }
Example #2
0
        private IEnumerator EndRoutine()
        {
            MusicManager.Play(MusicTrack.None);
            yield return(new WaitForSeconds(1.75f));

            MusicManager.Play(MusicTrack.Results);
            TransitionManager.ToScene(3);
        }
Example #3
0
        private IEnumerator Start()
        {
            AnimatedFloatManager.Add(this, sx, false);
            AnimatedFloatManager.Add(this, sy, false);
            yield return(new WaitForSeconds(1.25f));

            sx.target = sy.target = 1f;
            MusicManager.Play(MusicTrack.Start);
            yield return(new WaitForSeconds(1f));

            acceptInput = true;
        }
        private void Update()
        {
            // If all the beetles are ready, transition to the race scene

            if (!isDone && beetles.All(b => b.IsReady))
            {
                isDone = true;

                foreach (CustomizeBeetle b in beetles)
                {
                    b.BlockInput();
                }

                MusicManager.Play(MusicTrack.None);
                TransitionManager.ToScene(2);
            }
        }
Example #5
0
        public void WormCrashed()
        {
            if (state == State.Play)
            {
                MusicManager.Play(Sound.Crash);
                wormOverlay.Show(placement);

                placement = 1;
                foreach (RaceOverlay o in beetleOverlays)
                {
                    o.Show(placement);
                }

                state = State.End;
                StartCoroutine(EndRoutine());
            }
        }
Example #6
0
        // ====================================================================================================================
        // Race logic / end conditions

        public void BeetleCrashed(int index)
        {
            if (state == State.Play)
            {
                MusicManager.Play(Sound.Crash);
                beetleOverlays[index].Show(placement);
                placement--;

                // If we've reached 1st place, the worm won

                if (placement == 1)
                {
                    wormOverlay.Show(placement);

                    state = State.End;
                    StartCoroutine(EndRoutine());
                }
            }
        }
        private void Awake()
        {
            // Create customizable beetles for each beetle player, give them their indices, and put them in a list

            for (int i = 0; i < Game.BEETLE_COUNT; i++)
            {
                Vector3    p = new Vector3(i * 100, 0, 0);
                GameObject g = Instantiate(beetlePrefab, p, Quaternion.identity);

                CustomizeBeetle b = g.GetComponent <CustomizeBeetle>();
                b.Initialize(i);
                beetles.Add(b);
            }

            // Arrange the cameras (for the customizable beetles / worm) on the screen

            var beetleCameras = beetles.Select(b => b.Camera).ToList();

            Game.ArrangeCameras(beetleCameras, wormCamera);

            // Play the start music in case we're coming from the results scene

            MusicManager.Play(MusicTrack.Start);
        }
Example #8
0
 void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
 {
     MusicManager.Play(Sound.Tick);
 }
Example #9
0
 void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
 {
     MusicManager.Play(Sound.Select);
 }
Example #10
0
        /*public Text labels;
         * public Text results;
         *
         * private void Awake()
         * {
         *  float[] times = Settings.loseTimes;
         *
         *  string l = "";
         *  string r = "";
         *  for (int i = 0; i < times.Length; i++)
         *  {
         *      l += string.Format("Beetle {0}:\n", i + 1);
         *
         *      if (times[i] == -1)
         *          r += "Winner!\n";
         *      else
         *          r += string.Format("{0:.00} s\n", times[i]);
         *  }
         *
         *  Labels.text = l;
         *  Results.text = r;
         * }*/

        public void ToScene(int index)
        {
            MusicManager.Play(MusicTrack.None);
            TransitionManager.ToScene(index);
        }
Example #11
0
        private void Update()
        {
            // Read input

            bool left  = false;
            bool right = false;
            bool up    = false;
            bool down  = false;

            if (acceptInput)
            {
                BeetleControls controls = Game.BEETLE_CONTROLS[index];

                if (controls.useGamepad)
                {
                    float h = Input.GetAxisRaw(controls.hor);
                    float v = Input.GetAxisRaw(controls.ver);

                    left  = (h < -0.5f && h < gamepadHorPrev);
                    right = (h > +0.5f && h > gamepadHorPrev);
                    up    = (v < -0.5f && v < gamepadVerPrev);
                    down  = (v > +0.5f && v > gamepadVerPrev);

                    gamepadHorPrev = h;
                    gamepadVerPrev = v;
                }

                else
                {
                    left  = Input.GetKeyDown(controls.left);
                    right = Input.GetKeyDown(controls.right);
                    up    = Input.GetKeyDown(controls.up);
                    down  = Input.GetKeyDown(controls.down);
                }
            }

            // ====================================================================================

            // Allow customization

            switch (state)
            {
            case State.ModelSelect:

                messageText.text = "CHOOSE A MODEL";

                if (down)
                {
                    state = State.PaletteSelect;
                }
                else
                {
                    int cur = Game.BEETLE_MODEL_CHOICE[index];
                    int add = (right ? 1 : 0) - (left ? 1 : 0);
                    int len = data.models.Length;

                    Game.BEETLE_MODEL_CHOICE[index] = (cur + add + len) % len;

                    if (add != 0)
                    {
                        visuals.UpdateAppearance();
                        visuals.Jiggle(Mathf.Abs(add) * -0.05f);

                        MusicManager.Play(Sound.Tick);
                        messageX.velocity += add * 10f;
                    }
                }

                break;

            case State.PaletteSelect:

                messageText.text = "CHOOSE A PALETTE";

                if (down)
                {
                    state = State.Ready;
                }
                else if (up)
                {
                    state = State.ModelSelect;
                }
                else
                {
                    int cur = Game.BEETLE_PALETTE_CHOICE[index];
                    int add = (right ? 1 : 0) - (left ? 1 : 0);
                    int len = data.palettes.Length;

                    Game.BEETLE_PALETTE_CHOICE[index] = (cur + add + len) % len;

                    if (add != 0)
                    {
                        visuals.UpdateAppearance();
                        visuals.Jiggle(Mathf.Abs(add) * -0.05f);

                        MusicManager.Play(Sound.Tick);
                        messageX.velocity += add * 10f;
                    }
                }

                break;

            case State.Ready:

                messageText.text = "READY!";

                if (up)
                {
                    state = State.PaletteSelect;
                }
                break;
            }

            if (up != down)
            {
                MusicManager.Play(Sound.Select);
                messageY.velocity += (up ? 5f : 0f) - (down ? 5f : 0f);
            }

            // ====================================================================================

            visuals.transform.rotation = Quaternion.Euler(0, index * 120f + Time.time * 20f, 0);
            messageText.rectTransform.anchoredPosition = new Vector2(messageX, messageY - 25);
        }