示例#1
0
        private IEnumerator InvincibilityTime(float invincibleTime)
        {
            LifeSystem.SetInvincible(true);
            OnPlayerInvincibilityChange?.Invoke(true);

            yield return(new WaitForSeconds(invincibleTime));

            LifeSystem.SetInvincible(false);
            OnPlayerInvincibilityChange?.Invoke(false);
        }
示例#2
0
        public void OnObjectSpawn(object[] parameters = null)
        {
            if (!LifeSystem.StillAlive)
            {
                LifeSystem = new LifeSystem(this);
            }

            OnPlayerHeal?.Invoke(LifeSystem.CurrentLife, LifeSystem.MaxHealth);

            OnPlayerSpawn?.Invoke(gameObject);
            gameObject.SetActive(true);
        }
示例#3
0
        public void Hit(int damage, Transform attacker)
        {
            _hurtParticles.EmitParticle();
            _playerAnimatorController.Hurt();
            LifeSystem.Damage(damage);

            if (attacker != null)
            {
                var forceAux = (this.transform.position - attacker.position).normalized;
                if (forceAux.y < 0.2f)
                {
                    forceAux += (Vector3.up * 1f);
                }

                forceAux = forceAux.normalized * _playerParameters.KnockBackForce;
                PushPlayer(forceAux);
            }
        }
示例#4
0
        private void Awake()
        {
            AttackerTimer.SetTimer(_playerParameters.TimeBetweenAttacks);
            _waitForSecondsDash = new WaitForSeconds(_playerParameters.TimeBetweenDashes);

            Grounder      = new Grounder(this);
            LifeSystem    = new LifeSystem(this);
            _mover        = new NewMover(this);
            _jumper       = new Jumper(this);
            _playerLocker = new PlayerLocker(this);
            _glider       = new Glider(this);
            _attacker     = new BasicAttacker(this);
            _wallJumper   = new WallJumper(this);

            Rigidbody = this.GetComponent <Rigidbody2D>();

            // _attackerList = new List<IAttacker>();
            // _attackerList.Add(new BasicAttacker(this));
            // _attackerList.Add(new StrongAttacker(this));
        }