Beispiel #1
0
    private void CheckWin()
    {
        if (playersLastFrame != 5 && playerCount.alivePlayers == 5)
        {
            Debug.Log("Top 5!");
            //Top 5!
            foreach (Transform child in ballManager.parent)
            {
                if (!child.GetChild(0).GetComponent <Ball>().isBot)
                {
                    //Statistics: Top 5 placement
                    dataManager.playerSessionDataArray[child.name].topFives += 1;
                    dataManager.playerTotalDataArray[child.name].topFives   += 1;
                }
            }
        }

        if (playersLastFrame != 2 && playerCount.alivePlayers == 2)
        {
            Debug.Log("Top 2!");
            //Top 2!
            int i = 0;

            foreach (Transform child in ballManager.parent)
            {
                topTwo[i] = child.name;
                i++;
            }
        }

        if (playersLastFrame != 1 && playerCount.alivePlayers == 1)
        {
            gameEnded = true;
            Debug.Log("Game ended!");

            //Player won!
            string lastPlayerName = ballManager.parent.GetChild(0).name;
            if (dataManager.playerTotalDataArray.ContainsKey(lastPlayerName))
            {
                //Statistics: 1st place win
                dataManager.playerSessionDataArray[lastPlayerName].wins += 1;
                dataManager.playerTotalDataArray[lastPlayerName].wins   += 1;

                Debug.Log("Adding score to winner! Name: " + lastPlayerName);
                tempScoreDisplay.AddScore(lastPlayerName, ScoreEvent.PLACE1);
            }

            if (topTwo[0] != null)
            {
                for (int i = 0; i < topTwo.Length; i++)
                {
                    if (topTwo[i] != ballManager.parent.GetChild(0).name)
                    {
                        //2nd place identified

                        //If the ball has loaded data, which only players joining through twitch.tv do
                        if (dataManager.playerSessionDataArray.ContainsKey(topTwo[i]))
                        {
                            //Statistics: 2nd place
                            dataManager.playerSessionDataArray[topTwo[i]].secondPlaces += 1;
                            dataManager.playerTotalDataArray[topTwo[i]].secondPlaces   += 1;

                            Debug.Log("Adding score to first loser! Name: " + topTwo[i]);
                            tempScoreDisplay.AddScore(topTwo[i], ScoreEvent.PLACE2);
                        }
                    }
                }
            }
        }

        playersLastFrame = playerCount.alivePlayers;
    }
Beispiel #2
0
    /// <summary>
    /// Kills are posted by the dead player.
    /// </summary>
    public void PostKill(string killed, string killer)
    {
        if (!started)
        {
            killFeed.transform.parent.GetComponent <Image>().enabled = true;
        }

        //If it's a bot
        if (!dataManager.playerSessionDataArray.ContainsKey(killer))
        {
            return; //Give no points
        }

        // Kill is determined to be posted beyond this point, so run InitMessage();
        InitMessage();

        bool defaultKill = true;

        if (killed == tempScoreDisplay.bountyName)
        {
            tempScoreDisplay.AddScore(killer, ScoreEvent.BOUNTYKILL);
            killFeed.text = killFeed.text + "-v- BOUNTY KILL -v-" + "\n";
            defaultKill   = false;
        }

        if (playerCount.alivePlayers == playerCount.totalPlayers)
        {
            tempScoreDisplay.AddScore(killer, ScoreEvent.FIRSTBLOOD);
            killFeed.text = killFeed.text + "-v- FIRST BLOOD -v-" + "\n";
            defaultKill   = false;
        }

        //Return if player killed itself (with bomb, for example)
        if (killer == killed)
        {
            killFeed.text = killFeed.text + killed + " " + selfDestruct;
            return;
        }

        if (defaultKill && playerCount.alivePlayers > 1)
        {
            tempScoreDisplay.AddScore(killer, ScoreEvent.KILL);
        }

        //chatBox.text = chatBox.text + "\n" + String.Format("{0}: {1}", chatName, message);
        if (killed == "")
        {
            killed = "nobody??";
        }

        if (killer == "")
        {
            killFeed.text = killFeed.text + killed + " " + selfDestruct;
            return;
        }


        killFeed.text = killFeed.text + killer + " " + killArrow + " " + killed;

        if (playerCount.alivePlayers == 1)
        {
            return;
        }

        ExitMessage();
    }