Exemplo n.º 1
0
    private void HandleMovement()
    {
        if (Input.IsActionPressed("dpad_left"))
        {
            moveVelocity.x = Utils.Approach(moveVelocity.x, -moveSpeed, moveAcceleration);
            sprite.SetScale(new Vector2(-1.0f, 1.0f));

            if (animationPlayback.IsPlaying())
            {
                animationPlayback.Travel("run");
            }
        }
        else if (Input.IsActionPressed("dpad_right"))
        {
            moveVelocity.x = Utils.Approach(moveVelocity.x, moveSpeed, moveAcceleration);
            sprite.SetScale(new Vector2(1.0f, 1.0f));

            if (animationPlayback.IsPlaying())
            {
                animationPlayback.Travel("run");
            }
        }
        else
        {
            moveVelocity.x = Utils.Approach(moveVelocity.x, 0.0f, moveFriction);

            if (animationPlayback.IsPlaying())
            {
                animationPlayback.Travel("stand");
            }
        }
    }
Exemplo n.º 2
0
    private void _MoveState(float delta)
    {
        // Get input from the user
        Vector2 InputVector = new Vector2();

        InputVector.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");

        // gun stuff and mouse position
        gunNode.Visible         = false;
        gunNode.RotationDegrees = angle;
        if (angle > -90 && angle < 90)
        {
            gunNode.Scale = new Vector2(1, 1);
        }
        else
        {
            gunNode.Scale = new Vector2(1, -1);
        }

        if (InputVector != Vector2.Zero)
        {
            // Begin accelerating in a specific direction
            animationTree.Set("parameters/Idle/blend_position", InputVector);
            animationTree.Set("parameters/Run/blend_position", InputVector);
            animationState.Travel("Run");
            velocity = velocity.MoveToward(InputVector * MAXSPEED, ACCELERATION * delta);
            isWalking++;
        }
        else
        {
            // Begin slowing down
            animationState.Travel("Idle");
            velocity = velocity.MoveToward(Vector2.Zero, FRICTION * delta);
            walkTimer.Stop();
            isWalking = 0;
        }

        if (isWalking == 1)
        {
            walkTimer.Start();
        }

        // velocity = MoveAndSlideWithSnap(velocity, snapDist, snap, stopOnSlope: true);
        velocity = MoveAndSlide(velocity);

        if (Input.IsActionJustPressed("shoot") && ammo > 0)
        {
            EmitSignal(nameof(Shoot), bullet, gunNode.RotationDegrees, gunNode.GlobalPosition);
            state = Actions.SHOOT;
            ammo--;
            timer.Start();
        }

        if (Input.IsActionJustPressed("flash") && canFlash == true)
        {
            EmitSignal(nameof(Throw), flashbang, gunNode.RotationDegrees, gunNode.GlobalPosition);
            canFlash = false;
            flashCooldown.Start();
        }
    }
Exemplo n.º 3
0
    public void getInput()
    {
        // Detect up/down/left/right keystate and only move when pressed
        _velocity = new Vector2();
        if (Input.IsActionPressed("ui_right"))
        {
            _velocity.x        += 1;
            _playerSprite.FlipH = false;
            _stateMachine.Travel("run");
        }
        if (Input.IsActionPressed("ui_left"))
        {
            _velocity.x        -= 1;
            _playerSprite.FlipH = true;
            _stateMachine.Travel("run");
        }
        if (Input.IsActionPressed("ui_down"))
        {
            _velocity.y += 1;
        }
        if (Input.IsActionPressed("ui_up"))
        {
            //_velocity.y -= 1;
            _stateMachine.Travel("kick");
        }

        if (Input.IsActionJustReleased("ui_right") | Input.IsActionJustReleased("ui_left"))
        {
            _stateMachine.Travel("idle");
        }
    }
Exemplo n.º 4
0
    // runs every frame
    public override void _PhysicsProcess(float delta)
    {
        // player movement
        var inputVector = Vector2.Zero;

        // checks for direction
        inputVector.x = Input.GetActionStrength("move_right") - Input.GetActionStrength("move_left");
        inputVector.y = Input.GetActionStrength("move_down") - Input.GetActionStrength("move_up");

        // normalizes input to prevent double speed when two directions are entered
        inputVector = inputVector.Normalized();

        // set velocity of player
        if (inputVector != Vector2.Zero)
        {
            // running animation
            animationTree.Set("parameters/Idle/blend_position", inputVector);
            animationTree.Set("parameters/Run/blend_position", inputVector);
            animationState.Travel("Run");
            velocity = velocity.MoveToward(inputVector * MAX_SPEED, ACCELERATION * delta);
        }
        else
        {
            animationState.Travel("Idle");
            velocity = velocity.MoveToward(Vector2.Zero, FRICTION * delta);
        }



        velocity = MoveAndSlide(velocity);
    }
