private static void cutHole(Vector3 pos, Vector3 sca, Transform wall)
        {
            var position = calculateHolePosition(pos, wall);
            var scale = calculateHoleScale(sca, wall);

            var parentScale = getParentScale(wall);
            var scaledPos = NodeHelper.InverseScale(position, parentScale);
            var scaledSca = NodeHelper.InverseScale(scale, parentScale);

            var hole = new NodeJson(wall.name, scaledPos, scaledSca, "", NodeType.HOLE);

            NodeDataManager.AddNode(hole);
            NodeFactory.CreateNode(hole);
        }
예제 #2
0
            private void updateLeft(NodeBehaviour node)
            {
                var w = node.transform;

                w.localRotation = Quaternion.identity;
                var startScale = w.localScale;
                var holeLeft   = this.position.x - this.scale.x / 2;
                var hs         = w.localScale.x / 2;

                var s2 = hs + holeLeft;
                var p2 = (-hs + holeLeft) / 2;

                w.localPosition = new Vector3(p2, this.position.y, 0);
                w.localScale   += new Vector3(s2 - hs * 2, this.scale.y - w.localScale.y, 0);

                w.localPosition = NodeHelper.InverseScale(w.localPosition, startScale);
                w.localScale    = NodeHelper.InverseScale(w.localScale, startScale);

                if (Mathf.Abs(s2) < SMALLEST_WALL)
                {
                    this.deleteNode(node);
                }
            }
예제 #3
0
            private void updateTop(NodeBehaviour node)
            {
                var w = node.transform;

                w.localRotation = Quaternion.identity;
                var startScale = w.localScale;
                var holeTop    = this.position.y + this.scale.y / 2;
                var hs         = w.localScale.y / 2;

                var s2 = hs - holeTop;
                var p2 = (hs + holeTop) / 2;

                w.localPosition = new Vector3(0, p2, 0);
                w.localScale   += new Vector3(0, s2 - hs * 2, 0);

                w.localPosition = NodeHelper.InverseScale(w.localPosition, startScale);
                w.localScale    = NodeHelper.InverseScale(w.localScale, startScale);

                if (Mathf.Abs(s2) < SMALLEST_WALL)
                {
                    this.deleteNode(node);
                }
            }
예제 #4
0
        public void UpdateFromJson(NodeJson updatedJson)
        {
            if (updatedJson == null)
            {
                return;
            }

            this.name = updatedJson.name;
            this.transform.localPosition = updatedJson.position;
            if (this.GetScale() != updatedJson.scale)
            {
                var newScale = NodeHelper.InverseScale(updatedJson.scale, this.GetScale());
                this.transform.localScale = newScale;
                NodeHelper.NormaliseScale(this);
            }

            var parentName = this.HasParent ? this.parent.name : "";

            if (updatedJson.parentName != parentName)
            {
                var newParent = updatedJson.parentName == "" ? RootParent : NodeDataManager.FindNode(updatedJson.parentName);
                this.ChangeParent(newParent);
            }
        }