Пример #1
0
    public void ModulateFadeOut(Control control, float duration, Tween.TransitionType transitionType =
                                Tween.TransitionType.Sine, Tween.EaseType easeType = Tween.EaseType.In, bool hideOnFinished = true)
    {
        control.Modulate = new Color(1, 1, 1, 1);

        Tween.InterpolateProperty(control, "modulate:a", 1, 0, duration, transitionType, easeType);
        Tween.Start();

        if (!Tween.IsConnected("tween_completed", this, nameof(HideControlOnFadeOutComplete)) && hideOnFinished)
        {
            Tween.Connect("tween_completed", this, nameof(HideControlOnFadeOutComplete),
                          new Array {
                control
            }, (int)ConnectFlags.Oneshot);
        }
    }
Пример #2
0
 public override void _Ready()
 {
     Instance = this;
     SetProcessInput(true);
     SetPauseMode(PauseModeEnum.Process);
     m_top         = (Panel)GetNode("Top");
     m_bottom      = (Panel)GetNode("Bottom");
     m_tween       = (Tween)GetNode("Tween");
     m_audioStream = (AudioStreamPlayer)GetNode("Audio");
     m_tween.Connect("tween_completed", this, "TweenCompleted");
     m_label           = (Label)GetNode("Label");
     m_label.MarginTop = -m_bottomBarSize;
     m_label.Text      = "";
     m_hint            = (Label)GetNode("Hint");
     m_hint.Visible    = false;
 }
Пример #3
0
        public override void _Ready()
        {
            base._Ready();
            arrowIndicator         = GetChild <TextureRect>(0);
            indicatorStartPosition = arrowIndicator.RectPosition;
            indicatorEndPosition   = indicatorStartPosition + new Vector2(destinationOffset, 0f);
            Connect("focus_entered", this, nameof(OnFocusEntered));

            indicatorTween = GetChild <Tween>(1);
            indicatorTween.Connect("tween_completed", this, nameof(OnIndicatorTweenCompleted));

            animationPlayer = GetChild <AnimationPlayer>(2);

            textureNormal  = TextureNormal;
            texturePressed = TexturePressed;
        }
Пример #4
0
        public override void _Ready()
        {
            _eventManager = GetNode <EventManager>("/root/EventManager");
            _guiBrain     = GetNode <GuiBrain>("/root/GuiBrain");

            _eventManager.Connect("Options", this, "OnOptions");
            _eventManager.Connect("Exit", this, "OnExit");
            _eventManager.Connect("ChangeScene", this, "OnChangeScene");
            _eventManager.Connect("Restart", this, "RestartScene");

            _fadeLayer = GetNode <FadeLayer>("FadeLayer");
            _fadeTween = _fadeLayer.GetNode <Tween>("FadeTween");

            _fadeTween.Connect("tween_completed", this, "OnFadeTweenComplete");

            _guiBrain.GuiCollectFocusGroup();
        }
Пример #5
0
    public async void Add(CanvasItem newNode, float delay = 0)
    {
        // Fade-in effect
        Tween tween = new Tween();

        tween.InterpolateProperty(newNode, "modulate", Colors.Transparent, Colors.White, 0.5f,
                                  Tween.TransitionType.Linear, Tween.EaseType.InOut, delay);
        tween.Connect("tween_all_completed", tween, "queue_free");
        newNode.AddChild(tween);
        newNode.Modulate = Colors.Transparent;
        container.AddChild(newNode); // We actually add the thing here
        tween.Start();

        // Wait for the scrollbar to recalculate and scroll to the bottom
        await ToSignal(GetTree(), "idle_frame");

        scroll.ScrollVertical = (int)scroll.GetVScrollbar().MaxValue;
    }
