Exemplo n.º 1
0
    public void AttackPointTrue()
    {
        AttackPoint = true;
        // 계산 관리 함수
        CalculationMessage calMessage = new CalculationMessage(BackEndMatchManager.instance.hostSession);

        BackEndMatchManager.instance.SendDataToInGame(calMessage);
    }
Exemplo n.º 2
0
        public override Task <CalculationResult> Calc(CalculationMessage request, ServerCallContext context)
        {
            this.logger.LogInformation($"Berechne: {request.Lhs} {request.Operand.ToString().ToUpperInvariant()} {request.Rhs}");

            var value = request.Operand switch
            {
                Operand.Plus => request.Lhs + request.Rhs,
                Operand.Minus => request.Lhs - request.Rhs,
                Operand.Multipy => request.Lhs * request.Rhs,
                Operand.Divide => request.Lhs / request.Rhs,
                _ => throw new NotSupportedException($"{nameof(request.Operand)} '{request.Operand}' is unknown"),
            };

            this.logger.LogInformation($"Ergebnis: {value}");

            return(Task.FromResult(new CalculationResult {
                Value = value
            }));
        }
Exemplo n.º 3
0
    private void ProcessCalData(CalculationMessage calMessage)
    {
        Debug.Log("계산 들어옴");

        if (players[otherPlayerIndex].GetAttackPoint())
        {
            Debug.Log("AI 아님");

            if (players[otherPlayerIndex].State == PlayerCurState.WEAK_ATTACK && players[otherPlayerIndex].GetAttackPoint() == true)
            {
                if (players[myPlayerIndex].State == PlayerCurState.DEFENSE && players[myPlayerIndex].Direction == players[otherPlayerIndex].Direction)
                {
                    players[myPlayerIndex].SufferDamage(players[myPlayerIndex].Stats.WeakAttackDamage
                                                        * ((100 - players[otherPlayerIndex].Stats.Armor - players[myPlayerIndex].Stats.WeakAttackPenetration) * 0.01f)
                                                        * players[myPlayerIndex].Stats.DefeneseReceivingDamage, players[myPlayerIndex].Direction);

                    players[otherPlayerIndex].StunOn(players[otherPlayerIndex].Stats.WeakAttackStun);

                    players[myPlayerIndex].AttackPointFalse();

                    players[myPlayerIndex].HitStop(0.2f, 0.2f);
                    players[otherPlayerIndex].AttackPointFalse();

                    return;
                }
                else
                {
                    players[myPlayerIndex].SufferDamage(players[myPlayerIndex].Stats.WeakAttackDamage
                                                        * ((100 - players[otherPlayerIndex].Stats.Armor - players[myPlayerIndex].Stats.WeakAttackPenetration) * 0.01f), players[myPlayerIndex].Direction);

                    players[myPlayerIndex].StunOn(players[otherPlayerIndex].Stats.WeakAttackStun);

                    players[myPlayerIndex].AttackPointFalse();

                    players[myPlayerIndex].HitStop(0.2f, 0.2f);
                    players[otherPlayerIndex].AttackPointFalse();

                    Debug.Log("약공 들어감");
                    return;
                }
            } // 약공

            if (players[otherPlayerIndex].State == PlayerCurState.STRONG_ATTACK && players[otherPlayerIndex].GetAttackPoint() == true)
            {
                if (players[myPlayerIndex].State == PlayerCurState.DEFENSE && players[myPlayerIndex].Direction == players[otherPlayerIndex].Direction)
                {
                    players[myPlayerIndex].SufferDamage(players[myPlayerIndex].Stats.StrongAttackDamage
                                                        * ((100 - players[otherPlayerIndex].Stats.Armor - players[myPlayerIndex].Stats.StrongAttackPenetration) * 0.01f)
                                                        * players[myPlayerIndex].Stats.DefeneseReceivingDamage, players[myPlayerIndex].Direction);

                    players[otherPlayerIndex].StunOn(players[otherPlayerIndex].Stats.StrongAttackStun);

                    players[myPlayerIndex].AttackPointFalse();

                    players[myPlayerIndex].HitStop(0.2f, 0.2f);
                    players[otherPlayerIndex].AttackPointFalse();
                }
                else
                {
                    players[myPlayerIndex].SufferDamage(players[myPlayerIndex].Stats.StrongAttackDamage
                                                        * ((100 - players[otherPlayerIndex].Stats.Armor - players[myPlayerIndex].Stats.StrongAttackPenetration) * 0.01f), players[myPlayerIndex].Direction);

                    players[myPlayerIndex].StunOn(players[otherPlayerIndex].Stats.StrongAttackStun);

                    players[myPlayerIndex].AttackPointFalse();

                    players[myPlayerIndex].HitStop(0.2f, 0.2f);
                    players[otherPlayerIndex].AttackPointFalse();

                    Debug.Log("강공 들어감");
                }
            } // 강공
        }
        else if (players[myPlayerIndex].GetAttackPoint() && players[otherPlayerIndex].isAI)
        {
            Debug.Log("AI : " + players[myPlayerIndex].GetAttackPoint());

            if (players[myPlayerIndex].State == PlayerCurState.WEAK_ATTACK && players[myPlayerIndex].GetAttackPoint() == true)
            {
                Debug.Log("AI1");

                if (players[otherPlayerIndex].State == PlayerCurState.DEFENSE && players[otherPlayerIndex].Direction == players[myPlayerIndex].Direction)
                {
                    Debug.Log("AI2");
                    players[otherPlayerIndex].SufferDamage(players[otherPlayerIndex].Stats.WeakAttackDamage
                                                           * ((100 - players[myPlayerIndex].Stats.Armor - players[otherPlayerIndex].Stats.WeakAttackPenetration) * 0.01f)
                                                           * players[otherPlayerIndex].Stats.DefeneseReceivingDamage, players[otherPlayerIndex].Direction);

                    players[myPlayerIndex].StunOn(players[myPlayerIndex].Stats.WeakAttackStun);

                    players[otherPlayerIndex].AttackPointFalse();

                    players[otherPlayerIndex].HitStop(0.2f, 0.2f);
                    players[myPlayerIndex].AttackPointFalse();

                    return;
                }
                else
                {
                    Debug.Log("AI3");

                    players[otherPlayerIndex].SufferDamage(players[otherPlayerIndex].Stats.WeakAttackDamage
                                                           * ((100 - players[myPlayerIndex].Stats.Armor - players[otherPlayerIndex].Stats.WeakAttackPenetration) * 0.01f), players[otherPlayerIndex].Direction);

                    players[otherPlayerIndex].StunOn(players[myPlayerIndex].Stats.WeakAttackStun);

                    players[otherPlayerIndex].AttackPointFalse();

                    players[otherPlayerIndex].HitStop(0.2f, 0.2f);
                    players[myPlayerIndex].AttackPointFalse();

                    Debug.Log("약공 들어감");
                    return;
                }
            } // 약공

            if (players[myPlayerIndex].State == PlayerCurState.STRONG_ATTACK && players[myPlayerIndex].GetAttackPoint() == true)
            {
                if (players[otherPlayerIndex].State == PlayerCurState.DEFENSE && players[otherPlayerIndex].Direction == players[myPlayerIndex].Direction)
                {
                    players[otherPlayerIndex].SufferDamage(players[otherPlayerIndex].Stats.StrongAttackDamage
                                                           * ((100 - players[myPlayerIndex].Stats.Armor - players[otherPlayerIndex].Stats.StrongAttackPenetration) * 0.01f)
                                                           * players[otherPlayerIndex].Stats.DefeneseReceivingDamage, players[otherPlayerIndex].Direction);

                    players[myPlayerIndex].StunOn(players[myPlayerIndex].Stats.StrongAttackStun);

                    players[otherPlayerIndex].AttackPointFalse();

                    players[otherPlayerIndex].HitStop(0.2f, 0.2f);
                    players[myPlayerIndex].AttackPointFalse();
                }
                else
                {
                    players[otherPlayerIndex].SufferDamage(players[otherPlayerIndex].Stats.StrongAttackDamage
                                                           * ((100 - players[myPlayerIndex].Stats.Armor - players[otherPlayerIndex].Stats.StrongAttackPenetration) * 0.01f), players[otherPlayerIndex].Direction);

                    players[otherPlayerIndex].StunOn(players[myPlayerIndex].Stats.StrongAttackStun);

                    players[otherPlayerIndex].AttackPointFalse();

                    players[otherPlayerIndex].HitStop(0.2f, 0.2f);
                    players[myPlayerIndex].AttackPointFalse();

                    Debug.Log("강공 들어감");
                }
            } // 강공
        }
    }
Exemplo n.º 4
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;
        }
    }