/// <summary>Sets the bgItem lists and loads saved data, if possible.</summary>
        /// <param name="info"></param>
        public static void Load(IList <TagCompound> info)
        {
            bgItems        = new List <BaseBGItem>();     //Set all lists
            organizedItems = bgItems.OrderBy(x => x.scale);
            Loaded         = true;

            if (info != null)
            {
                foreach (var item in info)
                {
                    string name = item.GetString("Name");
                    try
                    {
                        Type bgItemType = typeof(BackgroundItemManager).Assembly.GetType(name, true);
                        var  bgItem     = Activator.CreateInstance(bgItemType) as BaseBGItem;
                        bgItem.Load(item);
                        bgItems.Add(bgItem);
                    }
                    catch (Exception e)
                    {
                        SpiritMod mod = SpiritMod.Instance;
                        mod.Logger.Warn("Failed to load BGItem assembly type.\n", e);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override bool UseItem(Player player)
        {
            if (Main.netMode == NetmodeID.SinglePlayer)
            {
                NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType <Infernon>());
            }

            else if (Main.netMode == NetmodeID.MultiplayerClient && player == Main.LocalPlayer)
            {
                Vector2 spawnPos = player.Center;
                int     tries    = 0;
                int     maxtries = 300;
                while ((Vector2.Distance(spawnPos, player.Center) <= 200 || WorldGen.SolidTile((int)spawnPos.X / 16, (int)spawnPos.Y / 16) || WorldGen.SolidTile2((int)spawnPos.X / 16, (int)spawnPos.Y / 16) || WorldGen.SolidTile3((int)spawnPos.X / 16, (int)spawnPos.Y / 16)) && tries <= maxtries)
                {
                    spawnPos = player.Center + Main.rand.NextVector2Circular(800, 800);
                    tries++;
                }

                if (tries >= maxtries)
                {
                    return(false);
                }

                SpiritMod.WriteToPacket(SpiritMod.instance.GetPacket(), (byte)MessageType.BossSpawnFromClient, (byte)player.whoAmI, ModContent.NPCType <Infernon>(), (int)spawnPos.X, (int)spawnPos.Y).Send(-1);
            }
            Main.PlaySound(SoundID.Roar, player.position, 0);
            return(true);
        }
Exemplo n.º 3
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if (projectile.ai[0] == 0)
            {
                Player    owner = Main.player[projectile.owner];
                Texture2D tex   = mod.GetTexture("Extras/Medusa_Ray");
                Vector2   scale = new Vector2(projectile.Distance(owner.Center) / tex.Width, 1) * 0.75f;
                spriteBatch.Draw(tex,
                                 owner.Center - Main.screenPosition + new Vector2(tex.Size().X *scale.X, 0).RotatedBy(projectile.AngleFrom(owner.Center)) / 2,
                                 null,
                                 SpiritMod.StarjinxColor(Main.GlobalTime * 4) * 0.5f * (1 - (Math.Abs(0.5f - projectile.Opacity) * 2)),
                                 projectile.AngleFrom(owner.Center),
                                 tex.Size() / 2,
                                 scale,
                                 SpriteEffects.None,
                                 0);
            }
            for (int i = 0; i < 3; i++)
            {
                spriteBatch.Draw(mod.GetTexture("Extras/StardustPillarStar"),
                                 projectile.Center - Main.screenPosition,
                                 null,
                                 SpiritMod.StarjinxColor(Main.GlobalTime * 4) * 0.75f * projectile.Opacity * (1 - (i * 0.33f)),
                                 0,
                                 new Vector2(36, 36),
                                 projectile.scale * ((float)Math.Sin(Main.GlobalTime * 3) / 4 + 1) * 0.8f * (1 + (i * 0.5f)),
                                 SpriteEffects.None,
                                 0);
            }

            return(false);
        }
Exemplo n.º 4
0
        private void DrawBeams(SpriteBatch sB)
        {
            if (LampTargetNPC == null || LampTargetTime == 0)
            {
                return;
            }

            Texture2D beam = mod.GetTexture("Effects/Mining_Helmet");


            Color color = Color.Lerp(SpiritMod.StarjinxColor(Main.GameUpdateCount / 12f), Color.White, 0.5f);

            float   halfTargetTime = MaxTargetTime / 2f;
            float   starOpacity    = Math.Min(2 * ((halfTargetTime - Math.Abs(halfTargetTime - LampTargetTime)) / halfTargetTime), 0.7f);
            float   baseOpacity    = Math.Max((15f - Math.Abs(15f - (MaxTargetTime - LampTargetTime))) / 15f, starOpacity);
            Vector2 position       = GetHoldPosition + new Vector2(0, 26);
            Vector2 dist           = LampTargetNPC.Center - position;

            for (int i = -1; i <= 1; i++)
            {
                float   rot        = dist.ToRotation();
                Vector2 offset     = (i == 0) ? Vector2.Zero : Vector2.UnitX.RotatedBy(rot + MathHelper.PiOver4 * i) * 4;
                float   opacityMod = (i == 0) ? 1f : 0.5f;
                sB.Draw(beam, position - Main.screenPosition + offset, null, color * baseOpacity * opacityMod, rot + MathHelper.PiOver2, new Vector2(beam.Width / 2f, beam.Height * 0.58f), new Vector2(1, (dist.Length() * 1.2f) / (beam.Height / 2f)), SpriteEffects.None, 0);
            }
        }
Exemplo n.º 5
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            for (int i = 1; i < ProjectileID.Sets.TrailCacheLength[projectile.type]; i++)
            {
                Vector2 newCenter  = projectile.oldPos[i] + projectile.Size / 2;
                float   lerpamount = 0.5f + (i / (float)(ProjectileID.Sets.TrailCacheLength[projectile.type] * 2));
                float   scale      = (ProjectileID.Sets.TrailCacheLength[projectile.type] - i) / (float)ProjectileID.Sets.TrailCacheLength[projectile.type];
                spriteBatch.Draw(mod.GetTexture("Textures/StardustPillarStar"),
                                 newCenter - Main.screenPosition,
                                 null,
                                 Color.Lerp(SpiritMod.StarjinxColor(Main.GlobalTime * 4 + i), Color.Transparent, lerpamount) * projectile.Opacity, 0, new Vector2(36, 36),
                                 scale * ((float)Math.Sin(projectile.timeLeft / 14) / 8 + 1) * 0.4f,
                                 SpriteEffects.None,
                                 0);
            }
            spriteBatch.Draw(mod.GetTexture("Textures/StardustPillarStar"),
                             projectile.Center - Main.screenPosition,
                             null,
                             Color.Lerp(SpiritMod.StarjinxColor(Main.GlobalTime * 4), Color.Transparent, 0.75f) * projectile.Opacity,
                             0,
                             new Vector2(36, 36),
                             projectile.scale * ((float)Math.Sin(projectile.timeLeft / 14) / 8 + 1),
                             SpriteEffects.None,
                             0);

            return(false);
        }
Exemplo n.º 6
0
        public override bool NewRightClick(int i, int j)
        {
            //don't bother if there's already a Crystal King in the world
            for (int x = 0; x < Main.npc.Length; x++)
            {
                if (Main.npc[x].active && Main.npc[x].type == ModContent.NPCType <ReachBoss>())
                {
                    return(false);
                }
            }
            Player player = Main.LocalPlayer;

            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                Main.NewText("The Vinewrath Bane has awoken!", 175, 75, 255, true);
                int npcID = NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, ModContent.NPCType <ReachBoss>());
                Main.npc[npcID].Center     = player.Center + new Vector2(600, 600);
                Main.npc[npcID].netUpdate2 = true;
            }
            else
            {
                if (Main.netMode == NetmodeID.SinglePlayer)
                {
                    return(false);
                }
                SpiritMod.WriteToPacket(SpiritMod.instance.GetPacket(), (byte)MessageType.BossSpawnFromClient, (byte)player.whoAmI, (int)ModContent.NPCType <ReachBoss>(), "Vinewrath Bane Has Been Summoned!", (int)player.Center.X + 600, (int)player.Center.Y + 600).Send(-1);
            }
            return(true);
        }
