private void CreateWorld() { network = new LiteNetLibNetwork(); networkCommandQueue = new NetworkCommandQueue(network); networkCommandQueue.InitReceived += (sender, init) => { rand = new Random(init.Seed); for (int i = 0; i < 100; i++) { var mushroom = scene.CreateChild("Mushroom"); mushroom.Position = new Vector3(rand.Next(90) - 45, 0, rand.Next(90) - 45); mushroom.Rotation = new Quaternion(0, rand.Next(360), 0); mushroom.SetScale(0.5f + rand.Next(20000) / 10000.0f); var mushroomObject = mushroom.CreateComponent <StaticModel>(); mushroomObject.Model = ResourceCache.GetModel("Models/Mushroom.mdl"); mushroomObject.SetMaterial(ResourceCache.GetMaterial("Materials/Mushroom.xml")); } simulation.Start(init.SimulationSpeed, init.ActorID, init.AllActors); }; simulation = new Simulation(Contexts.sharedInstance, networkCommandQueue, new ViewService(ResourceCache, scene.GetChild("Jacks"))); network.Start(); network.Connect("127.0.0.1", 9050); }
public OnlineProcessor() { network = Layer.Get <LiteNetLibNetwork>(); gameState = Layer.Get <GameState>(); network.DataReceived += NetworkOnDataReceived; }
protected override void Setup() { SetupLogger(); gameState = Add <GameState>(); onlineManager = Add <LiteNetLibNetwork>(); onlineManager.Start(gameState); Add <OnlineProcessor>(); Add <ClickMoveProcessor>(); Add <UnitSelectionProcessor>(); Add <SpawnProcessor>(); Add <MoveProcessor>(); Add <SelectionProcessor>(); Add <DebugInputProcessor>(); //Add<DynamicNavProcessor>(); }
public Game() : base("YOUR_ORGANIZATION", "PROJECT_NAME") { _frameWatch = Stopwatch.StartNew(); _authorityNet = new LiteNetLibNetwork(CreateSerializer()); _authoritySim = new SimultaneousSim(this, _authorityNet); _authoritySim.ListenToPort(5555); _authoritySim.ClientSimConnected += _authoritySim_ClientSimConnected; _controllerNet = new LiteNetLibNetwork(CreateSerializer()); _controllerSim = new SimultaneousSim(this, _controllerNet); _controllerSim.ConnectToHost("localhost", 5555); _observerNet = new LiteNetLibNetwork(CreateSerializer()); _observerSim = new SimultaneousSim(this, _observerNet); _observerSim.ConnectToHost("localhost", 5555); }
public ClickMoveProcessor() { gameState = Layer.Get <GameState>(); network = Layer.Get <LiteNetLibNetwork>(); }
public DebugInputProcessor() { network = Layer.Get <LiteNetLibNetwork>(); }