public void UseAbility(int ability)
    {
        float angle = 0;

        switch (ability)
        {
        case 0:
            Vector2 direction = ((player.transform.position + player.GetDirection() * Random.Range(0, 2)) - rotator.position).normalized;
            angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
            rotator.eulerAngles = Vector3.forward * angle;

            WoodBranchWhip newWhip = Instantiate(whip, shootPoint.position, shootPoint.rotation).GetComponent <WoodBranchWhip>();
            newWhip.SetStats(gameObject, whipRotationSpeed, whipLifeTime);
            break;

        case 1:
            for (int i = 0; i < seeds; i++)
            {
                angle = Random.Range(0, 360);
                rotator.eulerAngles = Vector3.forward * angle;

                SeedBullet newSeed = Instantiate(seed, shootPoint.position, shootPoint.rotation).GetComponent <SeedBullet>();
                newSeed.SetStats(gameObject, Random.Range(0.1f, 1f));
            }
            break;
        }
    }
    protected override void Attack()
    {
        base.Attack();

        if (player)
        {
            if (playerObject == null)
            {
                playerObject = player.gameObject.GetComponent <Player>();
            }

            Vector2 direction = ((player.transform.position + playerObject.GetDirection() * Random.Range(0, 2)) - rotator.position).normalized;
            float   angle     = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
            rotator.eulerAngles = Vector3.forward * angle;

            WoodBranchWhip newWhip = Instantiate(whip, shootPoint.position, shootPoint.rotation).GetComponent <WoodBranchWhip>();
            newWhip.SetStats(gameObject, whipRotationSpeed, whipLifeTime, 0.5f);

            attackTimer = Random.Range(attackCooldown / 2, attackCooldown);
        }
    }
Esempio n. 3
0
    public void UseAbility(int ability)
    {
        switch (ability)
        {
        case 0:
            GrassWaterCreepSet summonedCreeps = Instantiate(summon, shootPoint.position, transform.rotation).GetComponent <GrassWaterCreepSet>();
            summonedCreeps.SetTargets(gameObject, player);
            break;

        case 1:
            if (boss.health.health <= boss.health.maxHealth / 4)
            {
                Vector2 direction = ((player.transform.position + player.GetDirection() * Random.Range(0, 2)) - rotator.position).normalized;
                float   angle     = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
                rotator.eulerAngles = Vector3.forward * angle;

                WoodBranchWhip newWhip = Instantiate(whip, shootPoint.position, shootPoint.rotation).GetComponent <WoodBranchWhip>();
                newWhip.SetStats(gameObject, whipRotationSpeed, whipLifeTime, 1, true);
            }
            break;
        }
    }