Exemplo n.º 7
0
        internal static void RegisterParticles()
        {
            particles                     = new Particle[MaxParticlesAllowed];
            particleTypes                 = new Dictionary <Type, int>();
            particleTextures              = new Dictionary <int, Texture2D>();
            particleInstances             = new List <Particle>();
            batchedAlphaBlendParticles    = new List <Particle>(MaxParticlesAllowed);
            batchedAdditiveBlendParticles = new List <Particle>(MaxParticlesAllowed);

            Type      baseParticleType = typeof(Particle);
            SpiritMod spiritMod        = ModContent.GetInstance <SpiritMod>();

            foreach (Type type in spiritMod.Code.GetTypes())
            {
                if (type.IsSubclassOf(baseParticleType) && !type.IsAbstract && type != baseParticleType)
                {
                    int assignedType = particleTypes.Count;
                    particleTypes[type] = assignedType;

                    string texturePath = type.Namespace.Replace('.', '/') + "/" + type.Name;
                    particleTextures[assignedType] = ModContent.GetTexture(texturePath);

                    particleInstances.Add((Particle)FormatterServices.GetUninitializedObject(type));
                }
            }
        }
Exemplo n.º 8
0
        public override bool UseItem(Player player)
        {
            if (player.whoAmI != Main.myPlayer)
            {
                return(false);
            }

            MyPlayer   myPlayer   = player.GetModPlayer <MyPlayer>();
            AuroraStag auroraStag = myPlayer.hoveredStag;

            if (auroraStag != null && !auroraStag.Scared && !auroraStag.npc.immortal && auroraStag.TameAnimationTimer == 0)
            {
                auroraStag.TameAnimationTimer = AuroraStag.TameAnimationLength;
                myPlayer.hoveredStag          = null;

                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    SpiritMod.WriteToPacket(SpiritMod.instance.GetPacket(4), (byte)MessageType.TameAuroraStag, auroraStag.npc.whoAmI).Send();
                }
            }
            else
            {
                player.AddBuff(ModContent.BuffType <IceBerryBuff>(), 19600);
            }

            return(true);
        }
