Пример #1
0
	public void Rule1(float dt, World world){ if (!Connected)
{
Lidgren.Network.NetOutgoingMessage message = NetworkAPI.Client.CreateMessage();
message.Write((int)NetworkAPI.MessageType.NewConnection);
message.Write(0);
message.Write(0);
message.Write(0);
message.Write(0);
NetworkAPI.Client.SendMessage(message, Lidgren.Network.NetDeliveryMethod.ReliableOrdered);
switch (s1)
	{

	case -1:
	foreach (var entity in Ships)
                  {
                    if (NetworkAPI.ShipInfos.ContainsKey(entity.Net_ID) && NetworkAPI.ShipInfos[entity.Net_ID].IsLocal)
                    {
                      Lidgren.Network.NetOutgoingMessage entityMessage = NetworkAPI.CreateWorldShipsMessage(entity, NetworkAPI.Client, this.Net_ID, 2);
                      NetworkAPI.Client.SendMessage(entityMessage, Lidgren.Network.NetDeliveryMethod.ReliableOrdered);
                    }
                  }
	Ships = Ships;
	Connected = true;
	s1 = -1;
return;	
	default: return;}
Connected = true;
}}
Пример #2
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
   // TODO: Add your initialization logic here
   world = new World();
   world.Start();
   base.Initialize();
 }
Пример #3
0
	public void Update(float dt, World world) {
var t = System.DateTime.Now;NetworkAPI.DispatchMessages(NetworkAPI.Client);		this.Rule3(dt, world);

		for(int x0 = 0; x0 < Ships.Count; x0++) { 
			Ships[x0].Update(dt, world);
		}
		this.Rule0(dt, world);
		this.Rule1(dt, world);
		this.Rule2(dt, world);
	}
Пример #4
0
	public void Rule0(float dt, World world){ if (NetworkAPI.ReceivedMessages.ContainsKey(new Tuple<NetworkAPI.MessageType, NetworkAPI.EntityType, int>(NetworkAPI.MessageType.NewConnection, 0, 0)))
{switch (s0)
	{

	case -1:
	foreach (var entity in Ships)
        {
          if (NetworkAPI.ShipInfos.ContainsKey(entity.Net_ID) && NetworkAPI.ShipInfos[entity.Net_ID].IsLocal)
          {
            Lidgren.Network.NetOutgoingMessage entityMessage = NetworkAPI.CreateWorldShipsMessage(entity, NetworkAPI.Client, this.Net_ID, 2);
            NetworkAPI.Client.SendMessage(entityMessage, Lidgren.Network.NetDeliveryMethod.ReliableOrdered);
            NetworkAPI.ReceivedMessages.Remove(new Tuple<NetworkAPI.MessageType, NetworkAPI.EntityType, int>(NetworkAPI.MessageType.NewConnection, 0, 0));
          }
        }
	Ships = Ships;
	s0 = -1;
return;	
	default: return;}}}
Пример #5
0
	public void Rule3(float dt, World world) 
	{
	Input = Microsoft.Xna.Framework.Input.Keyboard.GetState();
	}
Пример #6
0
	public void Rule2(float dt, World world){ if (NetworkAPI.ShipInfos.ContainsKey(this.Net_ID) && NetworkAPI.ShipInfos[this.Net_ID].IsLocal)
{switch (s2)
	{

	case -1:
	___vy21 = new Microsoft.Xna.Framework.Vector2(-300f,0f);
	goto case 3;
	case 3:
	if(!(world.Input.IsKeyDown(Keys.A)))
	{

	s2 = 3;
return;	}else
	{

	goto case 2;	}
	case 2:
	___v20 = ((Position) + (((___vy21) * (dt))));
	Lidgren.Network.NetOutgoingMessage message = NetworkAPI.UpdateShipPositionMessage(this, NetworkAPI.Client, Net_ID, 2);
NetworkAPI.Client.SendMessage(message, Lidgren.Network.NetDeliveryMethod.UnreliableSequenced);
	Position = ___v20;
	s2 = -1;
return;	
	default: return;}}}
Пример #7
0
	public void Rule0(float dt, World world){ if (NetworkAPI.ShipInfos.ContainsKey(this.Net_ID) && !NetworkAPI.ShipInfos[this.Net_ID].IsLocal)
{switch (s0)
	{

	case -1:
	NetworkAPI.UpdateShipPositionMessage(this.Net_ID);
	s0 = -1;
return;	
	default: return;}}}
Пример #8
0
	public void Update(float dt, World world) {
frame = World.frame;

		this.Rule0(dt, world);
		this.Rule1(dt, world);
		this.Rule2(dt, world);
	}
Пример #9
0
	public void Rule2(float dt, World world){ switch (s2)
	{

	case -1:
	
	wait1 = NetworkAPI.ReceiveWorldShipsMessage(this.Net_ID);;
	if(wait1.IsNone)
	{

	s2 = -1;
return;	}else
	{

	___ships20 = wait1.Value;
	goto case 0;	}
	case 0:
	Ships = (Ships).Concat(___ships20).ToList<Ship>();
	s2 = -1;
return;	
	default: return;}}