示例#1
0
    void GrabControls()
    {
        if (!ActivityManager.Instance)
        {
            return;
        }

        //Store the controls manager
        ControlsManager mgr = ActivityManager.Instance.HUDController;

        if (mgr)
        {
            loadedControls = ActivityManager.Instance.HUDController.LoadedControls;
        }

        if (loadedControls)
        {
            //When we grab... hide all the controls...
            loadedControls.Shoot.gameObject.SetActive(false);
            loadedControls.Shield.gameObject.SetActive(false);
            loadedControls.Overheat.gameObject.SetActive(false);
        }


        //Take the hud off when we grab.
        ActivityManager.Instance.ToggleHud(false);
    }
    public override void OnActivate()
    {
        //Just incase, we shuld always be 'closed' as we are actiavted. right?
        closed = true;


        //Calculate the ranges.
        DZRange = Deadzone_Max - Deadzone_Min;
        RangeR  = Range_Max - Range_Min;

        //Grab the joystick upon activate.
        _joystick = ToyBox.GetPandora().Controls;


        //Set the position of the joystick.
        JoystickPosition.localPosition = _joystick.JoystickScreenPosition;

        //Get the loaded controls to access
        loadedControls = controlsManager.LoadedControls;

        //Set the deadzone and the analog range.
        DeadZone.transform.localScale     = new Vector3(_joystick.DeadzoneRange.x, _joystick.DeadzoneRange.y, 1.0f);
        AnalogeRange.transform.localScale = new Vector3(_joystick.AnalogRange.x, _joystick.AnalogRange.y, 1.0f);


        //Load the adjusted values from here.
        ShieldButton.localPosition = loadedControls.Shield.localPosition;
        ShootButton.localPosition  = loadedControls.Shoot.localPosition;


        //Load values from controler and apply to the knobs.
        ShootKnob.transform.localPosition  = loadedControls.ShootButton.transform.localPosition;
        ShieldKnob.transform.localPosition = loadedControls.ShieldButton.transform.localPosition;

        ShootKnob.transform.localScale  = loadedControls.ShootButton.transform.localScale;
        ShieldKnob.transform.localScale = loadedControls.ShieldButton.transform.localScale;



        RValue  = _joystick.AnalogRange;
        DZValue = _joystick.DeadzoneRange;

        sliderRange.onValueChange    += OnRangeChange;
        sliderDeadzone.onValueChange += OnDeadzoneChange;

        closed = false;

        //Update the sliders to match.
        UpdateSliders();

        UpdateVisual();


        //	Debug.LogError("Finish Start");
    }
示例#3
0
    public void Reset(bool KeepBlackBG = false)
    {
        //Just clear activitites upon reset for now.
        if (pause)
        {
            pause.TogglePause(true);
        }

        HUD.TogglePanel(true);

        //Reset all activities
        foreach (FUIActivity a in Activities)
        {
            a.OnReset();
        }

        PullCurtain();

        //make sure contorls are turned on upon reset.

        if (_myControlsManager)
        {
            if (_myControlsManager.LoadedControls)
            {
                ControlsLayoutObject loadedControls = _myControlsManager.LoadedControls;

                //When we grab... hide all the controls...
                loadedControls.Shoot.gameObject.SetActive(true);
                loadedControls.Shield.gameObject.SetActive(true);
                loadedControls.Overheat.gameObject.SetActive(true);
            }
        }


        //Toggle off boss notif
        BossNotif.CloseWindow();

        if (!KeepBlackBG)
        {
            //Make sure the black BG is always 0 alpha.
            BlackBG.alpha = 0.0f;
            BlackBG.gameObject.SetActive(false);
        }
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        //This be the default?
        if (GameObjectTracker.instance == null)
        {
            Debug.LogError("NO GOT!!");
        }


        //DeviceControlsStartIndex = DEVICE.iphone;
        //GameObjectTracker.instance._PlayerData.currentDevice = DEVICE.iphone;



#if UNITY_IPHONE
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            //Check the device and assign the index.
            if ((iPhone.generation == iPhoneGeneration.iPad2Gen) ||
                (iPhone.generation == iPhoneGeneration.iPad3Gen) ||
                (iPhone.generation == iPhoneGeneration.iPad4Gen))
            {
                DeviceControlsStartIndex = DEVICE.iPad;

                //let the player data know waht device we have
                GameObjectTracker.instance._PlayerData.currentDevice = DEVICE.iPad;
            }
            else
            {
                DeviceControlsStartIndex = DEVICE.iphone;

                if (iPhone.generation == iPhoneGeneration.iPhone4S ||
                    iPhone.generation == iPhoneGeneration.iPodTouch5Gen)
                {
                    QualitySettings.SetQualityLevel(0, true);
                }

                //let the player data know waht device we have
                GameObjectTracker.instance._PlayerData.currentDevice = DEVICE.iphone;
            }
        }
#endif



        // start the current Device controls index to the starting index.
        currentDeviceControlsIndex = DeviceControlsStartIndex;

        //Then based on the current device index we load the prefab for the device.

        // we going to instantiate with the ngui tools because it needs to be correctly
        // inserted below us.
        if (loadAtStart)
        {
            if (controlsLayoutPrefabs.Length > (int)currentDeviceControlsIndex)
            {
                ControlsLayoutObject loadPrefab = controlsLayoutPrefabs[(int)currentDeviceControlsIndex];
                if (loadPrefab)                  // we have a prefab to load

                {
                    loadedObject = NGUITools.AddChild(this.gameObject, loadPrefab.gameObject).GetComponent <ControlsLayoutObject>();
                    if (loadedObject)
                    {
//						Debug.Log("We have a controls Layout Object " + loadedObject.name);
                    }
                }
            }
            else              // we're out of bounds, load the default or nothing
            {
                if (defaultControlsLayout != null)
                {
                    loadedObject = NGUITools.AddChild(this.gameObject, defaultControlsLayout.gameObject).GetComponent <ControlsLayoutObject>();
                    if (loadedObject)
                    {
                        Debug.LogWarning("Loaded Default Controls Layout Object " + loadedObject.name);
                    }
                }
            }
        }
    }