protected override void Update(TimeSpan gameTime) { touchPanelState = WaveServices.Input.TouchPanelState; if (touchPanelState.IsConnected && touchPanelState.Count > 0) { if (!pressed) { pressed = true; if (ball == null) { ball = Helpers.CreateSphere("ball", Vector3.Zero, ballSize, BALL_MASS, Color.Gray); EntityManager.Add(ball); } RigidBody3D rigidBody = ball.FindComponent <RigidBody3D>(); rigidBody.ResetPosition(Camera.Position); var direction = Camera.Transform.WorldTransform.Forward; direction.Normalize(); rigidBody.ApplyLinearImpulse(direction * 100f); } } else { pressed = false; } }
private void StartGame(object sender, GestureEventArgs e) { if (_started) { return; } _started = true; EntityManager.Find <TextBlock>("ToasterPosition").Text = "Start"; Entity toastModel = new Entity("toastModel") .AddComponent(new Transform3D()) .AddComponent(new MaterialsMap(new BasicMaterial(Color.Gray))) .AddComponent(Model.CreateCube()) .AddComponent(new SphereCollider()) .AddComponent(new RigidBody3D() { Mass = 1, EnableContinuousContact = true }) .AddComponent(new ModelRenderer()); EntityManager.Add(toastModel); RigidBody3D rigidBody = toastModel.FindComponent <RigidBody3D>(); rigidBody.ResetPosition(Vector3.Zero); rigidBody.ApplyLinearImpulse(25 * Vector3.UnitY); WaveServices.Input.TouchPanelState.Clear(); EntityManager.Find <FixedCamera>("MainCamera").Entity.AddComponent(new FlightBehavior(toastModel)); //EntityManager.Find<FixedCamera>("MainCamera").Entity.AddComponent(new RigidBody3D() { IsKinematic = true, }); }
protected override void Update(TimeSpan gameTime) { var touches = WaveServices.Input.TouchPanelState; if (touches.Count > 0) { if (!pressed) { pressed = true; var sphere = new Entity() .AddComponent(new Transform3D() { Scale = new Vector3(1) }) .AddComponent(new MaterialsMap() { DefaultMaterialPath = WaveContent.Assets.basicMaterial }) .AddComponent(Model.CreateSphere()) .AddComponent(new SphereCollider3D()) .AddComponent(new RigidBody3D() { Mass = 2, EnableContinuousContact = true }) .AddComponent(new TimeAliveBehavior()) .AddComponent(new ModelRenderer()); this.EntityManager.Add(sphere); RigidBody3D rigidBody = sphere.FindComponent <RigidBody3D>(); rigidBody.ResetPosition(Camera.Position); var direction = Camera.Transform.WorldTransform.Forward; direction.Normalize(); rigidBody.ApplyLinearImpulse(100 * direction); } } else { pressed = false; } }
protected override void Update(TimeSpan gameTime) { var touches = WaveServices.Input.TouchPanelState; if (touches.Count > 0) { if (!pressed) { pressed = true; if (sphere == null) { sphere = new Entity("ball") .AddComponent(new Transform3D() { Scale = new Vector3(1) }) .AddComponent(new MaterialsMap(new BasicMaterial(Color.Red))) .AddComponent(Model.CreateSphere()) .AddComponent(new SphereCollider()) .AddComponent(new RigidBody3D() { Mass = 2, EnableContinuousContact = true }) .AddComponent(new ModelRenderer()); EntityManager.Add(sphere); } RigidBody3D rigidBody = sphere.FindComponent <RigidBody3D>(); rigidBody.ResetPosition(Camera.Position); var direction = Camera.LookAt - Camera.Position; direction.Normalize(); rigidBody.ApplyLinearImpulse(100 * direction); } } else { pressed = false; } }
protected override void Update(TimeSpan gameTime) { var touches = WaveServices.Input.TouchPanelState; if (touches.Count > 0) { if (!pressed) { pressed = true; RigidBody3D rigidBody = linkedEntity.FindComponent <RigidBody3D>(); rigidBody.ResetPosition(Camera.Position); var direction = Camera.Transform.WorldTransform.Forward; direction.Normalize(); rigidBody.ApplyLinearImpulse(100 * direction); } } else { pressed = false; } }
protected override void Update(TimeSpan gameTime) { rigidBody3D.ResetPosition(this.RenderManager.ActiveCamera3D.Position); }