コード例 #1
0
ファイル: Lane.cs プロジェクト: ojas-sanghi/scaling-out
    float dangerZonePositionModifier = 1.255f; // hardcoded number, how much the x position of the zone is divded

    public override void _Ready()
    {
        if (laneImg == null)
        {
            GD.PushError("You must set laneImg for Lane!");
            GD.PrintStack();
            GetTree().Quit(1);
        }

        TextureButton button = GetNode <TextureButton>("Button");

        spawnPoint = button.RectGlobalPosition + new Vector2(70, 30);

        GetNode <Sprite>("Sprite").Texture = laneImg;
        Events.roundWon         += OnRoundWon;
        Events.dinoDiedInstance += OnDinoDiedInstance;

        // we're an empty lane, don't allow deploys
        if (Curve.GetPointCount() == 0)
        {
            button.Hide();
            return;
        }

        dangerZoneCollision = GetNode("DangerZone").GetNode <CollisionShape2D>("DangerZoneCollision");
        var dangerBox = new RectangleShape2D(); // make a hitbox for the danger zone

        dangerZoneCollision.Shape = dangerBox;

        // divide by 1/2 since that's how extents work
        // divide x by 1/3 since we want it to be that big
        dangerBox.Extents            = new Vector2(laneImg.GetSize().x / 2 / 3, laneImg.GetSize().y / 2 * GetNode <Sprite>("Sprite").Scale.y);
        dangerZoneCollision.Position = new Vector2(this.GlobalPosition.x / dangerZonePositionModifier, 0);
    }
コード例 #2
0
ファイル: MicrobeHUD.cs プロジェクト: rhythms06/Thrive
    private void PauseButtonPressed()
    {
        GUICommon.Instance.PlayButtonPressSound();

        paused = !paused;
        if (paused)
        {
            pauseButton.Hide();
            resumeButton.Show();
            pauseButton.Pressed = false;

            // Pause the game
            GetTree().Paused = true;
        }
        else
        {
            pauseButton.Show();
            resumeButton.Hide();
            resumeButton.Pressed = false;

            // Unpause the game
            GetTree().Paused = false;
        }
    }