Пример #6
0
    public override void Initialize(Vector2 position, int size = 24)
    {
        base.Initialize(position, size: size);
        findTargetSfx.Stream = ResourceLoader.Load("res://assets/audio/boss_golem_find_target.wav") as AudioStreamSample;
        sprite.Frames        = ResourceLoader.Load("res://entities/enemies/bosses/golem/Golem.tres") as SpriteFrames;
        ChangeState(EEnemyState.STATE_IDLE);
        MaxVelocity = 40f;

        // Overload material setup
        vent.ProcessMaterial = mat;
        vent.SpeedScale      = 2;
        vent.Amount          = 2500;
        vent.Emitting        = false;
        mat.InitialVelocity  = overloadRange;

        // Overload area setup
        Vector2[] points =
        {
            new Vector2(-10,  -3),
            new Vector2(75,  -80),
            new Vector2(110, -45),
            new Vector2(120,   0),
            new Vector2(110,  45),
            new Vector2(75,   80),
            new Vector2(-10, 3)
        };
        polygon.Polygon             = points;
        polygon.Disabled            = true;
        overloadArea.CollisionLayer = 0;
        overloadArea.SetCollisionMaskBit(0, false);
        overloadArea.SetCollisionMaskBit(19, true);
        overloadArea.Connect("area_entered", this, "_OnPlayerEnter_OverloadVent");

        lurchTimer.OneShot = true;
        lurchTimer.Connect("timeout", this, "FindLurchTarget");
        tween.Connect("tween_completed", this, "OverloadVent");

        overloadArea.AddChild(vent);
        overloadArea.AddChild(polygon);
        AddChild(overloadArea);
        AddChild(tween);
        AddChild(lurchTimer);
        AddChild(findTargetSfx);
    }
Пример #7
0
 private void onClockItemBodyEntered(PhysicsBody body)
 {
     if (body.IsInGroup("player"))
     {
         picked = true;
         Global.MainScene.TimeLeft += ExtraTime;
         particles.Emitting         = true;
         collision.SetDeferred("disabled", true);
         Tween t = new Tween();
         t.InterpolateProperty(sprite, "modulate", sprite.Modulate, Colors.Transparent, 1F);
         extraTimeLabel.Text = $"+{ExtraTime:0.0}";
         Debug.Log($"Extratime: {ExtraTime}");
         extraTimeLabel.Visible = true;
         t.InterpolateProperty(extraTimeLabel, "rect_position", extraTimeLabel.RectPosition, extraTimeLabel.RectPosition + (Vector2.Up * 40F), 2F);
         AddChild(t);
         t.Connect("tween_all_completed", this, nameof(destroy));
         t.Start();
     }
 }
Пример #8
0
        private void Load(Node node, Vector2 position, string text, Color color, Color?outline)
        {
            float duration = 0.6f;

            label      = GetNode <Label>("Label");
            label.Text = text;
            label.AddColorOverride("font_color", color);
            if (outline.HasValue)
            {
                label.AddColorOverride("font_outline_modulate", outline.Value);
            }
            node.AddChild(this);
            Position = position;
            Tween tween = new Tween();

            AddChild(tween);
            tween.InterpolateProperty(this, "modulate:a", 1f, 0f, duration, Tween.TransitionType.Cubic, Tween.EaseType.In);
            tween.InterpolateProperty(this, "position:y", position.y, position.y - 16, duration, Tween.TransitionType.Sine, Tween.EaseType.Out);
            tween.Connect("tween_all_completed", this, nameof(on_TweenAllCompleted));
            tween.Start();
        }
Пример #9
0
        public override void _Ready()
        {
            if (_randomPitch)
            {
                PitchScale = Main.RNG.RandfRange(MIN_PITCH, MAX_PITCH);
            }

            if (_randomSeek && Stream != null)
            {
                var topos = Main.RNG.RandfRange(0f, Stream.GetLength());
                Seek(topos);
            }

            if (_projectileDeleterComponentPath != null)
            {
                GetNode <ProjectileDeleterComponent>(_projectileDeleterComponentPath).Connect(nameof(ProjectileDeleterComponent.Deleted), this, nameof(OnDeleted));
            }

            _tween = GetNode <Tween>("Tween");
            _tween.Connect("tween_all_completed", this, nameof(OnTweenCompleted));
        }
