public void onControl( SwitchableTexture callingSwitch )
    {
        int playerIndex = Array.IndexOf( ed_controlSelectors, callingSwitch );
        int type = ed_controlSelectors[playerIndex].index ;

        if ( type == 0 ) //off
        {
            //turn off this guy
            ed_playerViewCameras[playerIndex].farClipPlane = 2;
            ed_playerViewCameras[playerIndex].clearFlags = CameraClearFlags.SolidColor;
            ed_joinButtonTexts[playerIndex].SetActive(true);
            ed_detailControls[playerIndex].SetActive(false);
        }
        else if ( type == 1 ) //joystick
        {
            ed_playerViewCameras[playerIndex].farClipPlane = 1000;
            ed_playerViewCameras[playerIndex].clearFlags = CameraClearFlags.Skybox;
            ed_joinButtonTexts[playerIndex].SetActive(false);
            ed_detailControls[playerIndex].SetActive(true);
            //bind to not already used joystick
        }
        else if ( type == 2) //keyboard
        {
            ed_playerViewCameras[playerIndex].farClipPlane = 1000;
            ed_playerViewCameras[playerIndex].clearFlags = CameraClearFlags.Skybox;
            ed_joinButtonTexts[playerIndex].SetActive(false);
            ed_detailControls[playerIndex].SetActive(true);

            foreach( SwitchableTexture switchable in ed_controlSelectors)
            {
                if ( callingSwitch != switchable && switchable.index == 2) //if keyboard
                    switchable.setIndex(1);//switch to joystick
            }
        }
    }
    public void onControl(SwitchableTexture callingSwitch)
    {
        int playerIndex = Array.IndexOf(ed_controlSelectors, callingSwitch);
        int type        = ed_controlSelectors[playerIndex].index;

        if (type == 0)           //off
        {
            //turn off this guy
            ed_playerViewCameras[playerIndex].farClipPlane = 2;
            ed_playerViewCameras[playerIndex].clearFlags   = CameraClearFlags.SolidColor;
            ed_joinButtonTexts[playerIndex].SetActive(true);
            ed_detailControls[playerIndex].SetActive(false);
        }
        else if (type == 1)           //joystick
        {
            ed_playerViewCameras[playerIndex].farClipPlane = 1000;
            ed_playerViewCameras[playerIndex].clearFlags   = CameraClearFlags.Skybox;
            ed_joinButtonTexts[playerIndex].SetActive(false);
            ed_detailControls[playerIndex].SetActive(true);
            //bind to not already used joystick
        }
        else if (type == 2)          //keyboard
        {
            ed_playerViewCameras[playerIndex].farClipPlane = 1000;
            ed_playerViewCameras[playerIndex].clearFlags   = CameraClearFlags.Skybox;
            ed_joinButtonTexts[playerIndex].SetActive(false);
            ed_detailControls[playerIndex].SetActive(true);

            foreach (SwitchableTexture switchable in ed_controlSelectors)
            {
                if (callingSwitch != switchable && switchable.index == 2) //if keyboard
                {
                    switchable.setIndex(1);                               //switch to joystick
                }
            }
        }
    }
    public void onControl( SwitchableTexture callingSwitch )
    {
        int playerIndex = Array.IndexOf( ed_controlSelectors, callingSwitch );

        int type = ed_controlSelectors[playerIndex].index ;

        if ( type == 0 ) //off
        {
            //turn off this guy
            ed_playerViewCameras[playerIndex].farClipPlane = 2;
            ed_playerViewCameras[playerIndex].clearFlags = CameraClearFlags.SolidColor;
            ed_joinButtonTexts[playerIndex].SetActive(true);
            ed_detailControls[playerIndex].SetActive(false);
            controllerHighlights[playerIndex].SetActive(false);

            //if this is a controller turning off then remove from map
            if ( controllerDeviceIndexToPlayerIndexMap.ContainsValue(playerIndex) )
            {
                foreach( KeyValuePair<int,int> kv in controllerDeviceIndexToPlayerIndexMap)
                {
                    if ( kv.Value == playerIndex)
                    {
                        controllerDeviceIndexToPlayerIndexMap.Remove( kv.Key);
                        break;
                    }
                }
            }
        }
        else if ( type == 1 ) //joystick
        {
            ed_playerViewCameras[playerIndex].farClipPlane = 1000;
            ed_playerViewCameras[playerIndex].clearFlags = CameraClearFlags.Skybox;
            ed_joinButtonTexts[playerIndex].SetActive(false);
            ed_detailControls[playerIndex].SetActive(true);

        }
        else if ( type == 2) //keyboard
        {
            //if this is a controller skip keyboard
            if ( controllerDeviceIndexToPlayerIndexMap.ContainsValue(playerIndex) )
            {
                foreach( KeyValuePair<int,int> kv in controllerDeviceIndexToPlayerIndexMap)
                {
                    if ( kv.Value == playerIndex)
                    {
                        ed_controlSelectors[playerIndex].setIndex(0);
                        break;
                    }
                }
            }
            else //set keyboard
            {
                ed_playerViewCameras[playerIndex].farClipPlane = 1000;
                ed_playerViewCameras[playerIndex].clearFlags = CameraClearFlags.Skybox;
                ed_joinButtonTexts[playerIndex].SetActive(false);
                ed_detailControls[playerIndex].SetActive(true);

                //if this was a controller remove it
                if ( controllerDeviceIndexToPlayerIndexMap.ContainsValue(playerIndex) )
                {
                    foreach( KeyValuePair<int,int> kv in controllerDeviceIndexToPlayerIndexMap)
                    {
                        if ( kv.Value == playerIndex)
                        {
                            controllerDeviceIndexToPlayerIndexMap.Remove( kv.Key );
                            controllerHighlights[playerIndex].SetActive(false);
                            break;
                        }
                    }
                }

                //check if keyboard was somewhere else, change it to blank
                foreach( SwitchableTexture switchable in ed_controlSelectors)
                {
                    if ( callingSwitch != switchable && switchable.index == 2) //if keyboard
                    {
                        switchable.setIndex(0);
                    }
                }
            }
        }
    }
