protected override void InitInput() { //create the touch manager component var touches = new TouchComponent(this, ResolutionBuddy.Resolution.ScreenToGameCoord); //add the input helper for menus var input = new TouchInputHelper(this); }
public override SensorComponent MakeComponent(GameObject gameObject) { TouchComponent component = gameObject.AddComponent <TouchComponent>(); component.filter = filter; component.minVelocity = minVelocity; component.direction = direction; return(component); }
public virtual void OnTouch(Entity other) { // Also pass the information to the hurt touch component if there is one TouchComponent touchComponent = GetComponent <TouchComponent>(); if (touchComponent) { touchComponent.OnTouch(other); } }
/// <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() { var touch = new TouchComponent(this, null); touch.SupportedGestures = GestureType.Tap | GestureType.Pinch | GestureType.PinchComplete | GestureType.DoubleTap | GestureType.Flick; _input = touch; var debug = new InputHelper.DebugInputComponent(this, null); base.Initialize(); }
public Shield(World world, TouchComponent touch, Projectile[] projectiles) : base(world) { BodyType = BodyType.Static; touchComp = touch; verts = new Vertices(100); vertsList = new List<Vertices>(100); projs = projectiles; updateThread = new Thread(new ThreadStart(update)); updateThread.Priority = ThreadPriority.Lowest; threadSem = new Semaphore(0, 2); threadSemCount = 0; updateThread.Start(); #if DEBUG debugImg = new Texture2D(touchComp.Game.GraphicsDevice, 1024, 768, 1, TextureUsage.AutoGenerateMipMap, SurfaceFormat.Luminance8); debugImgData = new byte[1024 * 768]; #endif }
public void Update(TouchComponent touchComp) { foreach (var c in touchComp.CurrentContacts) if (new Vector2(c.CenterX - Position.X * 100, c.CenterY - Position.Y * 100).Length() < radius) { if (contact != null) contact = c; if (touchComp.NewContacts.Any(c1 => c1.Id == c.Id)) { contact = c; angle = c.Orientation; count = 0; } } if (contact != null && touchComp.CurrentContacts.Contains(contact.Id)) { var deltaRot = contact.Orientation - angle; if (deltaRot > 5.8f && deltaRot < 7) angle += MathHelper.TwoPi; else if (deltaRot < -5.8f && deltaRot > -7) angle -= MathHelper.TwoPi; if (Math.Abs(deltaRot) < 1) { angle = (angle * Math.Min(count, 19) + contact.Orientation) / Math.Min(count + 1, 20); count++; } } if (contact != null && touchComp.OldContacts.Any(c => c.Id == contact.Id)) { screen.CreateProjectile(Position, angle, count, this); shootSnd.Play(0.2f, -Math.Min(count, 100) / 100f, 0); contact = null; count = 0; } }