Example #1
0
    public void Respawn()
    {
        StopAllCoroutines();

        // Enable Player
        this.enabled      = true;
        collider.enabled  = true;
        Time.timeScale    = 1.0f;
        health.Resistance = 0;

        // Reattach Camera
        this.camera.transform.parent   = this.transform;
        camera.transform.localPosition = cameraPosition;

        // Show Weapon
        Weapon newWeapon = GetCurrentWeapon();

        newWeapon.gameObject.SetActive(true);
        newWeapon.transform.SetParent(camera.transform, false);

        // Reset Broken Pot
        brokenPot = GameObject.Instantiate(PlayerBrokenPotPrefab, this.transform);

        // UI
        DeathScreen.Instance.DisableDeathScreen();
        PlayerHud.Instance.EnablePlayerHud();
        PlayerHud.Instance.SetPlayerHealthBar(1.0f, true);

        // Respawn...
        Game.Instance.LoadPlayerStats();
    }
Example #2
0
    void Awake()
    {
        collider = GetComponent <Collider>();
        if (collider == null)
        {
            collider = GetComponentInChildren <Collider>(true);
        }

        rigidbody = GetComponent <Rigidbody>();
        if (rigidbody == null)
        {
            rigidbody = GetComponentInChildren <Rigidbody>(true);
        }

        pot = GetComponent <Pot>();
        if (pot == null)
        {
            pot = GetComponentInChildren <Pot>(true);
        }

        brokenPot = GetComponent <BrokenPot>();
        if (brokenPot == null)
        {
            brokenPot = GetComponentInChildren <BrokenPot>(true);
        }

        health = GetComponent <Health>();
        if (health == null)
        {
            health = GetComponentInChildren <Health>(true);
        }

        if (agent == null)
        {
            agent = GetComponentInChildren <NavMeshAgent>(true);
        }

        if (renderer == null)
        {
            renderer = GetComponentInChildren <MeshRenderer>(true);
        }

        animator = GetComponentInChildren <Animator>();
    }
Example #3
0
    void Start()
    {
        if (collider == null)
        {
            collider = GetComponentInChildren <Collider>(true);
        }

        if (controller == null)
        {
            controller = GetComponentInChildren <CharacterController>(true);
        }

        if (health == null)
        {
            health = GetComponentInChildren <Health>(true);
        }

        if (camera == null)
        {
            camera = GetComponentInChildren <Camera>(true);
        }

        if (brokenPot == null)
        {
            brokenPot = GetComponentInChildren <BrokenPot>(true);
        }
        if (brokenPot == null)
        {
            brokenPot = GameObject.Instantiate(PlayerBrokenPotPrefab, this.transform);
        }

        //Weapons
        Weapon[] weaponArray = GetComponentsInChildren <Weapon>(true);
        CurrWeaponIndex = Mathf.Min(weaponArray.Length - 1, CurrWeaponIndex);
        foreach (Weapon w in weaponArray)
        {
            AddWeapon(w);
        }

        // Physics
        layerMask = 1 << this.gameObject.layer;

        // Camera
        Cursor.lockState = CursorLockMode.Locked;
        rotation         = this.transform.rotation.eulerAngles;
        cameraPosition   = camera.transform.localPosition;

        // Compass
        compass.Origin = Shoulder;
        compass.Base   = camera.transform;
        compass.transform.SetParent(Shoulder);

        // Input Scheme Rotation
        CheckInputScheme();

        PlayerHud.Instance.EnablePlayerHealthBar();
        this.health.OnHeal   += this.ChangeHealthUI;
        this.health.OnDamage += this.ChangeHealthUI;
        this.health.OnDamage += this.OnDamage;
        this.health.OnDeath  += this.Die;

        Settings.OnLoad    += OnSettingsLoad;
        PlayerStats.OnLoad += OnStatsLoad;
        InputManager.ControlSchemesChanged += OnControlSchemeChanged;
        InputManager.PlayerControlsChanged += OnPlayerControlChanged;
    }