Exemple #4
0
    public void onControl(SwitchableTexture callingSwitch)
    {
        int playerIndex = Array.IndexOf(ed_controlSelectors, callingSwitch);

        int type = ed_controlSelectors[playerIndex].index;

        if (type == 0)           //off
        {
            //turn off this guy
            ed_playerViewCameras[playerIndex].farClipPlane = 2;
            ed_playerViewCameras[playerIndex].clearFlags   = CameraClearFlags.SolidColor;
            ed_joinButtonTexts[playerIndex].SetActive(true);
            ed_detailControls[playerIndex].SetActive(false);
            controllerHighlights[playerIndex].SetActive(false);

            if (playerIndex == keyboardIndex)
            {
                keyboardIndex = -1;
            }

            //if this is a controller turning off then remove from map
            if (controllerDeviceIndexToPlayerIndexMap.ContainsValue(playerIndex))
            {
                foreach (KeyValuePair <int, int> kv in controllerDeviceIndexToPlayerIndexMap)
                {
                    if (kv.Value == playerIndex)
                    {
                        controllerDeviceIndexToPlayerIndexMap.Remove(kv.Key);
                        break;
                    }
                }
            }

            //remove player from active players
            PlayerInfo p = nvs.getPlayer(playerIndex);
            nvs.players.Remove(p);
        }
        else if (type == 1)           //joystick
        {
            ed_playerViewCameras[playerIndex].farClipPlane = 1000;
            ed_playerViewCameras[playerIndex].clearFlags   = CameraClearFlags.Skybox;
            ed_joinButtonTexts[playerIndex].SetActive(false);
            ed_detailControls[playerIndex].SetActive(true);
        }
        else if (type == 2)          //keyboard
        {
            //if this is a controller skip keyboard
            if (controllerDeviceIndexToPlayerIndexMap.ContainsValue(playerIndex))
            {
                foreach (KeyValuePair <int, int> kv in controllerDeviceIndexToPlayerIndexMap)
                {
                    if (kv.Value == playerIndex)
                    {
                        ed_controlSelectors[playerIndex].setIndex(0);
                        break;
                    }
                }
            }
            else             //set keyboard
            {
                ed_playerViewCameras[playerIndex].farClipPlane = 1000;
                ed_playerViewCameras[playerIndex].clearFlags   = CameraClearFlags.Skybox;
                ed_joinButtonTexts[playerIndex].SetActive(false);
                ed_detailControls[playerIndex].SetActive(true);
                keyboardIndex = playerIndex;

                controllerHighlights[playerIndex].GetComponent <ControllerHighlightManager>().sendHoverRemoveMessage();

                //if this was a controller remove it
                if (controllerDeviceIndexToPlayerIndexMap.ContainsValue(playerIndex))
                {
                    foreach (KeyValuePair <int, int> kv in controllerDeviceIndexToPlayerIndexMap)
                    {
                        if (kv.Value == playerIndex)
                        {
                            controllerDeviceIndexToPlayerIndexMap.Remove(kv.Key);
                            controllerHighlights[playerIndex].SetActive(false);
                            break;
                        }
                    }
                }

                //check if keyboard was somewhere else, change it to blank
                foreach (SwitchableTexture switchable in ed_controlSelectors)
                {
                    if (callingSwitch != switchable && switchable.index == 2)                      //if keyboard
                    {
                        switchable.setIndex(0);
                    }
                }
            }
        }
    }