public static void SendConfrimSelect(ConfrimType ct, byte m) { NetOutgoingMessage outmsg = client.CreateMessage(); outmsg.Write((byte)PacketType.ConfrimSelect); outmsg.Write(core.GetPlayerName()); outmsg.Write((byte)ct); if (ct == ConfrimType.SelectFaction) { outmsg.Write((byte)m); } client.SendMessage(outmsg, NetDeliveryMethod.Unreliable); }
private void ConfrimSelect(NetIncomingMessage incmsg) { string playerName = incmsg.ReadString(); World w = serverCore.GetWorld(); DataBase db = serverCore.GetDataBase(); ConfrimType ct = (ConfrimType)incmsg.ReadByte(); int xpos = serverCore.random.Next(2) == 0 ? 750 : -750; int ypos = serverCore.random.Next(2) == 0 ? 750 : -750; if (ct == ConfrimType.SelectFaction) { Faction f = (Faction)incmsg.ReadByte(); ShipType st = 0; Vector2 pos = Vector2.Zero; GunSlot[] gs = new GunSlot[2]; int[] components = { 1, 1, 0, 0, 0, 0, 0 }; if (f == Faction.Civilian) { st = ShipType.CivSmall1; pos = new Vector2(1500, -500); } else if (f == Faction.Enemy) { st = ShipType.EnemySmall1; pos = new Vector2(-1500, -500); } else if (f == Faction.Human) { st = ShipType.HumanSmall1; pos = new Vector2(0, 1500); } ShipPlayer s = new ShipPlayer(pos, pos, f, st, components, w, 0, 0); s.shipName = playerName; if (f == Faction.Civilian) { for (int i = 0; i < 2; i++) { gs[i] = new GunSlot(GunType.GausSmall, s); } } else if (f == Faction.Enemy) { for (int i = 0; i < 2; i++) { gs[i] = new GunSlot(GunType.LaserSmall, s); } } else if (f == Faction.Human) { for (int i = 0; i < 2; i++) { gs[i] = new GunSlot(GunType.PlasmSmall, s); } } s.jumpX = xpos; s.jumpY = ypos; s.AddGuns(gs); //timersToSendNpcs.Add(0); //netConnections.Add(incmsg.SenderConnection); ServerPacketSender.SendAllNpcs(w, incmsg.SenderConnection); w.ships.Add(s); ServerPacketSender.SendNewPlayer(s, false); ServerCore.LogAdd(playerName + " connected."); db.SaveUser(playerName, s); } }