Exemplo n.º 9
0
        public override void PrimStructure(SpriteBatch spriteBatch)
        {
            /*if (PointCount <= 1) return; //for easier, but less customizable, drawing
             * float colorSin = (float)Math.Sin(Counter / 3f);
             * Color c1 = Color.Lerp(Color.White, Color.Cyan, colorSin);
             * float widthVar = (float)Math.Sqrt(Points.Count) * Width;
             * DrawBasicTrail(c1, widthVar);*/

            if (PointCount <= 6)
            {
                return;
            }
            float widthVar;
            float colorSin = (float)Math.Sin(Counter / 3f);

            for (int i = 0; i < Points.Count; i++)
            {
                if (i == 0)
                {
                    widthVar = (float)Math.Sqrt(Points.Count) * Width;
                    Color   c1          = Color.Lerp(Color.White, SpiritMod.StarjinxColor(Main.GlobalTime * 2), colorSin);
                    Vector2 normalAhead = CurveNormal(Points, i + 1);
                    Vector2 secondUp    = Points[i + 1] - normalAhead * widthVar;
                    Vector2 secondDown  = Points[i + 1] + normalAhead * widthVar;
                    //AddVertex(Points[i], c1 * AlphaValue, new Vector2((float)Math.Sin(Counter / 20f), (float)Math.Sin(Counter / 20f)));
                    // AddVertex(secondUp, c1 * AlphaValue, new Vector2((float)Math.Sin(Counter / 20f), (float)Math.Sin(Counter / 20f)));
                    //AddVertex(secondDown, c1 * AlphaValue, new Vector2((float)Math.Sin(Counter / 20f), (float)Math.Sin(Counter / 20f)));
                }
                else
                {
                    if (i != Points.Count - 1)
                    {
                        float dist = Math.Abs((Points.Count - i) - Counter * 3);
                        widthVar = (float)Math.Sin(i * (3.14f / Points.Count)) * Width * (i) / 100f;
                        float   widthVar2   = (float)Math.Sin((i + 1) * (3.14f / Points.Count)) * Width * ((i + 1)) / 100f;
                        Color   c           = Color.White * ((100 - dist) * 0.01f) * (Counter / 10f);
                        Color   CBT         = Color.White * ((100 - dist) * 0.01f) * (Counter / 10f);
                        Vector2 normal      = CurveNormal(Points, i);
                        Vector2 normalAhead = CurveNormal(Points, i + 1);
                        Vector2 firstUp     = Points[i] - normal * widthVar;
                        Vector2 firstDown   = Points[i] + normal * widthVar;
                        Vector2 secondUp    = Points[i + 1] - normalAhead * widthVar2;
                        Vector2 secondDown  = Points[i + 1] + normalAhead * widthVar2;

                        AddVertex(firstDown, c * AlphaValue, new Vector2((i / (float)Cap), 1));
                        AddVertex(firstUp, c * AlphaValue, new Vector2((i / (float)Cap), 0));
                        AddVertex(secondDown, CBT * AlphaValue, new Vector2((i + 1) / (float)Cap, 1));

                        AddVertex(secondUp, CBT * AlphaValue, new Vector2((i + 1) / (float)Cap, 0));
                        AddVertex(secondDown, CBT * AlphaValue, new Vector2((i + 1) / (float)Cap, 1));
                        AddVertex(firstUp, c * AlphaValue, new Vector2((i / (float)Cap), 0));
                    }
                    else
                    {
                    }
                }
            }
        }
Exemplo n.º 10
0
        public override void PlaceInWorld(int i, int j, Item item)
        {
            MyWorld.superSunFlowerPositions.Add(new Point16(i, j));

            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                SpiritMod.WriteToPacket(SpiritMod.instance.GetPacket(4), (byte)MessageType.PlaceSuperSunFlower, (ushort)i, (ushort)j).Send();
            }
        }
Exemplo n.º 11
0
        public override Color?GetAlpha(Gore gore, Color lightColor)
        {
            Color color = SpiritMod.StarjinxColor(Main.GlobalTime * 0.8f);

            color.A = (byte)gore.alpha;
            float lerpamount = gore.alpha / 250f;

            return(Color.Lerp(color, Color.Transparent, lerpamount));
        }
Exemplo n.º 12
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            Helpers.DrawAdditive(Helpers.RadialMask, projectile.Center.ForDraw(), Color.White * (FlickerFactor * 0.1f + 0.12f), projectile.scale * Math.Abs((float)Math.Sin(counter / 120f) * 0.2f));
            Texture2D texture  = Main.projectileTexture[projectile.type];
            Color     color    = SpiritMod.StarjinxColor(Main.GlobalTime * 2 + projectile.ai[1]);
            Rectangle drawrect = new Rectangle(0, (int)projectile.ai[1] * texture.Height / 3, texture.Width, texture.Height / 3);

            spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(drawrect), color, projectile.rotation, drawrect.Size() / 2, projectile.scale, SpriteEffects.None, 0f);
            return(false);
        }
Exemplo n.º 13
0
        public Color GetColourAt(float distanceFromStart, float trailLength, List <Vector2> points)
        {
            float progress    = distanceFromStart / trailLength;
            Color returnColor = Color.Lerp(SpiritMod.StarjinxColor(_start + Main.GlobalTime * _speed), SpiritMod.StarjinxColor(_start + 5 + Main.GlobalTime * _speed), progress) * (1f - progress) * _opacity;

            if (_proj != null)
            {
                return(returnColor * _proj.Opacity);
            }
            return(returnColor);
        }
Exemplo n.º 14
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            spriteBatch.Draw(mod.GetTexture("Extras/StardustPillarStar"),
                             projectile.Center - Main.screenPosition,
                             null,
                             Color.Lerp(SpiritMod.StarjinxColor(Main.GlobalTime * 4), Color.Transparent, 0.5f), 0, new Vector2(36, 36),
                             Scale * 2.5f * ((float)Math.Sin(projectile.timeLeft / 7) / 8 + 1),
                             SpriteEffects.None,
                             0);

            return(false);
        }
 public static void AddItem(BaseBGItem item)
 {
     if (item != null)
     {
         bgItems.Add(item);
     }
     else
     {
         SpiritMod mod = SpiritMod.Instance;
         mod.Logger.Warn("Null BGItem add attempt. Report to mod devs.");
     }
 }
