示例#1
0
        /// <summary>
        /// Initializes the control.
        /// </summary>
        /// <param name="teammate">Teammate model to initialize the control from.</param>
        /// <param name="addIcon">Texture of the add icon.</param>
        /// <param name="removeIcon">Texture of the remove icon.</param>
        public void Init(Teammate teammate, Texture addIcon, Texture removeIcon)
        {
            Teammate = teammate;
            var actionIcon  = teammate.IsAddedToTeam ? removeIcon : addIcon;
            var usedTexture = teammate.IsAddedToTeam ? teammate.SmallTexture : teammate.BigTexture;

            _verticalContainer = GetNode <VBoxContainer>("VerticalContainer");
            _teammateButton    = _verticalContainer.GetNode <TextureButton>("TeammateButton");
            _actionIcon        = _teammateButton.GetNode <TextureRect>("ActionIcon");
            _teammateName      = _verticalContainer.GetNode <Label>("CenterContainer/TeammateName");

            _teammateButton.TextureNormal = usedTexture;

            var teammateButtonSize = _teammateButton.TextureNormal.GetSize();

            this.RectMinSize = _teammateButton.TextureNormal.GetSize();

            _teammateName.Text  = teammate.Name;
            _actionIcon.Texture = teammate.IsAddedToTeam ? actionIcon : actionIcon;

            var actionIconSize = _actionIcon.Texture.GetSize();

            _actionIcon.SetPosition(new Vector2(teammateButtonSize.x - actionIconSize.x, teammateButtonSize.y - actionIconSize.y));

            _teammateButton.Connect("pressed", this, nameof(OnClick));

            _verticalContainer.Set("custom_constants/separation", VerticalContainerSeparation);
            _teammateName.AddFontOverride("font", Font);

            if (LabelColor.HasValue)
            {
                _teammateName.AddColorOverride("font_color", LabelColor.Value);
            }
        }
示例#2
0
        public override void _Ready()
        {
            base._Ready();

            _actionsBackground      = GetNode <TextureRect>("ActionsBackground");
            _actionsLabelsContainer = _actionsBackground.GetNode <VBoxContainer>("ActionsLabelsContainer");
            _completedActionsLabel  = _actionsLabelsContainer.GetNode <RichTextLabel>("CompletedActionsLabel");
            _correctActionsLabel    = _actionsLabelsContainer.GetNode <RichTextLabel>("CorrectActionsLabel");

            var labelsFont = (DynamicFont)GD.Load($"{_resourcesPath}bebas_neue_actions.tres");

            labelsFont.Size = 25;

            _completedActionsLabel.AddFontOverride("normal_font", labelsFont);
            _correctActionsLabel.AddFontOverride("normal_font", labelsFont);

            _actionsBackground.Texture      = (Texture)GD.Load($"{_resourcesPath}time_background.png");
            _actionsBackground.RectPosition = new Vector2(800, -10);

            _actionsLabelsContainer.RectPosition = new Vector2(70, 15);
            _actionsLabelsContainer.Set("custom_constants/separation", -2);

            _completedActionsLabel.RectMinSize   = new Vector2(250, 30);
            _completedActionsLabel.BbcodeEnabled = true;
            _completedActionsLabel.ScrollActive  = false;
            _correctActionsLabel.RectMinSize     = new Vector2(250, 30);
            _correctActionsLabel.BbcodeEnabled   = true;
            _correctActionsLabel.ScrollActive    = false;
        }
