void DisplayKillGround(int threwTheBomb, int op1, int op2, int op3, int op4)
    {
        PlayerController gotKillPlayer = null;

        PlayerController[]      players     = GameObject.FindObjectsOfType <PlayerController> ();
        List <PlayerController> deadPlayers = new List <PlayerController> ();

        foreach (var p in players)
        {
            if (p.playerID == sb.ownerID)
            {
                gotKillPlayer = p;
            }
            if (p.playerID == op1)
            {
                deadPlayers.Add(p);
            }
            else if (p.playerID == op2)
            {
                deadPlayers.Add(p);
            }
            else if (p.playerID == op3)
            {
                deadPlayers.Add(p);
            }
            else if (p.playerID == op4)
            {
                deadPlayers.Add(p);
            }
        }

        foreach (PlayerController dp in deadPlayers)
        {
            dp.isStuck           = false;
            dp.gameObject.active = false;
            if (dp != gotKillPlayer)
            {
                gotKillPlayer.myStats.Kills++;
            }
            dp.myStats.Deaths++;
        }

        players = GameObject.FindObjectsOfType <PlayerController>();
        if (players.Length == 1 && PhotonNetwork.playerList.Length != 1)
        {
            PopText.Create("ROUND OVER - P" + gotKillPlayer.playerID.ToString() + " WINS!", Color.white, 250,
                           new Vector3(0, 4, 1));
            gotKillPlayer.myStats.RoundsWon++;
            GameObject.FindObjectOfType <GameCamera>().RoundOver();
        }
        else if (deadPlayers.Count == 1)
        {
            if (deadPlayers[0].playerID == gotKillPlayer.playerID)
            {
                PopText.Create("P" + deadPlayers[0].playerID.ToString() + " killed himself.", Color.white, 250,
                               new Vector3(0, 4, 1));

                if (players.Length == 0)
                {
                    //PopText.Create ("ROUND OVER - Tie!", Color.white, 250,
                    //new Vector3(0, 4, 1));
                    GameObject.FindObjectOfType <GameCamera>().RoundOver();
                }
            }
            else
            {
                PopText.Create("P" + deadPlayers[0].playerID.ToString() + " was killed by P" + gotKillPlayer.playerID.ToString(), Color.white, 250,
                               new Vector3(0, 4, 1));
            }
        }
        else if (players.Length == 0)
        {
            PopText.Create("ROUND OVER - Tie!", Color.white, 250,
                           new Vector3(0, 4, 1));
            GameObject.FindObjectOfType <GameCamera>().RoundOver();
        }
        else if (deadPlayers.Count > 1)
        {
            PopText.Create("P" + gotKillPlayer.playerID.ToString() + " got a " + deadPlayers.Count.ToString() + " player multikill!", Color.white, 250,
                           new Vector3(0, 4, 1));
        }

        this.gameObject.active = false;
    }
 void DisplayCountdown(int num)
 {
     PopText.Create(num.ToString(), Color.white, 60, transform.position + Vector3.up * .5f);
 }
Ejemplo n.º 3
0
 public void ClickJoin()
 {
     AudioSource.PlayClipAtPoint(click, this.transform.position);
     PhotonNetwork.JoinRoom(roomName.text);
     PopText.Create("Joining room \"" + roomName.text + "\"...", Color.white, 200, this.transform.position);
 }
Ejemplo n.º 4
0
 private void PopText_Initialized(object sender, EventArgs e)
 {
     PopText.Add((TextBox)sender);
 }
