示例#1
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            m_Controller.Command(new ShootCommand(m_Controller, m_RigidBody, m_Shell, m_FireTransform, m_ShootingAudio, m_FireClip));
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            m_Controller.Command(new ExplodeCommand(m_Controller, m_RigidBody, m_Health, m_ExplosionPrefab));
        }
    }
示例#2
0
    private void Move()
    {
        if (m_Controller.Status == TankStatus.Normal)
        {
            if (Input.GetMouseButtonDown(1))
            {
                var hit = new RaycastHit();
                Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit);

                m_Controller.Command(new MoveCommand(hit.point, m_Controller, m_Agent));
            }
        }
        else if (m_Controller.Status == TankStatus.Turned)
        {
            var turnAxis = (System.Math.Abs(Vector3.Dot(transform.forward, Vector3.up)) < 0.2) ? transform.forward : transform.right;

            if (Input.GetMouseButton(1))
            {
                m_RigidBody.AddTorque(turnAxis * 15);
            }

            if (Input.GetMouseButton(0))
            {
                m_RigidBody.AddTorque(turnAxis * -15);
            }
        }
    }