public override void CreateShape(EntityType type, Point?where = null) { base.CreateShape(type); switch (type) { case EntityType.Class: case EntityType.Delegate: case EntityType.Enum: case EntityType.Interface: case EntityType.Structure: shapeOutline = TypeShape.GetOutline(Style.CurrentStyle); break; case EntityType.Package: shapeOutline = PackageShape.GetOutline(Style.CurrentStyle); break; case EntityType.Comment: shapeOutline = CommentShape.GetOutline(Style.CurrentStyle); break; } //shapeOutline.Location = new Point((int) mouseLocation.X, (int) mouseLocation.Y); shapeOutline.Location = where ?? new Point((int)mouseLocation.X, (int)mouseLocation.Y); Redraw(); }
public override void CreateShape(EntityType type) { { state = State.CreatingShape; shapeType = type; newShapeType = type; switch (type) { case EntityType.Class: case EntityType.Delegate: case EntityType.Enum: case EntityType.Interface: case EntityType.Structure: shapeOutline = TypeShape.GetOutline(Style.CurrentStyle); break; case EntityType.Package: shapeOutline = PackageShape.GetOutline(Style.CurrentStyle); break; case EntityType.Comment: shapeOutline = CommentShape.GetOutline(Style.CurrentStyle); break; } shapeOutline.Location = new Point((int)mouseLocation.X, (int)mouseLocation.Y); Redraw(); } }
public PackageController SpawnRandomPackage() { PackageController package = Instantiate(packagePrefab, transform.position, transform.rotation); int shapeEnumValue = Random.Range(0, System.Enum.GetNames(typeof(PackageShape)).Length); PackageShape shape = (PackageShape)shapeEnumValue; package.SetShape(shape); int colorEnumValue = Random.Range(0, System.Enum.GetNames(typeof(PackageColor)).Length); PackageColor color = (PackageColor)colorEnumValue; package.SetColor(color); int layoutEnumValue = Random.Range(0, System.Enum.GetNames(typeof(PackageLayout)).Length); PackageLayout layout = (PackageLayout)layoutEnumValue; package.SetLayout(layout); Rigidbody rb = package.GetComponent <Rigidbody>(); float randomAngle = Random.Range(0.0f, 360.0f); float randomStrength = Random.Range(0.0f, randomImpulseStrength); Vector3 force = transform.rotation * Quaternion.AngleAxis(randomAngle, Vector3.up) * (Vector3.forward * randomStrength); Vector3 randomOffset = new Vector3(Mathf.Sin(Random.Range(0.0f, Mathf.PI * 2.0f)), Mathf.Sin(Random.Range(0.0f, Mathf.PI * 2.0f)), Mathf.Sin(Random.Range(0.0f, Mathf.PI * 2.0f))) * 0.5f; rb.AddForceAtPosition(force, package.transform.position + randomOffset); if (OnPackageSpawned != null) { OnPackageSpawned(this, package); } return(package); }
private void mnuEditPackage_Click(object sender, EventArgs e) { if (Diagram != null) { PackageShape packageShape = Diagram.TopSelectedElement as PackageShape; packageShape?.EditText(); } }
internal override void Init(DiagramElement element) { shape = (PackageShape)element; txtName.BackColor = Style.CurrentStyle.PackageBackColor; txtName.ForeColor = Style.CurrentStyle.PackageTextColor; txtName.Text = shape.Name; Font font = Style.CurrentStyle.PackageFont; txtName.Font = new Font(font.FontFamily, font.SizeInPoints * shape.Diagram.Zoom, font.Style); }
internal void Relocate(PackageShape shape) { IDiagram diagram = shape.Diagram; if (diagram != null) { Rectangle absolute = shape.GetNameRectangle(); this.SetBounds( (int)(absolute.X * diagram.Zoom) - diagram.Offset.X + ParentLocation.X, (int)(absolute.Y * diagram.Zoom) - diagram.Offset.Y + ParentLocation.Y, (int)(absolute.Width * diagram.Zoom), (int)(absolute.Height * diagram.Zoom)); this.txtName.Width = (int)(absolute.Width * diagram.Zoom); this.txtName.Height = (int)(absolute.Height * diagram.Zoom); } }
public void SetShape(PackageShape _shape) { packageShape = _shape; Mesh m = null; Texture2D t = null; Texture2D colorT = null; switch (packageShape) { case PackageShape.Box: { m = boxMesh; t = boxTexture; colorT = boxColorTexture; } break; case PackageShape.Pyramid: { m = pyramidMesh; t = pyramidTexture; colorT = pyramidColorTexture; } break; case PackageShape.Flat: { m = flatMesh; t = flatTexture; colorT = flatColorTexture; } break; case PackageShape.Cylinder: { m = cylinderMesh; t = cylinderTexture; colorT = cylinderColorTexture; } break; case PackageShape.Rectangle: { m = rectangleMesh; t = rectangleTexture; colorT = rectangleColorTexture; Vector3 localScale = transform.localScale; localScale.x *= 1.3f; localScale.z *= 0.8f; transform.localScale = localScale; } break; case PackageShape.Sphere: { m = sphereMesh; t = sphereTexture; colorT = sphereColorTexture; } break; default: break; } GetComponent <MeshCollider>().sharedMesh = m; cardboardObject.GetComponent <MeshFilter>().sharedMesh = m; cardboardObject.GetComponent <MeshRenderer>().material.mainTexture = t; colorObject.GetComponent <MeshFilter>().sharedMesh = m; colorObject.GetComponent <MeshRenderer>().material.mainTexture = colorT; layoutObject.GetComponent <MeshFilter>().sharedMesh = m; }