示例#1
0
        void Start()
        {
            _playerController = PlayerController.Instance;
            _playerController.Reset();

            HealthBar.Init(CurHp, 0, _playerController.MaxHp);
            XpBar.Init(CurXp, 0, _playerController.NextLevelXp);

            _playerController.CurHp.OnCurValueChanged += OnCurHpChanged;
            _playerController.MaxHp.OnCurValueChanged += OnMaxHpChanged;
            _hpAnim = new FloatValueAnim(CurHp);
            _hpAnim.OnCurValueChanged += OnCurHpAnimValueChanged;
            OnMaxHpChanged(_playerController.MaxHp);

            _playerController.CurXp.OnCurValueChanged += OnCurXpChanged;
            _xpAnim = new XpValueAnim(CurXp, CurLevel, 0.2f);
            _xpAnim.OnCurValueChanged += OnCurXpAnimValueChanged;
            _xpAnim.OnCurLevelChanged += OnCurXpAnimLevelChanged;
            _xpAnim.SetNextValue(CurXp);
            OnCurXpAnimLevelChanged(0);

            Spear.OnEnemyKilled += OnEnemyKilled;

            WeaponViewRoot.SetActive(false);

            _isAlive = true;
            UpdateAnimParams();
        }
 void Start()
 {
     _curHp  = StartHp;
     _hpAnim = new FloatValueAnim(_curHp);
     _hpAnim.OnCurValueChanged += OnCurHpAnimValueChanged;
     HealthBar.Init(_curHp, 0, _curHp);
     CollisionNotifier.OnCollisionEnter += OnDetectCollisionStart;
 }