Пример #1
0
    public override void OnResponse(ProtocalData msg)
    {
        PlayInfoData playInfo = ProtoBufSerializable.Decode <PlayInfoData>(msg.Bytes);

        if (PlayerManager.Instance.LocalPlayer.UserId == playInfo.UserId)
        {
            return;
        }
        GameObject tank;

        if (PlayerManager.Instance.PlayerList.TryGetValue(playInfo.UserId, out tank))
        {
            tank.GetComponent <Complete.TankMovement>().RemoteTransform(playInfo.GetPosition(), playInfo.GetRotation());
            if (playInfo.Shoot)
            {
                tank.GetComponent <Complete.TankShooting>().Fire(playInfo.Force);
            }
            tank.GetComponent <Complete.TankHealth>().SyncHealth(playInfo.ServerHealth);
        }
        else
        {
            PlayerManager.Instance.AddPlayer(playInfo);
        }
    }
Пример #2
0
    public void AddPlayer(PlayInfoData data)
    {
        Color      color = tankColors[PlayerList.Count];
        GameObject tank  = gameManager.AddTank(PlayerList.Count + 1, color, data.PlayName, data.UserId, data.GetPosition(), data.GetRotation());

        PlayerList.Add(data.UserId, tank);
        gameManager.m_PlayerList.AddItem(tank.name, color);
    }