Esempio n. 1
0
    private IEnumerator SetupLeftController()
    {
        do
        {
            leftController = SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost));
            yield return(null);
        } while (leftController == null);

        SteamVR_ControllerManager steamVR_ControllerManager = GetComponent <SteamVR_ControllerManager>();
        Transform transform = null;

        Instantiate(orbGunPrefab, steamVR_ControllerManager.left.transform);

        do
        {
            leftOrbGun = steamVR_ControllerManager.left.GetComponentInChildren <OrbGun>();
            yield return(null);
        } while (leftOrbGun == null);

        leftOrbGun.SetPlayerRootTransform(gameObject.transform);
        leftOrbGun.SetCompanion(companion);

        do
        {
            transform = steamVR_ControllerManager.left.transform.Find("Model/trackpad");
            yield return(null);
        } while (transform == null);

        leftOrbGun.SetViveTrackpadMeshRenderer(transform.gameObject.GetComponent <MeshRenderer>());
    }
Esempio n. 2
0
    private void Start()
    {
        player = GameObject.Find("[DebugPlayer]");

        if (player == null)
        {
            player = GameObject.Find("[CameraRig]");
            StartCoroutine(SetupOrbGuns(player));
        }
        else
        {
            OrbGun orbGun = player.GetComponentInChildren <OrbGun>(true);

            orbGun.OnOrbShot   += OrbGunShot;
            orbGun.OnChangeOrb += OrbChange;
        }

        paintOrbWasShot    = false;
        teleportOrbWasShot = false;
        orbChanged         = false;

        paintOrb.SetActive(false);
        teleportOrb.SetActive(false);

        StartCoroutine(Introduction());
    }
Esempio n. 3
0
    private void Start()
    {
        companion.autoFollowTransforms = GetComponentInChildren <AutoFollowPosition>().GetAutoFollowPositions();

        orbGun = GetComponentInChildren <OrbGun>();

        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;
    }
Esempio n. 4
0
    private IEnumerator SetupOrbGuns(GameObject player)
    {
        OrbGun[] orbGuns = new OrbGun[0];

        do
        {
            orbGuns = player.GetComponentsInChildren <OrbGun>(true);
            yield return(new WaitForSeconds(0.1f));
        } while (orbGuns.Length != 2);

        for (int i = 0; i < orbGuns.Length; ++i)
        {
            orbGuns[i].OnOrbShot   += OrbGunShot;
            orbGuns[i].OnChangeOrb += OrbChange;
        }

        yield return(new WaitForSeconds(5.0f));
    }
Esempio n. 5
0
    //change orb type depending on which orbs can be used and showing the colors on the trackpad
    private void ChangeOrbType(OrbGun orbGun, ViveController viveController, Vector2 position)
    {
        Vector2 bottomToTop          = Vector2.up;
        Vector2 leftBottomToRightTop = new Vector2(2.0f, 2.0f);
        Vector2 rightBottomToLeftTop = new Vector2(-2.0f, 2.0f);

        bool left     = (-bottomToTop.x * position.y + bottomToTop.y * position.x) < 0;
        bool leftTop  = (-leftBottomToRightTop.x * position.y + leftBottomToRightTop.y * position.x) < 0;
        bool rightTop = (-rightBottomToLeftTop.x * position.y + rightBottomToLeftTop.y * position.x) > 0;

        int numberOfActiveOrbs = 0;

        for (OrbType orbType = OrbType.CommandOrb; orbType <= OrbType.TeleportOrb; ++orbType)
        {
            if (orbGun.IsOrbActive(orbType))
            {
                ++numberOfActiveOrbs;
            }
        }

        OrbType newOrb = OrbType.None;

        if (numberOfActiveOrbs == 2)
        {
            newOrb = GetOrbTypeForTwoActiveOrbs(left);
        }
        else if (numberOfActiveOrbs == 3)
        {
            newOrb = GetOrbTypeForFourActiveOrbs(left, leftTop, rightTop);
        }
        else if (numberOfActiveOrbs == 4)
        {
            newOrb = GetOrbTypeForFourActiveOrbs(leftTop, rightTop);
        }

        if (newOrb != OrbType.None)
        {
            if (orbGun.SetCurrentOrbTo(newOrb))
            {
                Vibration(viveController);
            }
        }
    }