Ejemplo n.º 5
0
    void FixedUpdate()
    {
        if (!gamePaused)
        {
            PlayerController[] players = GameObject.FindObjectsOfType <PlayerController> ();
            for (int i = 0; i < players.Length; i++)
            {
                if (players [i].isPaused)
                {
                    gamePaused = true;
                }
            }
            if (sb == null)
            {
                sb = GetComponent <StickyBomb> ();
            }

            if (sb.isStuck)
            {
                PopText.Create("o", Color.cyan, 30, this.transform.position);
                countdownTimer--;

                if (countdownTimer % 60 == 0)
                {
                    LOCAL_DisplayCountdown(countdownTimer / 60);
                }

                if (countdownTimer == 0)
                {
                    bool lastBomb = true;

                    StickyBomb[] allStickys = GameObject.FindObjectsOfType <StickyBomb> ();
                    if (allStickys.Length > 1)
                    {
                        lastBomb = false;
                    }
                    if (PlayerController.SomeoneHasSticky())
                    {
                        lastBomb = false;
                    }

                    Blowup();
                    GameObject.Destroy(this.gameObject);

                    PlayerController stuckPlayer   = null;
                    PlayerController gotKillPlayer = null;

                    foreach (var p in players)
                    {
                        if (p.playerID == sb.stuckID)
                        {
                            stuckPlayer = p;
                        }
                        if (p.playerID == sb.ownerID)
                        {
                            gotKillPlayer = p;
                        }
                    }

                    if (stuckPlayer.GetComponent <BigBoy> () != null &&
                        !stuckPlayer.GetComponent <BigBoy> ().alreadyHit)
                    {
                        //take away a life but dont kill him
                        BigBoyHit(stuckPlayer.playerID, gotKillPlayer.playerID);
                    }
                    else
                    {
                        if (stuckPlayer != null && gotKillPlayer != null)
                        {
                            DisplayKill(stuckPlayer.playerID, gotKillPlayer.playerID);
                        }
                    }

                    //check to see if we should spawn a crate
                    players = GameObject.FindObjectsOfType <PlayerController> ();
                    if (players.Length == 1)
                    {
                        //dont spawn crate
                        Debug.Log("DIDNT SPAWN CRATE BECAUSE ONLY ONE PLAYER!");
                    }
                    else if (lastBomb)
                    {
                        //spawn crate
                        GameObject crate = (GameObject)GameObject.Instantiate(localCratePrefab,
                                                                              GameObject.FindObjectOfType <GameCamera> ().GetRandomSpawnPoint(), Quaternion.identity);
                    }

                    GameObject.FindObjectOfType <GameCamera> ().UpdateStatsLocal();
                }

                if (justTransfered)
                {
                    justTransferedTimer--;

                    if (justTransferedTimer == 0)
                    {
                        justTransfered = false;
                    }
                }
            }
            else if (sb.hitGround)
            {
                groundedTimer--;

                if (groundedTimer % 60 == 0)
                {
                    LOCAL_DisplayCountdown(groundedTimer / 60);
                }

                if (groundedTimer <= 180 && groundedTimer % 30 == 0)
                {
                    Bursting(bursting);
                    bursting = !bursting;
                }

                if (groundedTimer == 0)
                {
                    bool lastBomb = true;

                    StickyBomb[] allStickys = GameObject.FindObjectsOfType <StickyBomb> ();
                    if (allStickys.Length > 1)
                    {
                        lastBomb = false;
                    }
                    if (PlayerController.SomeoneHasSticky())
                    {
                        lastBomb = false;
                    }

                    Blowup();

                    PlayerController stuckPlayer   = null;
                    PlayerController gotKillPlayer = null;

                    foreach (var p in players)
                    {
                        if (p.playerID == sb.stuckID)
                        {
                            stuckPlayer = p;
                        }
                        if (p.playerID == sb.ownerID)
                        {
                            gotKillPlayer = p;
                        }
                    }

                    int[] hits = new int[] { -1, -1, -1, -1 };
                    int[] pID  = new int[] { -1, -1, -1, -1 };
                    for (int i = 0; i < players.Length; ++i)
                    {
                        PlayerController p = players [i];
                        //pID[i] = p.playerID;
                        if (Vector3.Distance(this.transform.position, p.transform.position) < 1.8f)
                        {
                            hits [i] = p.playerID;
                        }
                    }

                    if (gotKillPlayer != null)
                    {
                        DisplayKillGround(gotKillPlayer.playerID,
                                          hits [0], hits [1], hits [2], hits [3]);
                    }

                    //check to see if we should spawn a crate
                    players = GameObject.FindObjectsOfType <PlayerController> ();
                    if (players.Length == 1)
                    {
                        //dont spawn crate, round is over
                    }
                    else if (lastBomb)                    //only spawn a crate if all the bombs are gone (there might be a scientist on the map)
                    {
                        GameObject crate = (GameObject)GameObject.Instantiate(localCratePrefab,
                                                                              GameObject.FindObjectOfType <GameCamera> ().GetRandomSpawnPoint(), Quaternion.identity);
                    }
                }
            }
            else if (!sb.hitGround)
            {
                PopText.Create("o", Color.cyan, 30, this.transform.position);
            }
        }

        else
        {
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            for (int i = 0; i < players.Length; i++)
            {
                if (players [i].GetComponent <PlayerController> ().isPaused)
                {
                    gamePaused = false;
                }
            }
        }
    }
Ejemplo n.º 6
0
 void LOCAL_DisplayCountdown(int num)
 {
     PopText.Create(num.ToString(), Color.white, 60, transform.position + Vector3.up * .5f);
     AudioSource.PlayClipAtPoint(countdownSound, GameObject.FindObjectOfType <GameCamera>().transform.position);
 }