Exemplo n.º 5
0
    private void moveState(float delta)
    {
        Vector2 inputVector = getInputVector();

        if (inputVector != Vector2.Zero)
        {
            rollVector = inputVector;
            swordHitbox.knockbackVector = inputVector;
            setAnimationTree(inputVector);
            animationState.Travel("Run");
            velocity = velocity.MoveToward(inputVector * MAX_SPEED, ACCELERATION * delta);
        }
        else
        {
            animationState.Travel("Idle");
            velocity = velocity.MoveToward(Vector2.Zero, FRICTION * delta);
        }
        move();

        if (Input.IsActionJustPressed("roll"))
        {
            if (isRollReady())
            {
                //playerStats.setMaxHealth(playerStats.maxHealth - 1);
                rollCdTimer = 0f;
                state       = States.ROLL;
            }
        }
        if (Input.IsActionJustPressed("attack"))
        {
            state = States.ATTACK;
        }
    }
Exemplo n.º 6
0
    public override void _PhysicsProcess(float delta)
    {
        var         inputVector  = Vector2.Zero;
        const float acceleration = 200;
        const float maxSpeed     = 75;
        const float friction     = 250;

        base._PhysicsProcess(delta);
        inputVector.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");
        inputVector.y = Input.GetActionStrength("ui_down") - Input.GetActionStrength("ui_up");
        inputVector   = inputVector.Normalized();

        if (inputVector != Vector2.Zero)
        {
            animationTree.Set("parameters/idle/blend_position", inputVector);
            animationTree.Set("parameters/walk/blend_position", inputVector);
            animationState.Travel("walk");
            velocity = velocity.MoveToward(inputVector * maxSpeed, acceleration * delta);
        }
        else
        {
            animationState.Travel("idle");
            velocity = velocity.MoveToward(Vector2.Zero, friction * delta);
        }

        velocity = MoveAndSlide(velocity);
    }
Exemplo n.º 7
0
        private void PlayAnimations()
        {
            if (this.MovementComponent.Velocity != Vector2.Zero)
            {
                _animationTree.Set("parameters/Idle/blend_position", MovementComponent.Velocity);
                _animationTree.Set("parameters/Run/blend_position", MovementComponent.Velocity);
                _animationTree.Set("parameters/Attack1/blend_position", MovementComponent.Velocity);
            }

            switch (this._stateMachine.CurrentState?.Code)
            {
            case StatesIndex.Attack:
                _animationNodeStateMachinePlayback.Travel("Attack1");
                break;

            case StatesIndex.Idle:
                _animationNodeStateMachinePlayback.Travel("Idle");
                break;

            case StatesIndex.MoveForward:
                _animationNodeStateMachinePlayback.Travel("Run");
                break;

            default:
                _animationNodeStateMachinePlayback.Travel("Idle");
                break;
            }
        }
Exemplo n.º 8
0
    //  // Called every frame. 'delta' is the elapsed time since the previous frame.
    //  public override void _Process(float delta)
    //  {
    //
    //  }
    public override void _PhysicsProcess(float delta)
    {
        Vector2 inputVector = Vector2.Zero;

        animationState = (AnimationNodeStateMachinePlayback)animationTree.Get("parameters/playback");

        inputVector.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");
        inputVector.y = Input.GetActionStrength("ui_down") - Input.GetActionStrength("ui_up");
        inputVector   = inputVector.Normalized();

        if (inputVector != Vector2.Zero)
        {
            // Set animation tree blend position values based on inputVector value
            animationTree.Set("parameters/Idle/blend_position", inputVector);
            animationTree.Set("parameters/Run/blend_position", inputVector);

            animationState.Travel("Run");
            velocity = velocity.MoveToward(inputVector * MAX_SPEED, ACCELERATION * delta);
        }
        else
        {
            animationState.Travel("Idle");
            // Move
            velocity = velocity.MoveToward(Vector2.Zero, FRICTION * delta);
        }

        velocity = MoveAndSlide(velocity);
    }
