Exemplo n.º 1
0
    public void RESPONSE_GAME_PLAYER_ATTACK(TcpPacket packet)
    {
        if (packet.header.extra == (int)EXTRA.SUCCESS)
        {
            SERVERtoHOST_GamePlayerAttackPacketData recvData = new SERVERtoHOST_GamePlayerAttackPacketData();
            recvData.Deserialize(packet);

            CLIENTtoSERVER_GamePlayerAttackPacketData sendData = new CLIENTtoSERVER_GamePlayerAttackPacketData();
            sendData.playerKey = recvData.playerKey;
            sendData.gameKey   = GameManager.Instance.GameKey;

            NetworkManager.Instance.SendCommand((int)PROTOCOL.GAME_PLAYER_ATTACK, (int)EXTRA.HOST_TO_SERVER, sendData);
        }
    }
Exemplo n.º 2
0
    public void Shoot()
    {
        if (GameManager.Instance.IsGameStart)
        {
            Vector3 angle  = new Vector3(0, transform.eulerAngles.y, 0);
            Bullet  bullet = Instantiate(bulletPrefab, gunMount.position, Quaternion.Euler(angle)).GetComponent <Bullet>();
            bullet.Owner = this;
            SoundManager.Instance.PlayShootSound();

            CLIENTtoSERVER_GamePlayerAttackPacketData data = new CLIENTtoSERVER_GamePlayerAttackPacketData();
            data.gameKey   = GameManager.Instance.GameKey;
            data.playerKey = GameFramework.Instance.MyPlayer.PlayerKey;

            if (!GameManager.Instance.IsHost)
            {
                NetworkManager.Instance.SendCommand((int)PROTOCOL.GAME_PLAYER_ATTACK, (int)EXTRA.CLIENT_TO_SERVER, data);
            }
            else
            {
                NetworkManager.Instance.SendCommand((int)PROTOCOL.GAME_PLAYER_ATTACK, (int)EXTRA.HOST_TO_SERVER, data);
            }
        }
    }