Пример #10
0
    public override void _Ready()
    {
        GD.Randomize();

        // Get references to all the nodes we need to manipulate
        _mortar            = GetNode <Mortar>("MortarPestle/Mortar");
        _potionCircle      = GetNode <PotionCircle>("MortarPestle/Crush/PotionCircle");
        _potionReagentsBox = GetNode <VBoxContainer>("MortarPestle/PickReagents/PotionReagentsBox");
        _helpDialog        = GetNode <AcceptDialog>("HelpDialog");
        _proceedToCrush    = GetNode <Button>("MortarPestle/PickReagents/ProceedToCrush");
        _tween             = GetNode <Tween>("MortarPestle/PickReagents/Tween");
        _inventory         = GetNode <Inventory>("MortarPestle/PickReagents/Inventory");
        _inventory.SetSize(4, 4);
        _inventory.DrawPosition = new Vector2(324f, 16f);
        _inventory.CanDeselect  = false;
        _itemTooltip            = GetNode <ItemTooltip>("MortarPestle/PickReagents/ItemTooltip");
        _debugOverlay           = GetNode <DebugOverlay>("DebugOverlay");

        // Load assets needed
        _itemBtnBg      = GD.Load <Texture>("res://textures/item_slot.png");
        _singleItemSlot = GD.Load <Texture>("res://textures/single_item_slot.png");
        _smallFont      = GD.Load <DynamicFont>("res://font/small_font.tres");

        // Signal connections
        GetNode <TouchScreenButton>("HelpButton").Connect("released", this, nameof(DisplayHelpPopup));
        _proceedToCrush.Connect("pressed", this, nameof(ProceedToCrushPressed));
        _tween.Connect("tween_all_completed", this, nameof(TweenAllCompleted));
        _inventory.Connect("ItemSlotSelected", this, nameof(InventorySlotSelected));
        GetNode <Button>("MortarPestle/PickReagents/AddToPotion").Connect("pressed", this, nameof(ItemButtonReleased));

        // Adding items to simulate an inventory
        _itemList.AddRange(new Item.ItemStack[] { new Item.ItemStack(Items.BRIMSTONE, 1), new Item.ItemStack(Items.FLY_AGARIC, 3), new Item.ItemStack(Items.ELDERBERRIES, 5), new Item.ItemStack(Items.ORPIMENT, 1), new Item.ItemStack(Items.HOLLY_BERRIES, 3) });
        _inventory.UpdateSlots(_itemList);

        // Tracking stuff for debug
        _debugOverlay.TrackProperty(nameof(_mortarPestleStage), this, "MortarPestleStage");
        _debugOverlay.TrackProperty(nameof(_mortar.CurrentParticleColour), _mortar, "Splash Colour");
    }
Пример #11
0
        public DoorSecret(int x, int y, Level level)
        {
            if (level != null)
            {
                Location = new Point2(x, y);
                Level    = level;

                Type = level.Map.Planes[(int)Level.Planes.Walls][y, x];

                // This will be the physical body for the door itself.

                BoxShape box = new BoxShape();
                box.Extents = new Vector3(Level.CellSize * 0.5f, Level.CellSize * 0.5f, Level.CellSize * 0.5f);

                _wallShape       = new CollisionShape();
                _wallShape.Shape = box;

                _wallBody                = new RigidBody();
                _wallBody.Mode           = RigidBody.ModeEnum.Static;
                _wallBody.CollisionLayer = (uint)Level.CollisionLayers.Walls;
                _wallBody.CollisionMask  = (uint)(Level.CollisionLayers.Characters | Level.CollisionLayers.Projectiles);
                _wallBody.AddChild(_wallShape);

                AddChild(_wallBody);

                // Create the actual mesh for the door

                _mesh      = new MeshInstance();
                _mesh.Mesh = GetMeshForDoor(Type);

                _wallBody.AddChild(_mesh);

                // Add an audio player to play the "pushing" sound when the door
                // is activated.

                _audioPlayer = new AudioStreamPlayer3D();

                _wallBody.AddChild(_audioPlayer);

                _activateSound = Assets.GetSoundClip(Assets.DigitalSoundList.PushWallActivation);

                // Add the tween that will be used to animate the door.

                _tween = new Tween();
                _tween.Connect("tween_all_completed", this, "OnTweenCompleted");

                AddChild(_tween);

                // Add myself to the world and set my position.

                level.AddChild(this);

                Transform tform = this.Transform;
                tform.origin   = level.MapToWorld(x, y);
                this.Transform = tform;

                // Set my default state.

                State   = DoorState.Stopped;
                Enabled = true;

                SetProcess(true);
                SetPhysicsProcess(true);
            }
        }