Exemplo n.º 9
0
        private Vector2 GetInput(float delta)
        {
            Vector2 inputVelocity = Vector2.Zero;

            if (!_sword.Swinging)
            {
                inputVelocity.x = Input.GetActionStrength("right") - Input.GetActionStrength("left");
                inputVelocity.y = Input.GetActionStrength("down") - Input.GetActionStrength("up");

                inputVelocity = inputVelocity.Normalized();
            }

            if (inputVelocity == Vector2.Zero)
            {
                _isMoving = false;
            }
            else
            {
                _isMoving = true;

                if (inputVelocity.Abs() != Vector2.One)
                {
                    _playerDirection = inputVelocity.Round();
                }
            }


            if (_isMoving)
            {
                _aTreePlayback.Travel("Running");
                _aTree.Set("parameters/AnimationNodeStateMachine/Idle/blend_position", inputVelocity);
                _aTree.Set("parameters/AnimationNodeStateMachine/Running/blend_position", inputVelocity);

                _currentSpeed += _acceleration * delta;

                if (_currentSpeed > _maxSpeed)
                {
                    _currentSpeed = _maxSpeed;
                }

                float animationSpeed = 1 + 2 * (_currentSpeed / _maxSpeed);

                _aTree.Set("parameters/TimeScale/scale", animationSpeed);

                return(_velocity.MoveToward(inputVelocity * _currentSpeed, _acceleration * delta));
            }

            _aTreePlayback.Travel("Idle");
            _aTree.Set("parameter/playback", "Idle");

            _currentSpeed = 0;

            return(_velocity.MoveToward(Vector2.Zero, _friction * delta));
        }
Exemplo n.º 10
0
    private Vector2 GetInput(float delta)
    {
        Vector2 inputVelocity = Vector2.Zero;

        if (!_Sword.Swinging)
        {
            inputVelocity.x = Input.GetActionStrength("right") - Input.GetActionStrength("left");
            inputVelocity.y = Input.GetActionStrength("down") - Input.GetActionStrength("up");

            inputVelocity = inputVelocity.Normalized();
        }

        if (inputVelocity == Vector2.Zero)
        {
            IsMoving = false;
        }
        else
        {
            IsMoving = true;
        }


        if (IsMoving)
        {
            ATreePlayback.Travel("Running");
            ATree.Set("parameters/AnimationNodeStateMachine/Idle/blend_position", inputVelocity);
            ATree.Set("parameters/AnimationNodeStateMachine/Running/blend_position", inputVelocity);

            CurrentSpeed += Acceleration * delta;

            if (CurrentSpeed > MaxSpeed)
            {
                CurrentSpeed = MaxSpeed;
            }

            float animationSpeed = 1 + (2 * (CurrentSpeed / MaxSpeed));
            GD.Print(animationSpeed);

            ATree.Set("parameters/TimeScale/scale", animationSpeed);

            return(Velocity.MoveToward(inputVelocity * CurrentSpeed, (Acceleration * delta)));
        }
        else
        {
            ATreePlayback.Travel("Idle");
            ATree.Set("parameter/playback", "Idle");

            CurrentSpeed = 0;

            return(Velocity.MoveToward(Vector2.Zero, (Friction * delta)));
        }
    }
Exemplo n.º 11
0
 protected override void OnCantMoveStaticBody2D(StaticBody2D pared) //si "NO" podemos movernos recibe el cuerpo estatico y es un una pared.Este es un metodo que se sobreescribe
 {
     if (pared.IsInGroup("Wall"))                                   //si esta en el grupo suelo
     {
         food--;                                                    //en cada paso dismunuje la comida
         _FoodText.Text = "food " + food;                           //comida del jugador es disminuida
         hitWall        = (Wall)pared.GetParent();                  //con esto tendria que poder acceder al script que maneja ese piso para cambiar la figura al ser golpeado
     }
     if (hitWall != null)                                           //si el personaje esta chocando con un muro
     {
         hitWall.DamageWall(wallDamage);                            //descuento el hp al suelo,se me esta complicando entender el concepto de unity y pasarlo a godot
         //activo animación romper bloque
         playback.Travel("PlayerChop");                             //activo animación romper pared
     }
 }
Exemplo n.º 12
0
 public void ChangeAnimationState(string stateName)
 {
     if (_AnimStateMachine.GetCurrentNode() != stateName)
     {
         _AnimStateMachine.Travel(stateName);
     }
 }
