private void ShowToken(Random random, BattleToken token, Object2D parent, int index)
        {
            var tokenObj = new BattleTokenView(token);

            Tokens[token.Index] = tokenObj;
            Layer.AddObject(tokenObj);

            var x = (float)random.NextDouble() * 2 - 1;
            var y = (float)random.NextDouble() * 2 - 1;

            tokenObj.Position = coordinateConverter.Convert(new Vector2DF(x, y));

            var profileObj = new ProfileCardView(token, headerFont, planeFont);

            Profiles[token.Index] = profileObj;
            parent.AddChild(profileObj, ChildManagementMode.Disposal | ChildManagementMode.RegistrationToLayer,
                            ChildTransformingMode.All);

            var sizeX = 160.0f;
            var px    = (index % 2) * (sizeX + 4);
            var py    = (index / 2) * (sizeX * 1.61805f + 4);

            profileObj.Position = new Vector2DF(-px, -py) - new Vector2DF(sizeX, sizeX * 1.61805f);

            var scale = sizeX / profileObj.CardSize.X;

            profileObj.Scale = new Vector2DF(scale, scale);
        }
Beispiel #2
0
 void OpenMenu()
 {
     Parent = new Object2D("DebugMenu", new Vector2(0, 0), new Vector2(0, 0), 0, new Component2D[] { new Spacer2DComponent(SpacerOption.VerticalSpacer, new Vector2(0, 5), Alignment.TopLeft, new Vector2(5, 5)), new Image2DComponent(DefaultValues.PixelTexture, Color.Black, 0) }, layer: 1);
     Parent.AddChild(new Object2D("DebugMenu_FPS", new Vector2(0, 0), new Vector2(120, 30), 0, new Component2D[] { new Text2DComponent("FPS", DefaultValues.DefaultFont, Color.Green, 0, 0.5f, textBreaking: false, subLayer: 0), new FPSScript() }), 0);
 }
Beispiel #3
0
        public static void Init()
        {
            Debug.Log("    UI");

            // TopBar
            TopBar = new Object2D("Editor_TopBar", Vector2.Zero, new Vector2(Screen.Resolution.X, 25), 0, new Component2D[] {
                new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.ToolBar),
                new Spacer2DComponent(SpacerOption.HorizontalSpacer, new Vector2(5, 0), Alignment.MiddleLeft, new Vector2(5, 0))
            }, Alignment.TopLeft, EditorUILayer - 0.0001f);

            FileButton = new Object2D("Editor_FileButton", Vector2.Zero, new Vector2(100, 25), 0, new Component2D[] {
                new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.ToolBar),
                new Text2DComponent("File", DefaultValues.DefaultFont, EditorTheme.Window, 0, 0.2f, Alignment.Center, false),
                new Button2DComponent(
                    onHover: () => FileButton.GetComponent <Image2DComponent>().Color = new Color(EditorTheme.ToolBar.ToVector3() + new Vector3(0.1f)),
                    onExit: () => FileButton.GetComponent <Image2DComponent>().Color  = EditorTheme.ToolBar
                    ),
                new Dropdown2DComponent(new Object2D[] { new Object2D("Editor_SaveButton", Vector2.Zero, new Vector2(240, 25), 0, new Component2D[] { new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.ToolBar), new Text2DComponent("Save Level", DefaultValues.DefaultFont, EditorTheme.Window, 0, 0.2f, Alignment.Center), new Button2DComponent(onClick: () => Level.SaveLevel(FileExplorer.SaveFile("Save"))) }) }, new Vector2(250, 500), new Vector2(5, 5), EditorTheme.Window, true)
            }, Alignment.TopLeft, EditorUILayer - 0.0005f);

            TopBar.AddChild(FileButton);

            // Properties Bar
            Properties = new Object2D("Editor_PropertiesContainer", new Vector2(Screen.Resolution.X, Screen.Resolution.Y), new Vector2(300, Screen.Resolution.Y - 75), 0, new Component2D[] {
                new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.Window),
                new Spacer2DComponent(SpacerOption.VerticalSpacer, new Vector2(0, 10), Alignment.TopCenter, new Vector2(0, 10))
            }, Alignment.BottomRight, EditorUILayer - 0.0005f);
            Properties.Parent = new Object2D("Editor_PropertiesContainerTitle", Properties.Position + new Vector2(0, -Properties.Size.Y), new Vector2(300, 50), 0, new Component2D[] {
                new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.TitleBar),
                new Text2DComponent("Properties", DefaultValues.DefaultFont, EditorTheme.Window, 0, 0.2f, Alignment.Center, false, 1)
            }, Alignment.BottomRight, EditorUILayer - 0.0005f);

            // Level Contents
            LevelContent = new Object2D("Editor_LevelContents", new Vector2(0, Screen.Resolution.Y), new Vector2(300, Screen.Resolution.Y - 75), 0, new Component2D[] {
                new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.Window),
                new Spacer2DComponent(SpacerOption.VerticalSpacer, new Vector2(0, 10), Alignment.TopCenter, new Vector2(0, 10))
            }, Alignment.BottomLeft, EditorUILayer - 0.0005f);

            LevelContent.Parent = new Object2D("Editor_LevelContentTitle", LevelContent.Position + new Vector2(0, -LevelContent.Size.Y), new Vector2(300, 50), 0, new Component2D[] {
                new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.TitleBar),
                new Text2DComponent("Level Content", DefaultValues.DefaultFont, EditorTheme.Window, 0, 0.2f, Alignment.Center, false, 1)
            }, Alignment.BottomLeft, EditorUILayer - 0.0005f);

            // RightClickMenu
            RClick = new Object2D("Editor_RClickMenu", Vector2.Zero, new Vector2(250, 500), 0, new Component2D[] {
                new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.Window),
                new Spacer2DComponent(SpacerOption.VerticalSpacer, new Vector2(0, 5), Alignment.TopCenter, new Vector2(0, 5))
            }, Alignment.TopLeft, EditorUILayer - 0.0004f, children: new Object2D[] {
                // Menu Items
                new Object2D("Editor_RClickMenu_NewObject2D", Vector2.Zero, new Vector2(240, 25), 0, new Component2D[] {
                    new Image2DComponent(DefaultValues.PixelTexture, EditorTheme.ToolBar),
                    new Text2DComponent("Create 2D Object", DefaultValues.DefaultFont, EditorTheme.Window, 0.1f, 0.2f, Alignment.Center, false),
                    new Button2DComponent(
                        onHover: () => RClick.Children.Find((x) => x.ObjectName == "Editor_RClickMenu_NewObject2D").GetComponent <Image2DComponent>().Color = new Color(EditorTheme.ToolBar.ToVector3() + new Vector3(0.1f)),
                        onExit: () => RClick.Children.Find((x) => x.ObjectName == "Editor_RClickMenu_NewObject2D").GetComponent <Image2DComponent>().Color  = EditorTheme.ToolBar,
                        onClick: Add2DObject
                        )
                })
            });
            RClick.Enabled = false;
        }