Example #1
0
    /// <summary>
    ///
    /// </summary>
    public void LeftOfRoom()
    {
#if ULSP
        if (DataBase != null)
        {
            Player p = PhotonNetwork.LocalPlayer;
            DataBase.SaveData(p.GetPlayerScore(), p.GetKills(), p.GetDeaths());
            DataBase.StopAndSaveTime();
        }
#endif
        //Good place to save info before reset statistics
        if (PhotonNetwork.IsConnected)
        {
            PhotonNetwork.LeaveRoom();
        }
        else
        {
            bl_UtilityHelper.LoadLevel(bl_GameData.Instance.MainMenuScene);
        }
    }
Example #2
0
    /// <summary>
    ///
    /// </summary>
    public void CollectData()
    {
        int kills  = PhotonNetwork.LocalPlayer.GetKills();
        int deaths = PhotonNetwork.LocalPlayer.GetDeaths();
        int score  = PhotonNetwork.LocalPlayer.GetPlayerScore();
        int kd     = kills;

        if (kills <= 0)
        {
            kd = -deaths;
        }
        else if (deaths > 0)
        {
            kd = kills / deaths;
        }
        int  timePlayed   = Mathf.RoundToInt(bl_GameManager.Instance.PlayedTime);
        int  scorePerTime = timePlayed * bl_GameData.Instance.ScoreReward.ScorePerTimePlayed;
        int  hsscore      = bl_GameManager.Instance.Headshots * bl_GameData.Instance.ScoreReward.ScorePerHeadShot;
        bool winner       = false;

        if (!isOneTeamMode)
        {
            if (bl_RoomSettings.Instance.Team_1_Score > bl_RoomSettings.Instance.Team_2_Score)
            {
                if (PhotonNetwork.LocalPlayer.GetPlayerTeam() == Team.Delta)
                {
                    winner = true;
                }
            }
            else if (bl_RoomSettings.Instance.Team_1_Score < bl_RoomSettings.Instance.Team_2_Score)
            {
                if (PhotonNetwork.LocalPlayer.GetPlayerTeam() == Team.Recon)
                {
                    winner = true;
                }
            }
        }
        else
        {
            if (bl_RoomSettings.Instance.GetWinnerName == PhotonNetwork.NickName)
            {
                winner = true;
            }
        }
        int winScore = (winner) ? bl_GameData.Instance.ScoreReward.ScoreForWinMatch : 0;

        PlayerNameText.text = PhotonNetwork.NickName;
        int tscore = score + winScore + scorePerTime;

        int coins = 0;

        if (tscore > 0 && bl_GameData.Instance.VirtualCoins.CoinScoreValue > 0 && tscore > bl_GameData.Instance.VirtualCoins.CoinScoreValue)
        {
            coins = tscore / bl_GameData.Instance.VirtualCoins.CoinScoreValue;
        }

#if LOCALIZATION
        KillsText.text      = string.Format("{0}: <b>{1}</b>", bl_Localization.Instance.GetText(126).ToUpper(), kills);
        DeathsText.text     = string.Format("{0}: <b>{1}</b>", bl_Localization.Instance.GetTextPlural(58).ToUpper(), deaths);
        ScoreText.text      = string.Format("{0}: <b>{1}</b>", bl_Localization.Instance.GetText(58).ToUpper(), score - hsscore);
        WinScoreText.text   = string.Format(bl_Localization.Instance.GetText(61), winScore);
        KDRText.text        = string.Format("{0}\n<size=10>KDR</size>", kd);
        TimePlayedText.text = string.Format("{0} <b>{1}</b> +{2}", bl_Localization.Instance.GetText(60).ToUpper(), bl_UtilityHelper.GetTimeFormat((float)timePlayed / 60, timePlayed), scorePerTime);
        HeadshotsText.text  = string.Format("{0} <b>{1}</b> +{2}", bl_Localization.Instance.GetTextPlural(16).ToUpper(), bl_GameManager.Instance.Headshots, hsscore);
        TotalScoreText.text = string.Format("{0}\n<size=9>{1}</size>", tscore, bl_Localization.Instance.GetText(35).ToUpper());
#else
        KillsText.text      = string.Format("{0}: <b>{1}</b>", bl_GameTexts.Kills.ToUpper(), kills);
        DeathsText.text     = string.Format("{0}: <b>{1}</b>", bl_GameTexts.Deaths.ToUpper(), deaths);
        ScoreText.text      = string.Format("{0}: <b>{1}</b>", bl_GameTexts.Score.ToUpper(), score - hsscore);
        WinScoreText.text   = string.Format(bl_GameTexts.WinMatch, winScore);
        KDRText.text        = string.Format("{0}\n<size=10>KDR</size>", kd);
        TimePlayedText.text = string.Format("{0} <b>{1}</b> +{2}", bl_GameTexts.TimePlayed.ToUpper(), bl_UtilityHelper.GetTimeFormat((float)timePlayed / 60, timePlayed), scorePerTime);
        HeadshotsText.text  = string.Format("{0} <b>{1}</b> +{2}", bl_GameTexts.HeadShot.ToUpper(), bl_GameManager.Instance.Headshots, hsscore);
        TotalScoreText.text = string.Format("{0}\n<size=9>{1}</size>", tscore, bl_GameTexts.TotalScore.ToUpper());
        CoinsText.text      = string.Format("+{0}\n<size=9>COINS</size>", coins);
#endif

#if ULSP
        DataBase = bl_DataBase.Instance;
        if (DataBase != null)
        {
            Player p = PhotonNetwork.LocalPlayer;
            DataBase.SaveData(tscore, p.GetKills(), p.GetDeaths());
            DataBase.StopAndSaveTime();
            if (coins > 0)
            {
                DataBase.SaveNewCoins(coins);
            }
#if CLANS
            DataBase.SetClanScore(score);
#endif
        }
#else
        if (coins > 0)
        {
            bl_GameData.Instance.VirtualCoins.SetCoins(coins, PhotonNetwork.NickName);
        }
#endif
    }