Exemple #1
0
    void Start()
    {
        controller     = GetComponent <Controller2D>();
        grappleThrower = GetComponent <GrappleThrower>();
        replay         = FindObjectOfType <BReplay>();

        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;

        state = new PlayerStateStop(this);
        state.OnAttach();
        stateName = state.GetName();
        if (stateLabel)
        {
            stateLabel.text = stateName;
        }
        print("Gravity: " + gravity + "  Jump Velocity: " + jumpVelocity);
        fuMouse = new FixedMouseButtons();
    }
Exemple #2
0
    void FixedUpdate()
    {
        replay.HandleInput(ref fuMouse);
        if (fuMouse.wasDown || fuMouse.wasUp)
        {
            fuMouse.x = 0.001f * fuMouse.str_x;
            fuMouse.y = 0.001f * fuMouse.str_y;

            Debug.Log("player # " + replay.frameID + " (" + (fuMouse.wasDown ? "Down" : "Up") + ") x=" + fuMouse.x + " y=" + fuMouse.y);
        }
        //Debug.Log(
        //    controller.collisions.above + " " +
        //    controller.collisions.below + " " +
        //    controller.collisions.left + " " +
        //    controller.collisions.right + " " +
        //    controller.collisions.climbingSlope
        //    );

        //Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        if (!replay.isEnded)
        {
            if (controller.collisions.below)
            {
                velocity.y = 0;
            }
            nextState = state.HandleInput();
            fuMouse   = new FixedMouseButtons();
            if (nextState != null)
            {
                ChangeState(nextState);
                nextState = null;
            }
            state.HandleMovement();
            stateLabel.text = stateName + " " + velocity.magnitude.ToString("00.00");
        }
    }