public Stitch(Textile owner, Vector2 position, Vector2 coordinate, Color color) { this.owner = owner; this.Position = owner.Transform(position); this.homePosition = position; this.Coordinate = coordinate; this.color = color; }
/// <summary> /// Loads textile content. /// </summary> protected override void LoadContent() { GraphicsDevice.PresentationParameters.DepthStencilFormat = DepthFormat.Depth24Stencil8; Vector2 screenSize = new Vector2(Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height); // Create and position the textiles using some hand-picked values. const int cols = 32; // number of stitches horizontally const int rows = 24; // number of stitches vertically textiles[0] = new Textile(cols, rows, new Vector2(0.5f, 0.5f) * screenSize,// center 0.6f, // scale -10, // Orientation new Vector3(0.65f, 0.24f, 0.1f), // startColor new Vector3(0.45f, 0.76f, 0.5f), // endColor screenSize); textiles[1] = new Textile(cols, rows, new Vector2(0.65f, 0.65f) * screenSize, 1.2f, 15, new Vector3(0.24f, 0.5f, 0.65f), new Vector3(0.20f, 0.9f, 0.65f), screenSize); textiles[2] = new Textile(cols, rows, new Vector2(0.59f, 1.04f) * screenSize, 1.1f, 38, new Vector3(0.1f, 0.0f, 0.74f), new Vector3(0.1f, 0.9f, 0.74f), screenSize); LoadTextures(); textileComponent.Textiles.Clear(); // Initialize each flag and add it to the textileComponent manager. for (int i = 0; i < textiles.Length; i++) { textiles[i].Texture = textures[(int)CurrentTheme + i]; textiles[i].RenderStyle = RenderStyles.Texture; textileComponent.Textiles.Add(textiles[i]); } base.LoadContent(); }
/// <summary> /// Get a capturing Textile object for the given touchId /// </summary> /// <param name="touchId">Id of captured touch</param> /// <param name="capturingTextile">Textile which is capturing the touch</param> /// <returns></returns> public bool TryFindCapturingTextile(int touchId, out Textile capturingTextile) { foreach (Textile textile in textiles) { if (textile.IsCapturing(touchId)) { capturingTextile = textile; return true; } } capturingTextile = null; return false; }