Пример #1
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            if ((Ammo > 0 && GunTimer.Ready == true) || MaxAmmo == 0)
            {
                Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;
                Game1.soundElectro.Play(1f, (float)(Globals.GlobalRandom.NextDouble()) / 2f, 0f);
                Ammo--;

                fireRay(barrel, destination);

                if (Owner is Player)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Game1.mapLive.mapLightings.Add(new Lightning(barrel, destination.Vector2, Game1.Textures["Lightning"], 16, -1));
                    }
                    for (int i = 0; i < 1; i++)
                    {
                        Game1.mapLive.mapLightings.Add(new Lightning(barrel, destination.Vector2, Game1.Textures["LightningBig"], 16, -1));
                    }
                    for (int i = 0; i < 1; i++)
                    {
                        Game1.mapLive.mapLightings.Add(new Lightning(barrel, destination.Vector2, Game1.Textures["lightningChain"], 16, -3, 3f));
                    }
                }

                GunTimer.Reset();

                return(true);
            }

            return(false);
        }
Пример #2
0
    private void _on_Timer_timeout()
    {
        GD.Print("fire");
        Position2D muzzle = (Position2D)GetNode("Body/Muzzle");

        ShootGun(muzzle);
        GunTimer.Start();
    }
Пример #3
0
 public void Update()
 {
     GunTimer.Update();
     if (_muzzleAlpha > 0)
     {
         _muzzleAlpha -= Game1.Delta / 50;
     }
     CompareF.DecreaseToZero(ref OffsetKick, 1f);
 }
Пример #4
0
 private void _on_DetectRadius_body_entered(Godot.Object body)
 {
     if (body is KinematicBody2D player)
     {
         if (player.Name == "TestTankPlayer")
         {
             GunTimer.Start();
             Target = player;
         }
     }
 }
Пример #5
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;

            if (GunTimer.Ready == true)
            {
                Sound.PlaySoundSimple(Game1.sound, 1f, (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f);
                GunTimer.Reset();
                Game1.mapLive.MapProjectiles.Add(new Projectile((short)(Damage + OwnerGun.DamagePlus), CompareF.RotateVector2(rayEnlonged.NormalizedWithZeroSolution(), (float)((Globals.GlobalRandom.NextDouble() - 0.5f) * (Dispersion + OwnerGun.DispersionPlus))) * (VelocityOfProjectile + OwnerGun.VelocityOfProjectile), barrel, Owner));
                return(true);
            }
            return(false);
        }
    public override void _Ready()
    {
        _parent  = GetParent();
        GunTimer = (Timer)GetNode("Timer");
        GunTimer.Start();
        var circle = new CircleShape2D();

        circle.Radius = DetectRadius;
        var radius = (CollisionShape2D)GetNode("DetectRadius/CollisionShape2D");

        radius.Shape = circle;
        _enemyTurret = (Sprite)GetNode("Turret");
    }
Пример #7
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;

            if (GunTimer.Ready == true)
            {
                Game1.sound.Play(1f, (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f);
                GunTimer.Reset();
                Game1.mapLive.MapProjectiles.Add(new Projectile(Damage, rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner));
                return(true);
            }
            return(false);
        }
Пример #8
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;

            if (Ammo > 0 && GunTimer.Ready == true)
            {
                Sound.PlaySoundSimple(Game1.soundVortex, (float)((1f / 2f) + Globals.GlobalRandom.NextDouble() / 2f), (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f);
                Ammo--;
                GunTimer.Reset();
                Game1.mapLive.MapProjectiles.Add(new EnergyBall(rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner, Damage));
                Kick(4);
                return(true);
            }
            return(false);
        }
Пример #9
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;

            if (Ammo > 0 && GunTimer.Ready == true)
            {
                Game1.soundFlamb.Play((float)((1f / 2f) + Globals.GlobalRandom.NextDouble() / 2f), (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f);
                GunTimer.Reset();
                Game1.mapLive.MapProjectiles.Add(new FlameProjectile(rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner, 16));
                _muzzleAlpha = 1f;
                Ammo--;
                return(true);
            }
            return(false);
        }
Пример #10
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;

            if (Ammo > 0 && GunTimer.Ready == true)
            {
                Ammo--;
                GunTimer.Reset();
                Game1.mapLive.MapProjectiles.Add(new Rocket(rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner, 64));
                _muzzleAlpha = 1;
                Kick(8);
                return(true);
            }
            return(false);
        }
Пример #11
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;

            if (destination != null && destination != null)
            {
                if (Owner is Player)
                {
                    _line = new LineSegmentF(rayEnlonged.Start, destination.Vector2);
                }
                if (Owner is Inpc)
                {
                    _line = new LineSegmentF((Owner as Inpc).Boundary.Origin, destination.Vector2);
                }
            }

            _rotation = rayEnlonged.ToAngle();

            if ((Ammo > 0 && GunTimer.Ready == true) || MaxAmmo == 0)
            {
                Ammo--;
                SetOn();
                fireRay(barrel, destination);

                GunTimer.Reset();

                if (destination != null && destination != null)
                {
                    if (Owner is Player)
                    {
                    }
                    if (Owner is Inpc)
                    {
                        //Game1.PlayerIns.Push(LineSegmentF.SegmentToNormalizedVector((Owner as Enemy).Ray) * 0.02f);
                    }
                }

                return(true);
            }

            return(false);
        }
Пример #12
0
 public override void _Process(float delta)
 {
     base._Process(delta);
     if (Target != null)
     {
         Vector2 targetDir  = (Target.GlobalPosition - GlobalPosition).Normalized();
         Vector2 currentDir = new Vector2(1, 0).Rotated(EnemyTurret.GlobalRotation);
         EnemyTurret.GlobalRotation = currentDir.LinearInterpolate(targetDir, 75 * delta).Angle();
         if (targetDir.Dot(currentDir) > 0.9)
         {
             if (CanShoot)
             {
                 GD.Print("fire");
                 Position2D muzzle = (Position2D)GetNode("Turret/Muzzle");
                 ShootGun(muzzle);
                 GunTimer.Start();
                 CanShoot = false;
             }
         }
     }
 }
Пример #13
0
 public void Update()
 {
     GunTimer.Update();
     CompareF.DecreaseToZero(ref OffsetKick, 1f);
 }
Пример #14
0
 public void Update()
 {
     GunTimer.Update();
 }
Пример #15
0
 public override void _Ready()
 {
     Parent   = GetParent();
     GunTimer = (Timer)GetNode("Timer");
     GunTimer.Start();
 }
Пример #16
0
 private void _on_Timer_timeout()
 {
     GunTimer.Start();
     CanShoot = true;
 }