Exemplo n.º 1
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.K))
        {
            ForceEnd();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            StartGame();
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            if (lastManRingCanons != null)
            {
                Destroy(lastManRingCanons.gameObject);
                lastManRingCanons = null;
            }

            lastManRingCanons = Instantiate(ringCanonMasterPrefab, Vector3.zero, Quaternion.identity).GetComponent <RingCanonMaster>();
            lastManRingCanons.CreateCanons();
        }

        //Create rings by time
        if (State.Equals(GameState.LastManStanding))
        {
            if (lastManRingCanons == null && ring.Radius < ring.MinRadiusSize + 0.1f)
            {
                lastManRingCanons = Instantiate(ringCanonMasterPrefab, Vector3.zero, Quaternion.identity).GetComponent <RingCanonMaster>();
                lastManRingCanons.CreateCanons();
            }
        }
    }
Exemplo n.º 2
0
    public void PlayerKilled()
    {
        int alive = 0;
        PlayerController lastAlive = null;

        foreach (var item in players)
        {
            if (item.Value.IsAlive)
            {
                lastAlive = item.Value;
                alive++;
            }
        }

        if (State.Equals(GameState.LastManStanding) && alive == 1)
        {
            //Game Ends
            GameEnds(lastAlive);
            return;
        }
        else if (State.Equals(GameState.PlayersVsPlayerBoss) && alive == 1)
        {
            GameEnds(null);
        }
        else if (State.Equals(GameState.PlayersVsLastBoss) && alive == 0)
        {
            GameEnds(null);
        }

        //Cache first dead
        if (firstBloodedPlayer == null)
        {
            foreach (var item in players)
            {
                if (!item.Value.IsAlive)
                {
                    firstBloodedPlayer = item.Value;
                }
            }
        }


        if (State.Equals(GameState.LastManStanding) && alive < 5 && lastManRingCanons == null)
        {
            lastManRingCanons = Instantiate(ringCanonMasterPrefab, Vector3.zero, Quaternion.identity).GetComponent <RingCanonMaster>();
            lastManRingCanons.CreateCanons();
        }
    }
Exemplo n.º 3
0
    public void WeakPointDamage(float amount)
    {
        if (!GameManager.Instance.IsGameActive)
        {
            return;
        }

        HP -= amount;
        if (HP <= 0f)
        {
            //Dead
            IsAlive = false;
            GameManager.Instance.PlayerBossKilled();
            this.gameObject.SetActive(false);
            //Spawn particles
            GameObject             go     = Instantiate(destroyedParticlesPrefab, transform.position, transform.rotation);
            ParticleColorChanger[] colors = go.GetComponentsInChildren <ParticleColorChanger>();
            for (int i = 0; i < colors.Length; i++)
            {
                colors[i].Init(this);
            }
            Destroy(go, 1.5f);
        }
        else //Still alive
        {
            OnHPUpdate();

            if (colorRoutine != null)
            {
                StopCoroutine(colorRoutine);                     //Stop if there is a routine running
            }
            colorRoutine = StartCoroutine(ColorDamageRoutine()); //Start new one


            if (smallInnerCanons == null && (HP / startHP) < 0.5f)
            {
                smallInnerCanons = Instantiate(smallInnerCanonsPrefab, Vector3.zero, Quaternion.identity).GetComponent <RingCanonMaster>();
                smallInnerCanons.CreateCanons();
            }

            //if(outerCanons == null && (HP / startHP) < 0.2f)
            //{
            //    outerCanons = Instantiate(outerCanonsPrefab, Vector3.zero, Quaternion.identity).GetComponent<RingCanonMaster>();
            //    outerCanons.CreateCanons();
            //}
        }
    }