示例#3
0
        protected override void SetupView()
        {
            _textureOff = (Texture)GD.Load($"{_resourcesPath}star_off.png");
            _textureOn  = (Texture)GD.Load($"{_resourcesPath}star_on.png");

            _background.Texture  = (Texture)GD.Load($"{_resourcesPath}rating_background.png");
            _background.Position = new Vector2(181, 155);

            var font = (DynamicFont)GD.Load($"{_resourcesPath}montserrat_light.tres");

            font.Size = 24;
            _title.AddFontOverride("font", font);
            _title.Text = "Ohodnotit";

            _windowWrapper.RectPosition = new Vector2(25, 10);
            _windowWrapper.Set("custom_constants/separation", 21);

            _marginContainer.Set("custom_constants/margin_left", 28);

            _horizontalContainer.Set("custom_constants/separation", 15);

            _commentsMarginContainer = _windowWrapper.GetNode <MarginContainer>("CommentsMarginContainer");
            _commentsMarginContainer.Set("custom_constants/margin_left", 7);

            _commentsContainer = _commentsMarginContainer.GetNode <VBoxContainer>("CommentsContainer");
            _commentsContainer.Set("custom_constants/separation", 15);

            var lineTexture = (Texture)GD.Load($"{_resourcesPath}line.png");
            var comments    = new string[]
            {
                "skvělé\nHana",
                "Líbí se mi tato verze.\nPetr"
            };

            foreach (var comment in comments)
            {
                var line = new TextureRect();
                line.Texture = lineTexture;

                _commentsContainer.AddChild(line);

                var margin = new MarginContainer();
                margin.Set("custom_constants/margin_left", 10);

                var label = new Label();
                label.AddFontOverride("font", font);
                label.Text = comment;

                margin.AddChild(label);
                _commentsContainer.AddChild(margin);
            }
        }
示例#4
0
    public void OnLevelCompleted(LevelResult result, SceneManager parent)
    {
        this.parent = parent;

        VBoxContainer textContainer  = (VBoxContainer)FindNode("TextContainer");
        VBoxContainer splitContainer = (VBoxContainer)FindNode("UISplitContainer");

        splitContainer.Set("custom_constants/separation", 200 - result.enemies.Count * 18);

        DynamicFont headerFont = new DynamicFont();

        headerFont.FontData     = (DynamicFontData)ResourceLoader.Load("res://fonts/Comfortaa-Bold.ttf");
        headerFont.OutlineSize  = 3;
        headerFont.OutlineColor = new Color("#000000");
        headerFont.Size         = 36;

        Label waveCompletedLabel = new Label();

        waveCompletedLabel.Text = "Game over";
        waveCompletedLabel.AddFontOverride("font", headerFont);

        textContainer.AddChild(waveCompletedLabel);

        DynamicFont waveClearedFont = new DynamicFont();

        waveClearedFont.FontData     = (DynamicFontData)ResourceLoader.Load("res://fonts/Comfortaa-Bold.ttf");
        waveClearedFont.OutlineSize  = 3;
        waveClearedFont.OutlineColor = new Color("#000000");
        waveClearedFont.Size         = 24;

        Label waveClearedLabel = new Label();

        waveClearedLabel.Text = "Reached wave " + result.waveNum + " at -" + result.altitude + "M";
        waveClearedLabel.AddFontOverride("font", waveClearedFont);

        textContainer.AddChild(waveClearedLabel);

        DynamicFont font = new DynamicFont();

        font.FontData     = (DynamicFontData)ResourceLoader.Load("res://fonts/Comfortaa-Bold.ttf");
        font.OutlineSize  = 2;
        font.OutlineColor = new Color("#000000");
        font.Size         = 16;

        Label enemyHeaderLabel = new Label();

        enemyHeaderLabel.Text = "Enemies slain";
        enemyHeaderLabel.AddFontOverride("font", font);

        textContainer.AddChild(enemyHeaderLabel);

        int totalXP = 0;

        foreach (KeyValuePair <string, EnemyResult> entry in result.getEnemies())
        {
            Label label = new Label();
            label.Text = "    " + entry.Value.count + " x " + entry.Key;
            label.AddFontOverride("font", font);

            totalXP += entry.Value.xp * entry.Value.count;

            textContainer.AddChild(label);
        }

        Label totalTotalXpLabel = new Label();

        totalTotalXpLabel.Text = "Total xp";
        totalTotalXpLabel.AddFontOverride("font", font);

        textContainer.AddChild(totalTotalXpLabel);

        Label totalTotalTotalXpLabel = new Label();

        totalTotalTotalXpLabel.Text = "    " + result.getTotalXp();
        totalTotalTotalXpLabel.AddFontOverride("font", font);

        textContainer.AddChild(totalTotalTotalXpLabel);
    }