Exemple #1
0
    public static void SpawnPlayer()
    {
        // Load from the last save files
        LoadGameState();
        LoadLevelState();

        // Move the player to the correct spot
        Player.transform.position = LastCheckPoint.position;

        // Allow the player to start moving
        Player.IgnoreMovement  = false;
        Player.Direction       = Vector3.right;
        Player.HorizontalSpeed = 0;
        Player.VerticalSpeed   = 0;

        // Reset it's health to max
        HeartBox heart = Player.GetComponentInChildren <HeartBox>();

        if (heart != null)
        {
            heart.HitPoints = heart.MaxHitPoints;
        }

        // Turn off ragdoll if coming back to life
        if (Player.IsDead && Player.Settings.RootRigidBody.GetComponent <Collider>().enabled)
        {
            Player.UndoRagdoll();
        }

        // Make sure the camera is looking at the player
        MainCamera.Target = Player.transform;

        // Enable the input
        UI.EnableInput();
    }
    void OnTriggerExit(Collider other)
    {
        // Manage the list of sounds this character has heard
        SoundEvent sound = other.GetComponent <SoundEvent>();

        if (sound)
        {
            //sound.HeardBy.Remove(this);
            _objectsHeard.Remove(sound);
        }

        HeartBox heart = other.GetComponent <HeartBox>();

        if (heart)
        {
            _charactersCouldHear.Remove(heart);
        }

        OutlineInteractive barrier = other.GetComponent <OutlineInteractive>();

        if (barrier)
        {
            _barriers.Remove(barrier);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        // Manage the list of sounds this character has heard
        SoundEvent          sound    = other.GetComponent <SoundEvent>();
        FootstepAudioPlayer footstep = other.GetComponent <FootstepAudioPlayer>();

        if (sound && footstep != null && footstep.LifetimeLived == 0)
        {
            // NOTE: THE SIMPLICITY OF THIS SPHERECOLLIDER ALLOWS SOUNDS TO BE HEARD THROUGH WALLS
            sound.HeardBy.Add(this);
            // HACK: THIS CHECK ALLOWS BABYBOT TO NOT HEAR THE SIGHT PUZZLE IN THE SEWER TUTORIAL
            if (!IgnoreAbove || other.transform.position.y < 70)
            {
                _objectsHeard.AddFirst(sound);
            }
        }

        HeartBox heart = other.GetComponent <HeartBox>();

        if (heart && !_charactersCouldHear.Contains(heart))
        {
            _charactersCouldHear.Add(heart);
        }

        OutlineInteractive barrier = other.GetComponent <OutlineInteractive>();

        if (barrier && !_barriers.Contains(barrier))
        {
            _barriers.Add(barrier);
        }
    }
Exemple #4
0
    void OnTriggerEnter(Collider other)
    {
        // Manage the list of all the objects that block our vision
        if (other.gameObject.layer == _groundLayer && !_barriers.ContainsKey(other))
        {
            _barriers.Add(other, CreateMask(other, null));
        }

        // Then manage the list of characters that we see
        HeartBox heart = other.GetComponent <HeartBox>();

        if (heart != null)
        {
            _charactersSeen.Add(heart);
        }
    }
Exemple #5
0
    public virtual void OnDeath(Vector3 knockForce)
    {
        DoRagDoll(knockForce);

        // Remove AI components we won't need anymore (if they exist)
        EnemyAI ai = GetComponent <EnemyAI>();

        if (ai != null)
        {
            CharacterAnimatorDebugger debug1 = GetComponent <CharacterAnimatorDebugger>();
            if (debug1 != null)
            {
                Destroy(debug1);
            }
            EnemyAIDebugger debug2 = GetComponent <EnemyAIDebugger>();
            if (debug2 != null)
            {
                Destroy(debug2);
            }
            Destroy(ai);
            Seeker seeker = GetComponent <Seeker>();
            if (seeker != null)
            {
                Destroy(seeker);
            }
            HeartBox heart = GetComponentInChildren <HeartBox>();
            if (heart != null)
            {
                Destroy(heart);
            }
            StealthKillTrigger stealthTrigger = GetComponentInChildren <StealthKillTrigger>();
            if (stealthTrigger != null)
            {
                Destroy(stealthTrigger);
            }

            // Remove ourselves
            Destroy(this);
            Destroy(CharInput);
            Destroy(Controller);
            Destroy(MecanimAnimator);
        }
    }
Exemple #6
0
    void OnTriggerExit(Collider other)
    {
        // Manage the list of all the objects that block our vision
        if (_barriers.ContainsKey(other))
        {
            GameObject mask;
            _barriers.TryGetValue(other, out mask);
            Destroy(mask);
            _barriers.Remove(other);
        }

        // Then manage the list of characters that we see
        HeartBox heart = other.GetComponent <HeartBox>();

        if (heart != null && _charactersSeen.Contains(heart))
        {
            _charactersSeen.Remove(heart);
        }
    }
Exemple #7
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;
    }