Exemplo n.º 16
0
        public override bool NewRightClick(int i, int j)
        {
            //don't bother if there's already a Crystal King in the world
            for (int x = 0; x < Main.npc.Length; x++)
            {
                if (Main.npc[x].active && Main.npc[x].type == ModContent.NPCType <SteamRaiderHead>())
                {
                    return(false);
                }
            }

            //check if player has a Cryptic Crystal
            Player player = Main.player[Main.myPlayer];

            if (Main.dayTime)
            {
                return(false);
            }
            if (player.HasItem(ModContent.ItemType <StarWormSummon>()))
            {
                //now to search for it
                Item[] inventory = player.inventory;
                for (int k = 0; k < inventory.Length; k++)
                {
                    if (inventory[k].type == ModContent.ItemType <StarWormSummon>())
                    {
                        //consume it, and summon the Crystal King!
                        inventory[k].stack--;
                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Main.NewText("The Starplate Voyager has awoken!", 175, 75, 255, true);
                            int npcID = NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, ModContent.NPCType <SteamRaiderHead>());
                            Main.npc[npcID].Center     = player.Center - new Vector2(600, 600);
                            Main.npc[npcID].netUpdate2 = true;
                        }
                        else
                        {
                            if (Main.netMode == NetmodeID.SinglePlayer)
                            {
                                return(false);
                            }
                            SpiritMod.WriteToPacket(SpiritMod.instance.GetPacket(), (byte)MessageType.BossSpawnFromClient, (byte)player.whoAmI, (int)ModContent.NPCType <SteamRaiderHead>(), "Steam Raider Head Has Been Summoned!", (int)player.Center.X - 600, (int)player.Center.Y - 600).Send(-1);
                        }
                        //  Main.PlaySound(SoundID.Roar, (int)player.position.X, (int)player.position.Y, 0);
                        //	Main.NewText("Starplate Voyager has awoken!", 175, 75, 255, false);
                        //and don't spam crystal kings if the player didn't ask for it :P
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 17
0
        public override bool UseItem(Player player)
        {
            if (Main.netMode == NetmodeID.MultiplayerClient && player.whoAmI == Main.myPlayer)
            {
                SpiritMod.WriteToPacket(SpiritMod.Instance.GetPacket(), (byte)MessageType.StartTide).Send();
            }
            else
            {
                TideWorld.TheTide = true;
                TideWorld.TideWaveIncrease();
            }

            return(true);
        }
Exemplo n.º 18
0
        public static void ManualTrailSpawn(Projectile projectile)
        {
            if (projectile.modProjectile is IManualTrailProjectile)
            {
                if (Main.netMode == NetmodeID.SinglePlayer)
                {
                    (projectile.modProjectile as IManualTrailProjectile).DoTrailCreation(SpiritMod.TrailManager);
                }

                else
                {
                    SpiritMod.WriteToPacket(SpiritMod.Instance.GetPacket(), (byte)MessageType.SpawnTrail, projectile.whoAmI).Send();
                }
            }
        }
Exemplo n.º 19
0
        private void OnCollision()
        {
            projectile.rotation  = projectile.oldVelocity.ToRotation() - MathHelper.PiOver2;
            projectile.velocity  = Vector2.Zero;
            projectile.netUpdate = true;

            if (Main.dedServ)
            {
                return;
            }

            for (int i = 0; i < 4; i++)
            {
                ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, projectile.oldVelocity.RotatedByRandom(MathHelper.Pi / 16) * Main.rand.NextFloat(0.2f, 0.4f), Color.White,
                                                               SpiritMod.StarjinxColor(Main.GlobalTime - 1), Main.rand.NextFloat(0.2f, 0.4f), 25));
            }

            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/starHit").WithPitchVariance(0.2f).WithVolume(0.3f), projectile.Center);
        }
Exemplo n.º 20
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D tex       = Main.projectileTexture[projectile.type];
            Rectangle rectangle = new Rectangle(0, 0, tex.Width, tex.Height);
            Color     color     = SpiritMod.StarjinxColor(Main.GlobalTime * 2);
            Vector2   scale     = new Vector2(1f - projectile.velocity.Length() / 50, 1f + projectile.velocity.Length() / 50) * projectile.scale;

            spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, rectangle, color, projectile.rotation, rectangle.Size() / 2, scale, SpriteEffects.None, 0);
            spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, rectangle, Color.White, projectile.rotation, rectangle.Size() / 2, scale * 0.5f, SpriteEffects.None, 0);
            spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, rectangle, Color.Lerp(color, Color.Transparent, 0.5f), projectile.rotation, rectangle.Size() / 2,
                             scale * ((float)Math.Sin(Main.GlobalTime * 3) / 10 + 1.3f), SpriteEffects.None, 0);

            /*for(int i = 0; i < 2; i++)
             * {
             *      Vector2 offset = projectile.Center + (projectile.scale * new Vector2((50 + 5 * (float)Math.Sin(Main.GlobalTime * 4))/(1 + projectile.velocity.Length()/8), 0).RotatedBy(i * MathHelper.Pi + Main.GlobalTime * 6)) - Main.screenPosition;
             *      spriteBatch.Draw(tex, offset, new Rectangle?(rectangle), color, projectile.rotation, rectangle.Size() / 2, projectile.scale * 0.33f, SpriteEffects.None, 0);
             * }*/
            return(false);
        }
