Ejemplo n.º 1
0
    void stick(EntityStats target) //Sticks onto the target
    {
        myBase.myMovement.moving = false;
        target.AddAttribute(stickSpeed, myBase.myStats);
        target.AddAttribute(stickDamage, myBase.myStats);
        if (myBase.myStats.elite)
        {
            // Become invulnerable
            myBase.myStats.AddAttribute(eliteStick, myBase.myStats);
        }
        stickVictim = target;
        stickVector = transform.position - target.transform.position;
        float angle = Mathf.Atan2(stickVector.y, stickVector.x) * Mathf.Rad2Deg - 90;

        sprite.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        anim.SetInteger("State", 1);
        isSticking = true;
        playSound(0);
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        GameObject collider = collision.gameObject;
        Projectile proj     = collider.GetComponent <Projectile>();

        /* Don't collide with source */
        if (collider == source)
        {
            return;
        }

        /* Don't collide with the floor */
        if (collider.layer == LayerMask.NameToLayer("Ground") || collider.layer == LayerMask.NameToLayer("Object"))
        {
            return;
        }

        /* Do / Don't collide with other projectiles */
        if (!collideWithProjectile && (proj))
        {
            return;
        }

        /* Do / Don't collide with walls */
        if (!collideWithWall && collider.tag == "Wall")
        {
            return;
        }

        /* Do / Don't collide with things w/ the same tag as source */
        if (collider.tag == sourceTag && !friendlyFire)
        {
            return;
        }

        /* Don't collide with other projectiles shot by the same source */
        if (proj && (proj.source == source))
        {
            return;
        }

        /* Deflect with weapons if applicable, which will abort the rest of the collision */
        if (proj && proj.tag != sourceTag)
        {
            if ((proj.ProjectileType() == 1 && reflectMelee) || (proj.ProjectileType() != 1 && reflectRanged))
            {
                Reflect(proj);
                return;
            }
        }

        EntityStats ent = collider.GetComponent <EntityStats>();

        if (ent)
        {
            // If the collision is with something that uniquely reacts to projectiles
            EnemyCombat ec = collider.GetComponent <EnemyCombat>();
            if (ec)
            {
                if (ec.OnProjectileHit(this))
                {
                    return;
                }
            }
            pierceCount++;
            if (weaponSystem != null)
            {
                weaponSystem.OnHit(this, ent);
            }

            // Deal damage
            if (weaponSystem != null)
            {
                ent.setLastHit(ammoRefill);
            }
            EntityStats attacker = (source) ? source.GetComponent <EntityStats>() : null;
            ent.TakeDamage(damage, attacker, false, sourceName);


            // Inflict attribute if relevant
            if ((attrHit != null) && (Random.value <= attrChance))
            {
                ent.AddAttribute(attrHit, attacker);
            }
        }

        /* Range proj. always destroy on non-entities */
        //var weaponIsMelee = tables.tagWeapon.get(weaponClass) == WeaponFactory.TAG.MELEE;
        if ((destroyOnNonEntity && !ent) || destroyOnCollide)
        {
            Destroy();
        }
    }
Ejemplo n.º 3
0
 void Start()
 {
     attr = new EntityAttribute(ENT_ATTR.ARMOR_MULT, 0.75f, float.PositiveInfinity, false, true, "Dragon's Might");
     source.AddAttribute(attr, source);
 }