Ejemplo n.º 1
0
 private void Awake()
 {
     base.Awake();
     playerKnockBackControl      = transform.root.GetComponentInChildren(typeof(IKnockbackable)) as IKnockbackable;
     meleeAbilityStats           = GetComponent <MeleeAbilityStats>();
     meleeEffectCollider.enabled = false;
 }
Ejemplo n.º 2
0
        private void Awake()
        {
            _health    = GetComponent <Health>();
            _knockback = GetComponent <IKnockbackable>();

            _health.Damaged += OnDamaged;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Unity callback. Called on object instantiation.
        /// </summary>
        void Awake()
        {
            Source         = GetComponentInParent <Character>();
            _damageable    = GetComponentInParent <IDamageable>();
            _knockbackable = GetComponentInParent <IKnockbackable>();
            //_effect = GetComponent<ParticleSystem>();
            //_soundEffect = GetComponent<AudioSource>();

            gameObject.tag = Tags.Hitbox;
            switch (type)
            {
            case Type.Damageable:
            case Type.Shield:
                gameObject.layer = Layers.Hurtbox;
                break;

            default:
                gameObject.layer = Layers.Hitbox;
                break;
            }
            _colliders = GetComponents <Collider>();
            foreach (Collider col in _colliders)
            {
                col.isTrigger = true;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Knocks the colliding GameObject away. Knockback is handled differently
        /// for entities than for typical Rigidbodies to avoid bugs.
        /// </summary>
        /// <param name="collision">
        /// Collision holding information about colliding object.
        /// </param>
        protected virtual void Knockback(Collision collision)
        {
            if (KnockbackableMagnitude <= 0 || KnockbackMagnitude <= 0)
            {
                return;
            }
            Vector3        knockbackDir  = GetKnockbackDirection(collision);
            IKnockbackable knockbackable = collision.gameObject.GetComponent <IKnockbackable>();

            if (knockbackable != null)
            {
                knockbackable.Knockback(knockbackDir, KnockbackableMagnitude);
            }
            else
            {
                ApplyForceToRigidbody(collision, knockbackDir);
            }
        }
Ejemplo n.º 5
0
    protected void OnTriggerEnter2D(Collider2D collision)
    {
        IDamageable damageable =
            (IDamageable)collision.transform.root.GetComponentInChildren(typeof(IDamageable)) as IDamageable;
        IKnockbackable knockbackable =
            (IKnockbackable)collision.transform.root.GetComponentInChildren(typeof(IKnockbackable)) as IKnockbackable;

        if (damageable != null)
        {
            if (collision.tag == "Enemy")
            {
                float baseDamage = meleeAbilityStats.GetDamage();
                damageable.TakeDamage(baseDamage);
            }
        }
        if (knockbackable != null)
        {
            if (collision.tag == "Enemy")
            {
            }
        }

        /*
         * Player recoil
         */
        if (attackSide == AttackSide.horizontal)
        {
            if (collision.tag == "Ground")
            {
                playerKnockBackControl.KnockbackStraight(-knockBackStraightDirection, knockbackPlayerAmount, AttackSide.horizontal);
                //print(-knockBackStraightDirection);
            }
        }
        if (attackSide == AttackSide.down)
        {
            //if (collision.tag == "Ground"){
            //    playerKnockBackControl.KnockbackStraight(-knockBackStraightDirection, knockbackPlayerAmount, AttackSide.down);

            //}
        }
    }
Ejemplo n.º 6
0
 private void Awake()
 {
     unitKnockback = GetComponent <IKnockbackable>();
     unitHealth    = GetComponent <HealthComponent>();
 }