Beispiel #1
0
    private void ProcessSyncData(GameSyncMessage syncMessage)
    {
        // 플레이어 데이터 동기화
        int index = 0;

        if (players == null)
        {
            Debug.LogError("Player Poll is null!");
            return;
        }
        foreach (var player in players)
        {
            // 이 부분에서 모든 플레이어의 데이트를 동기화함
            if (!player.Value.isMe)
            {
                Debug.Log(player.Value.gameObject.name + " : 셋팅");

                // 그냥 여기에는 그 적의 모든 스탯을 대입만 해주면 됨 ㅇㅋ?
                player.Value.Stats.MaxHp                   = syncMessage.MaxHp[index];
                player.Value.Stats.CurHp                   = player.Value.Stats.MaxHp;
                player.Value.Stats.Armor                   = syncMessage.Armor[index];
                player.Value.Stats.Stamina                 = syncMessage.Stamina[index];
                player.Value.Stats.ReductionStamina        = syncMessage.ReductionStamina[index];
                player.Value.Stats.WeakAttackDamage        = syncMessage.WeakAttackDamage[index];
                player.Value.Stats.WeakAttackStun          = syncMessage.WeakAttackStun[index];
                player.Value.Stats.WeakAttackPenetration   = syncMessage.WeakAttackPenetration[index];
                player.Value.Stats.StrongAttackDamage      = syncMessage.StrongAttackDamage[index];
                player.Value.Stats.StrongAttackStun        = syncMessage.StrongAttackStun[index];
                player.Value.Stats.StrongAttackPenetration = syncMessage.StrongAttackPenetration[index];
                player.Value.Stats.DefeneseReceivingDamage = syncMessage.DefeneseReceivingDamage[index];
                player.Value.Stats.DefeneseReductionStun   = syncMessage.DefeneseReductionStun[index];
                player.Value.Stats.nowCharacter            = syncMessage.nowCharacter[index];
            }

            index++;
        }
        BackEndMatchManager.instance.SetHostSession(syncMessage.host);
    }
Beispiel #2
0
    public void OnRecieve(MatchRelayEventArgs args)
    {
        if (args.BinaryUserData == null)
        {
            Debug.LogWarning(string.Format("빈 데이터가 브로드캐스팅 되었습니다.\n{0} - {1}", args.From, args.ErrInfo));
            // 데이터가 없으면 그냥 리턴
            return;
        }
        Message msg = DataParser.ReadJsonData <Message>(args.BinaryUserData);

        if (msg == null)
        {
            return;
        }
        //if (BackEndMatchManager.instance.isHost != true && args.From.SessionId == myPlayerIndex)
        //{
        //    Debug.Log("패킷 받기 안됨");
        //    return;
        //}
        if (players == null)
        {
            Debug.Log("패킷 받기 안됨");
            return;
        }

        Debug.Log("패킷 받기 : " + (int)msg.type);
        switch (msg.type)
        {
        case Protocol.Type.StartCount:
            // 아무것도 못하게 하기
            StartCountMessage startCount = DataParser.ReadJsonData <StartCountMessage>(args.BinaryUserData);
            if (startCount.time == 0)
            {
                GameUI.instance.SetStartText("게임 시작");
            }
            else
            {
                GameUI.instance.SetStartText(startCount.time.ToString());
            }
            break;

        case Protocol.Type.GameStart:
            // 플레이 가능하게 하기
            GameManager.instance.ChangeState(GameManager.GameState.InGame);
            GameUI.instance.baseObj.SetActive(true);
            GameUI.instance.fadeObj.SetActive(false);
            StartCoroutine(GameUI.instance.gameTimeCheck(BackEndMatchManager.instance.matchInfos[0].matchMinute));
            break;

        case Protocol.Type.GameEnd:
            GameEndMessage endMessage = DataParser.ReadJsonData <GameEndMessage>(args.BinaryUserData);
            SetGameRecord(endMessage.count, endMessage.sessionList);
            break;

        case Protocol.Type.Idle:
            PlayerIdleMessage idleMsg = DataParser.ReadJsonData <PlayerIdleMessage>(args.BinaryUserData);
            ProcessPlayerData(idleMsg);
            break;

        case Protocol.Type.WeakAttack:
            PlayerWeakAttackMessage weakattackMsg = DataParser.ReadJsonData <PlayerWeakAttackMessage>(args.BinaryUserData);
            ProcessPlayerData(weakattackMsg);
            break;

        case Protocol.Type.StrongAttack:
            PlayerStrongAttackMessage strongattackMsg = DataParser.ReadJsonData <PlayerStrongAttackMessage>(args.BinaryUserData);
            ProcessPlayerData(strongattackMsg);
            break;

        case Protocol.Type.Defense:
            PlayerDefenseMessage defenseMsg = DataParser.ReadJsonData <PlayerDefenseMessage>(args.BinaryUserData);
            ProcessPlayerData(defenseMsg);
            break;

        case Protocol.Type.Stun:
            PlayerStunMessage stunMsg = DataParser.ReadJsonData <PlayerStunMessage>(args.BinaryUserData);
            ProcessPlayerData(stunMsg);
            break;

        case Protocol.Type.AttackEnd:
            PlayerAttackEndMessage endMsg = DataParser.ReadJsonData <PlayerAttackEndMessage>(args.BinaryUserData);
            ProcessPlayerData(endMsg);
            break;

        case Protocol.Type.GameSync:
            GameSyncMessage syncMessage = DataParser.ReadJsonData <GameSyncMessage>(args.BinaryUserData);
            ProcessSyncData(syncMessage);
            break;

        case Protocol.Type.GameMySync:
            Debug.Log("싱크 맞추기");
            GameMySyncMessage mySyncMessage = DataParser.ReadJsonData <GameMySyncMessage>(args.BinaryUserData);
            ProcessSyncData(mySyncMessage);
            break;

        case Protocol.Type.Calculation:
            CalculationMessage calMessage = DataParser.ReadJsonData <CalculationMessage>(args.BinaryUserData);
            ProcessCalData(calMessage);
            break;

        case Protocol.Type.Damaged:
            PlayerDamagedMessage damMessage = DataParser.ReadJsonData <PlayerDamagedMessage>(args.BinaryUserData);
            ProcessPlayerData(damMessage);
            break;

        case Protocol.Type.Stamina:
            PlayerStaminaMessage staMessage = DataParser.ReadJsonData <PlayerStaminaMessage>(args.BinaryUserData);
            ProcessPlayerData(staMessage);
            break;

        default:
            Debug.Log("Unknown protocol type");
            return;
        }
    }