Пример #12
0
 private void FadeOut(AudioStreamPlayer player, AudioStream stream)
 {
     _tween.InterpolateProperty(player, "volume_db", player.VolumeDb, _silenceDb, _fadeDuration, Tween.TransitionType.Cubic, Tween.EaseType.InOut);
     _tween.Connect("tween_completed", this, nameof(OnFadeOutCompleted));
     _tween.Start();
 }
Пример #13
0
        public DoorSliding(int x, int y, Level level)
        {
            if (level != null)
            {
                Location = new Point2(x, y);
                Level    = level;

                Type = (DoorType)level.Map.Planes[(int)Level.Planes.Walls][y, x];

                level.Cells[y, x] = Level.Cell.Default();

                // Adjust neighboring walls to show the door excavation.

                if (!IsVertical)
                {
                    if ((x - 1) > -1 &&
                        level.Cells[y, x - 1].East != Level.Cell.NoWall)
                    {
                        level.Cells[y, x - 1].East = DoorWestEastWall;
                    }

                    if ((x + 1) < level.Map.Width &&
                        level.Cells[y, x + 1].West != Level.Cell.NoWall)
                    {
                        level.Cells[y, x + 1].West = DoorWestEastWall;
                    }
                }
                else
                {
                    if ((y + 1) < level.Map.Height &&
                        level.Cells[y + 1, x].North != Level.Cell.NoWall)
                    {
                        level.Cells[y + 1, x].North = DoorNorthSouthWall;
                    }

                    if ((y - 1) > -1 &&
                        level.Cells[y - 1, x].South != Level.Cell.NoWall)
                    {
                        level.Cells[y - 1, x].South = DoorNorthSouthWall;
                    }
                }

                // Create a static body for the cell so that
                // we can block the player from entering or exiting the cell
                // when the door is closed or moving.

                _cellShape = new CollisionShape();
                BoxShape box = new BoxShape();
                box.Extents = new Vector3(Level.CellSize * 0.5f, Level.CellSize * 0.5f, Level.CellSize * 0.5f);

                _cellShape.Shape = box;
                _cellShape.Name  = "CollisionShape";

                _cellBody = new StaticBody();
                _cellBody.CollisionLayer = (uint)Level.CollisionLayers.Static;
                _cellBody.CollisionMask  = (uint)(Level.CollisionLayers.Characters);
                _cellBody.AddChild(_cellShape);

                AddChild(_cellBody);

                // Create the actual mesh for the door and set it up for
                // this particular instance.

                BuildDoorMesh();

                _mesh                  = new MeshInstance();
                _mesh.Mesh             = _doorMesh;
                _mesh.MaterialOverride = Assets.GetTexture(_doorTexture[Type]);

                if (IsVertical)
                {
                    _mesh.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * 0.5f);
                }
                else
                {
                    _mesh.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi);
                }

                // Setup a physics body for the door itself for the purposes
                // of detecting collisions with projectiles since projectiles shouldn't
                // be blocked by the cell's static body that is normally only used for
                // ensuring characters can't enter or exit the cell if the door is closed
                // or moving.

                _doorShape  = new CollisionShape();
                box         = new BoxShape();
                box.Extents = new Vector3(Level.CellSize * 0.5f, Level.CellSize * 0.5f, Mathf.Epsilon);

                _doorShape.Shape = box;
                _doorShape.Name  = "CollisionShape";

                _doorBody = new RigidBody();
                _doorBody.CollisionLayer = (uint)Level.CollisionLayers.Doors;
                _doorBody.CollisionMask  = (uint)Level.CollisionLayers.Projectiles;
                _doorBody.AddChild(_doorShape);
                _doorBody.Mode = RigidBody.ModeEnum.Static;

                _mesh.AddChild(_doorBody);

                AddChild(_mesh);

                // Add myself to the world and set my position
                // along with some default state variables.

                level.AddChild(this);

                Transform tform = this.Transform;
                tform.origin   = level.MapToWorld(x, y);
                this.Transform = tform;

                State = DoorState.Closed;

                _openCloseDuration = 0.75f;
                _canClose          = true;

                _openSound  = Assets.GetSoundClip(Assets.DigitalSoundList.DoorOpening);
                _closeSound = Assets.GetSoundClip(Assets.DigitalSoundList.DoorClosing);

                // Add a tween node for controlling the animation of the
                // door opening and closing.

                _tween = new Tween();
                _tween.Connect("tween_all_completed", this, "OnTweenCompleted");

                _mesh.AddChild(_tween);

                // Add an audio player so we can emit a sound
                // when the door opens and closes.

                _audioPlayer      = new AudioStreamPlayer3D();
                _audioPlayer.Name = "AudioPlayer";

                AddChild(_audioPlayer);

                SetProcess(true);
                SetPhysicsProcess(true);
            }
        }
