Exemplo n.º 1
0
    public void DisableInput()
    {
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
        if (_nontouchInput == null)
        {
            _nontouchInput = GetComponent <NontouchInput>();
        }
        _nontouchInput.Disable();
#elif (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        if (_touchInput == null)
        {
            _touchInput = GetComponent <TouchInput>();
        }
        _touchInput.Disable();
#endif
    }
Exemplo n.º 2
0
    void Start()
    {
        _uiCamera      = GetComponentInChildren <Camera>();
        _touchInput    = GetComponent <TouchInput>();
        _nontouchInput = GetComponent <NontouchInput>();
        _craftingMenu  = GetComponent <CraftingMenu>();

#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
        _touchInput.enabled = false;
#elif (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        _nontouchInput.enabled = false;
#endif

        _playerHeartBox = GameManager.Player.gameObject.GetComponentInChildren <HeartBox>();
        Transform hurtVignette = (Transform)Instantiate(HurtVignette, HurtVignette.position, HurtVignette.rotation);
        hurtVignette.parent = transform;
        _hurtVignetteAlpha  = hurtVignette.GetComponent <AlphaPulse>();

        Transform chaseVignette = (Transform)Instantiate(ChaseVignette, ChaseVignette.position, ChaseVignette.rotation);
        chaseVignette.parent = transform;
        _chaseVignetteAlpha  = chaseVignette.GetComponent <AlphaPulse>();

        Transform searchVignette = (Transform)Instantiate(SearchVignette, SearchVignette.position, SearchVignette.rotation);
        searchVignette.parent = transform;
        _searchVignetteAlpha  = searchVignette.GetComponent <AlphaPulse>();

        Transform flash = (Transform)Instantiate(LensFlareFlash, LensFlareFlash.position, LensFlareFlash.rotation);
        flash.parent = transform;
        _flashAlpha  = flash.GetComponent <AlphaPulse>();
        _hasFlashed  = false;

        _matteBars        = (Transform)Instantiate(MatteBars, MatteBars.position, MatteBars.rotation);
        _matteBars.parent = transform;
        Transform stealthKillVignette = (Transform)Instantiate(StealthKillVignette, StealthKillVignette.position, StealthKillVignette.rotation);
        stealthKillVignette.parent = transform;
        _stealthKillVignette       = stealthKillVignette.GetComponent <Fader>();
        Color stealthColor = _stealthKillVignette.GetComponent <Renderer>().material.color;
        stealthColor.a = 0;
        _stealthKillVignette.GetComponent <Renderer>().material.color = stealthColor;

        Transform stealthKillVignette1 = (Transform)Instantiate(StealthKillVignette1, StealthKillVignette1.position, StealthKillVignette1.rotation);
        stealthKillVignette1.parent = transform;
        _stealthKillVignette1       = stealthKillVignette1.GetComponent <Fader>();
        _stealthKillVignette1.GetComponent <Renderer>().material.color = stealthColor;

        Transform stealthKillVignette2 = (Transform)Instantiate(StealthKillVignette2, StealthKillVignette2.position, StealthKillVignette2.rotation);
        stealthKillVignette2.parent = transform;
        _stealthKillVignette2       = stealthKillVignette2.GetComponent <Fader>();
        _stealthKillVignette2.GetComponent <Renderer>().material.color = stealthColor;

        _weaponWheelPos = new Vector3(1, 1, 8);
        _weaponWheelPos = _uiCamera.ViewportToWorldPoint(_weaponWheelPos);
        _currentWeapon  = 0;

        // weapon quads at proper positions
        _weaponQuads      = new GameObject[3];
        _weaponCountQuads = new GameObject[3];

        Vector3 quadPos = _weaponWheelPos + Vector3.left * WeaponRadius;
        quadPos.z        = -4.0f;
        _weaponQuads [0] = (GameObject)Instantiate(WeaponQuadPrefab, quadPos, Quaternion.identity);
        _weaponQuads [0].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos          = _weaponWheelPos + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 4.0f, 0.0f) * WeaponRadius;
        quadPos.z        = -4.0f;
        _weaponQuads [1] = (GameObject)Instantiate(WeaponQuadPrefab, quadPos, Quaternion.identity);
        _weaponQuads [1].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos          = _weaponWheelPos + Vector3.down * WeaponRadius;
        quadPos.z        = -4.0f;
        _weaponQuads [2] = (GameObject)Instantiate(WeaponQuadPrefab, quadPos, Quaternion.identity);
        _weaponQuads [2].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos               = _weaponWheelPos + Vector3.left * WeaponCountRadius;
        quadPos.z             = -4.0f;
        _weaponCountQuads [0] = (GameObject)Instantiate(WeaponCountQuadPrefab, quadPos, Quaternion.identity);
        _weaponCountQuads [0].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos               = _weaponWheelPos + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 4.0f, 0.0f) * WeaponCountRadius;
        quadPos.z             = -4.0f;
        _weaponCountQuads [1] = (GameObject)Instantiate(WeaponCountQuadPrefab, quadPos, Quaternion.identity);
        _weaponCountQuads [1].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos               = _weaponWheelPos + Vector3.down * WeaponCountRadius;
        quadPos.z             = -4.0f;
        _weaponCountQuads [2] = (GameObject)Instantiate(WeaponCountQuadPrefab, quadPos, Quaternion.identity);
        _weaponCountQuads [2].transform.parent = _craftingMenu.WeaponWheel.transform;


        // *** track player objectives ***
        _playerObjectives = GetComponent <ObjectiveTracker>();

        ObjectiveQuadPos   = _uiCamera.ViewportToWorldPoint(ObjectiveQuadPos);
        ObjectiveQuadPos.z = 8.0f;
        _objectiveQuad     = (GameObject)Instantiate(ObjectiveQuadPrefab, ObjectiveQuadPos, Quaternion.identity);
        _objectiveQuad.transform.parent = transform;

        // load map

        /* TODO: GameObject mapQuad = (GameObject)Instantiate (MapQuadPrefab, _uiCamera.ViewportToWorldPoint (new Vector3 (0.5f, 0.5f, 7.0f)), Quaternion.identity);
         * _mapQuad = mapQuad.GetComponent<MapQuad> ();
         * _mapQuad.transform.parent = transform;
         * _mapQuad.gameObject.SetActive (false);*/

        // *** add all game objects to map ***
        // TODO: _mapQuad.renderer.material.mainTexture = Resources.Load<Texture2D> ("Textures/User Interface/Maps/Commercial Zone Map");
        //   _mapQuad.renderer.material.color = new Color (_mapQuad.renderer.material.color.r,
        //                                                 _mapQuad.renderer.material.color.g,
        //                                                 _mapQuad.renderer.material.color.b,
        //                                                 1.0f);

        // *** set up hints ***
        _hintQuad = (GameObject)Instantiate(HintQuadPrefab, _uiCamera.ViewportToWorldPoint(new Vector3(0.20f, 0.80f, 7.0f)), Quaternion.identity);
        _hintQuad.transform.parent = transform;
        _hintQuad.GetComponent <Renderer>().enabled = false;
        _hintDuration = 0.0f;
        _hintElapsed  = 0.0f;


        _isTrackingSwipe = false;
        _swipeID         = -1;
        _swipeStartPos   = Vector3.zero;

        _ready = true;
    }