/// <summary>
        /// Initialization method
        /// </summary>
        void Start()
        {
            // We assume that the Health component is on our parent
            _healthScript = GetComponentInParent<Health>();
            // We get it and we subscribe to its health changed event, so we know when to update current width
            _healthScript.HealthChangedEvent += HealthChangedEventListener;

            // We also find our masking component
            _maskRectTransform = GetComponentInChildren<Mask>().GetComponent<RectTransform>();
            _maxWidth = _maskRectTransform.rect.width;
        }
Esempio n. 2
0
        private void Start()
        {
            // Instantiate player on scene
            Transform instantiatedPlayer = Instantiate(this.Player, this.PlayerSpawn, Quaternion.identity) as Transform;
            Instantiate(this.SoulBag);
            if (instantiatedPlayer != null)
            {
                this._kosorub = instantiatedPlayer.GetComponent<Kosorub>();
                this._health = instantiatedPlayer.GetComponent<Health>();

                // Game variables
                this._souls = 0;

                this._uiManager.SetSouls(this._souls);
                this._uiManager.SetHealth(this._health.Healthpoints);
            }
        }