コード例 #1
0
ファイル: Gore.cs プロジェクト: woodcrafter123/Sources
        public static int NewGore(Vector2 Position, Vector2 Velocity, int Type, float Scale = 1f)
        {
            if (Main.netMode == 2 || Main.gamePaused)
            {
                return(500);
            }
            if (Main.rand == null)
            {
                Main.rand = new UnifiedRandom();
            }
            int index1 = 500;

            for (int index2 = 0; index2 < 500; ++index2)
            {
                if (!Main.gore[index2].active)
                {
                    index1 = index2;
                    break;
                }
            }
            if (index1 == 500)
            {
                return(index1);
            }
            Main.gore[index1].numFrames    = (byte)1;
            Main.gore[index1].frame        = (byte)0;
            Main.gore[index1].frameCounter = (byte)0;
            Main.gore[index1].behindTiles  = false;
            Main.gore[index1].light        = 0.0f;
            Main.gore[index1].position     = Position;
            Main.gore[index1].velocity     = Velocity;
            Main.gore[index1].velocity.Y  -= (float)Main.rand.Next(10, 31) * 0.1f;
            Main.gore[index1].velocity.X  += (float)Main.rand.Next(-20, 21) * 0.1f;
            Main.gore[index1].type         = Type;
            Main.gore[index1].active       = true;
            Main.gore[index1].alpha        = 0;
            Main.gore[index1].rotation     = 0.0f;
            Main.gore[index1].scale        = Scale;
            if (!ChildSafety.Disabled && ChildSafety.DangerousGore(Type))
            {
                Main.gore[index1].type      = Main.rand.Next(11, 14);
                Main.gore[index1].scale     = (float)((double)Main.rand.NextFloat() * 0.5 + 0.5);
                Main.gore[index1].velocity /= 2f;
            }
            if (Gore.goreTime == 0 || Type == 11 || (Type == 12 || Type == 13) || (Type == 16 || Type == 17 || (Type == 61 || Type == 62)) || (Type == 63 || Type == 99 || (Type == 220 || Type == 221) || (Type == 222 || Type == 435 || (Type == 436 || Type == 437))) || Type >= 861 && Type <= 862)
            {
                Main.gore[index1].sticky = false;
            }
            else if (Type >= 375 && Type <= 377)
            {
                Main.gore[index1].sticky = false;
                Main.gore[index1].alpha  = 100;
            }
            else
            {
                Main.gore[index1].sticky   = true;
                Main.gore[index1].timeLeft = Gore.goreTime;
            }
            if (Type >= 706 && Type <= 717 || Type == 943)
            {
                Main.gore[index1].numFrames   = (byte)15;
                Main.gore[index1].behindTiles = true;
                Main.gore[index1].timeLeft    = Gore.goreTime * 3;
            }
            if (Type == 16 || Type == 17)
            {
                Main.gore[index1].alpha = 100;
                Main.gore[index1].scale = 0.7f;
                Main.gore[index1].light = 1f;
            }
            if (Type >= 570 && Type <= 572)
            {
                Main.gore[index1].velocity = Velocity;
            }
            if (GoreID.Sets.SpecialAI[Type] == 3)
            {
                Main.gore[index1].velocity     = new Vector2((float)(((double)Main.rand.NextFloat() - 0.5) * 1.0), Main.rand.NextFloat() * 6.283185f);
                Main.gore[index1].numFrames    = (byte)8;
                Main.gore[index1].frame        = (byte)Main.rand.Next(8);
                Main.gore[index1].frameCounter = (byte)Main.rand.Next(8);
            }
            if (GoreID.Sets.SpecialAI[Type] == 1)
            {
                Main.gore[index1].velocity = new Vector2((float)(((double)Main.rand.NextFloat() - 0.5) * 3.0), Main.rand.NextFloat() * 6.283185f);
            }
            if (Type >= 411 && Type <= 430 && Main.goreLoaded[Type])
            {
                Main.gore[index1].position.X  = Position.X - (float)(Main.goreTexture[Type].Width / 2) * Scale;
                Main.gore[index1].position.Y  = Position.Y - (float)Main.goreTexture[Type].Height * Scale;
                Main.gore[index1].velocity.Y *= (float)Main.rand.Next(90, 150) * 0.01f;
                Main.gore[index1].velocity.X *= (float)Main.rand.Next(40, 90) * 0.01f;
                int num = Main.rand.Next(4) * 5;
                Main.gore[index1].type    += num;
                Main.gore[index1].timeLeft = Main.rand.Next(Gore.goreTime / 2, Gore.goreTime * 2);
                Main.gore[index1].sticky   = true;
                if (Gore.goreTime == 0)
                {
                    Main.gore[index1].timeLeft = Main.rand.Next(150, 600);
                }
            }
            if (Type >= 907 && Type <= 909)
            {
                Main.gore[index1].sticky       = true;
                Main.gore[index1].numFrames    = (byte)3;
                Main.gore[index1].frame        = (byte)Main.rand.Next(3);
                Main.gore[index1].frameCounter = (byte)Main.rand.Next(5);
                Main.gore[index1].rotation     = 0.0f;
            }
            if (GoreID.Sets.SpecialAI[Type] == 2)
            {
                Main.gore[index1].sticky = false;
                if (Main.goreLoaded[Type])
                {
                    Main.gore[index1].alpha      = 150;
                    Main.gore[index1].velocity   = Velocity;
                    Main.gore[index1].position.X = Position.X - (float)(Main.goreTexture[Type].Width / 2) * Scale;
                    Main.gore[index1].position.Y = Position.Y - (float)((double)Main.goreTexture[Type].Height * (double)Scale / 2.0);
                    Main.gore[index1].timeLeft   = Main.rand.Next(Gore.goreTime / 2, Gore.goreTime + 1);
                }
            }
            return(index1);
        }
