Esempio n. 1
0
		public WorldScene()
		{
			this.world = new World();
			this.world.DetailInterationTriggered += World_DetailInterationTriggered;
			this.debug = new DebugRenderer();
			this.worldRenderer = new WorldRenderer(this.world);

			using (var stream = typeof(WorldScene).Assembly.GetManifestResourceStream("BlocksWorld.Textures.UI.png"))
			{
				this.uiTextures = Image.FromStream(stream);
			}

			this.largeFont = new Font(FontFamily.GenericSansSerif, 16.0f);
			this.smallFont = new Font(FontFamily.GenericSansSerif, 8.0f);
			this.ui = new UIRenderer(1280, 720);
			this.ui.Paint += Ui_Paint;

			this.network = new Network(new TcpClient("localhost", 4523));
			this.receiver = new BasicReceiver(this.network, this.world);
			this.sender = new PhraseTranslator(this.network);

			this.network[NetworkPhrase.LoadWorld] = this.LoadWorldFromNetwork;
			this.network[NetworkPhrase.SpawnPlayer] = this.SpawnPlayer;
			this.network[NetworkPhrase.UpdateProxy] = this.UpdateProxy;
			this.network[NetworkPhrase.DestroyProxy] = this.DestroyProxy;

			this.network[NetworkPhrase.CreateDetail] = this.CreateDetail;
			this.network[NetworkPhrase.UpdateDetail] = this.UpdateDetail;
			this.network[NetworkPhrase.DestroyDetail] = this.DestroyDetail;

			this.network[NetworkPhrase.SetInteractions] = this.SetInteractions;
		}
Esempio n. 2
0
 public void SendWorld(World world)
 {
     this.sender.Send(NetworkPhrase.LoadWorld, (w) =>
     {
         // Only send blocks here because signals and details are transferred otherwise
         world.Save(w.BaseStream, WorldSaveMode.Blocks, true);
     });
 }
Esempio n. 3
0
        public BasicReceiver(Network network, World world)
        {
            this.network = network;
            this.world = world;

            // Register basic callbacks
            this.network[NetworkPhrase.RemoveBlock] = this.RemoveBlock;
            this.network[NetworkPhrase.SetBlock] = this.SetBlock;
        }
Esempio n. 4
0
 public Player(World world)
     : base(new CapsuleShape(0.9f, 0.4f))
 {
     this.world = world;
     this.camera = new FirstPersonCamera(this)
     {
         EyeHeight = 0.6f
     };
     this.Material = new Material()
     {
         StaticFriction = 0.05f,
         KineticFriction = 0.3f,
         Restitution = 0.0f
     };
     this.AllowDeactivation = false;
 }
Esempio n. 5
0
 public WorldRenderer(World world)
 {
     this.world = world;
     this.world.BlockChanged += (s, e) => this.invalid = true;
 }
Esempio n. 6
0
		private void GenerateWorld()
		{
			this.world = new World();
			this.LoadWorld();
			this.world.DetailInterationTriggered += World_DetailInterationTriggered;

			return;

			var objA = this.world.CreateDetail("table_a", new Vector3(8.0f, 1.3f, 4.0f));
			objA.Rotation = Quaternion.FromAxisAngle(Vector3.UnitY, (float)(0.32f * Math.PI));

			var objB = this.world.CreateDetail("table_b", new Vector3(10.0f, 1.3f, 4.0f));
			objA.Rotation = Quaternion.FromAxisAngle(Vector3.UnitY, (float)(0.1f * Math.PI));

			var behavA = objA.CreateBehaviour<FlipOverBehaviour>();
			var behavA1 = objA.CreateBehaviour<ButtonBehaviour>();
			var behavA2 = objA.CreateBehaviour<ButtonBehaviour>();

			var behavB = objB.CreateBehaviour<FlipOverBehaviour>();
			var behavB1 = objB.CreateBehaviour<ButtonBehaviour>();
			var behavB2 = objB.CreateBehaviour<RotationBehaviour>();

			// Connect the both behaviours
			behavB1.Signals["clicked"].Connect(behavA.Slots["flip"]);
			behavA1.Signals["clicked"].Connect(behavB2.Slots["toggle"]);
			behavA2.Signals["clicked"].Connect(behavB1.Slots["toggle"]);
		}