예제 #1
0
        public void MiniGunShoot(Player player, Item item, Projectile Lead, int projType, int damage, float knockBack, string sound)
        {
            if (comboTime <= 0)
            {
                soundInstance = Main.PlaySound(SoundLoader.customSoundType, (int)player.Center.X, (int)player.Center.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/" + sound));
                if (soundInstance != null)
                {
                    soundInstance.Volume *= 1f - 0.25f * (scalePlus / 20f);
                }

                float spray = 1f * (scalePlus / 20f);

                float scaleFactor2 = 14f;
                for (int i = 0; i < miniGunAmt; i++)
                {
                    float   rot     = Lead.velocity.ToRotation() + (float)Angle.ConvertToRadians(Main.rand.Next(18) * 10) - (float)Math.PI / 2f;
                    Vector2 vector3 = Lead.Center + rot.ToRotationVector2() * 7f * spray;
                    Vector2 vector5 = Vector2.Normalize(Lead.velocity) * scaleFactor2;
                    vector5 = vector5.RotatedBy((Main.rand.NextDouble() * 0.12 - 0.06) * spray, default(Vector2));
                    if (float.IsNaN(vector5.X) || float.IsNaN(vector5.Y))
                    {
                        vector5 = -Vector2.UnitY;
                    }
                    int proj = Projectile.NewProjectile(vector3.X, vector3.Y, vector5.X, vector5.Y, projType, damage, knockBack, player.whoAmI, 0f, 0f);
                    Main.projectile[proj].ai[0] = Lead.whoAmI;
                    MProjectile mProj = (MProjectile)Main.projectile[proj].modProjectile;
                    mProj.waveDir = waveDir;
                }

                waveDir *= -1;

                comboTime  = useTimeMax;
                useTimeMax = Math.Max(useTimeMax - miniRateIncr, comboUseTime);

                MGlobalItem mi = item.GetGlobalItem <MGlobalItem>();
                if (miniCostNum == 0)
                {
                    mi.statMissiles -= 1;
                }

                miniCostNum++;
                if (miniCostNum > miniGunCostReduct)
                {
                    miniCostNum = 0;
                }
            }
            else
            {
                comboTime--;
            }
            scalePlus = Math.Min(scalePlus + (2f / useTimeMax), 20f);
            ChargeLead chLead = (ChargeLead)Lead.modProjectile;

            chLead.extraScale = 0.3f * (scalePlus / 20f);
        }
예제 #2
0
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            MGlobalItem mi = item.GetGlobalItem <MGlobalItem>();

            if (isCharge)
            {
                int        ch = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("ChargeLead"), damage, knockBack, player.whoAmI);
                ChargeLead cl = (ChargeLead)Main.projectile[ch].modProjectile;
                cl.ChargeUpSound        = chargeUpSound;
                cl.ChargeTex            = chargeTex;
                cl.DustType             = dustType;
                cl.DustColor            = dustColor;
                cl.LightColor           = lightColor;
                cl.ShotSound            = shotSound;
                cl.ChargeShotSound      = chargeShotSound;
                cl.projectile.netUpdate = true;
                cl.missile      = true;
                cl.comboSound   = comboSound;
                cl.noSomersault = noSomersault;
                cl.aimSpeed     = leadAimSpeed;

                chargeLead = ch;
                return(false);
            }
            else if (isSeeker)
            {
                int ch = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("SeekerMissileLead"), damage, knockBack, player.whoAmI);
                chargeLead = ch;
                return(false);
            }
            else
            {
                mi.statMissiles -= 1;
                Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/" + shotSound), player.position);
            }
            return(true);
        }