コード例 #2
0
        // Token: 0x06000085 RID: 133 RVA: 0x0000AF60 File Offset: 0x00009160
        public static int NewGore(Vector2 Position, Vector2 Velocity, int Type, float Scale = 1f)
        {
            if (Main.netMode == 2)
            {
                return(500);
            }
            if (Main.gamePaused)
            {
                return(500);
            }
            if (Main.rand == null)
            {
                Main.rand = new UnifiedRandom();
            }
            int num = 500;

            for (int i = 0; i < 500; i++)
            {
                if (!Main.gore[i].active)
                {
                    num = i;
                    break;
                }
            }
            if (num == 500)
            {
                return(num);
            }
            Main.gore[num].numFrames    = 1;
            Main.gore[num].frame        = 0;
            Main.gore[num].frameCounter = 0;
            Main.gore[num].behindTiles  = false;
            Main.gore[num].light        = 0f;
            Main.gore[num].position     = Position;
            Main.gore[num].velocity     = Velocity;
            Gore expr_CE_cp_0_cp_0 = Main.gore[num];

            expr_CE_cp_0_cp_0.velocity.Y = expr_CE_cp_0_cp_0.velocity.Y - (float)Main.rand.Next(10, 31) * 0.1f;
            Gore expr_F8_cp_0_cp_0 = Main.gore[num];

            expr_F8_cp_0_cp_0.velocity.X = expr_F8_cp_0_cp_0.velocity.X + (float)Main.rand.Next(-20, 21) * 0.1f;
            Main.gore[num].type          = Type;
            Main.gore[num].active        = true;
            Main.gore[num].alpha         = 0;
            Main.gore[num].rotation      = 0f;
            Main.gore[num].scale         = Scale;
            if (!ChildSafety.Disabled && ChildSafety.DangerousGore(Type))
            {
                Main.gore[num].type      = Main.rand.Next(11, 14);
                Main.gore[num].scale     = Main.rand.NextFloat() * 0.5f + 0.5f;
                Main.gore[num].velocity /= 2f;
            }
            if (Gore.goreTime == 0 || Type == 11 || Type == 12 || Type == 13 || Type == 16 || Type == 17 || Type == 61 || Type == 62 || Type == 63 || Type == 99 || Type == 220 || Type == 221 || Type == 222 || Type == 435 || Type == 436 || Type == 437 || (Type >= 861 && Type <= 862))
            {
                Main.gore[num].sticky = false;
            }
            else if (Type >= 375 && Type <= 377)
            {
                Main.gore[num].sticky = false;
                Main.gore[num].alpha  = 100;
            }
            else
            {
                Main.gore[num].sticky   = true;
                Main.gore[num].timeLeft = Gore.goreTime;
            }
            if ((Type >= 706 && Type <= 717) || Type == 943)
            {
                Main.gore[num].numFrames   = 15;
                Main.gore[num].behindTiles = true;
                Main.gore[num].timeLeft    = Gore.goreTime * 3;
            }
            if (Type == 16 || Type == 17)
            {
                Main.gore[num].alpha = 100;
                Main.gore[num].scale = 0.7f;
                Main.gore[num].light = 1f;
            }
            if (Type >= 570 && Type <= 572)
            {
                Main.gore[num].velocity = Velocity;
            }
            if (GoreID.Sets.SpecialAI[Type] == 3)
            {
                Main.gore[num].velocity     = new Vector2((Main.rand.NextFloat() - 0.5f) * 1f, Main.rand.NextFloat() * 6.28318548f);
                Main.gore[num].numFrames    = 8;
                Main.gore[num].frame        = (byte)Main.rand.Next(8);
                Main.gore[num].frameCounter = (byte)Main.rand.Next(8);
            }
            if (GoreID.Sets.SpecialAI[Type] == 1)
            {
                Main.gore[num].velocity = new Vector2((Main.rand.NextFloat() - 0.5f) * 3f, Main.rand.NextFloat() * 6.28318548f);
            }
            if (Type >= 411 && Type <= 430 && Main.goreLoaded[Type])
            {
                Main.gore[num].position.X = Position.X - (float)(Main.goreTexture[Type].Width / 2) * Scale;
                Main.gore[num].position.Y = Position.Y - (float)Main.goreTexture[Type].Height * Scale;
                Gore expr_46A_cp_0_cp_0 = Main.gore[num];
                expr_46A_cp_0_cp_0.velocity.Y = expr_46A_cp_0_cp_0.velocity.Y * ((float)Main.rand.Next(90, 150) * 0.01f);
                Gore expr_497_cp_0_cp_0 = Main.gore[num];
                expr_497_cp_0_cp_0.velocity.X = expr_497_cp_0_cp_0.velocity.X * ((float)Main.rand.Next(40, 90) * 0.01f);
                int num2 = Main.rand.Next(4) * 5;
                Main.gore[num].type    += num2;
                Main.gore[num].timeLeft = Main.rand.Next(Gore.goreTime / 2, Gore.goreTime * 2);
                Main.gore[num].sticky   = true;
                if (Gore.goreTime == 0)
                {
                    Main.gore[num].timeLeft = Main.rand.Next(150, 600);
                }
            }
            if (Type >= 907 && Type <= 909)
            {
                Main.gore[num].sticky       = true;
                Main.gore[num].numFrames    = 3;
                Main.gore[num].frame        = (byte)Main.rand.Next(3);
                Main.gore[num].frameCounter = (byte)Main.rand.Next(5);
                Main.gore[num].rotation     = 0f;
            }
            if (GoreID.Sets.SpecialAI[Type] == 2)
            {
                Main.gore[num].sticky = false;
                if (Main.goreLoaded[Type])
                {
                    Main.gore[num].alpha      = 150;
                    Main.gore[num].velocity   = Velocity;
                    Main.gore[num].position.X = Position.X - (float)(Main.goreTexture[Type].Width / 2) * Scale;
                    Main.gore[num].position.Y = Position.Y - (float)Main.goreTexture[Type].Height * Scale / 2f;
                    Main.gore[num].timeLeft   = Main.rand.Next(Gore.goreTime / 2, Gore.goreTime + 1);
                }
            }
            return(num);
        }
