public override void OnPlayerAttacked(PlayerAttackedMessage msg)
    {
        base.OnPlayerAttacked(msg);

        var attackingCard = opponentBoardCards.Find(x => x.card.instanceId == msg.attackingCardInstanceId);

        if (attackingCard != null)
        {
            CombatAnimation.PlayFightAnimation(attackingCard.gameObject, GameObject.Find("Player/Avatar"), 0.1f, () =>
            {
                effectSolver.FightPlayer(msg.attackingPlayerNetId, msg.attackingCardInstanceId);
            });
        }
    }
Exemplo n.º 2
0
    public virtual void OnFightPlayer(NetworkMessage netMsg)
    {
        var msg = netMsg.ReadMessage <FightPlayerMessage>();

        if (msg != null)
        {
            // Only the current player can fight.
            if (netMsg.conn.connectionId != server.gameState.currentPlayer.connectionId)
            {
                return;
            }

            var playerAttackedMsg = new PlayerAttackedMessage();
            playerAttackedMsg.attackingPlayerNetId    = msg.attackingPlayerNetId;
            playerAttackedMsg.attackingCardInstanceId = msg.cardInstanceId;
            server.SafeSendToClient(server.gameState.currentOpponent, NetworkProtocol.PlayerAttacked, playerAttackedMsg);

            server.effectSolver.FightPlayer(msg.attackingPlayerNetId, msg.cardInstanceId);
        }
    }