예제 #1
0
        public override void OnPlayerPropertiesUpdate(Player targetPlayer, ExitGames.Client.Photon.Hashtable changedProps)
        {
            if (changedProps.ContainsKey(PunSettings.PropertiesKeyList.PlayerStateKey))
            {
                _rpcState.CheckState();
            }
            if ((int)_rpcState.RoomRPCAwaitState < (int)RPCAwaitStateList.FirstInMain)
            {
                return;
            }
            Debug.Log("PlayerPropertiesUpdate" + targetPlayer + " : " + changedProps);

            var gotFlag = (int)changedProps[PunSettings.PropertiesKeyList.FlagKey];

            _scoreManager.SortMemberScore(targetPlayer, gotFlag);


            var nowFlagNum = (int)changedProps[PunSettings.PropertiesKeyList.NowFlagKey];

            _flagManager.FlagNumJudge(targetPlayer, nowFlagNum);

            _flagManager.ChangeRoomFlagNum(targetPlayer);
            if (targetPlayer.IsLocal)
            {
                var flagInterval = (bool)changedProps[PunSettings.PropertiesKeyList.FlagIntervalKey];
                _flagManager.FlagSteelInterval(flagInterval);
            }

            //↓playerは旗を取られたプレイヤー
            //var player = (Player)changedProps[PunSettings.PropertiesKeyList.StolenPlayerKey];
            //if (player!=null&&player.IsLocal)
            //{
            //    BGMManager.Instance.Play(BGMPath.STOLEN);
            //}
            if ($"BGM/{BGMManager.Instance.GetCurrentAudioNames()[0]}" == BGMPath.STEAL &&
                PhotonNetwork.LocalPlayer.CustomProperties[PunSettings.PropertiesKeyList.StolenPlayerKey] != null)
            {
                return;
            }

            Player[] playerArray = PhotonNetwork.PlayerList;
            var      IsStolen    = playerArray
                                   .Select(x => (Player)x.CustomProperties[PunSettings.PropertiesKeyList.StolenPlayerKey])
                                   .Where(x => x != null)
                                   .Any(x => x.IsLocal);
            var bgm = IsStolen ? BGMPath.STOLEN : BGMPath.SUNRISE;

            if ($"BGM/{BGMManager.Instance.GetCurrentAudioNames()[0]}" == bgm)
            {
                return;
            }
            BGMManager.Instance.Play(bgm);
            //foreach (var x in playerArray)
            //{
            //    var p = (Player)x.CustomProperties[PunSettings.PropertiesKeyList.StolenPlayerKey];
            //    if (p == null) continue;
            //    if (p.IsLocal)
            //    {
            //        BGMManager.Instance.Play(BGMPath.STOLEN);
            //        break;
            //    }
            //    BGMManager.Instance.Play(BGMPath.SUNRISE);
            //}
        }