Exemple #1
0
 protected virtual void SnapSpriteToGrid()
 {
     Sprite.GlobalPosition = GlobalPosition.DistanceTo(Sprite.GlobalPosition) > 0.7
                         ? GlobalPosition.Round()
                         : Sprite.GlobalPosition.Round();
     DeathSprite.GlobalPosition = GlobalPosition.Round();
 }
Exemple #2
0
        private void StateSettled()
        {
            if (_stateMachine.IsStateNew())
            {
                CollisionLayer = 0;
                CollisionMask  = 0;
                _velocity      = Vector2.Zero;
                GlobalPosition = GlobalPosition.Round();
                _animationPlayer.Play(ANIM_IDLE);
                _collisionShape2d.Disabled = true;
                _deathTimer.Start();
            }

            var playerPosition = GetTree().GetFirstNodeInGroup <Player>(Player.GROUP)?.GlobalPosition ?? Vector2.Zero;
            var near           = GlobalPosition.DistanceSquaredTo(playerPosition) < PLAYER_NEAR_DISTANCE * PLAYER_NEAR_DISTANCE;

            if (!_deathTimer.IsStopped() && near)
            {
                _deathTimer.Start();
            }
            else if (near && _blinkAnimationPlayer.IsPlaying())
            {
                ResetBlink();
                _deathTimer.Start();
            }
        }
Exemple #3
0
 public override void _PhysicsProcess(float delta)
 {
     Camera2D.GlobalPosition = GlobalPosition.Round();
     CheckForTransitions();
 }
Exemple #4
0
 protected override void SnapSpriteToGrid()
 {
     base.SnapSpriteToGrid();
     Gravestone.GlobalPosition = GlobalPosition.Round();
 }