Exemplo n.º 13
0
    public void ChangeState(STATE newState)
    {
        State = newState;
        switch (State)
        {
        case STATE.FORCEDANIMATION:
            AI = AI_ForcedAnimation;
            break;

        case STATE.IDLE:
            AI = AI_Idle;
            break;

        case STATE.COMBAT:
            AI = AI_Combat;
            if (DynamicWaypoint == null)
            {
                DynamicWaypoint           = new Spatial();
                DynamicWaypoint.Transform = new Transform(DynamicWaypoint.Transform.basis, new Vector3(0, 0, 0));
                GetTree().GetRoot().AddChild(DynamicWaypoint);
            }
            WayPoint = DynamicWaypoint;
            break;

        case STATE.DEATH:
            StateMachine.Travel("Death");
            BodyCollisionShape.SetDisabled(true);
            AI = null;
            break;

        case STATE.PLAYER:
            AI = null;
            break;
        }
    }
Exemplo n.º 14
0
 // Called when physics
 public override void _PhysicsProcess(float delta)
 {
     if (STATE == 1)
     {
         // Begin accelerating in a specific direction
         animationTree.Set("parameters/Idle/blend_position", velocity);
         animationTree.Set("parameters/Run/blend_position", velocity);
         animationState.Travel("Run");
         velocity   = ((playerDetection.player as Player).GlobalPosition - GlobalPosition);
         velocity.y = 0;
         if (velocity.x > 10)
         {
             velocity.x = MAXSPEED;
         }
         else if (velocity.x < -10)
         {
             velocity.x = -MAXSPEED;
         }
         else
         {
             velocity.x = 0;
         }
         velocity = velocity.MoveToward(velocity * MAXSPEED, ACCELERATION * delta);
     }
     else if (playerDetection.player != null)
     {
         STATE = 1;
         audio.Play();
     }
     velocity = MoveAndSlide(velocity);
 }
Exemplo n.º 15
0
    public override void _Process(float delta)
    {
        CheckIfOwnerMobIsLoaded(); // TODO quick fix, consider rewriting

        if (Actions.IsIdle() || OwnerMob.IsDead())
        {
            return;
        }

        AbstractAction currentAction = Actions.GetCurrentAction();

        if (currentAction is Move)
        {
            Move moveAction = currentAction as Move;
            SetAnimationDirection(moveAction.VelocityVector);
            AnimationState.Travel("walk");
        }
    }
Exemplo n.º 16
0
    public override bool Blink()
    {
        _stateMachine.Travel("Blink");
        float cooldown = BLINK_COOLDOWN_TIME;

        cooldown       = DelegateManager.ApplySingleArgumentDelegate <float>(cooldown, (int)MouseFollowerDelegateManager.Group.BLINK_SPEED_MODIFIER);
        _blinkCooldown = cooldown;
        return(true);
    }
