Exemplo n.º 1
0
 public void ChangeAnimationState(string stateName)
 {
     if (_AnimStateMachine.GetCurrentNode() != stateName)
     {
         _AnimStateMachine.Travel(stateName);
     }
 }
Exemplo n.º 2
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.º 3
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.º 4
0
 public override void _PhysicsProcess(float delta)
 {
     state = checkState(stateMachine.GetCurrentNode());
     state._statePhysicsProcess(delta);
     if (Input.IsActionJustPressed("ui_changeTime"))
     {
         if (timeScale == 1)
         {
             ChangeTime(5);
         }
         else
         {
             ChangeTime(1);
         }
     }
 }
Exemplo n.º 5
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);
        }