Esempio n. 1
0
        protected override void SpawnAvatar(IEdge edge)
        {
            IEdgeAvatar  edgeAvatar   = new EdgeAvatar(this.avatarPrefab, edge);
            MBEdgeAvatar mbEdgeAvatar = edgeAvatar.GetGameObject().GetComponent <MBEdgeAvatar>();

            if (mbEdgeAvatar != null)
            {
                edgeAvatar = new EdgeAvatarHighlightable(edgeAvatar, mbEdgeAvatar);
                if (edge.GetEdgeType() == 'd')
                {
                    edgeAvatar = new EdgeAvatarDirected(edgeAvatar, mbEdgeAvatar);
                }
            }
            string labelText;

            if (edge.TryGetLabel(out labelText))
            {
                edgeAvatar = new EdgeAvatarLabeled(edgeAvatar, labelAvatarPrefab, labelText);
            }
            edge.SetAvatar(edgeAvatar);
        }
Esempio n. 2
0
        public EdgeAvatar(GameObject nodeAvatarPrefab, IEdge edge)
        {
            this.gameObject = MonoBehaviour.Instantiate(nodeAvatarPrefab, Vector3.zero, Quaternion.identity);

            MBEdgeAvatar mbEdegAvatar = this.gameObject.GetComponent <MBEdgeAvatar>();
            INode        source       = edge.GetSourceNode();
            INode        target       = edge.GetTargetNode();
            IAvatar      sourceAvatar;
            IAvatar      targetAvatar;

            if (source.TryGetAvatar(out sourceAvatar) && target.TryGetAvatar(out targetAvatar) && mbEdegAvatar != null)
            {
                this.sourceNodeAvatar = (INodeAvatar)sourceAvatar;
                this.targetNodeAvatar = (INodeAvatar)targetAvatar;

                mbEdegAvatar.SetSourceNodeAvatar(this.sourceNodeAvatar);
                mbEdegAvatar.SetTargetNodeAvatar(this.targetNodeAvatar);
            }
            else
            {
                G3DLogger.Log("Missing component in edge {0}, avatar constructor failed.", edge.GetId());
                this.SelfDestruct();
            }
        }