Exemplo n.º 21
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D glow  = mod.GetTexture(Texture.Remove(0, mod.Name.Length + 1) + "_glow");
            Texture2D glow2 = mod.GetTexture(Texture.Remove(0, mod.Name.Length + 1) + "_glow2");
            Rectangle rect  = glow.Bounds;

            //draw beam to player
            Texture2D tex       = mod.GetTexture("Extras/Medusa_Ray");
            Color     beamcolor = SpiritMod.StarjinxColor(Main.GlobalTime * 4) * 0.5f * ((float)Math.Sin(Main.GlobalTime * 3) / 4 + 0.75f);
            Vector2   scale     = new Vector2(projectile.Distance(Player.Center) / tex.Width, 1) * 0.75f;

            spriteBatch.Draw(tex,
                             projectile.Center - Main.screenPosition + new Vector2(tex.Size().X *scale.X, 0).RotatedBy(projectile.AngleTo(Player.Center)) / 2,
                             null,
                             SpiritMod.StarjinxColor(Main.GlobalTime * 4) * 0.5f * ((float)Math.Sin(Main.GlobalTime * 3) / 4 + 0.75f),
                             projectile.AngleTo(Player.Center),
                             tex.Size() / 2,
                             scale,
                             SpriteEffects.None,
                             0);

            float         newrotation = (Math.Abs(projectile.rotation) > MathHelper.Pi / 2) ? projectile.rotation - MathHelper.Pi : projectile.rotation;
            SpriteEffects flip        = (Math.Abs(projectile.rotation) > MathHelper.Pi / 2) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            //draw big glow underneath projectile
            spriteBatch.Draw(glow2, projectile.Center - Main.screenPosition, glow2.Bounds, beamcolor, newrotation,
                             glow2.Size() / 2, projectile.scale * 1.1f, flip, 0);
            spriteBatch.Draw(glow2, projectile.Center - Main.screenPosition, glow2.Bounds, beamcolor * 0.3f, newrotation,
                             glow2.Size() / 2, projectile.scale * ((float)Math.Sin(Main.GlobalTime * 3) / 6 + 1.2f), flip, 0);

            //redraw projectile and glowmask
            spriteBatch.Draw(Main.projectileTexture[projectile.type], projectile.Center - Main.screenPosition, rect, projectile.GetAlpha(lightColor), newrotation, rect.Size() / 2, projectile.scale, flip, 0);
            spriteBatch.Draw(glow, projectile.Center - Main.screenPosition, rect, projectile.GetAlpha(Color.White), newrotation, rect.Size() / 2, projectile.scale, flip, 0);

            spriteBatch.Draw(glow, projectile.Center - Main.screenPosition, rect, projectile.GetAlpha(Color.White * 0.5f), newrotation, rect.Size() / 2,
                             projectile.scale + (projectile.scale * (0.3f + (float)Math.Sin(Main.GlobalTime * 3) / 6)), flip, 0);



            return(false);
        }
Exemplo n.º 22
0
        private static void ProgressBarSection(SpriteBatch spriteBatch, float Scale, float Alpha, out Rectangle progressBarBG)
        {
            //Draw the background for the progress bar
            Rectangle progressBarBackground = Utils.CenteredRectangle(new Vector2(Main.screenWidth - OffsetX - 100f, Main.screenHeight - OffsetY - 23f), Size * Scale);

            Utils.DrawInvBG(spriteBatch, progressBarBackground, ProgressBarBGColor * 0.785f * Alpha);
            progressBarBG = progressBarBackground;

            //Display the % for how much of the wave has been cleared
            int    progress = (int)(100 * StarjinxEventWorld.KilledEnemies / (float)StarjinxEventWorld.MaxEnemies);
            string waveText = "Wave Progress : " + progress + "%";

            Utils.DrawBorderString(spriteBatch, waveText, new Vector2(progressBarBackground.Center.X, progressBarBackground.Y + 2.5f), TextColor, Scale, 0.5f, -0.1f);
            Rectangle waveProgressBar = Utils.CenteredRectangle(new Vector2(progressBarBackground.Center.X, progressBarBackground.Y + progressBarBackground.Height * 0.75f), Main.colorBarTexture.Size());

            //Scale the amount of the bar drawn based on progress
            var waveProgressAmount = new Rectangle(0, 0, (int)(Main.colorBarTexture.Width * BarProgress), Main.colorBarTexture.Height);
            var offset             = new Vector2((waveProgressBar.Width - (int)(waveProgressBar.Width * Scale)) * 0.5f, (waveProgressBar.Height - (int)(waveProgressBar.Height * Scale)) * 0.5f);

            //Make the part of the bar not filled out black, by drawing a full length black bar beneath the color bar
            spriteBatch.Draw(Main.colorBarTexture, waveProgressBar.Location.ToVector2() + offset, null, Color.White * Alpha, 0f, new Vector2(0f), Scale, SpriteEffects.None, 0f);

            //Bloom underneath shader bar
            Texture2D bloom       = SpiritMod.Instance.GetTexture("Effects/Masks/CircleGradient");
            float     sineCounter = (float)(Math.Sin(Main.GlobalTime * 4) * 0.05f) + 1f;

            Color bloomColor = Color.Lerp(SpiritMod.StarjinxColor(Main.GlobalTime * 0.75f), Color.White, 0.33f) * BarProgress * sineCounter;

            bloomColor.A = 0;

            //Scale to match color bar texture size
            Vector2 bloomScale = Main.colorBarTexture.Size() / bloom.Size();

            bloomScale   *= 2.2f * Scale * sineCounter;
            bloomScale.Y *= 1.75f;
            bloomScale.X *= BarProgress;             //Match progress bar effective width

            Vector2 bloomPos = waveProgressBar.Location.ToVector2() + offset + new Vector2((Main.colorBarTexture.Width / 2) * BarProgress * 0.95f, Main.colorBarTexture.Height / 2) * Scale;

            spriteBatch.Draw(bloom, bloomPos, null, bloomColor, 0f, bloom.Size() / 2, bloomScale, SpriteEffects.None, 0);

            //Draw the colored part of the bar, with a shader
            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.UIScaleMatrix);

            Effect progressbarEffect = SpiritMod.Instance.GetEffect("Effects/SjinxProgressBar");

            progressbarEffect.Parameters["vnoiseTex"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_2"));
            progressbarEffect.Parameters["timer"].SetValue(Main.GlobalTime * 0.75f);
            progressbarEffect.Parameters["progress"].SetValue(BarProgress);
            progressbarEffect.Parameters["Yellow"].SetValue(new Color(245, 236, 74).ToVector4());
            progressbarEffect.Parameters["Orange"].SetValue(new Color(255, 112, 68).ToVector4());
            progressbarEffect.Parameters["Pink"].SetValue(new Color(255, 84, 231).ToVector4());
            progressbarEffect.CurrentTechnique.Passes[0].Apply();

            spriteBatch.Draw(Main.colorBarTexture, waveProgressBar.Location.ToVector2() + offset, waveProgressAmount, Color.White, 0f, new Vector2(0f), Scale, SpriteEffects.None, 0f);

            spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.UIScaleMatrix);

            //Weaker bloom above shader bar
            spriteBatch.Draw(bloom, bloomPos, null, bloomColor * 0.33f, 0f, bloom.Size() / 2, bloomScale, SpriteEffects.None, 0);
        }
