예제 #1
0
        private void Start()
        {
            _coll             = GetComponent <CollisionHandler>();
            _rb               = GetComponent <Rigidbody2D>();
            _anim             = GetComponent <AnimationHandler>();
            _anim             = GetComponentInChildren <AnimationHandler>();
            _vfx              = GetComponent <VfxHandler>();
            _ghost            = GetComponent <GhostEffect>();
            _healthManager    = GetComponent <HealthManager>();
            _attackManager    = GetComponent <CharacterAttackManager>();
            _capsuleCollider  = GetComponent <CapsuleCollider2D>();
            _input            = GetComponent <IInputController>();
            _gameManager      = GameManager.Instance;
            _coll.OnGrounded += ResetIsJumping;
            _coll.OnWalled   += ResetIsJumping;

            _groundTouch   = true;
            _canStillJump  = true;
            _wasOnWall     = false;
            _side          = 1;
            _capsuleOffset = _capsuleCollider.offset;
            _capsuleSize   = _capsuleCollider.size;

            if (_showDebug)
            {
                CursedDebugger.Instance.Add("State", () => _state.ToString());
            }
        }
예제 #2
0
        public void OnAttack(GameObject attacker, Attack attack)
        {
            if (_isInvincible || IsInvicibleMovement())
            {
                //Do something if invincible
            }
            else
            {
                //Update health
                UpdateCurrentHealth(_currentHealth - attack.Damage);

                //Apply the effect of the attack
                if (attack.Effect != null && _stats != null)
                {
                    attack.Effect.Invoke(_stats);
                }


                if (attacker != null)
                {
                    Debug.Log(gameObject.name + " got attacked by " + attacker.name + " and did " + attack.Damage + " damages");
                }

                //Play sound, vfx and animation
                if (gameObject.tag.Equals("Player"))
                {
                    _sfx.LowHealth();
                }

                CharacterAttackManager atkMgr = attacker.GetComponent <CharacterAttackManager>();
                if (!attacker.tag.Equals("Creature") && !attacker.tag.Equals("Traps"))
                {
                    if (atkMgr)
                    {
                        _vfx.TouchImpact(transform.position, atkMgr.GetVfxTouchImpact());
                        _sfx.EnemyDamageSFX();

                        //Become invincible
                        StartInvincibility(_invincibleTime);
                    }
                }

                if (!attacker.tag.Equals("Creature") && gameObject.tag.Equals("Player"))
                {
                    // Player take damage
                    _sfx.PlayerDamageSFX();
                    _vfx.FlashScreenDmgPlayer();
                    ControllerVibration.Instance.StartVibration(_takeDamageVibration);
                    _invAnim.LaunchAnimation();

                    //Become invincible
                    StartInvincibility(_invincibleTime);
                }

                //Do something if critical
            }
        }
예제 #3
0
        private void Start()
        {
            _anim     = GetComponent <Animator>();
            _move     = GetComponentInParent <CharacterMovement>();
            _coll     = GetComponentInParent <CollisionHandler>();
            _renderer = GetComponent <SpriteRenderer>();
            _atttack  = GetComponent <CharacterAttackManager>();

            _previousFlipState = _move.Side == 1 ? false : true;

            GetComponent <CollisionHandler>().OnGrounded += () => { _anim.ResetTrigger(_decelerationTrigger); };
        }
예제 #4
0
 private void Start() => _attack = GetComponent <CharacterAttackManager>();
예제 #5
0
 private void Awake()
 {
     _input         = GetComponent <IInputController>();
     _attackManager = GetComponent <CharacterAttackManager>();
 }