public int ReceiveData ( PacketReader data, out NetworkGamer sender ) { throw new NotImplementedException(); }
public Blood(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.r = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.g = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.b = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.a = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16()); this.flag = NetPacker.SbyteToInt(reader.ReadSByte()); this.owner = -1; this.Exists = true; this.rotation = GlobalFunctions.GetAngle(new Vector2(), Trajectory); this.frame = Rand.GetRandomFloat(0.3f, 0.7f); }
public NetworkManager() { _maxGamers = 3; _maxLocalGamers = 2; _reader = new PacketReader(); _writer = new PacketWriter(); }
public NetGame(NetPlay _netPlay) { netPlay = _netPlay; writer = new PacketWriter(); reader = new PacketReader(); }
public Network(Game1 GameReference) { game1 = GameReference; TimeLastPosUpdate = Environment.TickCount; packetWriter = new PacketWriter(); packetReader = new PacketReader(); TimeSinceLastJoinGame = Environment.TickCount; }
public LobbyScreen(NetworkSession networkSession) { _networkSession = networkSession; TransitionOnTime = TimeSpan.FromSeconds(0.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); _packetReader = new PacketReader(); _packetWriter = new PacketWriter(); }
public static void updateStateFromNetwork(this CarActor carActor, PacketReader reader) { // read values and apply to carActor: // position and orientation and velocity carActor.WorldTransform = reader.ReadMatrix(); carActor.LinearVelocity = reader.ReadVector3(); carActor.AngularVelocity = reader.ReadVector3(); }
internal LocalGamer(SignedInGamer gamer) { SignedInGamer = gamer; SignedInGamer.Tag = this; reader = new PacketReader(); Writer = new PacketWriter(); InitializeSystemPackets(); }
public Reseau() { downBool = false; jumpBool = false; setPerso = false; perso = "renoi"; // Receive/Send reader = new PacketReader(); writer = new PacketWriter(); player2 = new Player2(Ressources.GetPerso(perso).heroTexture, Ressources.GetPerso(perso).heroTextureAnime, Vector2.Zero); }
/// <summary> /// Deserialize from the packet into the current object. /// </summary> /// <param name="packetReader">The packet reader that has the data.</param> public void Deserialize(PacketReader packetReader) { // safety-check the parameter, as it must be valid. if (packetReader == null) { throw new ArgumentNullException("packetReader"); } //ShipColor = packetReader.ReadByte(); //ShipVariation = packetReader.ReadByte(); }
public Game( ) { #if WINDOWS m_Form = new BloodBulletForm( this ); m_RenderFullscreen = false; m_Form.SetSize( 1280, 720, m_RenderFullscreen ); m_FormBorderStyle = FormBorderStyle.Sizable; #endif m_PacketReader = new PacketReader( ); }
/// <summary> /// Create a new ShipInput object based on the data in the packet. /// </summary> /// <param name="packetReader">The packet with the data.</param> public ShipInput(PacketReader packetReader) { // safety-check the parameters, as they must be valid if (packetReader == null) { throw new ArgumentNullException("packetReader"); } // read the data LeftStick = packetReader.ReadVector2(); RightStick = packetReader.ReadVector2(); MineFired = packetReader.ReadBoolean(); }
public Shockwave(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.size = NetPacker.ShortToMidFloat(reader.ReadInt16()); this.refract = reader.ReadBoolean(); this.owner = -1; this.Exists = true; this.frame = .5f; }
public HideSeek() : base() { graphics = new GraphicsDeviceManager (this); graphics.IsFullScreen = false; Content.RootDirectory = "Content"; caixaSaida = new PacketWriter (); caixaEntrada = new PacketReader (); splashScr = new SplashScreen (); this.IsFixedTimeStep = true; this.TargetElapsedTime = TimeSpan.FromSeconds (0.33f); }
public Fog(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2(80f, -30f); this.size = Rand.GetRandomFloat(6f, 8f); this.flag = Rand.GetRandomInt(0, 4); this.owner = -1; this.Exists = true; this.frame = (float)Math.PI * 2f; this.additive = true; this.rotation = Rand.GetRandomFloat(0f, 6.28f); }
public void ReadNetworkPacket(PacketReader packetReader, GameTime gameTime, TimeSpan latency) { float packetSendTime = packetReader.ReadSingle(); bool pIsAlive = packetReader.ReadBoolean(); if (pIsAlive) { float px = packetReader.ReadSingle(); float py = packetReader.ReadSingle(); float vx = packetReader.ReadSingle(); float vy = packetReader.ReadSingle(); rawPostion = new Vector2(px, py); rawVelocity = new Vector2(vx, vy); } //if (enableSmoothing) //{ // // Start a new smoothing interpolation from our current // // state toward this new state we just received. // previousState = displayState; // currentSmoothing = 1; //} //else //{ // currentSmoothing = 0; //} //// Read what time this packet was sent. //float packetSendTime = packetReader.ReadSingle(); //// Read simulation state from the network packet. //simulationState.Position = packetReader.ReadVector2(); //simulationState.Velocity = packetReader.ReadVector2(); //simulationState.TankRotation = packetReader.ReadSingle(); //simulationState.TurretRotation = packetReader.ReadSingle(); //// Read remote inputs from the network packet. //tankInput = packetReader.ReadVector2(); //turretInput = packetReader.ReadVector2(); //// Optionally apply prediction to compensate for //// how long it took this packet to reach us. //if (enablePrediction) //{ // ApplyPrediction(gameTime, latency, packetSendTime); //} }
public Rocket(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.owner = NetPacker.SbyteToInt(reader.ReadSByte()); this.frame = 4f; this.Exists = true; }
protected override void UpdateFromNetwork(GameTime gameTime) { // read any available data and process it: while (localGamer_.IsDataAvailable) { PacketReader reader = new PacketReader(); NetworkGamer sender; localGamer_.ReceiveData(reader, out sender); // only process remote data (ignore data sent from the local player): if (localGamer_.Id == sender.Id) continue; // also ignore data from wrong packet headers: if (reader.ReadByte() != PacketHeader.INGAME_DATA) continue; foreach (CarActor carActor in idTocarActorMap_[sender.Id]) carActor.updateFromNetwork(reader); } }
public MuzzleFlash(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16()); this.rotation = Rand.GetRandomFloat(0f, 6.28f); this.Exists = true; this.frame = 0.05f; this.additive = true; }
public Fire(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16()); this.flag = NetPacker.SbyteToInt(reader.ReadSByte()); this.frame = NetPacker.ShortToSmallFloat(reader.ReadInt16()); this.Exists = true; this.additive = true; }
public NetworkSession CreateSession() { session = NetworkSession.Create(NetworkSessionType.SystemLink, MAX_LOCAL_PLAYERS, MAX_TOTAL_PLAYERS); session.AllowHostMigration = true; session.AllowJoinInProgress = true; session.GamerJoined += new EventHandler<GamerJoinedEventArgs>(session_GamerJoined); session.GamerLeft += new EventHandler<GamerLeftEventArgs>(session_GamerLeft); session.GameStarted += new EventHandler<GameStartedEventArgs>(session_GameStarted); session.GameEnded += new EventHandler<GameEndedEventArgs>(session_GameEnded); session.SessionEnded += new EventHandler<NetworkSessionEndedEventArgs>(session_SessionEnded); pr = new PacketReader(); pw = new PacketWriter(); sender = session.LocalGamers[0]; return session; }
public Heat(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16()); this.flag = Rand.GetRandomInt(0, 4); this.owner = -1; this.Exists = true; this.rotation = Rand.GetRandomFloat(0f, 6.28f); this.frame = Rand.GetRandomFloat(.5f, .785f); this.refract = true; }
public Bullet(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.owner = NetPacker.ShortToInt(reader.ReadInt16()); this.rotation = GlobalFunctions.GetAngle(new Vector2(), Trajectory); this.Exists = true; this.frame = 0.5f; this.additive = true; }
public Smoke(PacketReader reader) { this.Location = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.Trajectory = new Vector2( NetPacker.ShortToBigFloat(reader.ReadInt16()), NetPacker.ShortToBigFloat(reader.ReadInt16())); this.r = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.g = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.b = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.a = NetPacker.ByteToTinyFloat(reader.ReadByte()); this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16()); this.flag = NetPacker.SbyteToInt(reader.ReadSByte()); this.owner = -1; this.Exists = true; this.frame = 1.0f; }
void restart() { youLoseSound.Play(); deterministicGame.currentLevel.gameRestart = false; graphics.PreferredBackBufferHeight = 600; graphics.PreferredBackBufferWidth = 800; graphics.ApplyChanges(); musicControl.Restart(); // Make the game object. The game is currently called 'DuckSlaughterGame' deterministicGame = new DuckSlaughterGame(); deterministicGame.ResetGame(playerIdentifiers, playerIdentifiers[0]); deterministicGame.LoadContent(Content); deterministicGame.Initialize(); // Debugging setup lastPressedKeys = new List<Keys>(); activePlayer = playerIdentifiers[0]; paused = false; gameStarted = false; //Added isHost = false; chatText = ""; reader.Close(); writer.Close(); networkSession.Dispose(); networkSession = null; reader = new PacketReader(); writer = new PacketWriter(); chatlines = 0; isChatting = false; mouseChange = false; buttonPressed = false; others = new player[4]; update = true; gameStarted = false; inMenu = true; startS.Show(); helpS.Hide(); activeS = startS; releasedKeys = new List<Keys>(); }
// Constructor public Game06() { musicControl = new MusicControl(); graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Make the game object. The game is currently called 'DuckSlaughterGame'. deterministicGame = new DuckSlaughterGame(); // Debugging setup lastPressedKeys = new List<Keys>(); activePlayer = playerIdentifiers[0]; paused = false; gameStarted = false; //Added Components.Add(new GamerServicesComponent(this)); isHost = false; chatText = ""; reader = new PacketReader(); writer = new PacketWriter(); chatlines = 0; isChatting = false; mouseChange = false; buttonPressed = false; others = new player[4]; update = true; inMenu = true; releasedKeys = new List<Keys>(); }
public int ReceiveData ( PacketReader data, out NetworkGamer sender) { lock (receivedData) { if (receivedData.Count >= 0) { data.Reset(0); // take it off the queue CommandReceiveData crd = (CommandReceiveData)receivedData.Dequeue(); // lets make sure that we can handle the data if (data.Length < crd.data.Length) { data.Reset(crd.data.Length); } Array.Copy(crd.data, data.Data, data.Length); sender = crd.gamer; return data.Length; } else { sender = null; return 0; } } }
public void ReadInputFromClient(PacketReader packetReader, GameTime gameTime) { PositionInput = packetReader.ReadVector2(); RotationInput = packetReader.ReadVector4(); }
public void ReadNetworkPacket(PacketReader packetReader, GameTime gameTime, TimeSpan latency, bool enablePrediction, bool enableSmoothing, float packetSendTime) { if (enableSmoothing) { previousState = displayState; _currentSmoothing = 1; } else _currentSmoothing = 0; //float packetSendTime = packetReader.ReadSingle(); simulationState.Position = packetReader.ReadVector3(); simulationState.Velocity = packetReader.ReadVector2(); simulationState.Rotation = packetReader.ReadSingle(); PositionInput = packetReader.ReadVector2(); RotationInput = packetReader.ReadVector4(); if (enablePrediction) ApplyPrediction(gameTime, latency, packetSendTime); }
/// <summary> /// Disposes this object. /// </summary> /// <param name="disposing"> /// True if this method was called as part of the Dispose method. /// </param> protected virtual void Dispose(bool disposing) { if (disposing) { lock (this) { if (packetReader != null) { packetReader.Close(); packetReader = null; } if (packetWriter != null) { packetWriter.Close(); packetWriter = null; } if (spriteBatch != null) { spriteBatch.Dispose(); spriteBatch = null; } cornerBarrierTexture = null; verticalBarrierTexture = null; horizontalBarrierTexture = null; //Ship.UnloadContent(); //Asteroid.UnloadContent(); //LaserProjectile.UnloadContent(); //MineProjectile.UnloadContent(); //RocketProjectile.UnloadContent(); //DoubleLaserPowerUp.UnloadContent(); //TripleLaserPowerUp.UnloadContent(); //Ship.ParticleEffectManager = null; //RocketProjectile.ParticleEffectManager = null; //MineProjectile.ParticleEffectManager = null; //LaserProjectile.ParticleEffectManager = null; particleEffectManager.UnregisterParticleEffect( ParticleEffectType.MineExplosion); particleEffectManager.UnregisterParticleEffect( ParticleEffectType.RocketExplosion); particleEffectManager.UnregisterParticleEffect( ParticleEffectType.RocketTrail); particleEffectManager.UnregisterParticleEffect( ParticleEffectType.ShipExplosion); particleEffectManager.UnregisterParticleEffect( ParticleEffectType.ShipSpawn); } } }