public static void ToOtherPlayers(NetIncomingMessage im, OtherPlayer[] d) { bool alive = im.ReadBoolean(); float xp = im.ReadFloat(); float yp = im.ReadFloat(); float zp = im.ReadFloat(); Int32 id = im.ReadInt32(); float xr = im.ReadFloat(); float yr = im.ReadFloat(); Int16 model = im.ReadInt16(); if (d[id] == null) { d[id] = new OtherPlayer(xp, yp, zp, id, model, xr, yr); } d[id].model = model; d[id].xr = xr; d[id].yr = yr; if (!alive) { d[id].ChangeLifeStatus(false); } d[id].position = new Vector3(xp, yp, zp); d[id].boundingSphere.Center = new Vector3(d[id].position.X, d[id].position.Y + Constants.HEADMAX/2, d[id].position.Z); }
public static void ToOtherPlayers(NetIncomingMessage im, OtherPlayer[] d) { bool alive = im.ReadBoolean(); float xp = im.ReadFloat(); float yp = im.ReadFloat(); float zp = im.ReadFloat(); Int32 id = im.ReadInt32(); float xr = im.ReadFloat(); float yr = im.ReadFloat(); Int16 model = im.ReadInt16(); if (d[id] == null) { d[id] = new OtherPlayer(xp, yp, zp, id, model, xr, yr); } d[id].model = model; d[id].xr = xr; d[id].yr = yr; if (!alive) { d[id].ChangeLifeStatus(false); } d[id].position = new Vector3(xp, yp, zp); d[id].boundingSphere.Center = new Vector3(d[id].position.X, d[id].position.Y + Constants.HEADMAX / 2, d[id].position.Z); }
public static OtherPlayer MsgToOtherPlayers(NetIncomingMessage im) { bool alive = im.ReadBoolean(); float xp = im.ReadFloat(); float yp = im.ReadFloat(); float zp = im.ReadFloat(); Int32 id = im.ReadInt32(); float xr = im.ReadFloat(); float yr = im.ReadFloat(); Int16 model = im.ReadInt16(); OtherPlayer d = new OtherPlayer(xp, yp, zp, id, xr, yr, false); d.model = model; return d; }
public static OtherPlayer MsgToOtherPlayers(NetIncomingMessage im) { bool alive = im.ReadBoolean(); float xp = im.ReadFloat(); float yp = im.ReadFloat(); float zp = im.ReadFloat(); Int32 id = im.ReadInt32(); float xr = im.ReadFloat(); float yr = im.ReadFloat(); Int16 model = im.ReadInt16(); OtherPlayer d = new OtherPlayer(xp, yp, zp, id, xr, yr, false); d.model = model; return(d); }
public void CheckHits(Player player, OtherPlayer[] players) { if (players[id] != null) { Vector3 shooterPos = players[id].GetPosition(); BoundingSphere b = new BoundingSphere(player.GetPosition(), Constants.BOLLRADIE); Ray r = new Ray(shooterPos, dir); if (r.Intersects(b) != null) { player.ChangeLifeStatus(false); } } }
static void SendInitialData(NetConnection receiver) { Console.WriteLine("Sending initial data"); Random random = new Random(); Vector3 initialPosition = new Vector3(100, 70, 100); Int16 model = (Int16)random.Next(0, 4); //model = 2; int a = FindOpenSlot(openSlots); if (a >= 0) { openSlots[a] = false; } OtherPlayer player = new OtherPlayer(initialPosition.X, initialPosition.Y, initialPosition.Z, a, 0,0, false); NetOutgoingMessage om = server.CreateMessage(); Console.WriteLine("Random val: " + model.ToString()); player.model = model; om.Write(Constants.NewConnection); Package.PlayerToOm(om, player); server.SendMessage(om, receiver, NetDeliveryMethod.Unreliable); Console.WriteLine(String.Format("Player {0} connected", player.IdToString())); players[a] = player; }