Exemplo n.º 23
0
        public void DrawPrimShape(BasicEffect effect)
        {
            if (projectile.velocity.Length() >= 1)
            {
                for (int i = 1; i < ProjectileID.Sets.TrailCacheLength[projectile.type]; i += 2)
                {
                    Vector2 newCenter  = projectile.oldPos[i] + projectile.Size / 2;
                    float   lerpamount = 0.5f + (i / (float)(ProjectileID.Sets.TrailCacheLength[projectile.type] * 2));
                    StarDraw.DrawStarBasic(effect, newCenter, projectile.oldRot[i], Scale * 100, Color.Lerp(SpiritMod.StarjinxColor(Main.GlobalTime * 4 + i), Color.Transparent, lerpamount));
                }
            }

            StarDraw.DrawStarBasic(effect, projectile.Center, projectile.rotation, Scale * 100, Color.Lerp(SpiritMod.StarjinxColor(Main.GlobalTime * 4), Color.Black, 0.1f));
            StarDraw.DrawStarBasic(effect, projectile.Center, projectile.rotation, Scale * 70, Color.White);
        }
Exemplo n.º 24
0
        public StarplateBeaconIntroEvent(Vector2 center)
        {
            _center = center;

            // set up the screen shaders
            _ripContrastData = new BeaconShaderData(new Ref <Effect>(SpiritMod.Instance.GetEffect("Effects/EventShaders")), "BeaconStartScreen");
            _burstData       = new BeaconShaderData(new Ref <Effect>(SpiritMod.Instance.GetEffect("Effects/EventShaders")), "BeaconBurstScreen");
            Filters.Scene["SpiritMod:Event-BeaconDistortion"] = new Filter(_ripContrastData, (EffectPriority)20);
            Filters.Scene["SpiritMod:Event-BeaconBurst"]      = new Filter(_burstData, (EffectPriority)35);

            const float BURST_START = BUILDUP_LENGTH + PAUSE_TIME;

            // screen rip animation
            _screenRipStrength = new EaseBuilder();
            _screenRipStrength.AddPoint(0f, 0f, EaseFunction.Linear);
            _screenRipStrength.AddPoint(BUILDUP_LENGTH * 0.9f, 1f, EaseFunction.EaseCubicIn);
            _screenRipStrength.AddPoint(BURST_START, 1f, EaseFunction.EaseCubicIn);
            _screenRipStrength.AddPoint(BURST_START + BURST_LENGTH, 0f, EaseFunction.EaseCubicOut);

            // contrast animation
            _contrastBubbleStrength = new EaseBuilder();
            _contrastBubbleStrength.AddPoint(0f, 0f, EaseFunction.Linear);
            _contrastBubbleStrength.AddPoint(BUILDUP_LENGTH, 1f, new PolynomialEase(x => x * x * x * x * x * x * x));
            _contrastBubbleStrength.AddPoint(BURST_START, 1f, EaseFunction.Linear);
            _contrastBubbleStrength.AddPoint(BURST_START + BURST_LENGTH, 0f, EaseFunction.EaseQuadOut);

            // burst radius animation
            _burstRadius = new EaseBuilder();
            _burstRadius.AddPoint(0f, 0f, EaseFunction.Linear);
            _burstRadius.AddPoint(BURST_START, 0f, EaseFunction.Linear);
            _burstRadius.AddPoint(BURST_START + BURST_LENGTH, BURST_RADIUS, EaseFunction.EaseQuadOut);

            // burst strength animation
            _burstStrength = new EaseBuilder();
            _burstStrength.AddPoint(0f, 0f, EaseFunction.Linear);
            _burstStrength.AddPoint(BURST_START - 0.01f, 0f, EaseFunction.Linear);
            _burstStrength.AddPoint(BURST_START, 1f, EaseFunction.Linear);
            _burstStrength.AddPoint(BURST_START + BURST_LENGTH, 0f, EaseFunction.EaseQuadOut);

            // overlay opacity animation
            _overlayOpacity = new EaseBuilder();
            _overlayOpacity.AddPoint(0f, 0f, EaseFunction.Linear);
            _overlayOpacity.AddPoint(BURST_START, 1f, EaseFunction.EaseCubicIn);
            _overlayOpacity.AddPoint(BURST_START + 0.2f, 0f, EaseFunction.Linear);

            // particle mass animation
            _particleMass = new EaseBuilder();
            _particleMass.AddPoint(0f, 1f, EaseFunction.Linear);
            _particleMass.AddPoint(BUILDUP_LENGTH, 5000000000000000f, EaseFunction.EaseQuadIn);

            // particle spawn count animation
            _particleSpawnCount = new EaseBuilder();
            _particleSpawnCount.AddPoint(0f, 7.5f, EaseFunction.Linear);
            _particleSpawnCount.AddPoint(BUILDUP_LENGTH, 6f, EaseFunction.EaseQuarticIn);

            // flash opacity animation
            _flashOpacity = new EaseBuilder();
            _flashOpacity.AddPoint(0f, 0f, EaseFunction.Linear);
            _flashOpacity.AddPoint(BURST_START - 0.01f, 0f, EaseFunction.Linear);
            _flashOpacity.AddPoint(BURST_START + 0.04f, 1f, EaseFunction.Linear);
            _flashOpacity.AddPoint(BURST_START + 0.2f, 0f, EaseFunction.EaseQuadOut);

            _particles = new List <Particle>();

            // add a sound to the queue
            AddToQueue(new ExpressionController(0, (int frame) =>
            {
                if (Main.netMode != NetmodeID.Server)
                {
                    Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/StarplateBlast"), center);
                }
            }));

            // add a screen shake event to the queue
            AddToQueue(new ExpressionController(BUILDUP_LENGTH + PAUSE_TIME, (int frame) =>
            {
                EventManager.PlayEvent(new ScreenShake(20f, 0.6f));
            }));

            // add the summoning to the queue
            AddToQueue(new ExpressionController(BUILDUP_LENGTH + PAUSE_TIME + BURST_LENGTH - 0.5f, (int frame) =>
            {
                Player player = Main.LocalPlayer;
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    Main.NewText("The Starplate Voyager has awoken!", 175, 75, 255, true);
                    int npcID = NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, ModContent.NPCType <SteamRaiderHead>());
                    Main.npc[npcID].Center     = player.Center - new Vector2(600, 600);
                    Main.npc[npcID].netUpdate2 = true;
                }
                else
                {
                    SpiritMod.WriteToPacket(SpiritMod.Instance.GetPacket(), (byte)MessageType.BossSpawnFromClient, (byte)player.whoAmI, (int)ModContent.NPCType <SteamRaiderHead>(), "The Starplate Voyager has awoken!", (int)player.Center.X - 600, (int)player.Center.Y - 600).Send(-1);
                }
            }));
        }