Exemplo n.º 17
0
    protected override void ProcessInput(float delta)
    {
        base.ProcessInput(delta);
        string currentNode = _stateMachineController.GetCurrentNode();

        //  ----------------------- Attacking -----------------------
        if (Input.IsActionJustPressed("main_mouse"))
        {
            if (currentNode == "idle_top")
            {
                _stateMachineController.Travel("attack_1");
                _attackTimer.Start(_attackDuration);
            }
            else if (currentNode == "attack_1" && _attackTimer.TimeLeft < _attackDuration / 3.0f)
            {
                _stateMachineController.Travel("attack_2");
                _attackTimer.Start(_attackDuration);
            }
            else if (currentNode == "attack_2" && _attackTimer.TimeLeft < _attackDuration / 3.0f)
            {
                _stateMachineController.Travel("attack_3");
            }
            else if (currentNode == "idle_top_right_weapon")
            {
                _stateMachineController.Travel("attack_1_right_weapon");
            }
            else if (currentNode == "idle_top_left_weapon")
            {
                _stateMachineController.Travel("attack_2_left_weapon");
            }
        }

        //  ---------------------- Sword Throwing / Teleporting ----------------------
        else if (Input.IsActionJustPressed("secondary_mouse"))
        {
            if (_targetingRaycast.GetCollider() is CollisionObject collidedWith && (collidedWith.HasNode("SigilOfTeleportation") || collidedWith.GetParent().HasNode("SigilOfTeleportation")))
            {
                if (collidedWith.GetParent() is MeleeCarry1Weapon weapon)
                {
                    TeleportWeapon(weapon);
                }
                else if (collidedWith is Enemy enemy)
                {
                    TeleportEnemy(enemy);
                }
                else if (collidedWith is TeleportationTotem totem)
                {
                    TeleportTotem(totem);
                }
            }
            else if (currentNode == "idle_top" || currentNode == "idle_top_left_weapon")
            {
                _stateMachineController.Travel("weapon_throw_left_bt");
            }
            else if (currentNode == "idle_top_right_weapon")
            {
                _stateMachineController.Travel("weapon_throw_right_bt");
            }
        }
Exemplo n.º 18
0
    public bool Transition(string newState, bool secondaryCondition = true)
    {
        string currentNodeName = _stateMachinePlayback.GetCurrentNode();

        string[] travelPath = _stateMachinePlayback.GetTravelPath();
        // if there is no travel path just put new state there so it passes
        if (travelPath.Length == 0)
        {
            travelPath = new string[1] {
                ""
            }
        }
        ;
        if (_stateMachine.HasTransition(currentNodeName, newState) && travelPath[0] != newState && secondaryCondition)
        {
            _stateMachinePlayback.Travel(newState);
            return(true);
        }
        return(false);
    }
Exemplo n.º 19
0
    public void TransitionTo(States stateID)
    {
        switch (stateID)
        {
        case States.IDLE:
            playback.Travel("idle");
            break;

        case States.RUN:
            playback.Travel("move_ground");
            break;

        case States.AIR:
            playback.Travel("jump");
            break;

        default:
            playback.Travel("idle");
            break;
        }
    }
Exemplo n.º 20
0
Arquivo: Player.cs Projeto: itlbv/evo
    public override void _PhysicsProcess(float delta)
    {
        var velocity = Vector2.Zero;

        velocity.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");
        velocity.y = Input.GetActionStrength("ui_down") - Input.GetActionStrength("ui_up");
        velocity   = velocity.Normalized();

        if (velocity != Vector2.Zero)
        {
            animationTree.Set("parameters/idle/blend_position", velocity);
            animationTree.Set("parameters/walk/blend_position", velocity);
            animationState.Travel("walk");
        }
        else
        {
            animationState.Travel("idle");
        }

        MoveAndSlide(velocity * speed);
    }
    public bool MoveBy(Vector2 direction)
    {
        if (State != OverworldState.IDLE)
        {
            return(false);
        }

        LookAt(direction);

        // collision detection
        if (TestMove(Transform, direction * MoveDistance))
        {
            return(false);
        }

        // move and animate
        _animationStateMachine.Travel("Moving");
        _tween.InterpolateProperty(this, "position", Position, Position + direction * MoveDistance, MoveTime);
        State = OverworldState.MOVING;
        return(_tween.Start());
    }
Exemplo n.º 22
0
    private void _MoveState(float delta)
    {
        Vector2 InputVector = new Vector2();

        InputVector.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");

        if (InputVector != Vector2.Zero)
        {
            // Begin accelerating in a specific direction
            animationTree.Set("parameters/Idle/blend_position", InputVector);
            animationTree.Set("parameters/Walk/blend_position", InputVector);
            animationState.Travel("Walk");
            velocity = velocity.MoveToward(InputVector * MAXSPEED, ACCELERATION * delta);
        }
        else
        {
            // Begin slowing down
            animationState.Travel("Idle");
            velocity = velocity.MoveToward(Vector2.Zero, FRICTION * delta);
        }
    }
Exemplo n.º 23
0
    void MoveState(float delta)
    {
        Vector2 input_vector = Vector2.Zero;

        input_vector.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");
        input_vector.y = Input.GetActionStrength("ui_down") - Input.GetActionStrength("ui_up");
        input_vector   = input_vector.Normalized();

        if (input_vector != Vector2.Zero)
        {
            rollVector = input_vector;
            animTree.Set("parameters/Idle/blend_position", lookDirection);
            animTree.Set("parameters/Run/blend_position", lookDirection);
            animTree.Set("parameters/Attack/blend_position", lookDirection);
            animTree.Set("parameters/Roll/blend_position", lookDirection);
            animState.Travel("Run");
            velocity = input_vector * maxSpeed;
        }
        else
        {
            rollVector = lookDirection;
            animState.Travel("Idle");
            animTree.Set("parameters/Idle/blend_position", lookDirection);
            animTree.Set("parameters/Attack/blend_position", lookDirection);
            animTree.Set("parameters/Roll/blend_position", lookDirection);
            velocity = Vector2.Zero;
        }

        Move();

        if (Input.IsActionJustPressed("attack"))
        {
            state = AnimationState.ATTACK;
        }
        if (Input.IsActionJustPressed("roll"))
        {
            state = AnimationState.ROLL;
        }
    }
Exemplo n.º 24
0
 // Called every frame. 'delta' is the elapsed time since the previous frame.
 public override void _Process(float delta)
 {
     if (Input.IsActionJustPressed("attack"))
     {
         _animationPlayer.Play("attack");
     }
     else
     {
         if (_animationPlayer.IsPlaying())
         {
             return;
         }
         if (_velocity.Length() > 0)
         {
             _stateMachine.Travel("run");
             _playerSprite.FlipH = _velocity.x < 0;
         }
         else
         {
             _stateMachine.Travel("idle");
         }
     }
 }
Exemplo n.º 25
0
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _PhysicsProcess(float delta)
    {
        Vector2 inputDirection = Vector2.Zero;
        Boolean inputMagnitude = false;

        mousePos = GetLocalMousePosition();



        inputDirection.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");
        inputDirection.y = Input.GetActionStrength("ui_down") - Input.GetActionStrength("ui_up");
        inputDirection   = inputDirection.Normalized();
        if (inputDirection != Vector2.Zero)
        {
            inputMagnitude = true;
        }
        else
        {
            inputMagnitude = false;
        }

        if (inputMagnitude)
        {
            velocity = velocity.MoveToward(inputDirection * maxSpeed, acceleration * delta);
            animatorTree.Set("parameters/Run/blend_position", mousePos);


            animatorState.Travel("Run");
        }
        else
        {
            velocity = velocity.MoveToward(Vector2.Zero, friction * delta);
            animatorTree.Set("parameters/Idle/blend_position", mousePos);
            animatorState.Travel("Idle");
        }
        velocity = MoveAndSlide(velocity);
    }
Exemplo n.º 26
0
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        Vector2 input_vector = Vector2.Zero;

        input_vector.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");
        input_vector.y = Input.GetActionStrength("ui_down") - Input.GetActionStrength("ui_up");
        input_vector   = input_vector.Normalized();

        if (input_vector != Vector2.Zero)
        {
            animationTree.Set("parameters/Idle/blend_position", input_vector);
            animationTree.Set("parameters/Run/blend_position", input_vector);
            animationState.Travel("Run");

            velocity = velocity.MoveToward(input_vector * MaxSpeed, Acceleration * delta);
        }
        else
        {
            animationState.Travel("Idle");
            velocity = velocity.MoveToward(Vector2.Zero, Friction * delta);
        }

        velocity = MoveAndSlide(velocity);
    }
