コード例 #1
0
 protected virtual void Awake()
 {
     if (f_needsGroundMovement)
     {
         f_groundMovement = new GroundMovementRaycast(this, f_height, HalfWidth, this is Player);
         f_movement       = f_groundMovement;
     }
     else
     {
         f_airMovement = new AirMovement(this);
         f_movement    = f_airMovement;
     }
 }
コード例 #2
0
ファイル: GoombaWalk.cs プロジェクト: Mega-Wolf/Metroidvania
    public override bool HandleFixedUpdate()
    {
        //TODO; this is such a hack
        if (InputManager.Instance.IgnoreInput)
        {
            return(true);
        }

        if (!f_controller.Grounded)
        {
            return(true);
        }

        if (f_controller.Backwards)
        {
            f_controller.Backwards = false;
        }

        if (Mathf.Abs(f_controller.Velocity.x) < 0.1f)
        {
            f_controller.GroundMovement.MovingRight = !f_controller.GroundMovement.MovingRight;
        }



        f_controller.Velocity = Vector2.zero;

        GroundTouch gt = f_controller.GroundMovement.Move((f_controller.GroundMovement.MovingRight ? 1 : -1) * SPEED * BossFightRhino.SPEED);

        if (m_stopAtEdges)
        {
            int airDirection = GroundMovementRaycast.AirDirection(gt);
            if (airDirection < 0)
            {
                f_controller.GroundMovement.MovingRight = true;
            }
            else if (airDirection > 0)
            {
                f_controller.GroundMovement.MovingRight = false;
            }
        }

        return(true);
    }
コード例 #3
0
ファイル: Charge.cs プロジェクト: Mega-Wolf/Metroidvania
    public override bool HandleFixedUpdate()
    {
        //TODO; this is such a hack
        if (InputManager.Instance.IgnoreInput)
        {
            return(true);
        }

        if (!f_controller.Grounded)
        {
            return(true);
        }

        if (m_cooldown == -1)
        {
            if (f_controller.Backwards)
            {
                f_controller.Backwards = false;
                // if (f_controller.Velocity.x != 0) {
                //     m_walkingRight =
                // }
            }

            if (Mathf.Abs(f_controller.Velocity.x) < 0.1f)
            {
                Cancel();
            }

            //TODO; does not care about transform
            if (f_controller.Velocity.x < -0.1f)
            {
                f_controller.GroundMovement.MovingRight = false;
            }
            else if (f_controller.Velocity.x > 0.1f)
            {
                f_controller.GroundMovement.MovingRight = true;
            }

            f_controller.Velocity = Vector2.zero;

            GroundTouch gt = f_controller.GroundMovement.Move((f_controller.GroundMovement.MovingRight ? 1 : -1) * CHARGE_SPEED * BossFightRhino.SPEED);

            if (m_stopAtEdges)
            {
                int airDirection = GroundMovementRaycast.AirDirection(gt);
                if (airDirection != 0)
                {
                    Cancel();
                }
            }
        }
        else
        {
            if (m_cooldown == CHARGE_COOLTIME)
            {
                f_futureStates = m_futureStatesHelper;
                m_cooldown     = -1;
            }

            ++m_cooldown;
        }

        return(true);
    }