float GetDegreeRotation()
    {
        float degrees = 0f;
        float X       = InputAbstraction.GetAxis(InputAbstraction.AxisAlias.X, InputAbstraction.PreferedHand());
        float Y       = InputAbstraction.GetAxis(InputAbstraction.AxisAlias.Y, InputAbstraction.PreferedHand());

        bool XIsNegative = X < 0 ? true : false;
        bool YIsNegative = Y < 0 ? true : false;

        X = Mathf.Abs(X);
        Y = Mathf.Abs(Y);

        degrees = (YIsNegative ^ XIsNegative) ? Mathf.Atan(Y / X) * (180 / Mathf.PI) : Mathf.Atan(X / Y) * (180 / Mathf.PI);

        if (YIsNegative && !XIsNegative)
        {
            degrees += 90;
        }
        else if (YIsNegative && XIsNegative)
        {
            degrees += 180;
        }
        else if (!YIsNegative && XIsNegative)
        {
            degrees += 270;
        }

        return(degrees);
    }
 // Update is called once per frame
 void Update()
 {
     m_Transform.localPosition = new Vector3(
         InputAbstraction.GetAxis(InputAbstraction.AxisAlias.X, hand, ignoreSDK) * amplitudeMaxX,
         m_Transform.localPosition.y,
         InputAbstraction.GetAxis(InputAbstraction.AxisAlias.Y, hand, ignoreSDK) * amplitudeMaxY);
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (m_Timer > 0)
        {
            m_Timer -= Time.deltaTime;
        }

        if (m_Timer <= 0 && InputAbstraction.FireControlActive(InputAbstraction.PreferedHand()))
        {
            if (m_NumSpecialAmmo > 0 && specialBulletPrefab != null)
            {
                Instantiate(specialBulletPrefab, m_Transform.position, m_Transform.rotation);
                if (m_audioSource != null)
                {
                    m_audioSource.PlayOneShot(specialAmmoFireClip);
                }
                HapticAbstraction.BuzzBothHands(hapticTime);

                m_NumSpecialAmmo--;
            }
            else if (bulletPrefab != null)
            {
                Instantiate(bulletPrefab, m_Transform.position, m_Transform.rotation);
                if (m_audioSource != null)
                {
                    m_audioSource.Play();
                }
                HapticAbstraction.BuzzBothHands(hapticTime);
            }

            m_Timer = cooldown;
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        // Do Raycast
        RaycastHit hit = new RaycastHit();

        if (Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity, layerMask))
        {
            // Show navigation aid
            m_NavigationAidPrefab.SetActive(true);
            m_NavigationAidPrefab.transform.position = hit.point;

            // Handle input
            if (InputAbstraction.GetButtonDown(InputAbstraction.ButtonAlias.AXIS_CLICK, InputAbstraction.PreferedHand()))
            {
                if (m_nmAgent == null)
                {
                    m_nmAgent = GameManager.instance.player.GetComponent <NavMeshAgent>();
                }

                if (m_nmAgent != null)
                {
                    m_nmAgent.destination = hit.point;
                    if (m_audioSource != null)
                    {
                        m_audioSource.Play();
                    }
                }
            }
        }
        else
        {
            m_NavigationAidPrefab.SetActive(false);
        }
    }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     inputAbstraction = GetComponent <InputAbstraction>();
     if (inputAbstraction == null)
     {
         Debug.LogError("Player Controller created with no input abstraction");
     }
     inputAbstraction.AddInputToAction(KeyCode.Space, new InputContainer(OnSpaceDown, OnSpaceHeld, OnSpaceUp));
 }
Пример #6
0
 private void _rbMouse2_CheckedChanged(object sender, EventArgs e)
 {
     if (_rbMouse2.Checked == true)
     {
         ArrowKeys.Enabled = false;
         P2         = new InputAbstraction(2);
         MouseMove += P2.Player_MouseMove;
     }
 }
Пример #7
0
 private void _rbMouse1_CheckedChanged(object sender, EventArgs e)
 {
     if (_rbMouse1.Checked == true)
     {
         _rbWASD.Enabled = false;
         P1         = new InputAbstraction(2);
         MouseMove += P1.Player_MouseMove;
     }
 }
Пример #8
0
 private void ArrowKeys_CheckedChanged(object sender, EventArgs e)
 {
     if (ArrowKeys.Checked == true)
     {
         _rbMouse2.Enabled = false;
         P2       = new InputAbstraction(1);
         KeyDown += P2.press_KeyDown;
         KeyUp   += P2.release_KeyUp;
     }
 }
Пример #9
0
 private void _rbWASD_CheckedChanged(object sender, EventArgs e)
 {
     if (_rbWASD.Checked == true)
     {
         _rbMouse1.Enabled = false;
         P1       = new InputAbstraction(0);
         KeyDown += P1.press_KeyDown;
         KeyUp   += P1.release_KeyUp;
     }
 }