示例#1
0
        public void Initialize(Transform t, PlayerEventHandler pl, AudioSource aS)
        {
            m_Transform = t;
            // m_Player = pl;
            //m_Audio = aS;

            m_Pulse = new AlphaPulse(m_PreviewColor, m_PulseMin, m_PulseMax);
        }
示例#2
0
    public void AddMapPoint(GameObject o, string objectName, string textureName, float scale = 2.0f)
    {
        Vector3 mapPoint = WorldToMapPoint(o.transform.position);

        // make a quad with the proper texture.
        GameObject newPoint = (GameObject)Instantiate(MapPointPrefab, new Vector3(mapPoint.x, mapPoint.y, -3.0f), Quaternion.identity);

        newPoint.name = objectName;
        newPoint.GetComponent <Renderer>().material.mainTexture = Resources.Load <Texture2D> (textureName);
//		newPoint.transform.localScale = new Vector3 (scale, scale, scale);

        AlphaPulse ap = newPoint.AddComponent <AlphaPulse> ();

        ap.MinAlpha   = 0.3f;
        ap.MaxAlpha   = 1.0f;
        ap.PulseSpeed = 1.5f;
        ap.On         = true;

        newPoint.transform.parent = transform;
    }
示例#3
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;
    }
示例#4
0
    public IEnumerator ShowTwoHands()
    {
        // Create the pieces we're showing
        Transform  leftHandVignette = (Transform)Instantiate(LeftHandVignette, LeftHandVignette.position, LeftHandVignette.rotation);
        AlphaPulse leftPulse        = leftHandVignette.GetComponent <AlphaPulse>();

        if (leftPulse == null)
        {
            leftPulse = leftHandVignette.gameObject.AddComponent <AlphaPulse>();
        }
        Transform  rightHandVignette = (Transform)Instantiate(RightHandVignette, RightHandVignette.position, RightHandVignette.rotation);
        AlphaPulse rightPulse        = rightHandVignette.GetComponent <AlphaPulse>();

        if (rightPulse == null)
        {
            rightPulse = rightHandVignette.gameObject.AddComponent <AlphaPulse>();
        }
        Transform leftThumb  = (Transform)Instantiate(LeftThumbPrint, LeftThumbPrint.position, LeftThumbPrint.rotation);
        Transform rightThumb = (Transform)Instantiate(RightThumbPrint, RightThumbPrint.position, RightThumbPrint.rotation);

        // We only need to force 2 hands on the mobile devices
        bool hasUsed2Hands = false;

#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
        hasUsed2Hands = true;
#endif

        // Wait until they finally have used both hands to move on
        bool leftSideTouched  = false;
        bool rightSideTouched = false;
        while (!hasUsed2Hands)
        {
            leftSideTouched  = false;
            rightSideTouched = false;

            foreach (Touch touch in Input.touches)
            {
                if (touch.position.x < Screen.width / 2)
                {
                    leftSideTouched = true;
                }
                if (touch.position.x > Screen.width / 2)
                {
                    rightSideTouched = true;
                }
            }

            leftPulse.On = !leftSideTouched;
            leftThumb.GetComponent <Renderer>().enabled = !leftSideTouched;
            rightPulse.On = !rightSideTouched;
            rightThumb.GetComponent <Renderer>().enabled = !rightSideTouched;

            if (leftSideTouched && rightSideTouched)
            {
                hasUsed2Hands = true;
            }

            yield return(null);
        }

        // Remove the shown pieces
        Destroy(leftHandVignette.gameObject);
        Destroy(leftThumb.gameObject);
        Destroy(rightHandVignette.gameObject);
        Destroy(rightThumb.gameObject);

        // Make the player get up
        GameManager.Player.MecanimAnimator.SetBool(MecanimHashes.Respawn, true);
        yield return(new WaitForSeconds(1.0f));

        // Let them move again
        GameManager.MainCamera.CinematicOverride = false;
        GameManager.IsPlayingCutscene            = false;
    }