Пример #1
0
    private void ProcessSyncData(GameMySyncMessage mySyncMessage)
    {
        // 플레이어 데이터 동기화
        if (players == null)
        {
            Debug.LogError("Player Poll is null!");
            return;
        }
        Debug.Log(BackEndMatchManager.instance.GetNickNameBySessionId(mySyncMessage.session) + " : 셋팅");

        players[mySyncMessage.session].Stats.MaxHp                   = mySyncMessage.MaxHp;
        players[mySyncMessage.session].Stats.CurHp                   = mySyncMessage.MaxHp;
        players[mySyncMessage.session].Stats.Stamina                 = mySyncMessage.Stamina;
        players[mySyncMessage.session].Stats.ReductionStamina        = mySyncMessage.ReductionStamina;
        players[mySyncMessage.session].Stats.WeakAttackDamage        = mySyncMessage.WeakAttackDamage;
        players[mySyncMessage.session].Stats.WeakAttackStun          = mySyncMessage.WeakAttackStun;
        players[mySyncMessage.session].Stats.WeakAttackPenetration   = mySyncMessage.WeakAttackPenetration;
        players[mySyncMessage.session].Stats.StrongAttackDamage      = mySyncMessage.StrongAttackDamage;
        players[mySyncMessage.session].Stats.StrongAttackStun        = mySyncMessage.StrongAttackStun;
        players[mySyncMessage.session].Stats.StrongAttackPenetration = mySyncMessage.StrongAttackPenetration;
        players[mySyncMessage.session].Stats.DefeneseReceivingDamage = mySyncMessage.DefeneseReceivingDamage;
        players[mySyncMessage.session].Stats.DefeneseReductionStun   = mySyncMessage.DefeneseReductionStun;
        players[mySyncMessage.session].Stats.nowCharacter            = mySyncMessage.nowCharacter;
        players[mySyncMessage.session].CharactersPrefab[players[mySyncMessage.session].Stats.nowCharacter].SetActive(true);
        players[mySyncMessage.session].Anim = players[mySyncMessage.session].CharactersPrefab[players[mySyncMessage.session].Stats.nowCharacter].GetComponent <Animator>();
        StartCoroutine(players[mySyncMessage.session].CR_StaminaHeal());
    }
Пример #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;
        }
    }