Пример #14
0
 public override void _Ready()
 {
     _barSlider = GetNode <Sprite>("BarSlider");
     _tween.Connect("tween_completed", this, nameof(OnTweenCompleted));
     AddChild(_tween);
 }
Пример #15
0
        public CharacterPlayer(int x, int y, Level level)
            : base(x, y, level)
        {
            if (level != null)
            {
                _camera         = new Camera();
                _camera.Current = true;

                switch (Type)
                {
                case CharacterType.Player_East:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -0.5f);
                    break;

                case CharacterType.Player_West:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * 0.5f);
                    break;

                case CharacterType.Player_South:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -1.0f);
                    break;
                }

                _moveSpeed = Level.CellSize * 200.0f;
                _turnSpeed = 3f;

                _useRay               = new RayCast();
                _useRay.Enabled       = true;
                _useRay.ExcludeParent = true;
                _useRay.CastTo        = Vector3.Forward * (Level.CellSize * 0.5f);
                _useRay.CollisionMask = (uint)(
                    Level.CollisionLayers.Characters |
                    Level.CollisionLayers.Static |
                    Level.CollisionLayers.Walls);
                _useRay.AddException(this);

                _camera.AddChild(_useRay);

                _flashDuration = 0.5f;

                _flashRect                  = new ColorRect();
                _flashRect.MouseFilter      = Control.MouseFilterEnum.Ignore;
                _flashRect.Color            = new Color(0.75f, 0.75f, 0f, 1f);
                _flashRect.AnchorTop        =
                    _flashRect.AnchorLeft   = 0f;
                _flashRect.AnchorRight      =
                    _flashRect.AnchorBottom = 1f;
                _flashRect.SetAsToplevel(true);
                _flashRect.ShowOnTop = true;
                _flashRect.Visible   = false;

                _flashTween = new Tween();
                _flashTween.Connect("tween_all_completed", this, "OnFlashTweenCompleted");
                _flashRect.AddChild(_flashTween);

                _flashCanvas = new CanvasLayer();
                _flashCanvas.AddChild(_flashRect);

                _camera.AddChild(_flashCanvas);

                AddChild(_camera);

                SetProcess(true);
                SetPhysicsProcess(true);
            }
        }