Exemplo n.º 4
0
    IEnumerator StartGameRoutine()
    {
        if (!isTitleHidden)
        {
            isTitleHidden = true;
            titleView.Hide();
            yield return(new WaitForSeconds(0.4f));
        }

        //Flash
        flashView.Show();                       //0.2f to show, and 0.2f to hide
        yield return(new WaitForSeconds(0.2f)); //Let flash finish on all screen


        SpawnAIs(); //SpawnAIs if needed

        //Clean
        Bullet[] bullets = FindObjectsOfType <Bullet>();
        for (int i = 0; i < bullets.Length; i++)
        {
            if (bullets[i].gameObject.activeInHierarchy)
            {
                ObjectPool.Instance.SaveObjectToPool(bullets[i].gameObject);
            }
        }

        ring.Restart();
        if (lastManRingCanons != null)
        {
            Destroy(lastManRingCanons.gameObject);
            lastManRingCanons = null;
        }

        HealAll();
        RepositionPlayers();


        //Change Mode
        if (State.Equals(GameState.Initializing))
        {
            MusicController.Instance.PlayNormalMusic(0.1f);
            State = GameState.LastManStanding;
            //Change View
            yield return(StartCoroutine(lastManStandingCounter.StartCountRoutine(null)));

            MusicController.Instance.PlayClip(0.6f, 4f);
        }
        else if (State.Equals(GameState.LastManStanding) && lastManStandingCounts >= 3)
        {
            State = GameState.PlayersVsPlayerBoss;

            //Change View
            yield return(StartCoroutine(playerBossCounter.StartCountRoutine(null)));

            //Flash
            flashView.Show();                       //0.2f to show, and 0.2f to hide
            yield return(new WaitForSeconds(0.2f)); //Let flash finish on all screen
        }
        else if (State.Equals(GameState.PlayersVsPlayerBoss) && (playerBossKilledWin || playersVsBossPlayerCounts >= 1))
        {
            State = GameState.PlayersVsLastBoss;

            if (bossPlayer != null)
            {
                Destroy(bossPlayer.gameObject);
                bossPlayer = null;
                players[firstBloodedPlayer.DeviceId] = firstBloodedPlayer;
                firstBloodedPlayer.gameObject.SetActive(true);
            }
            RepositionPlayers();

            MusicController.Instance.StopClip(3f);

            //Introduction dialogue
            yield return(StartCoroutine(bossDialogueBox.StartRoutine("Are you having fun...", null, 0.5f)));

            yield return(StartCoroutine(bossDialogueBox.StartRoutine("... Player?", null)));

            yield return(StartCoroutine(bossDialogueBox.StartRoutine("LET", null, 0.5f)));

            yield return(StartCoroutine(bossDialogueBox.StartRoutine("ME", null, 0.5f)));

            yield return(StartCoroutine(bossDialogueBox.StartRoutine("JOIN", null, 0.5f)));

            yield return(new WaitForSeconds(0.5f));

            //Flash
            flashView.Show();                       //0.2f to show, and 0.2f to hide
            yield return(new WaitForSeconds(0.2f)); //Let flash finish on all screen

            postProcessVolume.profile = finalProfile;
        }
        else if (State.Equals(GameState.PlayersVsLastBoss) && (finalBossKilledWin || finalBossCounts >= 3))
        {
            MusicController.Instance.StopClip(0.5f);
            //Boss dialogues
            yield return(StartCoroutine(bossDialogueBox.StartRoutine("Oh no. Did you really think you could WIN?", null)));

            yield return(StartCoroutine(hahaView.StartCountRoutine(null))); //HA HA

            finalBoss.Heal(15000);
            yield return(StartCoroutine(bossDialogueBox.StartRoutine("It's my world...", null, 0.5f)));

            yield return(StartCoroutine(bossDialogueBox.StartRoutine("... Player", null, 1f)));

            yield return(StartCoroutine(bossDialogueBox.StartRoutine("And, in my world, I do what I wish", null)));

            //Kill all players
            yield return(new WaitForSeconds(1f));

            foreach (var item in players)
            {
                item.Value.HardKill();
            }
            yield return(new WaitForSeconds(1f));

            //HA HA HA HA HA HA
            yield return(StartCoroutine(bossDialogueBox.StartRoutine("HA HA HA HA HA HA HA...", null, 0.1f)));

            //Obscure screen. Ready for credits
            gameOverView.Show();

            State = GameState.Credits;

            postProcessVolume.profile = normalProfile;
        }

        bool willGameActivate = true;

        if (State.Equals(GameState.LastManStanding))
        {
            lastManStandingCounts++;
        }
        else if (State.Equals(GameState.PlayersVsPlayerBoss))
        {
            if (bossPlayer == null)
            {
                //Instantiate player prefab, store device id + player script in a dictionary
                GameObject bossPlayerGo = Instantiate(playerBossPrefab, Vector3.zero, Quaternion.Euler(0f, 0f, -90f)) as GameObject;
                bossPlayer = bossPlayerGo.GetComponent <BossPlayer>();

                //Replace
                players[firstBloodedPlayer.DeviceId] = bossPlayer;

                //Set position and color
                bossPlayer.SetColor(firstBloodedPlayer.myColor);
                bossPlayer.SetDeviceId(firstBloodedPlayer.DeviceId);

                //Unactive old
                firstBloodedPlayer.gameObject.SetActive(false);
            }

            bossPlayer.ForceCenterLook();
            bossPlayer.transform.position = Vector3.zero;
            playersVsBossPlayerCounts++;
        }
        else if (State.Equals(GameState.PlayersVsLastBoss))
        {
            //Create Final Boss
            if (finalBoss == null)
            {
                GameObject finalBossGo = Instantiate(finalBossPrefab, Vector3.zero, Quaternion.Euler(0f, 0f, 0f)) as GameObject;
                finalBoss = finalBossGo.GetComponent <FinalBoss>();

                //Its show time
                yield return(StartCoroutine(finalBossTitle.StartCountRoutine(null)));

                MusicController.Instance.PlayBossMusic(0.75f);
            }

            finalBoss.Heal(15000);

            finalBossCounts++;
        }
        else if (State.Equals(GameState.Credits)) //Credits
        {
            //Delete boss
            if (finalBoss != null)
            {
                Destroy(finalBoss.gameObject);
                //Its show time
            }

            State = GameState.Initializing;
            lastManStandingCounts     = 0;
            playersVsBossPlayerCounts = 0;
            finalBossCounts           = 0;
            firstBloodedPlayer        = null;

            yield return(new WaitForSeconds(5f));

            gameOverView.Hide();

            creditsView.Show();//Show credits
            yield return(new WaitForSeconds(0.5f));

            yield return(new WaitForSeconds(10f)); //Wait

            creditsView.Hide();                    //Hide
            willGameActivate = false;
            Invoke("StartGame", 1f);
        }

        if (willGameActivate)
        {
            mainCounter.StartCount(ActivateGame);
        }
    }