예제 #1
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);
            }
        }
    }
예제 #2
0
    private void ChangeOrbType()
    {
        OrbType orb = orbGun.GetCurrentOrb();

        if (orb == OrbType.None)
        {
            return;
        }

        do
        {
            if (orb == OrbType.TeleportOrb)
            {
                orb = OrbType.CommandOrb;
            }
            else
            {
                ++orb;
            }
        } while(!orbGun.SetCurrentOrbTo(orb));
    }