예제 #1
0
    // Update is called once per frame
    void Update()
    {
        dieTimer += Time.deltaTime;
        if (dieTimer > 4)
        {
            fader -= Time.deltaTime;

            guiText.color = new Color(guiText.color.r, guiText.color.g, guiText.color.b, fader);

            if (fader <= 0)
            {
                GameManager.Instance.PlayingState = PlayingState.Playing;
                Destroy(guiText);
                Destroy(this);
            }
        }

        if (timer > 0)
        {
            timer     -= Time.deltaTime;
            textToShow = ready + timer.ToString("F2");
        }
        else
        {
            textToShow = go;
            timer      = 0;
            if (!hasShaken)
            {
                GoKitTweenExtensions.shake(transform, 1.5f, new Vector3(0.2f, 0.2f, 0f), GoShakeType.Position);
                hasShaken = true;
            }
        }

        guiText.text = textToShow;
    }
예제 #2
0
    private void Start()
    {
        missionFirstTimeDisplaying = true;
        targetFirstTimeDisplaying  = true;
        isDisplayingMissionOrTargetRumbleRightNow = false;

        GoKitTweenExtensions.shake(Camera.main.transform, 0.5f, new Vector3(1, 1, 1), GoShakeType.Position);
    }
예제 #3
0
    void Update()
    {
        if (GameManager.Instance.PlayingState != PlayingState.Playing) // only check if game is playing
        {
            return;
        }

        for (int i = InstantiatedMissions.Count - 1; i >= 0; i--)
        {
            MissionBase m = InstantiatedMissions[i];
            if (m != null)
            {
                if (!m.MissionIsActive) // dont look into inactive missions
                {
                    return;
                }

                if (m.MissionAccomplished()) // look if mission has been accomplished
                {
                    GoKitTweenExtensions.shake(Camera.main.transform, 0.5f, new Vector3(0.2f, 0.2f, 0.2f), GoShakeType.Position);

                    GameObject           g = (GameObject)Instantiate(MissionIsCompletedPrefab);
                    MissionCompletedText t = g.GetComponent <MissionCompletedText>();
                    t.SoundToPlay = m.ChooseCompletedSound();
                    t.ColorToUse  = new Color(m.PlayerScript.PlayerColor.r, m.PlayerScript.PlayerColor.g, m.PlayerScript.PlayerColor.b, 255);
                    DoorGoUpDown();
                    //Debug.Log(string.Format("Player {0} completed mission {1})", m.Player.ToString(), m.ToString()));
                    m.GivePointsToPlayer();
                }
            }
        }

        /*foreach (MissionBase m in InstantiatedMissions)
         * {
         *  if (!m.MissionIsActive) // dont look into inactive missions
         *      return;
         *
         *  if (m.MissionAccomplished()) // look if mission has been accomplished
         *  {
         *      GoKitTweenExtensions.shake(Camera.main.transform, 0.5f, new Vector3(0.2f, 0.2f, 0.2f), GoShakeType.Position);
         *      audio.PlayOneShot(AudioManager.Instance.MissionAccomplishedSound);
         *      Debug.Log(string.Format("{0} mission accomplished ({1} points)", m.ToString(), m.Points));
         *      m.GivePointsToPlayer();
         *  }
         * }*/
    }
예제 #4
0
    void Update()
    {
        if (PlayingState == PlayingState.Playing)
        {
            TimeLeft -= Time.deltaTime;

            if (TimeLeft <= 0 && CurrentRoundJustEnded == false)
            {
                CurrentRoundJustEnded = true;
                PlayingState          = PlayingState.DisplayingScore;
                MissionManager.Instance.RemoveAllMissions();
                GoKitTweenExtensions.shake(Camera.main.transform, 0.5f, new Vector3(0.8f, 0.8f, 0.8f), GoShakeType.Position);

                // TODO: who won?

                int highestScore = -10000;
                int numberOfPeopleWithSameHighScore = 0;

                // check highest score
                TargetIDColorState winningColor = TargetIDColorState.NotAssigned;
                foreach (GameObject g in Players)
                {
                    Player p = g.GetComponent <Player>();
                    if (p.Points >= highestScore)
                    {
                        highestScore = p.Points;
                        winningColor = g.GetComponent <TargetIDColor>().TargetIDColorState;
                    }
                }

                // check if draw
                foreach (GameObject g in Players)
                {
                    Player p = g.GetComponent <Player>();

                    if (p.Points == highestScore)
                    {
                        //Debug.Log(p.ToString() + p.Points);
                        numberOfPeopleWithSameHighScore++;
                    }
                }

                if (numberOfPeopleWithSameHighScore > 1) // draw?
                {
                    winningColor = TargetIDColorState.NotAssigned;
                }

                Destroy(GameObject.Find("Music")); // dont play game music when showing score
                switch (winningColor)
                {
                case TargetIDColorState.RedOne:
                    AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinRed);
                    if (DataSaver.Instance != null)
                    {
                        foreach (var score in DataSaver.Instance.highScores)
                        {
                            score.RedWins++;
                        }
                    }
                    //Debug.Log("Red won");
                    break;

                case TargetIDColorState.BlueTwo:
                    AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinBlue);
                    if (DataSaver.Instance != null)
                    {
                        foreach (var score in DataSaver.Instance.highScores)
                        {
                            score.BlueWins++;
                        }
                    }
                    //Debug.Log("blue won");
                    break;

                case TargetIDColorState.GreenThree:
                    AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinGreen);
                    if (DataSaver.Instance != null)
                    {
                        foreach (var score in DataSaver.Instance.highScores)
                        {
                            score.GreenWins++;
                        }
                    }
                    //Debug.Log("green won");
                    break;

                case TargetIDColorState.PinkFour:
                    AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinPink);
                    if (DataSaver.Instance != null)
                    {
                        foreach (var score in DataSaver.Instance.highScores)
                        {
                            score.PinkWins++;
                        }
                    }
                    //Debug.Log("pink won");
                    break;

                case TargetIDColorState.NotAssigned:
                    AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinDraw);
                    //Debug.Log("draw won");
                    break;
                }
                Instantiate(Congratulations);
                if (DataSaver.Instance != null)
                {
                    DataSaver.Instance.SaveScoresToDataFile();
                }
            }
        }

        /*if (PlayingState == PlayingState.DisplayingScore)
         *  Camera.GetComponent<GlitchEffect>().enabled = true;
         * else
         *  Camera.GetComponent<GlitchEffect>().enabled = false;*/

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            Application.LoadLevel(0);
        }
    }
예제 #5
0
    void Update()
    {
        UpdateControllerStates();

        for (int i = 0; i < 4; ++i)
        {
            ControllerPlayer p = ControllerPlayers[i];

            // check if connected
            if (!p.IsControllerConnected())
            {
                PlaneSlots[i].SetActive(false);
            }
            else
            {
                PlaneSlots[i].SetActive(true);
            }


            if (selected >= 2)
            {
                StartGameText.SetActive(true);

                if (p.ButtonPressedRightNow(ButtonsToPress.Start))
                {
                    StartGameAndFindControllers();
                }
            }
            else
            {
                StartGameText.SetActive(false);
            }


            // can move when thumbstick resets
            if (p.LeftStick().x == 0)
            {
                readyToMoveSlot[i] = true;
            }

            // go right (character select)
            if (p.LeftStick().x > 0.7 && readyToMoveSlot[i] && MyCharacter[i] == null)
            {
                if (currentSlots[i] + 1 <= 3)
                {
                    currentSlots[i]++;
                }
                else
                {
                    currentSlots[i] = 0;
                }

                FourCamerasSpots[i].transform.position = FourSlots[currentSlots[i]].transform.position;

                readyToMoveSlot[i] = false;

                Transform rightArrow = PlaneSlots[i].GetComponent <CharPlaneMenuNav>().ReadyObjects[2].transform;
                rightArrow.localScale = new Vector3(0.2981013f, 0.1465021f, 0.1377661f);
                GoKitTweenExtensions.shake(rightArrow, 0.5f, new Vector3(0.2f, 0.2f, 0.2f), GoShakeType.Scale);

                audio.PlayOneShot(ForwardMenuSound);
            }
            // go left (character select)
            else if (p.LeftStick().x < -0.7 && readyToMoveSlot[i] && MyCharacter[i] == null)
            {
                if (currentSlots[i] - 1 >= 0)
                {
                    currentSlots[i]--;
                }
                else
                {
                    currentSlots[i] = 3;
                }

                FourCamerasSpots[i].transform.position = FourSlots[currentSlots[i]].transform.position;

                readyToMoveSlot[i] = false;

                Transform leftArrow = PlaneSlots[i].GetComponent <CharPlaneMenuNav>().ReadyObjects[1].transform;
                leftArrow.localScale = new Vector3(0.2981013f, 0.1465021f, 0.1377661f);
                GoKitTweenExtensions.shake(leftArrow, 0.5f, new Vector3(0.2f, 0.2f, 0.2f), GoShakeType.Scale);

                audio.PlayOneShot(BackwardMenuSound);
            }

            // character already selected by another player?
            if (CharacterSelect[currentSlots[i]].Selected && CharacterSelect[currentSlots[i]] != MyCharacter[i])
            {
                PlaneSlots[i].renderer.material.color = new Color(0.1f, 0.1f, 0.1f);
                PlaneSlots[i].GetComponent <CharPlaneMenuNav>().CanUseAButtonRightNow(false);
            }
            else if (CharacterSelect[currentSlots[i]] == MyCharacter[i]) // I selected the character
            {
                PlaneSlots[i].renderer.material.color = Color.white;
                PlaneSlots[i].GetComponent <CharPlaneMenuNav>().CanUseAButtonRightNow(false);
            }
            else // character not selected by anybody
            {
                PlaneSlots[i].renderer.material.color = new Color(0.4f, 0.4f, 0.4f);
                PlaneSlots[i].GetComponent <CharPlaneMenuNav>().CanUseAButtonRightNow(true);
            }


            // select character
            if (p.ButtonPressedRightNow(ButtonsToPress.A))
            {
                if (!CharacterSelect[currentSlots[i]].Selected)
                {
                    CharacterSelect[currentSlots[i]].Selected = true;
                    MyCharacter[i] = CharacterSelect[currentSlots[i]];

                    CharacterSelect[currentSlots[i]].PlayerChosenSlot = (int)p.Index;

                    audio.PlayOneShot(SelectSounds[selected]);
                    selected++;



                    PlaneSlots[i].transform.position   = OriginalPositions[i];
                    PlaneSlots[i].transform.localScale = OriginalScales[i];

                    PlaneSlots[i].GetComponent <CharPlaneMenuNav>().SetReadyState(true);

                    GoKitTweenExtensions.shake(PlaneSlots[i].transform, 0.5f, new Vector3(0.2f, 0.2f, 0.2f), GoShakeType.Position);
                }
            }
            // deselect character
            else if (p.ButtonPressedRightNow(ButtonsToPress.B))
            {
                if (CharacterSelect[currentSlots[i]].Selected && CharacterSelect[currentSlots[i]] == MyCharacter[i])
                {
                    audio.PlayOneShot(CancelSound);
                    CharacterSelect[currentSlots[i]].Selected = false;
                    MyCharacter[i] = null;

                    selected--;

                    CharacterSelect[currentSlots[i]].PlayerChosenSlot = -10;


                    PlaneSlots[i].transform.position   = OriginalPositions[i];
                    PlaneSlots[i].transform.localScale = OriginalScales[i];

                    PlaneSlots[i].GetComponent <CharPlaneMenuNav>().SetReadyState(false);

                    GoKitTweenExtensions.shake(PlaneSlots[i].transform, 0.5f, new Vector3(0.1f, 0.1f, 0.1f), GoShakeType.Scale);
                }
            }

            // rotate screen left (controller)
            if (p.ButtonPressedRightNow(ButtonsToPress.LT) || p.ButtonPressedRightNow(ButtonsToPress.LB))
            {
                iTween.RotateBy(gameObject, iTween.Hash("y", -0.25, "easeType", "easeInOutBack", "onstart", "Pitch", "oncomplete", "GlitchNow", "loopType", iTween.LoopType.none, "delay", .4));
            }

            // rotate screen right (controller)
            else if (p.ButtonPressedRightNow(ButtonsToPress.RT) || p.ButtonPressedRightNow(ButtonsToPress.RB))
            {
                iTween.RotateBy(gameObject, iTween.Hash("y", .25, "easeType", "easeInOutBack", "onstart", "Pitch", "oncomplete", "GlitchNow", "loopType", iTween.LoopType.none, "delay", .4));
            }

            // rotate screen left (keyboard)
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                iTween.RotateBy(gameObject, iTween.Hash("y", -0.25, "easeType", "easeInOutBack", "onstart", "Pitch", "oncomplete", "GlitchNow", "loopType", iTween.LoopType.none, "delay", .4));
            }

            // rotate screen right (keyboard)
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                iTween.RotateBy(gameObject, iTween.Hash("y", .25, "easeType", "easeInOutBack", "onstart", "Pitch", "oncomplete", "GlitchNow", "loopType", iTween.LoopType.none, "delay", .4));
            }
        }
        //if (Input.GetKeyDown(KeyCode.RightArrow))
        //  iTween.RotateBy(gameObject, iTween.Hash("y", .25, "easeType", "easeInOutBack", "onstart", "Pitch", "oncomplete","GlitchNow", "loopType", iTween.LoopType.none, "delay", .4));
        //else if (Input.GetKeyDown(KeyCode.LeftArrow))
        //  iTween.RotateBy(gameObject, iTween.Hash("y", -0.25, "easeType", "easeInOutBack", "onstart", "Pitch", "oncomplete","GlitchNow", "loopType", iTween.LoopType.none, "delay", .4));

        // smash-styled rotation ... does notwork

        /*float x = Input.GetAxis("Horizontal");
         * float y = Input.GetAxis("Vertical");
         * Vector3 movement = new Vector3(-y, x, 0);
         * transform.RotateAround(transform.position, movement, 50 * Time.deltaTime);*/

        if (pitch)
        {
            timer += Time.deltaTime * 5;
            float fracJourney = timer / 5;
            float lerp        = Mathf.Lerp(1, 2f, fracJourney);
            MusicAudioSource.pitch = lerp;

            if (MusicAudioSource.pitch >= 2f)
            {
                pitch = false;
                MusicAudioSource.pitch = 1;
                timer = 0;
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        foreach (ControllerPlayer p in ControllerPlayers)
        {
            p.previousState = p.state;
        }
    }