public void SendFleet(int Ammount, int OriginID, int DestinationID,int Tick) { SendRequest request = new SendRequest(); request.Ammount = Ammount; request.Destination = DestinationID; request.Origin = OriginID; request.Owner = LeadingState.FromId(OriginID).Owner; request.SimulationTick = Tick; QueueAction(request); }
public override GameAction CreateCopy() { SendRequest copy = new SendRequest(); copy.ActionType = ActionType; copy.SimulationTick = SimulationTick; copy.Owner = Owner; copy.Origin = Origin; copy.Destination = Destination; copy.Ammount = Ammount; return copy; }
protected void ClientOnPacket(object sender, PacketRecievedArgs e) { e.Drop = true; byte Type = e.Packet.ReadByte(); switch (Type) { case 0: int Owner = e.Packet.ReadInt(); int SimulationTick = e.Packet.ReadInt(); int Count = e.Packet.ReadInt(); for (int i = 0; i < Count; i++) { int OriginID = e.Packet.ReadInt(); int DestinationID = e.Packet.ReadInt(); SendRequest r = new SendRequest(); r.SimulationTick = SimulationTick; r.Owner = Owner == 1 ? VelesConflict.Gameplay.PlayerType.Player1 : VelesConflict.Gameplay.PlayerType.Player2; r.Origin = OriginID; r.Destination = DestinationID; Manager.QueueAction(r); } break; case 0xFB: GameState = MultiplayerGameState.Waiting; KillGame(true); break; case 0xFD: GameState = MultiplayerGameState.Downloading; Map = e.Packet.ReadInt(); if (!storage.DirectoryExists("MultiplayerMaps")) { storage.CreateDirectory("MultiplayerMaps"); } if (storage.FileExists(string.Format(@"MultiplayerMaps\map{0}", Map))) { List<Planet> planets = (LoadMap(string.Format(@"MultiplayerMaps\map{0}", Map))); foreach (Planet p in planets) Manager.AddPlanet(p); GameState = MultiplayerGameState.Ready; Thread.Sleep(1000); Packet ready = new Packet(); ready.Write((byte)0xFE); client.SendPacket(ready); } else { string MapAddress = string.Format(@"http://www.velesconflict.com/maps/map{0}.xml", Map); WebClient = new WebClient(); WebClient.OpenReadCompleted += new OpenReadCompletedEventHandler(WebClient_OpenReadCompleted); WebClient.OpenReadAsync(new Uri(MapAddress)); } break; case 0xFC: Player = (VelesConflict.Gameplay.PlayerType)e.Packet.ReadByte(); break; case 0xFF: GameCounter = 0; GameState = MultiplayerGameState.Game; Syncing = true; FramesToSpin = 120 - (client.Ping() / 2 + 17 / 2) / 17; break; } e.Packet.ResetPointer(); }