예제 #3
0
        public override void AI()
        {
            Projectile P    = projectile;
            Player     O    = Main.player[P.owner];
            Vector2    oPos = O.RotatedRelativePoint(O.MountedCenter, true);

            Lead = Main.projectile[(int)P.ai[0]];
            if (!Lead.active || Lead.owner != P.owner || Lead.type != mod.ProjectileType("ChargeLead") || !O.controlUseItem)
            {
                P.Kill();
                return;
            }
            else
            {
                if (!initialize)
                {
                    initialize = true;
                }

                if (P.owner == Main.myPlayer)
                {
                    if (soundInstance == null || soundInstance.State != SoundState.Playing)
                    {
                        Main.PlaySound(SoundLoader.customSoundType, (int)O.position.X, (int)O.position.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/SolarComboSoundStart"));
                        soundInstance = Main.PlaySound(SoundLoader.customSoundType, (int)O.position.X, (int)O.position.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/SolarComboSoundLoop"));
                        if (Main.soundVolume > 0f)
                        {
                            soundInstance.Volume = 0f;
                        }
                        soundInstance2 = Main.PlaySound(SoundLoader.customSoundType, (int)O.position.X, (int)O.position.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/NovaLaserLoop"));
                    }
                    else if (P.numUpdates == 0 && Main.soundVolume > 0f)
                    {
                        soundInstance.Volume  = Math.Min(soundInstance.Volume + 0.05f * Main.soundVolume, 0.75f * Main.soundVolume);
                        soundInstance2.Volume = Math.Min(soundInstance2.Volume + 0.05f * Main.soundVolume, 0.75f * Main.soundVolume);
                    }
                }
                P.velocity = Vector2.Normalize(Lead.velocity);
                P.Center   = oPos;
                P.timeLeft = 2;
                P.rotation = P.velocity.ToRotation() - 1.57f;

                maxRange = Math.Min(maxRange + 16f, Max_Range);

                for (P.ai[1] = 0f; P.ai[1] <= maxRange; P.ai[1] += 4f)
                {
                    Vector2 end = oPos + P.velocity * P.ai[1];
                    if (CollideMethods.CheckCollide(end, 0, 0))
                    {
                        P.ai[1] -= 4f;
                        if (num <= 0)
                        {
                            end = oPos + P.velocity * P.ai[1];
                            int proj = Projectile.NewProjectile(end.X, end.Y, 0f, 0f, mod.ProjectileType("SolarLaserFlameTrail"), P.damage, P.knockBack, P.owner);
                            num = 4;
                        }
                        break;
                    }
                }
                if (num > 0 && P.numUpdates == 0)
                {
                    num--;
                }

                float leadDist = Vector2.Distance(oPos, Lead.Center);
                for (float i = leadDist; i < P.ai[1]; i += P.width)
                {
                    Vector2 sPos = oPos + P.velocity * i;
                    if (sPos.X > Main.screenPosition.X - 100f && sPos.X < Main.screenPosition.X + Main.screenWidth + 100f &&
                        sPos.Y > Main.screenPosition.Y - 100f && sPos.Y < Main.screenPosition.Y + Main.screenHeight + 100f)
                    {
                        if (Main.rand.Next(50) == 0 && P.ai[1] > leadDist)
                        {
                            int numX = 1;
                            if (Main.rand.Next(2) == 0)
                            {
                                numX = -1;
                            }

                            int        proj  = Projectile.NewProjectile(sPos.X, sPos.Y, P.velocity.X, P.velocity.Y, mod.ProjectileType("SolarLaserFlareShot"), P.damage, P.knockBack, P.owner);
                            Projectile sProj = Main.projectile[proj];
                            sProj.ai[0]      = Lead.whoAmI;
                            sProj.ai[1]      = P.whoAmI;
                            sProj.localAI[0] = i;
                            sProj.localAI[1] = (Main.rand.Next(50) + 60) * numX;
                        }

                        if (Main.rand.Next(10) == 0)
                        {
                            float   k    = Math.Min(i, P.ai[1]);
                            Vector2 dPos = (oPos - (P.Size / 2f) * scaleUp) + P.velocity * k;
                            Main.dust[Dust.NewDust(dPos, (int)((float)P.width * scaleUp), (int)((float)P.width * scaleUp), 6, 0, 0, 100, default(Color), 3f)].noGravity = true;
                        }
                    }
                }

                Vector2 dustPos = oPos - (P.Size / 2f) * scaleUp + P.velocity * P.ai[1];
                int     size    = (int)((float)P.width * scaleUp);
                float   num1    = P.velocity.ToRotation() + (Main.rand.Next(2) == 1 ? -1.0f : 1.0f) * 1.57f;
                float   num2    = (float)(Main.rand.NextDouble() * 0.8f + 1.0f);
                Vector2 dustVel = new Vector2((float)Math.Cos(num1) * num2, (float)Math.Sin(num1) * num2);
                Dust    dust    = Main.dust[Dust.NewDust(dustPos, size, size, 6, dustVel.X, dustVel.Y, 100, default(Color), 4f)];
                dust.noGravity = true;
                dust.velocity *= 3f;

                Color color = MetroidMod.novColor;
                DelegateMethods.v3_1 = new Vector3(color.R / 255f, color.G / 255f, color.B / 255f);
                Utils.PlotTileLine(P.Center, P.Center + P.velocity * P.ai[1], 26, DelegateMethods.CastLight);

                if (P.numUpdates == 0)
                {
                    scaleUp = Math.Min(scaleUp + 0.1f, 1.7f);                    //2f);
                    P.frame++;
                    if (P.frame >= Main.projFrames[projectile.type])
                    {
                        P.frame = 0;
                    }
                }
                ChargeLead chLead = (ChargeLead)Lead.modProjectile;
                chLead.extraScale = 1.125f * scaleUp;
            }
        }
예제 #4
0
        public override void AI()
        {
            Projectile P    = projectile;
            Player     O    = Main.player[P.owner];
            Vector2    oPos = O.RotatedRelativePoint(O.MountedCenter, true);

            Lead = Main.projectile[(int)P.ai[0]];
            if (!Lead.active || Lead.owner != P.owner || Lead.type != mod.ProjectileType("ChargeLead") || !O.controlUseItem)
            {
                P.Kill();
                return;
            }
            else
            {
                if (!initialize)
                {
                    initialize = true;
                }

                if (P.owner == Main.myPlayer)
                {
                    if (soundInstance == null || soundInstance.State != SoundState.Playing)
                    {
                        soundInstance = Main.PlaySound(SoundLoader.customSoundType, (int)O.position.X, (int)O.position.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/NovaLaserLoop"));
                    }
                }
                P.velocity = Vector2.Normalize(Lead.velocity);
                P.Center   = oPos;
                P.timeLeft = 2;
                P.rotation = P.velocity.ToRotation() - 1.57f;

                maxRange = Math.Min(maxRange + 16f, Max_Range);

                for (P.ai[1] = 0f; P.ai[1] <= maxRange; P.ai[1] += 4f)
                {
                    Vector2 end = oPos + P.velocity * P.ai[1];
                    if (CollideMethods.CheckCollide(end, 0, 0))
                    {
                        P.ai[1] -= 4f;
                        break;
                    }
                }

                float leadDist = Vector2.Distance(oPos, Lead.Center);
                for (float i = leadDist; i < P.ai[1]; i += P.width)
                {
                    if (Main.rand.Next(25) == 0)
                    {
                        float   k    = Math.Min(i, P.ai[1]);
                        Vector2 dPos = (oPos - P.Size / 2) + P.velocity * k;
                        Main.dust[Dust.NewDust(dPos, P.width, P.width, 75, 0, 0, 100, default(Color), 2f)].noGravity = true;
                    }
                }

                Vector2 dustPos = oPos + P.velocity * P.ai[1];
                float   num1    = P.velocity.ToRotation() + (Main.rand.Next(2) == 1 ? -1.0f : 1.0f) * 1.57f;
                float   num2    = (float)(Main.rand.NextDouble() * 0.8f + 1.0f);
                Vector2 dustVel = new Vector2((float)Math.Cos(num1) * num2, (float)Math.Sin(num1) * num2);
                Dust    dust    = Main.dust[Dust.NewDust(dustPos, 0, 0, 75, dustVel.X, dustVel.Y, 100, default(Color), 2f)];
                dust.noGravity = true;
                dust.velocity *= 3f;
                dust.position  = dustPos;

                Color color = MetroidMod.novColor;
                DelegateMethods.v3_1 = new Vector3(color.R / 255f, color.G / 255f, color.B / 255f);
                Utils.PlotTileLine(P.Center, P.Center + P.velocity * P.ai[1], 26, DelegateMethods.CastLight);

                if (P.numUpdates == 0)
                {
                    scaleUp = Math.Min(scaleUp + 0.1f, 1f);
                    P.frame++;
                    if (P.frame >= Main.projFrames[projectile.type])
                    {
                        P.frame = 0;
                    }
                }
                ChargeLead chLead = (ChargeLead)Lead.modProjectile;
                chLead.extraScale = 0.75f * scaleUp;
            }
        }