public void Random() { _sendPosition = true; _sendVelocity = true; Position = _position.Randomize(new Vector2(4096)); Velocity = _velocity.Randomize(new Vector2(30)); Type = (eAmmoType)Math.Round(Program.Rnd.NextDouble()); }
public void Random() { Random rnd = Program.Rnd; _sendPosition = true; Position = _position.Randomize(new Vector2(4096)); NbOfAmmo = rnd.Next(100); AmmoType = (eAmmoType)Math.Round(rnd.NextDouble()); }
public bool Serialize(Serializer pSerializer) { bool isActive = IsActive; Vector2 position = Position; int nbOfAmmo = NbOfAmmo; int ammoType = (int)AmmoType; if (!pSerializer.Error) { #if TRACE_LOG LogHelper.WriteToFile("Serialize Loot : ", this, Program.FileName); LogHelper.WriteToFile(" IsActive : ", this, Program.FileName); #endif pSerializer.Serialize(ref isActive); #if TRACE_LOG LogHelper.WriteToFile(" SendPosition : ", this, Program.FileName); LogHelper.WriteToFile(" Position : ", this, Program.FileName); #endif pSerializer.Serialize(ref position, Vector2.Zero, new Vector2(4096), ref _sendPosition); #if TRACE_LOG LogHelper.WriteToFile(" SendNbOfAmmo : ", this, Program.FileName); LogHelper.WriteToFile(" NbOfAmmo : ", this, Program.FileName); #endif pSerializer.Serialize(ref nbOfAmmo, 0, 100, ref _sendNbOfAmmo); #if TRACE_LOG LogHelper.WriteToFile(" AmmoType : ", this, Program.FileName); #endif pSerializer.Serialize(ref ammoType, 0, 1); } if (pSerializer is ReaderSerialize && !pSerializer.Error) { IsActive = isActive; if (_sendPosition) { Position = position; } if (_sendNbOfAmmo) { NbOfAmmo = nbOfAmmo; } AmmoType = (eAmmoType)ammoType; } #if TRACE_LOG LogHelper.WriteToFile("End of Bullet : ", this, Program.FileName); #endif ShouldBeSend = pSerializer.Error; return(pSerializer.Error); }
public bool Serialize(Serializer pSerializer) { Vector2 position = Position; Vector2 velocity = Velocity; int type = (int)Type; if (!pSerializer.Error) { #if TRACE_LOG LogHelper.WriteToFile("Serialize Bullet : ", this, Program.FileName); LogHelper.WriteToFile(" SendPosition : ", this, Program.FileName); LogHelper.WriteToFile(" Position : ", this, Program.FileName); #endif pSerializer.Serialize(ref position, Vector2.Zero, new Vector2(4096), ref _sendPosition); #if TRACE_LOG LogHelper.WriteToFile(" SendVelocity : ", this, Program.FileName); LogHelper.WriteToFile(" Velocity : ", this, Program.FileName); #endif pSerializer.Serialize(ref velocity, Vector2.Zero, new Vector2(30), ref _sendVelocity); #if TRACE_LOG LogHelper.WriteToFile(" Type : ", this, Program.FileName); #endif pSerializer.Serialize(ref type, 0, 1); } if (pSerializer is ReaderSerialize && !pSerializer.Error) { if (_sendPosition) { Position = position; } if (_sendVelocity) { Velocity = velocity; } Type = (eAmmoType)type; } #if TRACE_LOG LogHelper.WriteToFile("End of Bullet : ", this, Program.FileName); #endif ShouldBeSend = pSerializer.Error; return(pSerializer.Error); }