Exemplo n.º 1
0
    public override void Deserialize(NetworkReader reader)
    {
        int seed = reader.ReadInt32();

        BackgroundSelector.RoomType background =
            (BackgroundSelector.RoomType)reader.ReadInt32();
        DateTime time = Convert.ToDateTime(reader.ReadString());

        Game = new GameRecord(seed, background, time);

        Dictionary <int, PlayerProfile> players =
            new Dictionary <int, PlayerProfile> ();

        int count = reader.ReadInt32();

        for (int i = 0; i < count; i++)
        {
            PlayerProfile profile = reader.ReadMessage <PlayerProfileMessage>().Profile;
            players.Add(i, profile);
            Game.AddPlayer(profile);
        }

        for (int i = 0; i < count; i++)
        {
            int number = reader.ReadInt32();
            int score  = reader.ReadInt32();
            Game.UpdateScore(players[number], score);
        }

        count = reader.ReadInt32();
        for (int i = 0; i < count; i++)
        {
            PlayerEvent playerEvent = null;

            PlayerProfile profile = players[reader.ReadInt32()];
            int           frame   = reader.ReadInt32();

            short eventType = reader.ReadInt16();

            switch (eventType)
            {
            case _movementEvent:
                Vector3 position = reader.ReadVector3();
                playerEvent = new PlayerMovementEvent(profile, frame, position);
                break;

            case _droppedItemEvent:
                playerEvent = new PlayerDroppedItemEvent(profile, frame);
                break;

            case _dashStartedEvent:
                playerEvent = new PlayerDashStartedEvent(profile, frame);
                break;

            case _dashStoppedEvent:
                playerEvent = new PlayerDashStoppedEvent(profile, frame);
                break;

            case _quitEvent:
                playerEvent = new PlayerQuitEvent(profile, frame);
                break;
            }

            Game.AddEvent(playerEvent);
        }
    }
Exemplo n.º 2
0
 private void ExecuteEvent(PlayerDashStoppedEvent playerDashStoppedEvent)
 {
     eventEmitter.EmitPlayerDroppedItemEvent(
         playerObjects[playerDashStoppedEvent.Profile]
         );
 }