Beispiel #1
0
    public AudioClip ChooseCompletedSound()
    {
        TargetIDColorState t = Player.GetComponent <TargetIDColor>().TargetIDColorState;

        if (t == null)
        {
            return(AudioManager.Instance.MissionCompletedDefault);
        }

        switch (t)
        {
        case TargetIDColorState.RedOne:
            return(AudioManager.Instance.MissionCompletedRed);

            break;

        case TargetIDColorState.BlueTwo:
            return(AudioManager.Instance.MissionCompletedBlue);

            break;

        case TargetIDColorState.GreenThree:
            return(AudioManager.Instance.MissionCompletedGreen);

            break;

        case TargetIDColorState.PinkFour:
            return(AudioManager.Instance.MissionCompletedPink);

            break;

        default:
            return(AudioManager.Instance.MissionCompletedDefault);

            break;
        }
    }
Beispiel #2
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);
        }
    }
Beispiel #3
0
    // An abstract function has to be overridden while a virtual function may be overridden.
    public virtual void InitializeMission(GameObject player, MissionBase Template)
    {
        if (Template == null)
        {
            Debug.Log("ERROR, Mission Templates have not been assigned for " + player);
        }

        if (Template.TargetPool.Count <= 0)
        {
            Debug.Log("ERROR - Target pool is empty for " + player);
        }

        // Use specific values
        this.Player       = player;
        this.PlayerScript = player.GetComponent <Player>();

        if (PlayerScript == null)
        {
            Debug.Log("ERROR - mission doesn't have link to player! " + this);
        }

        this._missionIsActive = true;

        this.HowToChooseTarget = Template.HowToChooseTarget;

        this.Target = ChooseRandomTarget(Template);

        // Rumble IDs
        if (Target.GetComponent <TargetIDColor>() == null)
        {
            Debug.Log("ERROR  - target for " + gameObject + " doesn't have a TargetIDColor!");
        }
        this.TargetIDColorState = Target.GetComponent <TargetIDColor>().TargetIDColorState;

        // Use template values
        this.MissionType       = Template.MissionType;
        this.Points            = Template.Points;
        this.MissionIDRumble   = Template.MissionIDRumble;
        this.isInstanceMission = true;

        StopAllRumble();

        if (GameManager.Instance.PlayingState != PlayingState.ControllerCalibration && GameManager.Instance.PlayingState != PlayingState.TalkingBeforeControllerCalibration)
        {
            GameObject Particles = (GameObject)Instantiate(GameManager.Instance.MissionInitializedParticles);
            Particles.GetComponent <MissionParticle>().PlayerToFollow = this;
            GameObject ParticlesClone = (GameObject)Instantiate(GameManager.Instance.MissionInitializedParticles);
            Particles.GetComponent <MissionParticle>().SetUpParticleClone(ParticlesClone, this.Player);
        }
        HasHeardMissionRumble = false;

        //Debug.Log(string.Format("Mission {0} initialized for Player {1} with Target {2}", this, this.Player, this.Target.transform.name));

        ThisButtonPressNumberUp   = 0;
        ThisButtonPressNumberDown = 0;
        TimeSinceReceivedMission  = 0;

        HasHeardMissionAtLeastOneTime = false;

        StartCoroutine(WaitForMissionToGetActive());
    }
Beispiel #4
0
    // An abstract function has to be overridden while a virtual function may be overridden.
    public virtual void InitializeMission(GameObject player, MissionBase Template)
    {
        if (Template == null)
            Debug.Log("ERROR, Mission Templates have not been assigned for " + player);

        if (Template.TargetPool.Count <= 0)
            Debug.Log("ERROR - Target pool is empty for " + player);

        // Use specific values
        this.Player = player;
        this.PlayerScript = player.GetComponent<Player>();

        if (PlayerScript == null)
            Debug.Log("ERROR - mission doesn't have link to player! " + this);

        this._missionIsActive = true;

        this.HowToChooseTarget = Template.HowToChooseTarget;

        this.Target = ChooseRandomTarget(Template);

        // Rumble IDs
        if (Target.GetComponent<TargetIDColor>() == null)
            Debug.Log("ERROR  - target for " + gameObject + " doesn't have a TargetIDColor!");
        this.TargetIDColorState = Target.GetComponent<TargetIDColor>().TargetIDColorState;

        // Use template values
        this.MissionType = Template.MissionType;
        this.Points = Template.Points;
        this.MissionIDRumble = Template.MissionIDRumble;
        this.isInstanceMission = true;

        StopAllRumble();

        if (GameManager.Instance.PlayingState != PlayingState.ControllerCalibration && GameManager.Instance.PlayingState != PlayingState.TalkingBeforeControllerCalibration)
        {
            GameObject Particles = (GameObject)Instantiate(GameManager.Instance.MissionInitializedParticles);
            Particles.GetComponent<MissionParticle>().PlayerToFollow = this;
            GameObject ParticlesClone = (GameObject)Instantiate(GameManager.Instance.MissionInitializedParticles);
            Particles.GetComponent<MissionParticle>().SetUpParticleClone(ParticlesClone, this.Player);
        }
        HasHeardMissionRumble = false;

        //Debug.Log(string.Format("Mission {0} initialized for Player {1} with Target {2}", this, this.Player, this.Target.transform.name));

        ThisButtonPressNumberUp = 0;
        ThisButtonPressNumberDown = 0;
        TimeSinceReceivedMission = 0;

        HasHeardMissionAtLeastOneTime = false;

        StartCoroutine(WaitForMissionToGetActive());
    }