Пример #1
0
 private void CreateAllProxies()
 {
     foreach (Type proxyType in U.Object.GetImplementationsOfInterface(typeof(IProxy)))
     {
         IProxy proxy = U.Object.CreateGameObjectWithComponent(proxyType, VRView.viewerPivot) as IProxy;
         proxy.trackedObjectInput = m_PlayerHandle.GetActions <TrackedObject>();
         foreach (var rayOriginBase in proxy.rayOrigins)
         {
             var rayTransform = U.Object.Instantiate(m_ProxyRayPrefab.gameObject, rayOriginBase.Value).transform;
             rayTransform.position = rayOriginBase.Value.position;
             rayTransform.rotation = rayOriginBase.Value.rotation;
             m_DefaultRays.Add(rayOriginBase.Value, rayTransform.GetComponent <DefaultProxyRay>());
         }
         m_AllProxies.Add(proxy);
     }
 }
Пример #2
0
    public void Update()
    {
        // Listen to if the join button was pressed on a yet unassigned device.
        if (joinAction.control.wasJustPressed)
        {
            // These are the devices currently active in the global player handle.
            List <InputDevice> devices = globalHandle.GetActions(joinAction.action.actionMap).GetCurrentlyUsedDevices();

            PlayerHandle handle = PlayerHandleManager.GetNewPlayerHandle();
            for (int i = 0; i < devices.Count; i++)
            {
                handle.AssignDevice(devices[i]);
            }

            playerPrefab.SetPlayerHandleMaps(handle);
            for (int i = 0; i < handle.maps.Count; i++)
            {
                // Activate the ActionMap that is used to join,
                // disregard active state from ActionMapSlots for now (wait until instantiating player).
                var map = handle.maps[i];
                map.active = (map.actionMap == joinAction.action.actionMap);
            }

            players.Add(new PlayerInfo(handle, joinAction, leaveAction));
        }

        int readyCount = 0;

        for (int i = players.Count - 1; i >= 0; i--)
        {
            var player = players[i];
            if (!player.ready)
            {
                if (player.joinControl.wasJustPressed)
                {
                    player.ready = true;
                }
                if (player.leaveControl.wasJustPressed)
                {
                    player.playerHandle.Destroy();
                    players.Remove(player);
                    continue;
                }
            }
            else
            {
                if (player.joinControl.wasJustPressed || player.leaveControl.wasJustPressed)
                {
                    player.ready = false;
                }
            }
            if (player.ready)
            {
                readyCount++;
            }
        }

        if (readyCount >= 1 && (players.Count - readyCount) == 0)
        {
            StartGame();
        }
    }
Пример #3
0
 public PlayerInfo(PlayerHandle playerHandle, ButtonAction joinAction, ButtonAction leaveAction)
 {
     this.playerHandle = playerHandle;
     joinControl       = playerHandle.GetActions(joinAction.action.actionMap).GetControl(joinAction.action.actionIndex) as ButtonControl;
     leaveControl      = playerHandle.GetActions(leaveAction.action.actionMap).GetControl(leaveAction.action.actionIndex) as ButtonControl;
 }
    public void Update()
    {
        // Listen to if the join button was pressed on a yet unassigned device.
        if (joinAction.control.wasJustPressed)
        {
            // These are the devices currently active in the global player handle.
            List <InputDevice> devices = globalHandle.GetActions(joinAction.action.actionMap).GetCurrentlyUsedDevices();

            PlayerHandle handle = PlayerHandleManager.GetNewPlayerHandle();
            foreach (var device in devices)
            {
                handle.AssignDevice(device, true);
            }

            foreach (ActionMapSlot actionMapSlot in playerPrefab.actionMaps)
            {
                ActionMapInput map = ActionMapInput.Create(actionMapSlot.actionMap);
                map.TryInitializeWithDevices(handle.GetApplicableDevices());
                map.blockSubsequent = actionMapSlot.blockSubsequent;

                // Activate the ActionMap that is used to join,
                // disregard active state from ActionMapSlots for now (wait until instantiating player).
                if (map.actionMap == joinAction.action.actionMap)
                {
                    map.active = true;
                }

                handle.maps.Add(map);
            }

            players.Add(new PlayerInfo(handle, joinAction, leaveAction));
        }

        int readyCount = 0;

        for (int i = players.Count - 1; i >= 0; i--)
        {
            var player = players[i];
            if (!player.ready)
            {
                if (player.joinControl.wasJustPressed)
                {
                    player.ready = true;
                }
                if (player.leaveControl.wasJustPressed)
                {
                    player.playerHandle.Destroy();
                    players.Remove(player);
                    continue;
                }
            }
            else
            {
                if (player.joinControl.wasJustPressed || player.leaveControl.wasJustPressed)
                {
                    player.ready = false;
                }
            }
            if (player.ready)
            {
                readyCount++;
            }
        }

        if (readyCount >= 1 && (players.Count - readyCount) == 0)
        {
            StartGame();
        }
    }