Esempio n. 1
0
    public override void Shoot(float delta)
    {
        List <Node> bullets = new List <Node>();

        if (timeBetweenShots <= 0)
        {
            for (int i = 0; i < maxBullets; i++)
            {
                var bulletRoot = enemyBulletScene.Instance();
                bullets.Add(bulletRoot);

                float rotationDegrees = Utlities.LookAtSomething(player.Position, GlobalPosition) + (45 * i);
                var   bullet          = bullets[i].GetNode <Node2D>("BulletComponent");

                Utlities.SetNode2DParams(ref bullet, GlobalPosition, rotationDegrees);

                GetTree().CurrentScene.AddChild(bullets[i]);
            }

            timeBetweenShots = startTimeBetweenShots;
            bullets.Clear();
        }
        else
        {
            timeBetweenShots -= delta;
        }
    }
Esempio n. 2
0
    public virtual void Shoot(float delta)
    {
        if (timeBetweenShots <= 0)
        {
            if (enemyBulletScene != null)
            {
                var bulletRoot = enemyBulletScene.Instance();
                var bullet     = bulletRoot.GetNode <BulletComponent>("BulletComponent");

                float rotationDegrees = Utlities.LookAtSomething(player.Position, GlobalPosition);
                Utlities.SetNode2DParams(ref bullet, GlobalPosition, rotationDegrees);

                GetTree().CurrentScene.AddChild(bulletRoot);
                timeBetweenShots = startTimeBetweenShots;
            }
            else
            {
                return;
            }
        }
        else
        {
            timeBetweenShots -= delta;
        }
    }
Esempio n. 3
0
    public override void Shoot(Vector2 lookDir, float delta)
    {
        List <ShotgunShell> bullets = new List <ShotgunShell>();

        if (timeBetweenShots <= 0)
        {
            if (Input.IsActionPressed("Shoot"))
            {
                for (int i = 0; i < maxBullets; i++)
                {
                    var bulletRoot = bulletScene.Instance() as ShotgunShell;
                    bullets.Add(bulletRoot);
                }

                for (int i = 0; i < bullets.Count; i++)
                {
                    float rotationDegrees = Utlities.LookAtSomething(GetGlobalMousePosition(), GlobalPosition) + (20 * i);
                    var   bullet          = bullets[i].GetNode <BulletComponent>("BulletComponent");

                    Utlities.SetNode2DParams(ref bullet, firepoint.GlobalPosition, rotationDegrees);

                    GetTree().CurrentScene.AddChild(bullets[i]);
                }

                timeBetweenShots = startTimeBetweenShots;
                bullets.Clear();
            }
        }
        else
        {
            timeBetweenShots -= delta;
        }
    }