コード例 #3
0
ファイル: Gore.cs プロジェクト: Vednix/Mobile-Terraria-Server
        public static int NewGore(Vector2 Position, Vector2 Velocity, int Type, float Scale = 1f)
        {
            if (Main.netMode == 2)
            {
                return(500);
            }
            if (Main.gamePaused)
            {
                return(500);
            }
            if (Main.rand == null)
            {
                Main.rand = new Random();
            }
            int num = 500;

            for (int i = 0; i < 500; i++)
            {
                if (!Main.gore[i].active)
                {
                    num = i;
                    break;
                }
            }
            if (num == 500)
            {
                return(num);
            }
            Main.gore[num].numFrames    = 1;
            Main.gore[num].frame        = 0;
            Main.gore[num].frameCounter = 0;
            Main.gore[num].behindTiles  = false;
            Main.gore[num].light        = 0f;
            Main.gore[num].position     = Position;
            Main.gore[num].velocity     = Velocity;
            Main.gore[num].velocity.Y  -= (float)Main.rand.Next(10, 31) * 0.1f;
            Main.gore[num].velocity.X  += (float)Main.rand.Next(-20, 21) * 0.1f;
            Main.gore[num].type         = Type;
            Main.gore[num].active       = true;
            Main.gore[num].alpha        = 0;
            Main.gore[num].rotation     = 0f;
            Main.gore[num].scale        = Scale;
            if (!ChildSafety.Disabled && ChildSafety.DangerousGore(Type))
            {
                Main.gore[num].type      = Main.rand.Next(11, 14);
                Main.gore[num].scale     = Main.rand.NextFloat() * 0.5f + 0.5f;
                Main.gore[num].velocity /= 2f;
            }
            if (goreTime == 0 || Type == 11 || Type == 12 || Type == 13 || Type == 16 || Type == 17 || Type == 61 || Type == 62 || Type == 63 || Type == 99 || Type == 220 || Type == 221 || Type == 222 || Type == 435 || Type == 436 || Type == 437 || (Type >= 861 && Type <= 862))
            {
                Main.gore[num].sticky = false;
            }
            else if (Type >= 375 && Type <= 377)
            {
                Main.gore[num].sticky = false;
                Main.gore[num].alpha  = 100;
            }
            else
            {
                Main.gore[num].sticky   = true;
                Main.gore[num].timeLeft = goreTime;
            }
            if (Type >= 706 && Type <= 717)
            {
                Main.gore[num].numFrames   = 15;
                Main.gore[num].behindTiles = true;
                Main.gore[num].timeLeft    = goreTime * 3;
            }
            if (Type == 16 || Type == 17)
            {
                Main.gore[num].alpha = 100;
                Main.gore[num].scale = 0.7f;
                Main.gore[num].light = 1f;
            }
            if (Type >= 570 && Type <= 572)
            {
                Main.gore[num].velocity = Velocity;
            }
            if (Type == 860 || Type == 892 || Type == 893)
            {
                Main.gore[num].velocity = new Vector2((Main.rand.NextFloat() - 0.5f) * 3f, Main.rand.NextFloat() * ((float)Math.PI * 2f));
            }
            if (Type >= 411 && Type <= 430 && Main.goreLoaded[Type])
            {
                Main.gore[num].position.X  = Position.X - (float)(Main.goreTexture[Type].Width / 2) * Scale;
                Main.gore[num].position.Y  = Position.Y - (float)Main.goreTexture[Type].Height * Scale;
                Main.gore[num].velocity.Y *= (float)Main.rand.Next(90, 150) * 0.01f;
                Main.gore[num].velocity.X *= (float)Main.rand.Next(40, 90) * 0.01f;
                int num2 = Main.rand.Next(4) * 5;
                Main.gore[num].type    += num2;
                Main.gore[num].timeLeft = Main.rand.Next(goreTime / 2, goreTime * 2);
            }
            if (Type >= 825 && Type <= 827)
            {
                Main.gore[num].sticky = false;
                if (Main.goreLoaded[Type])
                {
                    Main.gore[num].alpha      = 150;
                    Main.gore[num].velocity   = Velocity;
                    Main.gore[num].position.X = Position.X - (float)(Main.goreTexture[Type].Width / 2) * Scale;
                    Main.gore[num].position.Y = Position.Y - (float)Main.goreTexture[Type].Height * Scale / 2f;
                    Main.gore[num].timeLeft   = Main.rand.Next(goreTime / 2, goreTime + 1);
                }
            }
            return(num);
        }