Esempio n. 1
0
        private void OnGameplayNetworkReceived(NetPeer peer, NetDataReader dataReader)
        {
            NetMessage instruction = (NetMessage)dataReader.GetInt();

            switch (instruction)
            {
            case NetMessage.ServerClosed:
                OnServerClosed();
                break;

            case NetMessage.CharacterUpdate:
                StatePacket packet = new StatePacket(dataReader);
                CharacterUpdated?.Invoke(this, new GameplayUpdateEventArgs()
                {
                    Packet = packet
                });
                break;

            case NetMessage.GoToScoresScreen:
                this.SetLobby();
                ScreenManager.ReplaceCurrent(new ScoresScreen());
                break;

            case NetMessage.AddDrop:
                DropAdded?.Invoke(this, new GameplayDropEventArgs()
                {
                    Id   = dataReader.GetInt(),
                    Type = dataReader.GetInt(),
                    X    = dataReader.GetInt(),
                    Y    = dataReader.GetInt()
                });
                break;

            case NetMessage.RemoveDrop:
                DropRemoved?.Invoke(this, new GameplayDropEventArgs()
                {
                    Id = dataReader.GetInt(),
                });
                break;

            case NetMessage.AddBuff:
                BuffAdded?.Invoke(this, new GameplayBuffEventArgs()
                {
                    BuffType = dataReader.GetInt(),
                    PlayerId = dataReader.GetString(),
                    BuffId   = dataReader.GetInt()
                });
                break;

            case NetMessage.RemoveBuff:
                BuffRemoved?.Invoke(this, new GameplayBuffEventArgs()
                {
                    PlayerId = dataReader.GetString(),
                    BuffId   = dataReader.GetInt()
                });
                break;

            case NetMessage.AddPowerUp:
                PowerUpAdded?.Invoke(this, new GameplayPowerUpEventArgs()
                {
                    PlayerId = dataReader.GetString(),
                    Type     = dataReader.GetInt()
                });
                break;

            case NetMessage.RemovePowerUp:
                PowerUpRemoved?.Invoke(this, new GameplayPowerUpEventArgs()
                {
                    PlayerId = dataReader.GetString(),
                });
                break;

            case NetMessage.Teleport:
                CharacterTeleported?.Invoke(this, new GameplayCharacterTeleportedEventArgs()
                {
                    PlayerId = dataReader.GetString(),
                    X        = dataReader.GetInt(),
                    Y        = dataReader.GetInt()
                });
                break;

            case NetMessage.AddTintaSplash:
                TintaSplashAdded?.Invoke(this, new GameplayTintaSplashEventArgs()
                {
                    Id       = dataReader.GetInt(),
                    X        = dataReader.GetInt(),
                    Y        = dataReader.GetInt(),
                    Rotation = dataReader.GetFloat(),
                    Duration = dataReader.GetFloat()
                });
                break;

            case NetMessage.RemoveTintaSplash:
                TintaSplashRemoved?.Invoke(this, new GameplayTintaSplashEventArgs()
                {
                    Id = dataReader.GetInt()
                });
                break;
            }
        }
Esempio n. 2
0
 public static void OnBuffAdded(BuffInfo buff)
 {
     BuffAdded?.Invoke(buff);
 }