Ejemplo n.º 1
0
 bool MoveInput()
 {
     if (Input.GetKeyDown("up") || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown("down") || Input.GetKeyDown(KeyCode.S))
     {
         return(player.Move(new Vector2(0.0F, Input.GetAxisRaw("Vertical"))));
     }
     if (Input.GetKeyDown("left") || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown("right") || Input.GetKeyDown(KeyCode.D))
     {
         return(player.Move(new Vector2(Input.GetAxisRaw("Horizontal"), 0.0F)));
     }
     return(false);
 }
Ejemplo n.º 2
0
    public void MovingUnit(int seq, int x, int y)
    {
        PlayerActor actor = unitTable[seq].GetComponent <PlayerActor>();

        if (actor != null)
        {
            actor.Move(x, y);
        }
        else
        {
            DebugLogger.Log("WARNING) no actor unit seq[{0}] pos[{1},{2}]", seq, x, y);
        }
    }
Ejemplo n.º 3
0
        private void Update()
        {
            blueAxis   = cameraTrans.forward;
            redAxis    = cameraTrans.right;
            blueAxis.y = 0;
            redAxis.y  = 0;

            if (isLocked)
            {
                return;
            }

            inputAxis = m_AndroidInput.GradientAxis;

            gravityOffset = Input.acceleration - standardGravityAxis;
            //P.PUBLIC.debugText2.text = gravityOffset.ToString();

            //重力在本地坐标系的向量为standard,当坐标系旋转后,变成Input.acceleration
            //坐标系所有点乘以旋转矩阵mat,Input.acceleration乘以mat的逆矩阵等于standard

            //Matrix4x4 rotateMatrix = STL.Geometry.Math.CalcRotateMatrix(Input.acceleration, standardGravityAxis);

            Vector3 rotateAxis = Vector3.Cross(Input.acceleration, standardGravityAxis);
            float   angle      = Vector3.Angle(Input.acceleration, standardGravityAxis);

            //m_rigidbody.MoveRotation
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.AngleAxis(angle, rotateAxis), 0.05f);
            m_Actor.GoForward();

            dir = inputAxis.x * redAxis + inputAxis.y * blueAxis;

            //m_Actor.Fly(dir);
            m_Actor.Move(dir);
            Debug.Log(gravityOffset);

            if (_AndroidInput.wantReset)
            {
                ResetGravityController();
            }
        }