Exemplo n.º 25
0
        public override void AI()
        {
            projectile.rotation += 0.1f;

            projectile.velocity.Y += 0.1f;

            if (Main.rand.Next(50) == 0)
            {
                Particles.ParticleHandler.SpawnParticle(new Particles.StarParticle(projectile.Center, projectile.velocity.RotatedByRandom(MathHelper.Pi / 8), Color.White * 0.66f, SpiritMod.StarjinxColor(Main.GlobalTime), Main.rand.NextFloat(0.2f, 0.3f), 35));
            }
        }
Exemplo n.º 26
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)
        {
            Vector2 direction = Vector2.Zero;
            Dust    dust;

            if (player.ownedProjectileCounts[mod.ProjectileType("StarfireLampYellow")] < 2)
            {
                int p = Projectile.NewProjectile(player.Center.X - Main.rand.Next(-50, 50), player.Center.Y - Main.rand.Next(40, 80), 0f, 0f, mod.ProjectileType("StarfireLampYellow"), damage, knockBack, player.whoAmI);
                Main.projectile[p].ai[0] = player.whoAmI;
            }
            if (player.ownedProjectileCounts[mod.ProjectileType("StarfireLampPurple")] < 2)
            {
                int p = Projectile.NewProjectile(player.Center.X - Main.rand.Next(-50, 50), player.Center.Y - Main.rand.Next(40, 80), 0f, 0f, mod.ProjectileType("StarfireLampPurple"), damage, knockBack, player.whoAmI);
                Main.projectile[p].ai[0] = player.whoAmI;
            }
            DustHelper.DrawStar2(player.Center - new Vector2(0, 60), 66, 5, 2f, 2f, 1f, 1, 0.5f, true, 0, -1, SpiritMod.StarjinxColor(Main.GlobalTime * 3));
            return(false);
        }
