コード例 #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
ファイル: City.cs プロジェクト: spthiel/mom-i-started-a-cult
    // Called when the node enters the scene tree for the first time
    public override void _Ready()
    {
        _setupChapterPanel         = GetNode <Panel>("SetupChapter");
        _setupChapterPanel.Visible = false;
        _statusPanel         = GetNode <Panel>("Status");
        _statusPanel.Visible = false;
        _statusPanel.GetNode <Label>("VerticalContainer/Name").Text = _name;
        GetNode <Label>("Name").Text = _name;

        _followerCounter        = _statusPanel.GetNode <Label>("VerticalContainer/Followers/Background/Count");
        _followerCounter.Text   = ((int)_followerCount).ToString();
        _followerRateLabel      = _followerCounter.GetNode <Label>("Rate");
        _followerRateLabel.Text = $"({_followersPerDay.ToString("+0;-#")}/day)";
        _moneyPerDayLabel       = _statusPanel.GetNode <Label>("VerticalContainer/Money/Background/Rate");
        _moneyPerDayLabel.Text  = $"{(Math.Round(_dailyCultFeesPerFollower*_followerCount, 2)).ToString("+0.00;-#.00")}/day";

        _menuSound = GetNode <AudioStreamPlayer>("MenuSound");

        _purchaseButton = _setupChapterPanel.GetNode <TextureButton>("Purchase");
        (_statusPanel.GetNode <Label>("VerticalContainer/Population/Background/Count")).Text = _populationNotFollowers.ToString();
        (_purchaseButton.GetNode <Label>("Price/Value")).Text = _price.ToString();

        var gameState = GetParent().GetParent().GetNode("Game State");

        Connect(nameof(Purchase), gameState, "OnPurchase");
        Connect(nameof(FollowersChange), gameState, "OnFollowersChangeInChapter");
        Connect(nameof(MoneyIncreased), gameState, "UpdateMoney");
        Connect(nameof(FullyConverted), gameState, "OnCityFullyConverted");

        var upgradeScene = (PackedScene)ResourceLoader.Load("res://scenes/Upgrade.tscn");

        var upgradesContainer = _statusPanel.GetNode("VerticalContainer/ScrollContainer/Upgrades");

        _upgrades = new List <Upgrade>();


        using (var file = new File()) {
            file.Open("res://upgradeData.json", File.ModeFlags.Read);

            var upgradesData = JsonConvert.DeserializeObject <UpgradeData[]>(file.GetAsText());

            // Initialise upgrades
            foreach (var upgradeData in upgradesData.Where(u => !u.Global))
            {
                var upgrade = (Upgrade)(upgradeScene.Instance());
                _upgrades.Add(upgrade);
                upgradesContainer.AddChild(upgrade);
                upgrade.Initialise(upgradeData, this);
            }
        }
    }
コード例 #3
0
 public override void _Ready()
 {
     _button     = GetNode("VBoxContainer").GetNode <TextureButton>("Tower");
     _priceLabel = GetNode("VBoxContainer").GetNode("PriceContainer").GetNode("PriceLabel").GetNode("Info").GetNode <Label>("Price");
     _towerLabel = _button.GetNode("TowerInfo").GetNode("VBoxContainer").GetNode <Label>("TowerLabel");
     _background = GetNode <ColorRect>("ColorRect");
     if (TowerType == null)
     {
         return;
     }
     _button.TextureNormal = GD.Load <Texture>(TowerType?.IconPath);
     _towerLabel.Text      = TowerType?.Name;
     _priceLabel.Text      = TowerType?.Cost.ToString();
     _normalTexture        = _button.TextureNormal;
     _buyingTexture        = _button.TexturePressed;
 }
コード例 #4
0
ファイル: MicrobeHUD.cs プロジェクト: rhythms06/Thrive
    /// <summary>
    ///   Enables the editor button.
    /// </summary>
    public void ShowReproductionDialog()
    {
        if (editorButton.Disabled)
        {
            GUICommon.Instance.PlayCustomSound(MicrobePickupOrganelleSound);

            editorButton.Disabled = false;
            editorButton.GetNode <TextureRect>("Highlight").Show();
            editorButton.GetNode <TextureProgress>("ReproductionBar/PhosphateReproductionBar").TintProgress =
                new Color(1, 1, 1, 1);
            editorButton.GetNode <TextureProgress>("ReproductionBar/AmmoniaReproductionBar").TintProgress =
                new Color(1, 1, 1, 1);
            editorButton.GetNode <TextureRect>("ReproductionBar/PhosphateIcon").Texture = PhosphatesBW;
            editorButton.GetNode <TextureRect>("ReproductionBar/AmmoniaIcon").Texture   = AmmoniaBW;
            editorButton.GetNode <AnimationPlayer>("AnimationPlayer").Play("EditorButtonFlash");
        }
    }
コード例 #5
0
 protected internal SpriteButton(Node parent, string name)
 {
     Button         = (TextureButton)parent.GetNode(name);
     Sprite         = (AnimatedSprite)Button.GetNode($"{name}Sprite");
     Sprite.Playing = true;
 }