Пример #1
0
    void Shoot()
    {
        RangedProjectile bullet = Instantiate(projectile, enemy.position, Quaternion.identity);

        projectile.parent = this.gameObject;
        Physics2D.IgnoreCollision(bullet.GetComponent <Collider2D>(), GetComponent <Collider2D>());
    }
Пример #2
0
    public override IEnumerator Attack(Creature wieldingCreature)
    {
        if (this.currentlyAttacking == true)
        {
            yield break;
        }

        this.currentlyAttacking = true;
        wieldingCreature.LockToRotation();

        //Repeatedly fire until player lets go of the attack button
        while (this.continueAttacking == true)
        {
            int currentNumFrames = this.windUpFrames;
            while (currentNumFrames > 0)
            {
                currentNumFrames--;
                yield return(new WaitForFixedUpdate());
            }

            GameObject       currentProjectileObject = GameObject.Instantiate(this.rangedProjectilePrefab, wieldingCreature.transform.position, new Quaternion()) as GameObject;
            RangedProjectile currentProjectile       = currentProjectileObject.GetComponent <RangedProjectile>();

            Vector3 launchDirection = wieldingCreature.transform.up;

            if (this.useAimAssist == true)
            {
                launchDirection = this.GetAimAssistDirection(wieldingCreature);
            }

            currentProjectile.Launch(launchDirection, this.projectileVelocity, this.GetRandomRangeValue(), this.projectileLifetime);

            currentNumFrames = this.windDownFrames;
            while (currentNumFrames > 0)
            {
                currentNumFrames--;
                yield return(new WaitForFixedUpdate());
            }
        }

        this.currentlyAttacking = false;
        wieldingCreature.EnableMovement();
    }
Пример #3
0
    private void PerformRangedAttack()
    {
        //Calculate the damage this projectile will cause.
        float        atkDefRatio = (float)user.stats.Att / (float)target.stats.Att;
        float        power       = basicAttackPowers[range][user.stats.BasicAttackLevel];
        float        agiRatio    = Mathf.Sqrt((float)user.stats.Agi / (float)target.stats.Agi);
        AttackResult hit         = AttackResultUtils.TryToHit(agiRatio);
        float        damage      = atkDefRatio * hit.DamageMultiplier() * power;
        HitsplatInfo info        = new HitsplatInfo
        {
            damage = (int)damage,
            type   = DamageType.STAB,
            result = hit
        };

        //Send the projectile on its way. It handles its own animation, etc, after that.
        RangedProjectile projectile = GameObject.Instantiate <RangedProjectile>(user.basicRangedProjectile);

        projectile.Init(10, user.transform.position, target, info, (int)damage);

        user.currentMP -= (int)basicAttackCosts[user.stats.BasicAttackLevel];
    }