Ejemplo n.º 1
0
        public void AddWidget(Widget widget)
        {
            Node widgetNode = new Node();

            widgetNode.SetScale(0.1f);
            widgetNode.Position += new Vector3(widget.Position[0] * 0.1f, widget.Position[1] * 0.1f, widget.Position[2] * 0.1f);

            //Background Plane
            Node backgroundPlaneNode = widgetNode.CreateChild();

            backgroundPlaneNode.Scale     = new Vector3(1.9f, 1f, 1f);
            backgroundPlaneNode.Rotation  = new Quaternion(-90, 0, 0);
            backgroundPlaneNode.Position += new Vector3(0, 0, 0.05f);

            Urho.Shapes.Plane plane = backgroundPlaneNode.CreateComponent <Urho.Shapes.Plane>();
            plane.SetMaterial(Material.FromColor(new Color(0.6f, 0.6f, 0.6f, 0.5f)));

            //Text Component
            Text3D text = widgetNode.CreateComponent <Text3D>();

            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.VerticalAlignment   = VerticalAlignment.Center;
            text.SetFont(CoreAssets.Fonts.AnonymousPro, 12);
            text.SetColor(Color.Red);
            text.Text = "LOADING...";

            switch (widget.type)
            {
            case WidgetType.Text:
                //Text Widget Display
                TextWidget textWidget = widgetNode.CreateComponent <TextWidget>();
                textWidget.Text  = text;
                textWidget.Key   = widget.NetworkKey;
                textWidget.Label = widget.Label;
                break;

            case WidgetType.Camera:
                //remove text
                text.Remove();

                //Camera Widget
                CameraWidget cameraWidget = new CameraWidget(widget.NetworkKey, plane);
                widgetNode.AddComponent(cameraWidget);
                break;

            case WidgetType.Status:
                //adjust the size of the background plane
                backgroundPlaneNode.Scale = new Vector3(0.5f, 1f, 0.25f);

                //Status Widget
                StatusWidget statusWidget = new StatusWidget(text, plane, widget.NetworkKey, widget.Label);
                widgetNode.AddComponent(statusWidget);
                break;
            }

            Node.AddChild(widgetNode);
        }
Ejemplo n.º 2
0
 protected override void OnDeleted()
 {
     base.OnDeleted();
     ReceiveSceneUpdates = false;
     if (!m_Geometry.IsDeleted)
     {
         IdlePlayerManager.Instance.Buildings.Remove(this);
         m_Geometry.Remove();
         m_Geometry = null;
         m_Text.Remove();
         m_TextNode.Remove();
         m_LevelText.Remove();
         m_LevelTextNode.Remove();
     }
 }