Exemplo n.º 27
0
        public override void HoldItem(Player player)
        {
            int     chosenDust = 66;
            Vector2 vector2_1  = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f;

            if (player.direction != 1)
            {
                vector2_1.X = player.bodyFrame.Width - vector2_1.X;
            }
            if (player.gravDir != 1.0)
            {
                vector2_1.Y = player.bodyFrame.Height - vector2_1.Y;
            }
            Vector2 vector2_2 = player.RotatedRelativePoint(player.position + vector2_1 - new Vector2(player.bodyFrame.Width - player.width, player.bodyFrame.Height - 42) / 2f, true) - player.velocity;

            for (int index = 0; index < 2; ++index)
            {
                Dust dust = Main.dust[Dust.NewDust(player.Center, 0, 0, chosenDust, player.direction * 2, 0.0f, 150, SpiritMod.StarjinxColor(Main.GlobalTime * 2), 1.3f)];
                dust.position  = vector2_2;
                dust.velocity *= 0.0f;
                dust.noGravity = true;
                dust.fadeIn    = 1f;
                dust.velocity += player.velocity;
                dust.scale    *= 0.8f;
                if (Main.rand.Next(2) == 0)
                {
                    dust.position += Utils.RandomVector2(Main.rand, -4f, 4f);
                    dust.scale    += Main.rand.NextFloat();
                    if (Main.rand.Next(2) == 0)
                    {
                        dust.customData = player;
                    }
                }
            }
        }
Exemplo n.º 28
0
        public override void AI()
        {
            Lighting.AddLight(projectile.Center, SpiritMod.StarjinxColor(Main.GlobalTime - 1).ToVector3() / 3);
            projectile.tileCollide = Timer > 15;
            void TargetCheck()
            {
                int maxDist = 1000;

                foreach (NPC npc in Main.npc.Where(x => x.Distance(projectile.Center) < maxDist && x.active && x.CanBeChasedBy(this) && x != null))
                {
                    StarfireLampPlayer player = Main.player[projectile.owner].GetModPlayer <StarfireLampPlayer>();
                    if (player.LampTargetNPC == npc && npc.active && npc != null && npc.CanBeChasedBy(this))
                    {
                        AiState = HomingAim;
                        Target  = npc;
                        projectile.netUpdate = true;
                        Timer = 0;
                    }
                }
            }

            switch (AiState)
            {
            case JustSpawned:
                Direction = Main.rand.NextBool() ? -1 : 1;
                OrigVel   = projectile.velocity;
                AiState   = Main.rand.NextBool(3) ? Circling : CosWave;
                break;

            case CosWave:
                ++Timer;
                projectile.velocity = OrigVel.RotatedBy(Math.Cos((Timer / 45) * MathHelper.TwoPi) * Direction * MathHelper.Pi / 8);
                if (Timer > 10)
                {
                    TargetCheck();
                }
                break;

            case Circling:
                ++Timer;
                projectile.velocity = (OrigVel.RotatedBy(MathHelper.ToRadians(Timer * Direction * 9) + MathHelper.PiOver2 * Direction) * 0.5f) + (OrigVel * 0.33f);
                if (Timer > 10)
                {
                    TargetCheck();
                }
                break;

            case HomingAim:
                ++Timer;
                if (Timer > 8 || Target == null || !Target.active || !Target.CanBeChasedBy(this))
                {
                    AiState = HomingAccelerate;
                    break;
                }
                projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(Target.Center) * 2, 0.22f);
                break;

            case HomingAccelerate:
                if (projectile.velocity.Length() < 24)
                {
                    projectile.velocity *= 1.05f;
                }

                if (Target != null && Target.active && Target.CanBeChasedBy(this))
                {
                    projectile.velocity = projectile.velocity.Length() *
                                          Vector2.Normalize(Vector2.Lerp(projectile.velocity, projectile.DirectionTo(Target.Center) * projectile.velocity.Length(), 0.1f));
                }
                break;
            }

            projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2;
            projectile.alpha    = Math.Max(projectile.alpha - 15, 0);

            if (projectile.frameCounter++ % 5 == 0)
            {
                projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type];
            }

            if (!Main.dedServ)
            {
                if (Main.rand.NextBool(12))
                {
                    ParticleHandler.SpawnParticle(new FireParticle(projectile.Center, projectile.velocity * Main.rand.NextFloat(0.75f),
                                                                   Yellow, Orange, Main.rand.NextFloat(0.25f, 0.3f), 25, delegate(Particle p)
                    {
                        p.Velocity *= 0.93f;
                    }));
                }

                if (Main.rand.NextBool(8))
                {
                    ParticleHandler.SpawnParticle(new StarParticle(projectile.Center, projectile.velocity * Main.rand.NextFloat(0.75f),
                                                                   Main.rand.NextBool(3) ? Orange : Yellow, Main.rand.NextFloat(0.15f, 0.2f), 20));
                }
            }
        }
Exemplo n.º 29
0
 public override void SetShaders()
 {
     PrepareShader(SpiritMod.StarfirePrims, "Edge2", Counter / 7.5f, SpiritMod.StarjinxColor(Main.GlobalTime * 2));
 }
Exemplo n.º 30
0
 public override void Update(ref float gravity, ref float maxFallSpeed)
 {
     if (Main.rand.Next(50) == 0)
     {
         Particles.ParticleHandler.SpawnParticle(new Particles.StarParticle(item.Center + Main.rand.NextVector2Circular(7, 7), Main.rand.NextVector2Circular(1, 1), Color.White * 0.66f, SpiritMod.StarjinxColor(Main.GlobalTime), Main.rand.NextFloat(0.2f, 0.3f), 25));
     }
 }