예제 #1
0
    protected override void HandleMsg(EPhotonMsg pReceivedMsg, object[] pParams, ByteBuffer bb)
    {
        switch (pReceivedMsg)
        {
        case EPhotonMsg.MainMenu_SyncGameInfo:

            GameInitInfoS infoS    = GameInitInfoS.GetRootAsGameInitInfoS(bb);
            GameInitInfo  gameInfo = GameInitInfo.Deserialize(infoS);
            Debug.Log(gameInfo);

            //reset current game info - DONT assign it
            //it will be set from UI elements
            brainiacs.GameInitInfo = new GameInitInfo();
            mainMenu.GameSetup.OpenMain(gameInfo);
            break;

        case EPhotonMsg.MainMenu_SyncPlayerInfo:
            PlayerInitInfoS playerInfoS = PlayerInitInfoS.GetRootAsPlayerInitInfoS(bb);
            PlayerInitInfo  playerInfo  = PlayerInitInfo.Deserialize(playerInfoS);
            mainMenu.GameSetup.SetupMain.UpdatePlayer(playerInfo);
            break;

        case EPhotonMsg.None:
        default:
            Debug.LogError("Message not handled");

            break;
        }
    }
예제 #2
0
    internal Offset <PlayerInitInfoS> Create(ref FlatBufferBuilder fbb)
    {
        StringOffset nameOff = fbb.CreateString(Name);

        Offset <PlayerInitInfoS> result = PlayerInitInfoS.CreatePlayerInitInfoS(fbb,
                                                                                nameOff, Number, (int)Hero, (int)Color, (int)PlayerType,
                                                                                PhotonPlayer != null ? PhotonPlayer.ActorNumber : -1,
                                                                                IsReady);

        return(result);
    }
예제 #3
0
    internal static PlayerInitInfo Deserialize(PlayerInitInfoS pPlayerS)
    {
        PlayerInitInfo playerInfo = new PlayerInitInfo();

        playerInfo.Number     = pPlayerS.Number;
        playerInfo.Hero       = (EHero)pPlayerS.Hero;
        playerInfo.Name       = pPlayerS.Name;
        playerInfo.Color      = (EPlayerColor)pPlayerS.Color;
        playerInfo.PlayerType = (EPlayerType)pPlayerS.PlayerType;
        playerInfo.IsReady    = pPlayerS.IsReady;

        if (PhotonNetwork.IsConnected && PhotonNetwork.CurrentRoom != null)
        {
            playerInfo.PhotonPlayer = PhotonNetwork.CurrentRoom.GetPlayer(pPlayerS.PhotonPlayerNumber);
        }

        return(playerInfo);
    }
예제 #4
0
 public static Offset <PlayerInitInfoS> CreatePlayerInitInfoS(FlatBufferBuilder builder,
                                                              StringOffset nameOffset = default(StringOffset),
                                                              int number             = 0,
                                                              int hero               = 0,
                                                              int color              = 0,
                                                              int playerType         = 0,
                                                              int photonPlayerNumber = 0,
                                                              bool isReady           = false)
 {
     builder.StartTable(7);
     PlayerInitInfoS.AddPhotonPlayerNumber(builder, photonPlayerNumber);
     PlayerInitInfoS.AddPlayerType(builder, playerType);
     PlayerInitInfoS.AddColor(builder, color);
     PlayerInitInfoS.AddHero(builder, hero);
     PlayerInitInfoS.AddNumber(builder, number);
     PlayerInitInfoS.AddName(builder, nameOffset);
     PlayerInitInfoS.AddIsReady(builder, isReady);
     return(PlayerInitInfoS.EndPlayerInitInfoS(builder));
 }
예제 #5
0
    internal byte[] Serizalize()
    {
        FlatBufferBuilder fbb     = new FlatBufferBuilder(1);
        StringOffset      nameOff = fbb.CreateString(Name);

        PlayerInitInfoS.StartPlayerInitInfoS(fbb);
        PlayerInitInfoS.AddName(fbb, nameOff);
        PlayerInitInfoS.AddNumber(fbb, Number);
        PlayerInitInfoS.AddHero(fbb, (int)Hero);
        PlayerInitInfoS.AddColor(fbb, (int)Color);
        PlayerInitInfoS.AddPlayerType(fbb, (int)PlayerType);
        PlayerInitInfoS.AddIsReady(fbb, IsReady);
        PlayerInitInfoS.AddPhotonPlayerNumber(fbb, PhotonPlayer.ActorNumber);
        Offset <PlayerInitInfoS> playerInfoOffset = PlayerInitInfoS.EndPlayerInitInfoS(fbb);

        fbb.Finish(playerInfoOffset.Value);
        byte[] result = fbb.SizedByteArray();
        return(result);
    }
예제 #6
0
 public static PlayerInitInfoS GetRootAsPlayerInitInfoS(ByteBuffer _bb, PlayerInitInfoS obj)
 {
     return(obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }