Esempio n. 1
0
    string GetString_CmdBool()
    {
        string s = " --- Zelda CmdBool ---\n";

        foreach (Cmd_Bool b in Enum.GetValues(typeof(Cmd_Bool)))
        {
            s += b.ToString() + " = " + ZeldaInput.GetCommand_Bool(b) + SEPERATOR;
        }
        return(s);
    }
Esempio n. 2
0
    public override void UpdateMovement()
    {
        if (HaltUpdateMovement)
        {
            return;
        }

        float moveHorzAxis = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MoveHorizontal);
        float moveVertAxis = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MoveVertical);
        bool  moveForward  = moveVertAxis > 0;
        bool  moveLeft     = moveHorzAxis < 0;
        bool  moveBack     = moveVertAxis < 0;
        bool  moveRight    = moveHorzAxis > 0;

        MoveScale = 1.0f;

        if ((moveForward && moveLeft) || (moveForward && moveRight) || (moveBack && moveLeft) || (moveBack && moveRight))
        {
            MoveScale = 0.70710678f;
        }

        MoveScale *= SimulationRate * Time.deltaTime;

        // Compute this for key movement
        float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;

        // Run
        if (ZeldaInput.GetCommand_Bool(ZeldaInput.Cmd_Bool.Run))
        {
            moveInfluence *= RunMultiplier;
        }


        Quaternion ort      = transform.rotation;
        Vector3    ortEuler = ort.eulerAngles;

        ortEuler.z = ortEuler.x = 0f;
        ort        = Quaternion.Euler(ortEuler);

        if (moveForward)
        {
            MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward);
        }
        if (moveBack)
        {
            MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back);
        }
        if (moveLeft)
        {
            MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left);
        }
        if (moveRight)
        {
            MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right);
        }

        // Jump
        if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.Jump))
        {
            Jump();
        }

        // Rotation
        Vector3 euler = transform.rotation.eulerAngles;

        float rotateInfluence = SimulationRate * Time.deltaTime * RotationAmount * RotationScaleMultiplier;

        //if (!SkipMouseRotation)
        //{
        //    euler.y += Input.GetAxis("Mouse X") * rotateInfluence * 3.25f;
        //}

        moveInfluence = SimulationRate * Time.deltaTime * Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;

        float lookHorzAxis  = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.LookHorizontal);
        float deltaRotation = lookHorzAxis * rotateInfluence * 3.25f;

        euler.y += deltaRotation;

        transform.rotation = Quaternion.Euler(euler);
    }