Exemplo n.º 1
0
    void ThrowFireball()
    {
        GameObject fireball = Instantiate(fireballPrefab, rigidbody2d.position + Vector2.up * 0.5f, Quaternion.identity);

        Fireball projectile = fireball.GetComponent <Fireball>();

        projectile.Launch(lookDirection, 600);

        animator.SetTrigger("Launch");
    }
Exemplo n.º 2
0
    private void FireBallAttack()
    {
        Vector2 spawnposition   = new Vector2(1.5f, 1.0f);
        Vector2 initialposition = rigidbody2d.position;

        // flip the spawn position.
        if (lookDirection.x < 0f)
        {
            spawnposition.x = -spawnposition.x;
        }
        GameObject fireballspawn  = Instantiate(fireball, initialposition + spawnposition, Quaternion.identity);
        Fireball   fireballattack = fireballspawn.GetComponent <Fireball>();

        fireballattack.Launch(lookDirection, 300, initialposition, this.gameObject);
    }
Exemplo n.º 3
0
    private void Shoot()
    {
        if (canShoot)
        {
            Vector2 direction = GetGlobalMousePosition() - GlobalPosition;
            direction = direction.Normalized();

            Fireball spawnedFireBall = (Fireball)fireBallScene.Instance();
            GetTree().Root.AddChild(spawnedFireBall);
            spawnedFireBall.GlobalPosition = GlobalPosition;
            spawnedFireBall.Launch(direction);

            canShoot = false;
            attackSpeedTimer.Start(attackSpeed);
        }
    }
Exemplo n.º 4
0
    private void OnTriggerEnter(Collider other)
    {
        if (ProjectileMask == (ProjectileMask | (1 << other.gameObject.layer)))
        {
            if (Hand.Velocity.magnitude > _minimumVelocity)
            {
                Fireball fireBall = other.gameObject.GetComponent <Fireball>();
                if (fireBall.Active)
                {
                    Vector3 force = Hand.Velocity * ForcePercentageCharged * _forcePower;

                    if (fireBall.Armed)
                    {
                        fireBall.ApplyForce(force);
                    }
                    else
                    {
                        fireBall.Launch(force);
                    }
                }
            }
        }
    }