Exemplo n.º 27
0
        public override void _PhysicsProcess(float delta)
        {
            base._PhysicsProcess(delta);

            HandleHorizontalFlip();
            if (Player.Jump.Coyote < -0.6 && Player.IsOnFloor())
            {
                return;
            }
            var anim = GetAnimationState();

            if (anim == StateMachine.GetCurrentNode())
            {
                return;
            }
            StateMachine.Travel(anim);
        }
Exemplo n.º 28
0
    protected override void OnCantMoveRigidBody2D(KinematicBody2D go)//sino puede moverse por un kinematicbody como un personaje
    {
        GD.Print("enemigo colisionando con alguien");
        //parece que hay un bug cuando colisionan entre enemigos por eso verifico si esta en el grupo player el cuerpo kinematico
        if (go.IsInGroup("Player")) //detectamos que esta en el grupo player para evitar un bug al solicionar los enemigos entre sí
        {
            hitPlayer = (Player)go; //de esta forma tendria que acceder al script que tiene el personaje
        }

        if (hitPlayer != null)                                                //si estoy en la casilla player
        {
            hitPlayer.LoseFood(playerDamage);                                 //descuento comida del personaje

            playback.Travel("EnemyAttack");                                   //el enemigo ataca cuando le quitamos puntos al jugador
            _GameManager.RandomizeSfx(scavengers_enemy, scavengersEnemyNode); //activo sonido golpe
            if (hitPlayer.food >= 10)                                         //si la comida del personaje es mayor o igual a 10
            {
                AnimationPlayerEfectos.Play("pantallaRoja");                  //play color rojo en pantalla
                AnimationPlayerEfectos.PlayBackwards("pantallaRoja");         //play al reves color rojo en pantalla para que quede transparente
            }
        }
    }
Exemplo n.º 29
0
 public override void Attack()
 {
     moveDirection.x += -sprite.GetScale().x *moveKnockback;
     moveDirection.y  = -moveKnockback;
     animationPlayback.Travel("hurt");
 }
Exemplo n.º 30
0
 public override void _PhysicsProcess(float delta)
 {
     animationState.Travel("Attack");
 }