Exemplo n.º 1
0
 void OnEnable()
 {
     hideFlags = HideFlags.HideAndDontSave;
     if (worldGen == null)
     {
         worldGen = ScriptableObject.CreateInstance<WorldGen>();
     }
 }
Exemplo n.º 2
0
	public void genIslands(int dimX_, int dimY_) {

		this.dimX = dimX_;
		this.dimY = dimY_;

		WorldGen wg = new WorldGen (tilesToUse);
		localArray = wg.islands (dimX, dimY, 25, 4);
		Debug.Log ("Generated islands...");
		Debug.Log (getTileIDArray ());
		grid = wg.getGrid ();
	}
Exemplo n.º 3
0
Arquivo: Ferret.cs Projeto: 9volt/ld29
 // Use this for initialization
 void Start()
 {
     next_node = pos;
     hp = maxhp;
     last_action = Time.time;
     wg = GameObject.FindGameObjectWithTag("world").GetComponent<WorldGen>();
     wl = GameObject.FindGameObjectWithTag("world").GetComponent<WorldLogic>();
     rf = gameObject.GetComponent<RabbitFinder>();
     rm = gameObject.GetComponent<RabbitMover>();
     rm.SetPosition(wg.VertexToVector3(pos));
     Camera.main.gameObject.GetComponent<CameraMove>().SetPosition(pos);
 }
        static void Main(string[] args)
        {
            Console.WriteLine("-----------------------");
            Console.WriteLine("-----------------------");
            Console.WriteLine("Pokemon World Generator");
            Console.WriteLine();

            Console.Write("Generating map");

            var generator = new WorldGen(400, 400, "Generated", true, true);

            var generationResult = Task.Run(() =>
            {
                var chrono = Stopwatch.StartNew();

                generator.GenerateMap();

                chrono.Stop();

                return chrono.Elapsed;
            });

            int nbLoop = 14;
            while (!generationResult.IsCompleted)
            {
                Console.Write(".");
                nbLoop++;

                if (nbLoop == 23)
                {
                    nbLoop = 0;
                    Console.WriteLine();
                }

                Thread.Sleep(5000);
            }

            Console.WriteLine("Map generated!");

            Console.WriteLine();
            Console.WriteLine("Generation took: {0:#.##}s", generationResult.Result.TotalSeconds);
            Console.WriteLine();

            Console.WriteLine("Pokemon World Generator");
            Console.WriteLine("-----------------------");
            Console.WriteLine("-----------------------");

            Console.WriteLine();
            Console.WriteLine("Press a key to finish");
            Console.ReadKey();
        }
Exemplo n.º 5
0
        public override bool Update(Gore gore)
        {
            if ((double)gore.position.Y < Main.worldSurface * 16.0 + 8.0)
            {
                gore.alpha = 0;
            }
            else
            {
                gore.alpha = 100;
            }
            int num = 4;

            gore.frameCounter += 1;
            if (gore.frame <= 4)
            {
                int num2 = (int)(gore.position.X / 16f);
                int num3 = (int)(gore.position.Y / 16f) - 1;
                if (WorldGen.InWorld(num2, num3, 0) && !Main.tile[num2, num3].active())
                {
                    gore.active = false;
                }
                if (gore.frame == 0 || gore.frame == 1 || gore.frame == 2)
                {
                    num = 24 + Main.rand.Next(256);
                }
                if (gore.frame == 3)
                {
                    num = 24 + Main.rand.Next(96);
                }
                if ((int)gore.frameCounter >= num)
                {
                    gore.frameCounter = 0;
                    gore.frame       += 1;
                    if (gore.frame == 5)
                    {
                        int num4 = Gore.NewGore(gore.position, gore.velocity, gore.type, 1f);
                        Main.gore[num4].frame     = 9;
                        Main.gore[num4].velocity *= 0f;
                    }
                }
            }
            else if (gore.frame <= 6)
            {
                num = 8;
                if ((int)gore.frameCounter >= num)
                {
                    gore.frameCounter = 0;
                    gore.frame       += 1;
                    if (gore.frame == 7)
                    {
                        gore.active = false;
                    }
                }
            }
            else if (gore.frame <= 9)
            {
                num             = 6;
                gore.velocity.Y = gore.velocity.Y + 0.2f;
                if (gore.velocity.Y < 0.5f)
                {
                    gore.velocity.Y = 0.5f;
                }
                if (gore.velocity.Y > 12f)
                {
                    gore.velocity.Y = 12f;
                }
                if ((int)gore.frameCounter >= num)
                {
                    gore.frameCounter = 0;
                    gore.frame       += 1;
                }
                if (gore.frame > 9)
                {
                    gore.frame = 7;
                }
            }
            else
            {
                gore.velocity.Y = gore.velocity.Y + 0.1f;
                if ((int)gore.frameCounter >= num)
                {
                    gore.frameCounter = 0;
                    gore.frame       += 1;
                }
                gore.velocity *= 0f;
                if (gore.frame > 14)
                {
                    gore.active = false;
                }
            }
            Vector2 velocity = gore.velocity;

            gore.velocity = Collision.TileCollision(gore.position, gore.velocity, 16, 14, false, false, 1);
            if (gore.velocity != velocity)
            {
                if (gore.frame < 10)
                {
                    gore.frame        = 10;
                    gore.frameCounter = 0;
                    Main.PlaySound(39, (int)gore.position.X + 8, (int)gore.position.Y + 8, Main.rand.Next(2), 1f, 0f);
                }
            }
            else if (Collision.WetCollision(gore.position + gore.velocity, 16, 14))
            {
                if (gore.frame < 10)
                {
                    gore.frame        = 10;
                    gore.frameCounter = 0;
                    Main.PlaySound(39, (int)gore.position.X + 8, (int)gore.position.Y + 8, 2, 1f, 0f);
                }
                int num5 = (int)(gore.position.X + 8f) / 16;
                int num6 = (int)(gore.position.Y + 14f) / 16;
                if (Main.tile[num5, num6] != null && Main.tile[num5, num6].liquid > 0)
                {
                    gore.velocity  *= 0f;
                    gore.position.Y = (float)(num6 * 16 - (int)(Main.tile[num5, num6].liquid / 16));
                }
            }
            gore.position += gore.velocity;
            return(false);
        }
Exemplo n.º 6
0
        public override void AI()
        {
            if (npc.localAI[1] == 0f)
            {
                npc.localAI[1] = 1f;
                Init();
            }
            if (npc.ai[3] > 0f)
            {
                npc.realLife = (int)npc.ai[3];
            }
            if (!head && npc.timeLeft < 300)
            {
                npc.timeLeft = 300;
            }
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
            {
                npc.TargetClosest(true);
            }
            if (Main.player[npc.target].dead && npc.timeLeft > 300)
            {
                npc.timeLeft = 300;
            }
            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                if (!tail && npc.ai[0] == 0f)
                {
                    if (head)
                    {
                        npc.ai[3]    = (float)npc.whoAmI;
                        npc.realLife = npc.whoAmI;
                        npc.ai[2]    = (float)Main.rand.Next(minLength, maxLength + 1);
                        npc.ai[0]    = (float)NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), bodyType, npc.whoAmI);
                    }
                    else if (npc.ai[2] > 0f)
                    {
                        npc.ai[0] = (float)NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type, npc.whoAmI);
                    }
                    else
                    {
                        npc.ai[0] = (float)NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), tailType, npc.whoAmI);
                    }
                    Main.npc[(int)npc.ai[0]].ai[3]    = npc.ai[3];
                    Main.npc[(int)npc.ai[0]].realLife = npc.realLife;
                    Main.npc[(int)npc.ai[0]].ai[1]    = (float)npc.whoAmI;
                    Main.npc[(int)npc.ai[0]].ai[2]    = npc.ai[2] - 1f;
                    npc.netUpdate = true;
                }
                if (!head && (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].type != headType && Main.npc[(int)npc.ai[1]].type != bodyType))
                {
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.active = false;
                }
                if (!tail && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].type != bodyType && Main.npc[(int)npc.ai[0]].type != tailType))
                {
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.active = false;
                }
                if (!npc.active && Main.netMode == NetmodeID.Server)
                {
                    NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                }
            }
            int num180 = (int)(npc.position.X / 16f) - 1;
            int num181 = (int)((npc.position.X + (float)npc.width) / 16f) + 2;
            int num182 = (int)(npc.position.Y / 16f) - 1;
            int num183 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2;

            if (num180 < 0)
            {
                num180 = 0;
            }
            if (num181 > Main.maxTilesX)
            {
                num181 = Main.maxTilesX;
            }
            if (num182 < 0)
            {
                num182 = 0;
            }
            if (num183 > Main.maxTilesY)
            {
                num183 = Main.maxTilesY;
            }
            bool flag18 = flies;

            if (!flag18)
            {
                for (int num184 = num180; num184 < num181; num184++)
                {
                    for (int num185 = num182; num185 < num183; num185++)
                    {
                        if (Main.tile[num184, num185] != null && (Main.tile[num184, num185].nactive() && (Main.tileSolid[(int)Main.tile[num184, num185].type] || Main.tileSolidTop[(int)Main.tile[num184, num185].type] && Main.tile[num184, num185].frameY == 0) || Main.tile[num184, num185].liquid > 64))
                        {
                            Vector2 vector17;
                            vector17.X = (float)(num184 * 16);
                            vector17.Y = (float)(num185 * 16);
                            if (npc.position.X + (float)npc.width > vector17.X && npc.position.X < vector17.X + 16f && npc.position.Y + (float)npc.height > vector17.Y && npc.position.Y < vector17.Y + 16f)
                            {
                                flag18 = true;
                                if (Main.rand.NextBool(100) && npc.behindTiles && Main.tile[num184, num185].nactive())
                                {
                                    WorldGen.KillTile(num184, num185, true, true, false);
                                }
                                if (Main.netMode != NetmodeID.MultiplayerClient && Main.tile[num184, num185].type == 2)
                                {
                                    ushort arg_BFCA_0 = Main.tile[num184, num185 - 1].type;
                                }
                            }
                        }
                    }
                }
            }
            if (!flag18 && head)
            {
                Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height);
                int       num186    = 1000;
                bool      flag19    = true;
                for (int num187 = 0; num187 < 255; num187++)
                {
                    if (Main.player[num187].active)
                    {
                        Rectangle rectangle2 = new Rectangle((int)Main.player[num187].position.X - num186, (int)Main.player[num187].position.Y - num186, num186 * 2, num186 * 2);
                        if (rectangle.Intersects(rectangle2))
                        {
                            flag19 = false;
                            break;
                        }
                    }
                }
                if (flag19)
                {
                    flag18 = true;
                }
            }
            if (directional)
            {
                if (npc.velocity.X < 0f)
                {
                    npc.spriteDirection = 1;
                }
                else if (npc.velocity.X > 0f)
                {
                    npc.spriteDirection = -1;
                }
            }
            float   num188   = speed;
            float   num189   = turnSpeed;
            Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            float   num191   = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
            float   num192   = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);

            num191     = (float)((int)(num191 / 16f) * 16);
            num192     = (float)((int)(num192 / 16f) * 16);
            vector18.X = (float)((int)(vector18.X / 16f) * 16);
            vector18.Y = (float)((int)(vector18.Y / 16f) * 16);
            num191    -= vector18.X;
            num192    -= vector18.Y;
            float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192));

            if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length)
            {
                try {
                    vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                    num191   = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X;
                    num192   = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y;
                }
                catch {
                }
                npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f;
                num193       = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192));
                int num194 = npc.width;
                num193         = (num193 - (float)num194) / num193;
                num191        *= num193;
                num192        *= num193;
                npc.velocity   = Vector2.Zero;
                npc.position.X = npc.position.X + num191;
                npc.position.Y = npc.position.Y + num192;
                if (directional)
                {
                    if (num191 < 0f)
                    {
                        npc.spriteDirection = 1;
                    }
                    if (num191 > 0f)
                    {
                        npc.spriteDirection = -1;
                    }
                }
            }
            else
            {
                if (!flag18)
                {
                    npc.TargetClosest(true);
                    npc.velocity.Y = npc.velocity.Y + 0.11f;
                    if (npc.velocity.Y > num188)
                    {
                        npc.velocity.Y = num188;
                    }
                    if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.4)
                    {
                        if (npc.velocity.X < 0f)
                        {
                            npc.velocity.X = npc.velocity.X - num189 * 1.1f;
                        }
                        else
                        {
                            npc.velocity.X = npc.velocity.X + num189 * 1.1f;
                        }
                    }
                    else if (npc.velocity.Y == num188)
                    {
                        if (npc.velocity.X < num191)
                        {
                            npc.velocity.X = npc.velocity.X + num189;
                        }
                        else if (npc.velocity.X > num191)
                        {
                            npc.velocity.X = npc.velocity.X - num189;
                        }
                    }
                    else if (npc.velocity.Y > 4f)
                    {
                        if (npc.velocity.X < 0f)
                        {
                            npc.velocity.X = npc.velocity.X + num189 * 0.9f;
                        }
                        else
                        {
                            npc.velocity.X = npc.velocity.X - num189 * 0.9f;
                        }
                    }
                }
                else
                {
                    if (!flies && npc.behindTiles && npc.soundDelay == 0)
                    {
                        float num195 = num193 / 40f;
                        if (num195 < 10f)
                        {
                            num195 = 10f;
                        }
                        if (num195 > 20f)
                        {
                            num195 = 20f;
                        }
                        npc.soundDelay = (int)num195;
                        Main.PlaySound(SoundID.Roar, npc.position, 1);
                    }
                    num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192));
                    float num196 = System.Math.Abs(num191);
                    float num197 = System.Math.Abs(num192);
                    float num198 = num188 / num193;
                    num191 *= num198;
                    num192 *= num198;
                    if (ShouldRun())
                    {
                        bool flag20 = true;
                        for (int num199 = 0; num199 < 255; num199++)
                        {
                            if (Main.player[num199].active && !Main.player[num199].dead && Main.player[num199].ZoneCorrupt)
                            {
                                flag20 = false;
                            }
                        }
                        if (flag20)
                        {
                            if (Main.netMode != NetmodeID.MultiplayerClient && (double)(npc.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0)
                            {
                                npc.active = false;
                                int num200 = (int)npc.ai[0];
                                while (num200 > 0 && num200 < 200 && Main.npc[num200].active && Main.npc[num200].aiStyle == npc.aiStyle)
                                {
                                    int num201 = (int)Main.npc[num200].ai[0];
                                    Main.npc[num200].active = false;
                                    npc.life = 0;
                                    if (Main.netMode == NetmodeID.Server)
                                    {
                                        NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num200, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                    num200 = num201;
                                }
                                if (Main.netMode == NetmodeID.Server)
                                {
                                    NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                }
                            }
                            num191 = 0f;
                            num192 = num188;
                        }
                    }
                    bool flag21 = false;
                    if (npc.type == NPCID.WyvernHead)
                    {
                        if ((npc.velocity.X > 0f && num191 < 0f || npc.velocity.X < 0f && num191 > 0f || npc.velocity.Y > 0f && num192 < 0f || npc.velocity.Y < 0f && num192 > 0f) && System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y) > num189 / 2f && num193 < 300f)
                        {
                            flag21 = true;
                            if (System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y) < num188)
                            {
                                npc.velocity *= 1.1f;
                            }
                        }
                        if (npc.position.Y > Main.player[npc.target].position.Y || (double)(Main.player[npc.target].position.Y / 16f) > Main.worldSurface || Main.player[npc.target].dead)
                        {
                            flag21 = true;
                            if (System.Math.Abs(npc.velocity.X) < num188 / 2f)
                            {
                                if (npc.velocity.X == 0f)
                                {
                                    npc.velocity.X = npc.velocity.X - (float)npc.direction;
                                }
                                npc.velocity.X = npc.velocity.X * 1.1f;
                            }
                            else
                            {
                                if (npc.velocity.Y > -num188)
                                {
                                    npc.velocity.Y = npc.velocity.Y - num189;
                                }
                            }
                        }
                    }
                    if (!flag21)
                    {
                        if (npc.velocity.X > 0f && num191 > 0f || npc.velocity.X < 0f && num191 < 0f || npc.velocity.Y > 0f && num192 > 0f || npc.velocity.Y < 0f && num192 < 0f)
                        {
                            if (npc.velocity.X < num191)
                            {
                                npc.velocity.X = npc.velocity.X + num189;
                            }
                            else
                            {
                                if (npc.velocity.X > num191)
                                {
                                    npc.velocity.X = npc.velocity.X - num189;
                                }
                            }
                            if (npc.velocity.Y < num192)
                            {
                                npc.velocity.Y = npc.velocity.Y + num189;
                            }
                            else
                            {
                                if (npc.velocity.Y > num192)
                                {
                                    npc.velocity.Y = npc.velocity.Y - num189;
                                }
                            }
                            if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && (npc.velocity.X > 0f && num191 < 0f || npc.velocity.X < 0f && num191 > 0f))
                            {
                                if (npc.velocity.Y > 0f)
                                {
                                    npc.velocity.Y = npc.velocity.Y + num189 * 2f;
                                }
                                else
                                {
                                    npc.velocity.Y = npc.velocity.Y - num189 * 2f;
                                }
                            }
                            if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && (npc.velocity.Y > 0f && num192 < 0f || npc.velocity.Y < 0f && num192 > 0f))
                            {
                                if (npc.velocity.X > 0f)
                                {
                                    npc.velocity.X = npc.velocity.X + num189 * 2f;
                                }
                                else
                                {
                                    npc.velocity.X = npc.velocity.X - num189 * 2f;
                                }
                            }
                        }
                        else
                        {
                            if (num196 > num197)
                            {
                                if (npc.velocity.X < num191)
                                {
                                    npc.velocity.X = npc.velocity.X + num189 * 1.1f;
                                }
                                else if (npc.velocity.X > num191)
                                {
                                    npc.velocity.X = npc.velocity.X - num189 * 1.1f;
                                }
                                if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5)
                                {
                                    if (npc.velocity.Y > 0f)
                                    {
                                        npc.velocity.Y = npc.velocity.Y + num189;
                                    }
                                    else
                                    {
                                        npc.velocity.Y = npc.velocity.Y - num189;
                                    }
                                }
                            }
                            else
                            {
                                if (npc.velocity.Y < num192)
                                {
                                    npc.velocity.Y = npc.velocity.Y + num189 * 1.1f;
                                }
                                else if (npc.velocity.Y > num192)
                                {
                                    npc.velocity.Y = npc.velocity.Y - num189 * 1.1f;
                                }
                                if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5)
                                {
                                    if (npc.velocity.X > 0f)
                                    {
                                        npc.velocity.X = npc.velocity.X + num189;
                                    }
                                    else
                                    {
                                        npc.velocity.X = npc.velocity.X - num189;
                                    }
                                }
                            }
                        }
                    }
                }
                npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f;
                if (head)
                {
                    if (flag18)
                    {
                        if (npc.localAI[0] != 1f)
                        {
                            npc.netUpdate = true;
                        }
                        npc.localAI[0] = 1f;
                    }
                    else
                    {
                        if (npc.localAI[0] != 0f)
                        {
                            npc.netUpdate = true;
                        }
                        npc.localAI[0] = 0f;
                    }
                    if ((npc.velocity.X > 0f && npc.oldVelocity.X < 0f || npc.velocity.X < 0f && npc.oldVelocity.X > 0f || npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f || npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f) && !npc.justHit)
                    {
                        npc.netUpdate = true;
                        return;
                    }
                }
            }
            CustomBehavior();
        }
Exemplo n.º 7
0
        public override void Convert(int i, int j, int size = 4)
        {
            for (int k = i - size; k <= i + size; k++)
            {
                for (int l = j - size; l <= j + size; l++)
                {
                    if (WorldGen.InWorld(k, l, 1) && Math.Abs(k - i) + Math.Abs(l - j) < Math.Sqrt(size * size + size * size))
                    {
                        if (Main.tile[k, l] == null)
                        {
                            Main.tile[k, l] = new Tile();
                        }
                        int type = (int)Main.tile[k, l].type;
                        if (type == 1 || type == 25 || type == 117 || type == 203)
                        {
                            int chance = Main.rand.Next(100);
                            if (chance < 20)
                            {
                                chance = Main.rand.Next(100);
                                if (chance < 50)
                                {
                                    if (Main.rand.Next(2) == 0)
                                    {
                                        Main.tile[k, l].type = 66;
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = 67;
                                    }
                                }
                                else if (chance < 90)
                                {
                                    switch (Main.rand.Next(3))
                                    {
                                    case 0:
                                        Main.tile[k, l].type = 63;
                                        break;

                                    case 1:
                                        Main.tile[k, l].type = 64;
                                        break;

                                    default:
                                        Main.tile[k, l].type = 65;
                                        break;
                                    }
                                }
                                else
                                {
                                    Main.tile[k, l].type = 68;
                                }
                            }
                            else if (chance >= 70 && Main.hardMode && WorldGen.oreTier1 != -1)
                            {
                                chance = Main.rand.Next(100);
                                if (chance >= 85 && WorldGen.oreTier3 != -1)
                                {
                                    if (Main.rand.Next(5) == 0)
                                    {
                                        Main.tile[k, l].type = (ushort)((WorldGen.oreTier3 == 111) ? 223 : 111);
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = (ushort)WorldGen.oreTier3;
                                    }
                                }
                                else if (chance < 35 && WorldGen.oreTier2 != -1)
                                {
                                    if (Main.rand.Next(5) == 0)
                                    {
                                        Main.tile[k, l].type = (ushort)((WorldGen.oreTier2 == 108) ? 222 : 108);
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = (ushort)WorldGen.oreTier2;
                                    }
                                }
                                else
                                {
                                    if (Main.rand.Next(5) == 0)
                                    {
                                        Main.tile[k, l].type = (ushort)((WorldGen.oreTier1 == 107) ? 221 : 107);
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = (ushort)WorldGen.oreTier1;
                                    }
                                }
                            }
                            else
                            {
                                chance = Main.rand.Next(100);
                                if (chance >= 85)
                                {
                                    if (Main.rand.Next(5) == 0)
                                    {
                                        Main.tile[k, l].type = (ushort)((WorldGen.GoldTierOre == 8) ? 169 : 8);
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = WorldGen.GoldTierOre;
                                    }
                                }
                                else if (chance >= 65)
                                {
                                    if (Main.rand.Next(5) == 0)
                                    {
                                        Main.tile[k, l].type = (ushort)((WorldGen.SilverTierOre == 9) ? 168 : 9);
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = WorldGen.SilverTierOre;
                                    }
                                }
                                else if (chance >= 40)
                                {
                                    if (Main.rand.Next(5) == 0)
                                    {
                                        Main.tile[k, l].type = (ushort)((WorldGen.IronTierOre == 6) ? 167 : 6);
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = WorldGen.IronTierOre;
                                    }
                                }
                                else
                                {
                                    if (Main.rand.Next(5) == 0)
                                    {
                                        Main.tile[k, l].type = (ushort)((WorldGen.CopperTierOre == 7) ? 166 : 7);
                                    }
                                    else
                                    {
                                        Main.tile[k, l].type = WorldGen.CopperTierOre;
                                    }
                                }
                            }
                            WorldGen.SquareTileFrame(k, l, true);
                            NetMessage.SendTileSquare(-1, k, l, 1);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        //npc.ai[0] = timer before the NPC shoots
        //npc.ai[1] = jump timer
        //npc.ai[2] = tile detection change

        public override void AI()
        {
            Player target = Main.player[npc.target];

            if (target.dead || npc.target == -1)
            {
                npc.TargetClosest();
            }
            if (npc.velocity.Y < 3f)
            {
                npc.velocity.Y += 0.05f;
            }
            if (npc.ai[1] > 0f)
            {
                npc.ai[1]--;
            }
            if (npc.Distance(target.Center) <= 200f)
            {
                npc.ai[0]++;
                npc.velocity.X = 0f;
            }
            else
            {
                npc.ai[0] = 0f;
                if (npc.position.X > target.position.X + 200f)
                {
                    npc.velocity.X = -1f;
                }
                if (npc.position.X < target.position.X - 200f)
                {
                    npc.velocity.X = 1f;
                }
                if (WorldGen.SolidOrSlopedTile((int)(npc.position.X / 16) + (int)npc.ai[2] * npc.direction, (int)(npc.position.Y / 16f) + 2) && npc.ai[1] <= 0f)
                {
                    npc.velocity.Y = -6f;
                    npc.ai[1]     += 40f;
                }
            }
            //Main.NewText((int)((npc.position.X / 16) + npc.ai[2] * npc.direction) + "; " + (int)((npc.position.Y / 16f) + 2) + "; " + (int)(Main.MouseWorld.X / 16f) + "; " + (Main.MouseWorld.Y / 16f));     Testing stuff to see where detection is and where it needs to be
            if (npc.justHit)
            {
                npc.ai[0] = 0f;
            }
            if (npc.ai[0] >= 90f)
            {
                npc.ai[0] = 0f;
                Vector2 shootVel = target.Center - npc.Center;
                if (shootVel == Vector2.Zero)
                {
                    shootVel = new Vector2(0f, 1f);
                }
                shootVel.Normalize();
                shootVel *= 10f;
                int proj = Projectile.NewProjectile(npc.Center.X + (4f * npc.direction), npc.Center.Y - 5f, shootVel.X, shootVel.Y, mod.ProjectileType("MinerLightning"), npc.damage, 2f);
                Main.projectile[proj].netUpdate = true;
                npc.netUpdate = true;
            }
            if (target.position.X > npc.position.X)
            {
                npc.direction = 1;
                npc.ai[2]     = 3f;
            }
            if (target.position.X < npc.position.X)
            {
                npc.direction = -1;
                npc.ai[2]     = 1f;
            }
        }
Exemplo n.º 9
0
	void Awake ()
	{
		//instantiate singleton
		m_instance = this;
	}
Exemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     wl = GameObject.FindGameObjectWithTag("world").GetComponent<WorldLogic>();
     wg = GameObject.FindGameObjectWithTag("world").GetComponent<WorldGen>();
     transform.position = new Vector3(Mathf.RoundToInt(wg.transform.position.x + (wg.width / 2)), Mathf.RoundToInt(wg.transform.position.y - (wg.height / 2)), transform.position.z);
 }
Exemplo n.º 11
0
        private void GenerateTunnelToSurface(int i, int j)
        {
            double  num    = GenBase._random.Next(5, 11);
            Vector2 vector = default(Vector2);

            vector.X = i;
            vector.Y = j;
            Vector2 vector2 = default(Vector2);

            vector2.X = (float)GenBase._random.Next(-10, 11) * 0.1f;
            vector2.Y = (float)GenBase._random.Next(10, 20) * 0.1f;
            int  num2 = 0;
            bool flag = true;

            while (flag)
            {
                if ((double)vector.Y < Main.worldSurface)
                {
                    if (WorldGen.drunkWorldGen)
                    {
                        flag = false;
                    }
                    int value  = (int)vector.X;
                    int value2 = (int)vector.Y;
                    value  = Utils.Clamp(value, 10, Main.maxTilesX - 10);
                    value2 = Utils.Clamp(value2, 10, Main.maxTilesY - 10);
                    if (value2 < 5)
                    {
                        value2 = 5;
                    }
                    if (Main.tile[value, value2].wall == 0 && !Main.tile[value, value2].active() && Main.tile[value, value2 - 3].wall == 0 && !Main.tile[value, value2 - 3].active() && Main.tile[value, value2 - 1].wall == 0 && !Main.tile[value, value2 - 1].active() && Main.tile[value, value2 - 4].wall == 0 && !Main.tile[value, value2 - 4].active() && Main.tile[value, value2 - 2].wall == 0 && !Main.tile[value, value2 - 2].active() && Main.tile[value, value2 - 5].wall == 0 && !Main.tile[value, value2 - 5].active())
                    {
                        flag = false;
                    }
                }
                JungleX = (int)vector.X;
                num    += (double)((float)GenBase._random.Next(-20, 21) * 0.1f);
                if (num < 5.0)
                {
                    num = 5.0;
                }
                if (num > 10.0)
                {
                    num = 10.0;
                }
                int value3 = (int)((double)vector.X - num * 0.5);
                int value4 = (int)((double)vector.X + num * 0.5);
                int value5 = (int)((double)vector.Y - num * 0.5);
                int value6 = (int)((double)vector.Y + num * 0.5);
                int num3   = Utils.Clamp(value3, 10, Main.maxTilesX - 10);
                value4 = Utils.Clamp(value4, 10, Main.maxTilesX - 10);
                value5 = Utils.Clamp(value5, 10, Main.maxTilesY - 10);
                value6 = Utils.Clamp(value6, 10, Main.maxTilesY - 10);
                for (int k = num3; k < value4; k++)
                {
                    for (int l = value5; l < value6; l++)
                    {
                        if ((double)(Math.Abs((float)k - vector.X) + Math.Abs((float)l - vector.Y)) < num * 0.5 * (1.0 + (double)GenBase._random.Next(-10, 11) * 0.015))
                        {
                            WorldGen.KillTile(k, l);
                        }
                    }
                }
                num2++;
                if (num2 > 10 && GenBase._random.Next(50) < num2)
                {
                    num2 = 0;
                    int num4 = -2;
                    if (GenBase._random.Next(2) == 0)
                    {
                        num4 = 2;
                    }
                    WorldGen.TileRunner((int)vector.X, (int)vector.Y, GenBase._random.Next(3, 20), GenBase._random.Next(10, 100), -1, addTile: false, num4);
                }
                vector    += vector2;
                vector2.Y += (float)GenBase._random.Next(-10, 11) * 0.01f;
                if (vector2.Y > 0f)
                {
                    vector2.Y = 0f;
                }
                if (vector2.Y < -2f)
                {
                    vector2.Y = -2f;
                }
                vector2.X += (float)GenBase._random.Next(-10, 11) * 0.1f;
                if (vector.X < (float)(i - 200))
                {
                    vector2.X += (float)GenBase._random.Next(5, 21) * 0.1f;
                }
                if (vector.X > (float)(i + 200))
                {
                    vector2.X -= (float)GenBase._random.Next(5, 21) * 0.1f;
                }
                if ((double)vector2.X > 1.5)
                {
                    vector2.X = 1.5f;
                }
                if ((double)vector2.X < -1.5)
                {
                    vector2.X = -1.5f;
                }
            }
        }
Exemplo n.º 12
0
 private void PlaceFirstPassMud(int x, int y, int xSpeedScale)
 {
     WorldGen.mudWall = true;
     WorldGen.TileRunner(x, y, GenBase._random.Next((int)(250f * _worldScale), (int)(500f * _worldScale)), GenBase._random.Next(50, 150), 59, addTile: false, DungeonSide * xSpeedScale);
     WorldGen.mudWall = false;
 }
Exemplo n.º 13
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result1;

            if (!WorldUtils.Find(origin,
                                 Searches.Chain(new Searches.Down(200), (GenCondition) new Conditions.IsSolid()),
                                 out result1) || result1 == origin)
            {
                return(false);
            }
            var room1 = GetRoom(result1);
            var room2 = GetRoom(new Point(room1.Center.X, room1.Y + 1));
            var room3 =
                GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));

            room3.Y = room1.Y + room1.Height - 1;
            var num1 = RoomSolidPrecentage(room2);
            var num2 = RoomSolidPrecentage(room3);

            room1.Y += 3;
            room2.Y += 3;
            room3.Y += 3;
            var rectangleList1 = new List <Rectangle>();

            if (_random.NextFloat() > num1 + 0.200000002980232)
            {
                rectangleList1.Add(room2);
            }
            else
            {
                room2 = room1;
            }
            rectangleList1.Add(room1);
            if (_random.NextFloat() > num2 + 0.200000002980232)
            {
                rectangleList1.Add(room3);
            }
            else
            {
                room3 = room1;
            }
            foreach (var rectangle in rectangleList1)
            {
                if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220)
                {
                    return(false);
                }
            }

            var resultsOutput = new Dictionary <ushort, int>();

            foreach (var rectangle in rectangleList1)
            {
                WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10),
                               new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20),
                               new Actions.TileScanner((ushort)0, (ushort)59, (ushort)147, (ushort)1, (ushort)161,
                                                       (ushort)53, (ushort)396, (ushort)397, (ushort)368, (ushort)367, (ushort)60,
                                                       (ushort)70)
                               .Output(resultsOutput));
            }
            var tupleList1 = new List <Tuple <BuildData, int> >();

            tupleList1.Add(Tuple.Create(BuildData.Default,
                                        resultsOutput[0] + resultsOutput[1]));
            tupleList1.Add(Tuple.Create(BuildData.Jungle,
                                        resultsOutput[59] + resultsOutput[60] * 10));
            tupleList1.Add(Tuple.Create(BuildData.Mushroom,
                                        resultsOutput[59] + resultsOutput[70] * 10));
            tupleList1.Add(Tuple.Create(BuildData.Snow,
                                        resultsOutput[147] + resultsOutput[161]));
            tupleList1.Add(Tuple.Create(BuildData.Desert,
                                        resultsOutput[397] + resultsOutput[396] + resultsOutput[53]));
            tupleList1.Add(Tuple.Create(BuildData.Granite,
                                        resultsOutput[368]));
            tupleList1.Add(Tuple.Create(BuildData.Marble,
                                        resultsOutput[367]));
            tupleList1.Sort(SortBiomeResults);
            var buildData = tupleList1[0].Item1;

            foreach (var area in rectangleList1)
            {
                if (buildData != BuildData.Granite)
                {
                    Point result2;
                    if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2),
                                        Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false),
                                                       (GenCondition) new Conditions.HasLava()), out result2))
                    {
                        return(false);
                    }
                }

                if (!structures.CanPlace(area, _blacklistedTiles, 5))
                {
                    return(false);
                }
            }

            var val1_1         = room1.X;
            var val1_2         = room1.X + room1.Width - 1;
            var rectangleList2 = new List <Rectangle>();

            foreach (var rectangle in rectangleList1)
            {
                val1_1 = Math.Min(val1_1, rectangle.X);
                val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1);
            }

            var num3 = 6;

            while (num3 > 4 && (val1_2 - val1_1) % num3 != 0)
            {
                --num3;
            }
            var x1 = val1_1;

            while (x1 <= val1_2)
            {
                for (var index1 = 0; index1 < rectangleList1.Count; ++index1)
                {
                    var rectangle = rectangleList1[index1];
                    if (x1 >= rectangle.X && x1 < rectangle.X + rectangle.Width)
                    {
                        var y    = rectangle.Y + rectangle.Height;
                        var num4 = 50;
                        for (var index2 = index1 + 1; index2 < rectangleList1.Count; ++index2)
                        {
                            if (x1 >= rectangleList1[index2].X &&
                                x1 < rectangleList1[index2].X + rectangleList1[index2].Width)
                            {
                                num4 = Math.Min(num4, rectangleList1[index2].Y - y);
                            }
                        }

                        if (num4 > 0)
                        {
                            Point result2;
                            var   flag = WorldUtils.Find(new Point(x1, y),
                                                         Searches.Chain(new Searches.Down(num4),
                                                                        (GenCondition) new Conditions.IsSolid()), out result2);
                            if (num4 < 50)
                            {
                                flag    = true;
                                result2 = new Point(x1, y + num4);
                            }

                            if (flag)
                            {
                                rectangleList2.Add(new Rectangle(x1, y, 1, result2.Y - y));
                            }
                        }
                    }
                }

                x1 += num3;
            }

            var pointList1 = new List <Point>();

            foreach (var rectangle in rectangleList1)
            {
                int exitY;
                if (FindSideExit(
                        new Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1,
                                      rectangle.Height - 2), false, out exitY))
                {
                    pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY));
                }
                if (FindSideExit(
                        new Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true,
                        out exitY))
                {
                    pointList1.Add(new Point(rectangle.X, exitY));
                }
            }

            var tupleList2 = new List <Tuple <Point, Point> >();

            for (var index = 1; index < rectangleList1.Count; ++index)
            {
                var rectangle1 = rectangleList1[index];
                var rectangle2 = rectangleList1[index - 1];
                if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width))
                {
                    tupleList2.Add(new Tuple <Point, Point>(
                                       new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1),
                                       new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1,
                                                 rectangle1.Y + rectangle1.Height - 1)));
                }
                else
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1),
                                                            new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1)));
                }
            }

            var pointList2 = new List <Point>();
            int exitX;

            if (FindVerticalExit(new Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1),
                                 true, out exitX))
            {
                pointList2.Add(new Point(exitX, room2.Y));
            }
            if (FindVerticalExit(
                    new Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1),
                    false, out exitX))
            {
                pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1));
            }
            foreach (var area in rectangleList1)
            {
                WorldUtils.Gen(new Point(area.X, area.Y), new Shapes.Rectangle(area.Width, area.Height),
                               Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile, false, true),
                                             (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(area.X + 1, area.Y + 1),
                               new Shapes.Rectangle(area.Width - 2, area.Height - 2),
                               Actions.Chain((GenAction) new Actions.ClearTile(true),
                                             (GenAction) new Actions.PlaceWall(buildData.Wall, true)));
                structures.AddStructure(area, 8);
            }

            foreach (var tuple in tupleList2)
            {
                var origin1 = tuple.Item1;
                var point   = tuple.Item2;
                var num4    = point.X > origin1.X ? 1 : -1;
                var data    = new ShapeData();
                for (var y = 0; y < point.Y - origin1.Y; ++y)
                {
                    data.Add(num4 * (y + 1), y);
                }
                WorldUtils.Gen(origin1, new ModShapes.All(data),
                               Actions.Chain((GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle),
                                             (GenAction) new Actions.SetSlope(num4 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(origin1.X + (num4 == 1 ? 1 : -4), origin1.Y - 1),
                               new Shapes.Rectangle(4, 1),
                               Actions.Chain((GenAction) new Actions.Clear(),
                                             (GenAction) new Actions.PlaceWall(buildData.Wall, true),
                                             (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle),
                                             (GenAction) new Actions.SetFrames(true)));
            }

            foreach (var origin1 in pointList1)
            {
                WorldUtils.Gen(origin1, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true));
                WorldGen.PlaceTile(origin1.X, origin1.Y, 10, true, true, -1, buildData.DoorStyle);
            }

            foreach (var origin1 in pointList2)
            {
                var rectangle = new Shapes.Rectangle(3, 1);
                var action    = Actions.Chain((GenAction) new Actions.ClearMetadata(),
                                              (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle),
                                              (GenAction) new Actions.SetFrames(true));
                WorldUtils.Gen(origin1, rectangle, action);
            }

            foreach (var rectangle in rectangleList2)
            {
                if (rectangle.Height > 1 && _tiles[rectangle.X, rectangle.Y - 1].type != 19)
                {
                    WorldUtils.Gen(new Point(rectangle.X, rectangle.Y),
                                   new Shapes.Rectangle(rectangle.Width, rectangle.Height),
                                   Actions.Chain((GenAction) new Actions.SetTile(124, false, true),
                                                 (GenAction) new Actions.SetFrames(true)));
                    var tile = _tiles[rectangle.X, rectangle.Y + rectangle.Height];
                    tile.slope(0);
                    tile.halfBrick(false);
                }
            }

            var pointArray = new Point[7]
            {
                new Point(14, buildData.TableStyle), new Point(16, 0), new Point(18, buildData.WorkbenchStyle),
                new Point(86, 0), new Point(87, buildData.PianoStyle), new Point(94, 0),
                new Point(101, buildData.BookcaseStyle)
            };

            foreach (var rectangle in rectangleList1)
            {
                var num4 = rectangle.Width / 8;
                var num5 = rectangle.Width / (num4 + 1);
                var num6 = _random.Next(2);
                for (var index1 = 0; index1 < num4; ++index1)
                {
                    var num7 = (index1 + 1) * num5 + rectangle.X;
                    switch (index1 + num6 % 2)
                    {
                    case 0:
                        var num8    = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5);
                        var vector2 = WorldGen.randHousePicture();
                        var x2      = (int)vector2.X;
                        var y       = (int)vector2.Y;
                        if (!WorldGen.nearPicture(num7, num8))
                        {
                            WorldGen.PlaceTile(num7, num8, x2, true, false, -1, y);
                        }

                        break;

                    case 1:
                        var j = rectangle.Y + 1;
                        WorldGen.PlaceTile(num7, j, 34, true, false, -1, _random.Next(6));
                        for (var index2 = -1; index2 < 2; ++index2)
                        {
                            for (var index3 = 0; index3 < 3; ++index3)
                            {
                                _tiles[index2 + num7, index3 + j].frameX += 54;
                            }
                        }

                        break;
                    }
                }

                var num9 = rectangle.Width / 8 + 3;
                WorldGen.SetupStatueList();
                for (; num9 > 0; --num9)
                {
                    var num7 = _random.Next(rectangle.Width - 3) + 1 + rectangle.X;
                    var num8 = rectangle.Y + rectangle.Height - 2;
                    switch (_random.Next(4))
                    {
                    case 0:
                        WorldGen.PlaceSmallPile(num7, num8, _random.Next(31, 34), 1, 185);
                        break;

                    case 1:
                        WorldGen.PlaceTile(num7, num8, 186, true, false, -1, _random.Next(22, 26));
                        break;

                    case 2:
                        var index = _random.Next(2, WorldGen.statueList.Length);
                        WorldGen.PlaceTile(num7, num8, WorldGen.statueList[index].X, true, false, -1,
                                           WorldGen.statueList[index].Y);
                        if (WorldGen.StatuesWithTraps.Contains(index))
                        {
                            WorldGen.PlaceStatueTrap(num7, num8);
                        }

                        break;

                    case 3:
                        var point = Utils.SelectRandom(_random, pointArray);
                        WorldGen.PlaceTile(num7, num8, point.X, true, false, -1, point.Y);
                        break;
                    }
                }
            }

            foreach (var room4 in rectangleList1)
            {
                buildData.ProcessRoom(room4);
            }
            var flag1 = false;

            foreach (var rectangle in rectangleList1)
            {
                var j     = rectangle.Height - 1 + rectangle.Y;
                var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                var num4  = 0;
                while (num4 < 10 && !(flag1 =
                                          WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0,
                                                                  false, Style)))
                {
                    ++num4;
                }
                if (!flag1)
                {
                    var i = rectangle.X + 2;
                    while (i <= rectangle.X + rectangle.Width - 2 &&
                           !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                    {
                        ++i;
                    }
                    if (flag1)
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            if (!flag1)
            {
                foreach (var rectangle in rectangleList1)
                {
                    var j     = rectangle.Y - 1;
                    var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    var num4  = 0;
                    while (num4 < 10 && !(flag1 =
                                              WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0,
                                                                      false, Style)))
                    {
                        ++num4;
                    }
                    if (!flag1)
                    {
                        var i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 &&
                               !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                        {
                            ++i;
                        }
                        if (flag1)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (!flag1)
            {
                for (var index = 0; index < 1000; ++index)
                {
                    var i     = _random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30);
                    var j     = _random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30);
                    var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    if (WorldGen.AddBuriedChest(i, j, 0, false, Style))
                    {
                        break;
                    }
                }
            }

            if (buildData == BuildData.Jungle && _sharpenerCount < _random.Next(2, 5))
            {
                var flag2 = false;
                foreach (var rectangle in rectangleList1)
                {
                    var j = rectangle.Height - 2 + rectangle.Y;
                    for (var index = 0; index < 10; ++index)
                    {
                        var i = _random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 377, true, true, -1, 0);
                        if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 377)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        var i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 &&
                               !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (flag2)
                {
                    ++_sharpenerCount;
                }
            }

            if (buildData == BuildData.Desert && _extractinatorCount < _random.Next(2, 5))
            {
                var flag2 = false;
                foreach (var rectangle in rectangleList1)
                {
                    var j = rectangle.Height - 2 + rectangle.Y;
                    for (var index = 0; index < 10; ++index)
                    {
                        var i = _random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 219, true, true, -1, 0);
                        if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 219)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        var i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 &&
                               !(flag2 = WorldGen.PlaceTile(i, j, 219, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (flag2)
                {
                    ++_extractinatorCount;
                }
            }

            return(true);
        }
Exemplo n.º 14
0
	void Start ()
	{
		worldGen = WorldGen.instance;
		//AStarSetup();
	}
Exemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     food_targets = new List<Vertex>();
     dig_targets = new List<Vertex>();
     fill_targets = new List<Vertex>();
     food_counts = new Dictionary<Vertex, int>();
     dig_counts = new Dictionary<Vertex, int>();
     ferreted_burrows = new List<Burrow>();
     wg = gameObject.GetComponent<WorldGen>();
     ass = gameObject.GetComponent<AudioSource>();
     ass2 = Camera.main.gameObject.GetComponent<AudioSource>();
     ass.clip = seasons[season];
     ass.Play();
     last_season = Time.time;
     burrows = new List<Burrow>();
 }
Exemplo n.º 16
0
        public override bool PreAI()
        {
            Player P          = Main.player[npc.target];
            bool   expertMode = Main.expertMode;

            if (Main.player[npc.target].dead)
            {
                npc.velocity.Y = npc.velocity.Y + 0.11f;
                npc.ai[3]++;
                if (npc.ai[3] >= 300)
                {
                    npc.active = false;
                }
            }
            else
            {
                if (Main.dayTime)
                {
                    if (dayTime == 0)
                    {
                        Main.NewText("Times up buddy, I'll tear you apart", Color.Purple.R, Color.Purple.G, Color.Purple.B);
                        speed      += 5;
                        npc.damage += 50;
                        dayTime++;
                    }
                }
                if (halfLife == 0)
                {
                    if (npc.life <= npc.lifeMax * 0.4f)
                    {
                        npc.damage += 25;
                        speed      += 5;
                        Main.NewText("Ill feast upon your soul just like I did with the countless others who challenged me", Color.Purple.R, Color.Purple.G, Color.Purple.B);
                        halfLife++;
                    }
                }
                if (!speech)
                {
                    if (Main.autoPause == true)
                    {
                        Main.NewText("Using autopause huh? What a wimp", Color.LightCyan.R, Color.LightCyan.G, Color.LightCyan.B);
                    }
                    speech = true;
                }
                if (npc.localAI[1] == 0)
                {
                    int soulCount = Main.expertMode ? 7 : 5;
                    for (int l = 0; l < soulCount; l++)
                    {
                        //cos = y, sin = x
                        int distance = 360 / soulCount;
                        int orbital  = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(l * distance) * 150)), (int)(npc.Center.Y + (Math.Cos(l * distance) * 150)), mod.NPCType("BarrenSoul"), npc.whoAmI, l * distance, npc.whoAmI);
                    }
                    npc.localAI[1]++;
                }
                roarTimer--;
                if (roarTimer <= 0)
                {
                    Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 10);
                    roarTimer = 300 + Main.rand.Next(1, 400);
                }
                aiTimer++;
                if (aiTimer > 1750)
                {
                    aiTimer = 0;
                }
                shootTimer++;
                if (shootTimer >= 500)
                {
                    int numProj = Main.expertMode ? 50 : 40;
                    for (int i = 0; i < numProj; ++i)
                    {
                        Projectile.NewProjectile(P.Center.X + Main.rand.Next(-4000, 4000), P.Center.Y + 1500, 0f, -8f, mod.ProjectileType("VoidStrike"), projectileBaseDamage, 0f);
                        Projectile.NewProjectile(P.Center.X + Main.rand.Next(-4000, 4000), P.Center.Y - 1500, 0f, 8f, mod.ProjectileType("VoidStrike"), projectileBaseDamage, 0f);
                    }
                    shootTimer = 0;
                }
                #region worm stuff
                // creating the worm
                if (Main.netMode != 1)
                {
                    if (npc.ai[0] == 0)
                    {
                        npc.realLife = npc.whoAmI;
                        int latestNPC        = npc.whoAmI;
                        int randomWormLength = Main.rand.Next(100, 110);
                        for (int i = 0; i < randomWormLength; ++i)
                        {
                            int body = mod.NPCType("VoidLeviathanBody");
                            if (Main.rand.Next(3) == 0)
                            {
                                body = mod.NPCType("VoidLeviathanBodyWeak");
                            }

                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, body, npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3]    = npc.whoAmI;
                        }
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("VoidLeviathanTail"), npc.whoAmI, 0, latestNPC);
                        Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                        Main.npc[(int)latestNPC].ai[3]    = npc.whoAmI;

                        npc.ai[0]     = 1;
                        npc.netUpdate = true;
                    }
                }

                int minTilePosX = (int)(npc.position.X / 16.0) - 1;
                int maxTilePosX = (int)((npc.position.X + npc.width) / 16.0) + 2;
                int minTilePosY = (int)(npc.position.Y / 16.0) - 1;
                int maxTilePosY = (int)((npc.position.Y + npc.height) / 16.0) + 2;
                if (minTilePosX < 0)
                {
                    minTilePosX = 0;
                }
                if (maxTilePosX > Main.maxTilesX)
                {
                    maxTilePosX = Main.maxTilesX;
                }
                if (minTilePosY < 0)
                {
                    minTilePosY = 0;
                }
                if (maxTilePosY > Main.maxTilesY)
                {
                    maxTilePosY = Main.maxTilesY;
                }

                bool collision = false;
                // This is the initial check for collision with tiles.
                for (int i = minTilePosX; i < maxTilePosX; ++i)
                {
                    for (int j = minTilePosY; j < maxTilePosY; ++j)
                    {
                        if (Main.tile[i, j] != null && TileID.Sets.Platforms[Main.tile[i, j].type] != true && (Main.tile[i, j].nactive() && (Main.tileSolid[(int)Main.tile[i, j].type] || Main.tileSolidTop[(int)Main.tile[i, j].type] && (int)Main.tile[i, j].frameY == 0) || (int)Main.tile[i, j].liquid > 64))
                        {
                            Vector2 vector2;
                            vector2.X = (float)(i * 16);
                            vector2.Y = (float)(j * 16);
                            if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16.0 && (npc.position.Y + npc.height > (double)vector2.Y && npc.position.Y < vector2.Y + 16.0))
                            {
                                collision = true;

                                //Main.PlaySound(2, npc.position, mod.GetSoundSlot(SoundType.Item, "Sounds/Item/EarthRumble"));
                                ElementsAwoken.screenshakeAmount = 6;

                                if (Main.rand.Next(100) == 0 && Main.tile[i, j].nactive())
                                {
                                    WorldGen.KillTile(i, j, true, true, false);
                                }
                            }
                        }
                    }
                }
                if (Vector2.Distance(npc.Center, P.Center) <= 500)
                {
                    Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                    if (Main.rand.Next(7) == 0)
                    {
                        int damage = Main.expertMode ? 45 : 60; // reduce damage in expert mode because it doubles anyway
                        Projectile.NewProjectile(vector8.X + npc.velocity.X, vector8.Y + npc.velocity.Y, npc.velocity.X * 1.5f + Main.rand.NextFloat(-0.7f, 0.7f) * 3, npc.velocity.Y * 1.5f + Main.rand.NextFloat(-0.7f, 0.7f) * 3, mod.ProjectileType("VoidLeviathanBreath"), damage, 0f, 0);
                        if (Main.rand.Next(2) == 0)
                        {
                            Main.PlaySound(SoundID.DD2_BetsyFlameBreath, npc.position);
                        }
                    }
                }

                if (Vector2.Distance(npc.Center, P.Center) <= 750)
                {
                    tooFar = false;
                }
                else
                {
                    tooFar = true;
                }
                Vector2 npcCenter  = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
                float   targetXPos = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2);
                float   targetYPos = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2);

                float targetRoundedPosX = (float)((int)(targetXPos / 16.0) * 16);
                float targetRoundedPosY = (float)((int)(targetYPos / 16.0) * 16);
                npcCenter.X = (float)((int)(npcCenter.X / 16.0) * 16);
                npcCenter.Y = (float)((int)(npcCenter.Y / 16.0) * 16);
                float   dirX      = targetRoundedPosX - npcCenter.X;
                float   dirY      = targetRoundedPosY - npcCenter.Y;
                Vector2 vector168 = npc.Center;
                float   length    = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
                // If we do not have any type of collision, we want the NPC to fall down and de-accelerate along the X axis.
                if (!collision)
                {
                    npc.TargetClosest(true);
                    npc.velocity.Y = npc.velocity.Y + 0.11f;
                    if (npc.velocity.Y > speed)
                    {
                        npc.velocity.Y = speed;
                    }
                    if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.4)
                    {
                        if (npc.velocity.X < 0.0)
                        {
                            npc.velocity.X = npc.velocity.X - acceleration * 1.1f;
                        }
                        else
                        {
                            npc.velocity.X = npc.velocity.X + acceleration * 1.1f;
                        }
                    }

                    else if (npc.velocity.Y == speed)
                    {
                        if (npc.velocity.X < dirX)
                        {
                            npc.velocity.X = npc.velocity.X + acceleration;
                        }
                        else if (npc.velocity.X > dirX)
                        {
                            npc.velocity.X = npc.velocity.X - acceleration;
                        }
                    }
                    else if (npc.velocity.Y > 4.0)
                    {
                        if (npc.velocity.X < 0.0)
                        {
                            npc.velocity.X = npc.velocity.X + acceleration * 0.9f;
                        }
                        else
                        {
                            npc.velocity.X = npc.velocity.X - acceleration * 0.9f;
                        }
                    }
                }
                // Else we want to play some audio (soundDelay) and move towards our target.
                if (collision || tooFar)
                {
                    if (npc.soundDelay == 0)
                    {
                        float num1 = length / 40f;
                        if (num1 < 10.0)
                        {
                            num1 = 10f;
                        }
                        if (num1 > 20.0)
                        {
                            num1 = 20f;
                        }
                        npc.soundDelay = (int)num1;
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 1);
                    }
                    float absDirX  = Math.Abs(dirX);
                    float absDirY  = Math.Abs(dirY);
                    float newSpeed = speed / length;
                    dirX = dirX * newSpeed;
                    dirY = dirY * newSpeed;
                    if (npc.velocity.X > 0.0 && dirX > 0.0 || npc.velocity.X < 0.0 && dirX < 0.0 || (npc.velocity.Y > 0.0 && dirY > 0.0 || npc.velocity.Y < 0.0 && dirY < 0.0))
                    {
                        if (npc.velocity.X < dirX)
                        {
                            npc.velocity.X = npc.velocity.X + acceleration;
                        }
                        else if (npc.velocity.X > dirX)
                        {
                            npc.velocity.X = npc.velocity.X - acceleration;
                        }
                        if (npc.velocity.Y < dirY)
                        {
                            npc.velocity.Y = npc.velocity.Y + acceleration;
                        }
                        else if (npc.velocity.Y > dirY)
                        {
                            npc.velocity.Y = npc.velocity.Y - acceleration;
                        }
                        if (Math.Abs(dirY) < speed * 0.2 && (npc.velocity.X > 0.0 && dirX < 0.0 || npc.velocity.X < 0.0 && dirX > 0.0))
                        {
                            if (npc.velocity.Y > 0.0)
                            {
                                npc.velocity.Y = npc.velocity.Y + acceleration * 2f;
                            }
                            else
                            {
                                npc.velocity.Y = npc.velocity.Y - acceleration * 2f;
                            }
                        }
                        if (Math.Abs(dirX) < speed * 0.2 && (npc.velocity.Y > 0.0 && dirY < 0.0 || npc.velocity.Y < 0.0 && dirY > 0.0))
                        {
                            if (npc.velocity.X > 0.0)
                            {
                                npc.velocity.X = npc.velocity.X + acceleration * 2f;
                            }
                            else
                            {
                                npc.velocity.X = npc.velocity.X - acceleration * 2f;
                            }
                        }
                    }
                    else if (absDirX > absDirY)
                    {
                        if (npc.velocity.X < dirX)
                        {
                            npc.velocity.X = npc.velocity.X + acceleration * 1.1f;
                        }
                        else if (npc.velocity.X > dirX)
                        {
                            npc.velocity.X = npc.velocity.X - acceleration * 1.1f;
                        }
                        if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                        {
                            if (npc.velocity.Y > 0.0)
                            {
                                npc.velocity.Y = npc.velocity.Y + acceleration;
                            }
                            else
                            {
                                npc.velocity.Y = npc.velocity.Y - acceleration;
                            }
                        }
                    }
                    else
                    {
                        if (npc.velocity.Y < dirY)
                        {
                            npc.velocity.Y = npc.velocity.Y + acceleration * 1.1f;
                        }
                        else if (npc.velocity.Y > dirY)
                        {
                            npc.velocity.Y = npc.velocity.Y - acceleration * 1.1f;
                        }
                        if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                        {
                            if (npc.velocity.X > 0.0)
                            {
                                npc.velocity.X = npc.velocity.X + acceleration;
                            }
                            else
                            {
                                npc.velocity.X = npc.velocity.X - acceleration;
                            }
                        }
                    }
                }
                // Set the correct rotation for this NPC.
                npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + 1.57f;

                // Some netupdate stuff (multiplayer compatibility).
                if (collision)
                {
                    if (npc.localAI[0] != 1)
                    {
                        npc.netUpdate = true;
                    }
                    npc.localAI[0] = 1f;
                }
                else
                {
                    if (npc.localAI[0] != 0.0)
                    {
                        npc.netUpdate = true;
                    }
                    npc.localAI[0] = 0.0f;
                }
                if ((npc.velocity.X > 0.0 && npc.oldVelocity.X < 0.0 || npc.velocity.X < 0.0 && npc.oldVelocity.X > 0.0 || (npc.velocity.Y > 0.0 && npc.oldVelocity.Y < 0.0 || npc.velocity.Y < 0.0 && npc.oldVelocity.Y > 0.0)) && !npc.justHit)
                {
                    npc.netUpdate = true;
                }
                #endregion
            }
            return(false);
        }
Exemplo n.º 17
0
        public override bool PreAI()
        {
            if (Main.netMode != 1)
            {
                if (npc.ai[0] == 0)
                {
                    npc.realLife = npc.whoAmI;
                    int latestNPC = npc.whoAmI;

                    int randomWormLength = Main.rand.Next(10, 11);
                    for (int i = 0; i < randomWormLength; ++i)
                    {
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("ReachWorm2"), npc.whoAmI, 0, latestNPC);
                        Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                        Main.npc[(int)latestNPC].ai[3]    = npc.whoAmI;
                    }
                    latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("ReachWorm3"), npc.whoAmI, 0, latestNPC);
                    Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                    Main.npc[(int)latestNPC].ai[3]    = npc.whoAmI;

                    npc.ai[0]     = 1;
                    npc.netUpdate = true;
                }
            }

            int minTilePosX = (int)(npc.position.X / 16.0) - 1;
            int maxTilePosX = (int)((npc.position.X + npc.width) / 16.0) + 2;
            int minTilePosY = (int)(npc.position.Y / 16.0) - 1;
            int maxTilePosY = (int)((npc.position.Y + npc.height) / 16.0) + 2;

            if (minTilePosX < 0)
            {
                minTilePosX = 0;
            }
            if (maxTilePosX > Main.maxTilesX)
            {
                maxTilePosX = Main.maxTilesX;
            }
            if (minTilePosY < 0)
            {
                minTilePosY = 0;
            }
            if (maxTilePosY > Main.maxTilesY)
            {
                maxTilePosY = Main.maxTilesY;
            }

            bool collision = false;

            for (int i = minTilePosX; i < maxTilePosX; ++i)
            {
                for (int j = minTilePosY; j < maxTilePosY; ++j)
                {
                    if (Main.tile[i, j] != null && (Main.tile[i, j].nactive() && (Main.tileSolid[(int)Main.tile[i, j].type] || Main.tileSolidTop[(int)Main.tile[i, j].type] && (int)Main.tile[i, j].frameY == 0) || (int)Main.tile[i, j].liquid > 64))
                    {
                        Vector2 vector2;
                        vector2.X = (float)(i * 16);
                        vector2.Y = (float)(j * 16);
                        if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16.0 && (npc.position.Y + npc.height > (double)vector2.Y && npc.position.Y < vector2.Y + 16.0))
                        {
                            collision = true;
                            if (Main.rand.Next(100) == 0 && Main.tile[i, j].nactive())
                            {
                                WorldGen.KillTile(i, j, true, true, false);
                            }
                        }
                    }
                }
            }
            if (!collision)
            {
                Rectangle rectangle1      = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height);
                int       maxDistance     = 1000;
                bool      playerCollision = true;
                for (int index = 0; index < 255; ++index)
                {
                    if (Main.player[index].active)
                    {
                        Rectangle rectangle2 = new Rectangle((int)Main.player[index].position.X - maxDistance, (int)Main.player[index].position.Y - maxDistance, maxDistance * 2, maxDistance * 2);
                        if (rectangle1.Intersects(rectangle2))
                        {
                            playerCollision = false;
                            break;
                        }
                    }
                }
                if (playerCollision)
                {
                    collision = true;
                }
            }

            float speed        = 10f;
            float acceleration = 0.25f;

            Vector2 npcCenter  = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
            float   targetXPos = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2);
            float   targetYPos = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2);

            float targetRoundedPosX = (float)((int)(targetXPos / 16.0) * 16);
            float targetRoundedPosY = (float)((int)(targetYPos / 16.0) * 16);

            npcCenter.X = (float)((int)(npcCenter.X / 16.0) * 16);
            npcCenter.Y = (float)((int)(npcCenter.Y / 16.0) * 16);
            float dirX = targetRoundedPosX - npcCenter.X;
            float dirY = targetRoundedPosY - npcCenter.Y;

            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);

            if (!collision)
            {
                npc.TargetClosest(true);
                npc.velocity.Y = npc.velocity.Y + 0.11f;
                if (npc.velocity.Y > speed)
                {
                    npc.velocity.Y = speed;
                }
                if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.4)
                {
                    if (npc.velocity.X < 0.0)
                    {
                        npc.velocity.X = npc.velocity.X - acceleration * 1.1f;
                    }
                    else
                    {
                        npc.velocity.X = npc.velocity.X + acceleration * 1.1f;
                    }
                }
                else if (npc.velocity.Y == speed)
                {
                    if (npc.velocity.X < dirX)
                    {
                        npc.velocity.X = npc.velocity.X + acceleration;
                    }
                    else if (npc.velocity.X > dirX)
                    {
                        npc.velocity.X = npc.velocity.X - acceleration;
                    }
                }
                else if (npc.velocity.Y > 4.0)
                {
                    if (npc.velocity.X < 0.0)
                    {
                        npc.velocity.X = npc.velocity.X + acceleration * 0.9f;
                    }
                    else
                    {
                        npc.velocity.X = npc.velocity.X - acceleration * 0.9f;
                    }
                }
            }
            else
            {
                if (npc.soundDelay == 0)
                {
                    float num1 = length / 40f;
                    if (num1 < 10.0)
                    {
                        num1 = 10f;
                    }
                    if (num1 > 20.0)
                    {
                        num1 = 20f;
                    }
                    npc.soundDelay = (int)num1;
                    Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 1);
                }
                float absDirX  = Math.Abs(dirX);
                float absDirY  = Math.Abs(dirY);
                float newSpeed = speed / length;
                dirX = dirX * newSpeed;
                dirY = dirY * newSpeed;
                if (npc.velocity.X > 0.0 && dirX > 0.0 || npc.velocity.X < 0.0 && dirX < 0.0 || (npc.velocity.Y > 0.0 && dirY > 0.0 || npc.velocity.Y < 0.0 && dirY < 0.0))
                {
                    if (npc.velocity.X < dirX)
                    {
                        npc.velocity.X = npc.velocity.X + acceleration;
                    }
                    else if (npc.velocity.X > dirX)
                    {
                        npc.velocity.X = npc.velocity.X - acceleration;
                    }
                    if (npc.velocity.Y < dirY)
                    {
                        npc.velocity.Y = npc.velocity.Y + acceleration;
                    }
                    else if (npc.velocity.Y > dirY)
                    {
                        npc.velocity.Y = npc.velocity.Y - acceleration;
                    }
                    if (Math.Abs(dirY) < speed * 0.2 && (npc.velocity.X > 0.0 && dirX < 0.0 || npc.velocity.X < 0.0 && dirX > 0.0))
                    {
                        if (npc.velocity.Y > 0.0)
                        {
                            npc.velocity.Y = npc.velocity.Y + acceleration * 2f;
                        }
                        else
                        {
                            npc.velocity.Y = npc.velocity.Y - acceleration * 2f;
                        }
                    }
                    if (Math.Abs(dirX) < speed * 0.2 && (npc.velocity.Y > 0.0 && dirY < 0.0 || npc.velocity.Y < 0.0 && dirY > 0.0))
                    {
                        if (npc.velocity.X > 0.0)
                        {
                            npc.velocity.X = npc.velocity.X + acceleration * 2f;
                        }
                        else
                        {
                            npc.velocity.X = npc.velocity.X - acceleration * 2f;
                        }
                    }
                }
                else if (absDirX > absDirY)
                {
                    if (npc.velocity.X < dirX)
                    {
                        npc.velocity.X = npc.velocity.X + acceleration * 1.1f;
                    }
                    else if (npc.velocity.X > dirX)
                    {
                        npc.velocity.X = npc.velocity.X - acceleration * 1.1f;
                    }
                    if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                    {
                        if (npc.velocity.Y > 0.0)
                        {
                            npc.velocity.Y = npc.velocity.Y + acceleration;
                        }
                        else
                        {
                            npc.velocity.Y = npc.velocity.Y - acceleration;
                        }
                    }
                }
                else
                {
                    if (npc.velocity.Y < dirY)
                    {
                        npc.velocity.Y = npc.velocity.Y + acceleration * 1.1f;
                    }
                    else if (npc.velocity.Y > dirY)
                    {
                        npc.velocity.Y = npc.velocity.Y - acceleration * 1.1f;
                    }
                    if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                    {
                        if (npc.velocity.X > 0.0)
                        {
                            npc.velocity.X = npc.velocity.X + acceleration;
                        }
                        else
                        {
                            npc.velocity.X = npc.velocity.X - acceleration;
                        }
                    }
                }
            }
            npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + 1.57f;

            if (collision)
            {
                if (npc.localAI[0] != 1)
                {
                    npc.netUpdate = true;
                }
                npc.localAI[0] = 1f;
            }
            else
            {
                if (npc.localAI[0] != 0.0)
                {
                    npc.netUpdate = true;
                }
                npc.localAI[0] = 0.0f;
            }
            if ((npc.velocity.X > 0.0 && npc.oldVelocity.X < 0.0 || npc.velocity.X < 0.0 && npc.oldVelocity.X > 0.0 || (npc.velocity.Y > 0.0 && npc.oldVelocity.Y < 0.0 || npc.velocity.Y < 0.0 && npc.oldVelocity.Y > 0.0)) && !npc.justHit)
            {
                npc.netUpdate = true;
            }

            return(false);
        }
Exemplo n.º 18
0
        public override bool PreAI()
        {
            if (fireAttack == true)
            {
                attackCounter++;
                if (attackCounter > 10)
                {
                    attackFrame++;
                    attackCounter = 0;
                }
                if (attackFrame >= 3)
                {
                    attackFrame = 2;
                }
            }
            Main.dayTime = true;
            Main.time    = 24000;
            Player player = Main.player[npc.target];
            float  dist   = npc.Distance(player.Center);

            if (dist > 300 & Main.rand.Next(20) == 1 && fireAttack == false)
            {
                fireAttack = true;
            }
            if (fireAttack == true)
            {
                attackTimer++;
                if ((attackTimer == 8 || attackTimer == 16 || attackTimer == 24 || attackTimer == 32 || attackTimer == 40 || attackTimer == 48 || attackTimer == 56 || attackTimer == 64 || attackTimer == 72 || attackTimer == 79) && !npc.HasBuff(103))
                {
                    for (int i = 0; i < 5; ++i)
                    {
                        if (Main.netMode != 1)
                        {
                            int num429 = 1;
                            if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width)
                            {
                                num429 = -1;
                            }
                            Vector2 PlayerDistance = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
                            float   PlayerPosX     = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num429 * 180) - PlayerDistance.X;
                            float   PlayerPosY     = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - PlayerDistance.Y;
                            float   PlayerPos      = (float)Math.Sqrt((PlayerPosX * PlayerPosX) + (PlayerPosY * PlayerPosY));
                            float   num433         = 6f;
                            PlayerDistance    = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
                            PlayerPosX        = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - PlayerDistance.X;
                            PlayerPosY        = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - PlayerDistance.Y;
                            PlayerPos         = (float)Math.Sqrt((PlayerPosX * PlayerPosX + PlayerPosY * PlayerPosY));
                            PlayerPos         = num433 / PlayerPos;
                            PlayerPosX       *= PlayerPos;
                            PlayerPosY       *= PlayerPos;
                            PlayerPosY       += Main.rand.Next(-40, 41) * 0.01f;
                            PlayerPosX       += Main.rand.Next(-40, 41) * 0.01f;
                            PlayerPosY       += npc.velocity.Y * 0.5f;
                            PlayerPosX       += npc.velocity.X * 0.5f;
                            PlayerDistance.X -= PlayerPosX * 1f;
                            PlayerDistance.Y -= PlayerPosY * 1f;
                            Projectile.NewProjectile(PlayerDistance.X, PlayerDistance.Y, npc.velocity.X * 2f, npc.velocity.Y * 2f, mod.ProjectileType("AkumaBreath"), npc.damage, 0, Main.myPlayer);
                        }
                    }
                }
                if ((attackTimer == 20 || attackTimer == 50 || attackTimer == 79) && npc.HasBuff(103))
                {
                    for (int spawnDust = 0; spawnDust < 2; spawnDust++)
                    {
                        int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("MireBubbleDust"), 0f, 0f, 100, default(Color), 2f);
                        Main.dust[num935].noGravity   = true;
                        Main.dust[num935].velocity.Y -= 1f;
                    }
                    if (weakness == false)
                    {
                        weakness = true;
                        Main.NewText("Water?! AGH...! I CAN'T BREATHE FIRE!", new Color(180, 41, 32));
                    }
                }
                if (attackTimer >= 80)
                {
                    fireAttack    = false;
                    attackTimer   = 0;
                    attackFrame   = 0;
                    attackCounter = 0;
                }
            }
            if (npc.alpha != 0)
            {
                for (int spawnDust = 0; spawnDust < 2; spawnDust++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AkumaDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = true;
                    Main.dust[num935].noLight   = true;
                }
            }
            npc.alpha -= 12;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }

            if (Main.netMode != 1)
            {
                if (npc.ai[0] == 0)
                {
                    npc.realLife = npc.whoAmI;
                    int latestNPC    = npc.whoAmI;
                    int segment      = 0;
                    int AkumaALength = 9;
                    for (int i = 0; i < AkumaALength; ++i)
                    {
                        if (segment == 0 || segment == 2 || segment == 3 || segment == 5 || segment == 6 || segment == 8)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AkumaBody"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3]    = npc.whoAmI;
                            segment += 1;
                        }
                        if (segment == 1 || segment == 4 || segment == 7)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AkumaArms"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3]    = npc.whoAmI;
                            segment += 1;
                        }
                    }

                    latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AkumaTail"), npc.whoAmI, 0, latestNPC);
                    Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                    Main.npc[(int)latestNPC].ai[3]    = npc.whoAmI;

                    npc.ai[0]     = 1;
                    npc.netUpdate = true;
                }
            }

            int minTilePosX = (int)(npc.position.X / 16.0) - 1;
            int maxTilePosX = (int)((npc.position.X + npc.width) / 16.0) + 2;
            int minTilePosY = (int)(npc.position.Y / 16.0) - 1;
            int maxTilePosY = (int)((npc.position.Y + npc.height) / 16.0) + 2;

            if (minTilePosX < 0)
            {
                minTilePosX = 0;
            }
            if (maxTilePosX > Main.maxTilesX)
            {
                maxTilePosX = Main.maxTilesX;
            }
            if (minTilePosY < 0)
            {
                minTilePosY = 0;
            }
            if (maxTilePosY > Main.maxTilesY)
            {
                maxTilePosY = Main.maxTilesY;
            }

            bool collision = true;

            for (int i = minTilePosX; i < maxTilePosX; ++i)
            {
                for (int j = minTilePosY; j < maxTilePosY; ++j)
                {
                    if (Main.tile[i, j] != null && (Main.tile[i, j].nactive() && (Main.tileSolid[(int)Main.tile[i, j].type] || Main.tileSolidTop[(int)Main.tile[i, j].type] && (int)Main.tile[i, j].frameY == 0) || (int)Main.tile[i, j].liquid > 64))
                    {
                        Vector2 vector2;
                        vector2.X = (float)(i * 16);
                        vector2.Y = (float)(j * 16);
                        if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16.0 && (npc.position.Y + npc.height > (double)vector2.Y && npc.position.Y < vector2.Y + 16.0))
                        {
                            collision = true;
                            if (Main.rand.Next(100) == 0 && Main.tile[i, j].nactive())
                            {
                                WorldGen.KillTile(i, j, true, true, false);
                            }
                        }
                    }
                }
            }
            float speed        = 8f;
            float acceleration = 0.16f;

            Vector2 npcCenter  = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
            float   targetXPos = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2);
            float   targetYPos = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2);

            float targetRoundedPosX = (float)((int)(targetXPos / 16.0) * 16);
            float targetRoundedPosY = (float)((int)(targetYPos / 16.0) * 16);

            npcCenter.X = (float)((int)(npcCenter.X / 16.0) * 16);
            npcCenter.Y = (float)((int)(npcCenter.Y / 16.0) * 16);
            float dirX = targetRoundedPosX - npcCenter.X;
            float dirY = targetRoundedPosY - npcCenter.Y;

            npc.TargetClosest(true);
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);

            float absDirX  = Math.Abs(dirX);
            float absDirY  = Math.Abs(dirY);
            float newSpeed = speed / length;

            dirX = dirX * (newSpeed * 2);
            dirY = dirY * (newSpeed * 2);
            if (npc.velocity.X > 0.0 && dirX > 0.0 || npc.velocity.X < 0.0 && dirX < 0.0 || (npc.velocity.Y > 0.0 && dirY > 0.0 || npc.velocity.Y < 0.0 && dirY < 0.0))
            {
                if (npc.velocity.X < dirX)
                {
                    npc.velocity.X = npc.velocity.X + acceleration;
                }
                else if (npc.velocity.X > dirX)
                {
                    npc.velocity.X = npc.velocity.X - acceleration;
                }
                if (npc.velocity.Y < dirY)
                {
                    npc.velocity.Y = npc.velocity.Y + acceleration;
                }
                else if (npc.velocity.Y > dirY)
                {
                    npc.velocity.Y = npc.velocity.Y - acceleration;
                }
                if (Math.Abs(dirY) < speed * 0.2 && (npc.velocity.X > 0.0 && dirX < 0.0 || npc.velocity.X < 0.0 && dirX > 0.0))
                {
                    if (npc.velocity.Y > 0.0)
                    {
                        npc.velocity.Y = npc.velocity.Y + acceleration * 2f;
                    }
                    else
                    {
                        npc.velocity.Y = npc.velocity.Y - acceleration * 2f;
                    }
                }
                if (Math.Abs(dirX) < speed * 0.2 && (npc.velocity.Y > 0.0 && dirY < 0.0 || npc.velocity.Y < 0.0 && dirY > 0.0))
                {
                    if (npc.velocity.X > 0.0)
                    {
                        npc.velocity.X = npc.velocity.X + acceleration * 2f;
                    }
                    else
                    {
                        npc.velocity.X = npc.velocity.X - acceleration * 2f;
                    }
                }
            }
            else if (absDirX > absDirY)
            {
                if (npc.velocity.X < dirX)
                {
                    npc.velocity.X = npc.velocity.X + acceleration * 1.1f;
                }
                else if (npc.velocity.X > dirX)
                {
                    npc.velocity.X = npc.velocity.X - acceleration * 1.1f;
                }

                if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                {
                    if (npc.velocity.Y > 0.0)
                    {
                        npc.velocity.Y = npc.velocity.Y + acceleration;
                    }
                    else
                    {
                        npc.velocity.Y = npc.velocity.Y - acceleration;
                    }
                }
            }
            else
            {
                if (npc.velocity.Y < dirY)
                {
                    npc.velocity.Y = npc.velocity.Y + acceleration * 1.1f;
                }
                else if (npc.velocity.Y > dirY)
                {
                    npc.velocity.Y = npc.velocity.Y - acceleration * 1.1f;
                }

                if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                {
                    if (npc.velocity.X > 0.0)
                    {
                        npc.velocity.X = npc.velocity.X + acceleration;
                    }
                    else
                    {
                        npc.velocity.X = npc.velocity.X - acceleration;
                    }
                }
            }
            if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 6000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 6000f)
            {
                if (loludided == false)
                {
                    Main.NewText("I thought you terrarians put up more of a fight. Guess not.", new Color(180, 41, 32));
                    loludided = true;
                }
                npc.velocity.Y = npc.velocity.Y + 1f;
                if ((double)npc.position.Y > Main.rockLayer * 16.0)
                {
                    npc.velocity.Y = npc.velocity.Y + 1f;
                    speed          = 30f;
                }
                if ((double)npc.position.Y > Main.rockLayer * 16.0)
                {
                    for (int num957 = 0; num957 < 200; num957++)
                    {
                        if (Main.npc[num957].aiStyle == npc.aiStyle)
                        {
                            Main.npc[num957].active = false;
                        }
                    }
                }
            }

            npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + 1.57f;
            if (npc.velocity.X < 0f)
            {
                npc.spriteDirection = 1;
            }
            else
            {
                npc.spriteDirection = -1;
            }

            if (collision)
            {
                if (npc.localAI[0] != 1)
                {
                    npc.netUpdate = true;
                }
                npc.localAI[0] = 1f;
            }
            if ((npc.velocity.X > 0.0 && npc.oldVelocity.X < 0.0 || npc.velocity.X < 0.0 && npc.oldVelocity.X > 0.0 || (npc.velocity.Y > 0.0 && npc.oldVelocity.Y < 0.0 || npc.velocity.Y < 0.0 && npc.oldVelocity.Y > 0.0)) && !npc.justHit)
            {
                npc.netUpdate = true;
            }

            return(false);
        }
Exemplo n.º 19
0
 void OnDestroy()
 {
     // RELEASE SINGLETON REFERENCE
     if (inst == this) { inst = null; }
 }
Exemplo n.º 20
0
        public virtual void DoAI()
        {
            if (projectile.localAI[0] > 300)
            {
                projectile.Kill();
                return;
            }

            oldHitbox = new Vector2(projectile.width, projectile.height);

            if (projectile.localAI[0] == 1)
            {
                projectile.rotation        = projectile.ai[0];
                projectile.spriteDirection = projectile.rotation > 500 ? -1 : 1;

                if (projectile.rotation > 500)
                {
                    projectile.rotation -= 1000;
                }

                projectile.ai[0]     = 0;
                projectile.netUpdate = true;
            }

            Vector2 target;

            SwingUp();
            SwingDown();

            void SwingUp()
            {
                if (projectile.localAI[0] < 70)//Swing up
                {
                    float progress = Math.Min(projectile.localAI[0] / 50f, 1f);
                    if (Helper.IsTargetValid(enemy))
                    {
                        strikeWhere = enemy.Center + new Vector2(enemy.velocity.X, enemy.velocity.Y / 2f);
                        enemySize   = new Vector2(enemy.width, enemy.height);
                    }

                    projectile.rotation = projectile.rotation.AngleLerp(-MathHelper.Pi / 4f, 0.075f * progress);
                    target = strikeWhere + new Vector2(projectile.spriteDirection * -(75 + (float)Math.Pow(projectile.localAI[0] * 2f, 0.80) + enemySize.X / 2f), -200);
                    projectile.velocity += (target - projectile.Center) / 75f;

                    if (projectile.velocity.Length() > 14f * progress)
                    {
                        projectile.velocity = Vector2.Normalize(projectile.velocity) * 14 * progress;
                    }

                    projectile.velocity /= 1.5f;
                }
            }

            void SwingDown()
            {
                if (projectile.localAI[0] >= 70)//Swing Down
                {
                    if (Helper.IsTargetValid(enemy))
                    {
                        strikeWhere.X = enemy.Center.X + enemy.velocity.X * 1.50f;
                    }

                    projectile.velocity.X += Math.Min(Math.Abs(projectile.velocity.X), 0) * projectile.spriteDirection;

                    float progress = Math.Min((projectile.localAI[0] - 70f) / 30f, 1f);

                    projectile.rotation = projectile.rotation.AngleTowards(MathHelper.Pi / 4f, 0.075f * progress);
                    target = strikeWhere + new Vector2(projectile.spriteDirection * -(32 + enemySize.X / 4f), -32);
                    projectile.velocity.X += MathHelper.Clamp(target.X - projectile.Center.X, -80f, 80f) / 24f;
                    projectile.velocity.Y += 1f;

                    if (projectile.velocity.Length() > 10 * progress)
                    {
                        projectile.velocity = Vector2.Normalize(projectile.velocity) * 10 * progress;
                    }

                    projectile.velocity.X /= 1.20f;

                    Smash();
                }
            }

            void Smash()
            {
                if (projectile.Center.Y > target.Y)//Smashing!
                {
                    int     tileTargetY = (int)(projectile.Center.Y / 16) + 1;
                    Point16 point       = new Point16((int)((projectile.Center.X + projectile.width / 3f * projectile.spriteDirection) / 16), Math.Min(Main.maxTilesY, tileTargetY));
                    Tile    tile        = Framing.GetTileSafely(point.X, point.Y);

                    //hard coded dust ids in worldgen.cs, still ew
                    //Tile hit!
                    if (tile != null && WorldGen.InWorld(point.X, point.Y, 1) && tile.active() && Main.tileSolid[tile.type])
                    {
                        projectile.localAI[0] = 301;
                        int dusttype = ModContent.DustType <Dusts.GlassGravity>();
                        DustHelper.TileDust(tile, ref dusttype);

                        int     ai0       = tile.type;
                        int     ai1       = 16 * projectile.spriteDirection;
                        Vector2 tilepos16 = new Vector2(point.X, point.Y - 1) * 16;

                        Projectile.NewProjectile(tilepos16, Vector2.Zero, ModContent.ProjectileType <ShockwaveSummon>(), (int)(projectile.damage * 0.25), 0, Main.myPlayer, ai0, ai1);
                        Main.LocalPlayer.GetModPlayer <StarlightPlayer>().Shake += 10;

                        for (float num315 = 2f; num315 < 15; num315 += 0.50f)
                        {
                            float   angle    = MathHelper.ToRadians(-Main.rand.Next(70, 130));
                            Vector2 vecangle = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * num315 * 3f;
                            Vector2 position = new Vector2(projectile.position.X + projectile.spriteDirection * (int)(projectile.width * 0.60), projectile.Center.Y - projectile.height / 2f);

                            int num316 = Dust.NewDust(position, projectile.width / 2, projectile.height, dusttype, 0f, 0f, 50, default, (12f - num315) / 5f);
Exemplo n.º 21
0
 // Use this for initialization
 void Start()
 {
     rrand = Random.Range(0, 100);
     food_hold = 0;
     last_hunger = Time.time;
     last_action = Time.time;
     last_sleep = Time.time + Random.Range(0, sleep_interval);
     last_mating = Time.time + Random.Range(mating_cooldown/2, mating_cooldown);
     nextNode = mySquare;
     currentDestination = mySquare;
     wg = GameObject.FindGameObjectWithTag("world").GetComponent<WorldGen>();
     wl = GameObject.FindGameObjectWithTag("world").GetComponent<WorldLogic>();
     rf = gameObject.GetComponent<RabbitFinder>();
     rm = gameObject.GetComponent<RabbitMover>();
     ng = gameObject.GetComponent<NameGen>();
     rm.SetPosition(wg.VertexToVector3(mySquare));
     anim = gameObject.GetComponent<Animator>();
     ng = gameObject.GetComponent<NameGen>();
     //initiate rabbit stats
     myname = ng.getName();
     hp = 20;
     maxhp = 20;
     hunger = 7;
     full = 10;
     str = Random.Range(1,4);
     spd = Random.Range(1,4);
     speed = 1 / (float)spd;
     if(!starting_rabbit){
         profession = "Guard";
         sex = Random.Range(0,2);
     }
 }
Exemplo n.º 22
0
        private static bool IsAGoodSpot(Point position)
        {
            if (!WorldGen.InWorld(position.X, position.Y, 50) || WorldGen.oceanDepths(position.X, position.Y))
            {
                return(false);
            }
            Tile tile1 = Main.tile[position.X, position.Y];

            if (tile1.type != (ushort)21 || (int)tile1.frameX / 36 != 1)
            {
                return(false);
            }
            Tile tile2 = Main.tile[position.X, position.Y + 2];

            return(TileID.Sets.CanBeClearedDuringGeneration[(int)tile2.type] && WorldGen.countWires(position.X, position.Y, 20) <= 0 && WorldGen.countTiles(position.X, position.Y, false, true) >= 40);
        }
Exemplo n.º 23
0
        private static bool CheckRitual(int x, int y)
        {
            if (CultistRitual.delay != 0 || !Main.hardMode || (!NPC.downedGolemBoss || !NPC.downedBoss3) || (y < 7 || WorldGen.SolidTile(Main.tile[x, y - 7]) || NPC.AnyNPCs(437)))
            {
                return(false);
            }
            Vector2 Center = new Vector2((float)(x * 16 + 8), (float)(y * 16 - 64 - 8 - 27));

            Point[] pointArray = (Point[])null;
            ref     Point[] local = ref pointArray;
Exemplo n.º 24
0
        public override void NPCLoot()
        {
            if (Main.expertMode && !NPC.AnyNPCs(mod.NPCType("SoulofTruth")) && !NPC.AnyNPCs(mod.NPCType("SoulofHope")))
            {
                npc.DropBossBags();
            }

            if (Main.netMode != 1)
            {
                int centerX    = (int)(npc.position.X + (float)(npc.width / 2)) / 16;
                int centerY    = (int)(npc.position.Y + (float)(npc.height / 2)) / 16;
                int halfLength = npc.width / 2 / 16 + 1;



                if (!NPC.AnyNPCs(mod.NPCType("SoulofHope")) && !NPC.AnyNPCs(mod.NPCType("SoulofTruth")))
                {
                    if (!Main.expertMode && Main.rand.Next(10) == 0)
                    {
                        Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TrinityTrophy"));
                    }

                    if (!Main.expertMode && Main.rand.Next(1) == 0)
                    {
                        Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OmnikronBar"), Main.rand.Next(9, 15));
                        Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TrueEssense"), Main.rand.Next(10, 25));
                    }

                    if (!TremorWorld.downedTrinity)
                    {
                        Main.NewText("This world has been enlightened with Angelite!", 0, 191, 255);
                        Main.NewText("This world has been attacked with Collapsium!", 255, 20, 147);

                        for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
                        {
                            WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)(Main.maxTilesY * .3f), (int)(Main.maxTilesY * .65f)), (double)WorldGen.genRand.Next(9, 15), WorldGen.genRand.Next(9, 15), mod.TileType("CollapsiumOreTile"), false, 0f, 0f, false, true);
                        }
                        for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
                        {
                            WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)(Main.maxTilesY * .3f), (int)(Main.maxTilesY * .65f)), (double)WorldGen.genRand.Next(9, 15), WorldGen.genRand.Next(9, 15), mod.TileType("AngeliteOreTile"), false, 0f, 0f, false, true);
                        }
                        TremorWorld.downedTrinity = true;
                    }
                }


                if (!Main.expertMode && Main.rand.Next(7) == 0)
                {
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ThrustMask"));
                }

                if (!Main.expertMode && Main.rand.Next(3) == 0)
                {
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Volcannon"));
                }

                if (!Main.expertMode && Main.rand.Next(3) == 0)
                {
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("HonestBlade"));
                }
            }
        }
Exemplo n.º 25
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y, false) || Main.tile[origin.X, origin.Y].wall == (ushort)216 || Main.tile[origin.X, origin.Y].wall == (ushort)187)
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, WorldGen.goldBar == 19 ? (ushort)8 : (ushort)169, WorldGen.silverBar == 21 ? (ushort)9 : (ushort)168, WorldGen.ironBar == 22 ? (ushort)6 : (ushort)167, WorldGen.copperBar == 20 ? (ushort)7 : (ushort)166);
            double num1 = GenBase._random.NextDouble() * 2.0 - 1.0;

            if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            ShapeData shapeData = new ShapeData();
            Ref <int> count1    = new Ref <int>(0);
            Ref <int> count2    = new Ref <int>(0);

            WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2)));
            if (count2.Value < count1.Value / 2)
            {
                return(false);
            }
            Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(origin.X - 15, origin.Y - 10, 30, 20);
            if (!structures.CanPlace(area, 0))
            {
                return(false);
            }
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true, true));
            WorldUtils.Gen(new Point(origin.X - (int)(num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.ClearTile(true)));
            Point result1;
            int   num2 = 1 & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0);
            int   num3 = GenBase._random.Next(4) == 0 ? 3 : 7;
            Point result2;
            int   num4 = WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num3 : num3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;

            if ((num2 & num4) == 0)
            {
                return(false);
            }
            --result1.Y;
            --result2.Y;
            Tile tile1 = GenBase._tiles[result1.X, result1.Y + 1];

            tile1.slope((byte)0);
            tile1.halfBrick(false);
            for (int index = -1; index <= 1; ++index)
            {
                WorldUtils.ClearTile(result2.X + index, result2.Y, false);
                Tile tile2 = GenBase._tiles[result2.X + index, result2.Y + 1];
                if (!WorldGen.SolidOrSlopedTile(tile2))
                {
                    tile2.ResetToType((ushort)1);
                    tile2.active(true);
                }
                tile2.slope((byte)0);
                tile2.halfBrick(false);
                WorldUtils.TileFrame(result2.X + index, result2.Y + 1, true);
            }
            WorldGen.PlaceTile(result1.X, result1.Y, 141, false, false, -1, 0);
            WorldGen.PlaceTile(result2.X, result2.Y, 411, true, true, -1, 0);
            WorldUtils.WireLine(result1, result2);
            structures.AddProtectedStructure(area, 5);
            return(true);
        }
Exemplo n.º 26
0
        public override void AI()
        {
            npc.position += npc.velocity * 1.7f;
            if (Main.rand.Next(500) == 0 && Main.expertMode)
            {
                for (int i = 0; i < 50; i++)
                {
                    int dust = Dust.NewDust(npc.position, npc.width, npc.height, 6);
                    Main.dust[dust].scale     = 1.5f;
                    Main.dust[dust].noGravity = true;
                    Main.dust[dust].velocity *= 0f;
                    Main.dust[dust].velocity *= 0f;
                }
                npc.position.X = (Main.player[npc.target].position.X - 250) + Main.rand.Next(500);
                npc.position.Y = (Main.player[npc.target].position.Y - 250) + Main.rand.Next(500);
            }

            if (Main.rand.Next(500) == 0 && !Main.expertMode)
            {
                npc.TargetClosest(true);
                Vector2 vector142 = new Vector2(npc.Center.X, npc.Center.Y);
                float   num1243   = Main.player[npc.target].Center.X - vector142.X;
                float   num1244   = Main.player[npc.target].Center.Y - vector142.Y;
                float   num1245   = (float)Math.Sqrt((double)(num1243 * num1243 + num1244 * num1244));
                if (npc.ai[1] == 0f)
                {
                    if (Main.netMode != 1)
                    {
                        npc.localAI[1] += 1f;
                        if (npc.localAI[1] >= (float)(120 + Main.rand.Next(200)))
                        {
                            npc.localAI[1] = 0f;
                            npc.TargetClosest(true);
                            int num1249 = 0;
                            int num1250;
                            int num1251;
                            while (true)
                            {
                                num1249++;
                                num1250  = (int)Main.player[npc.target].Center.X / 16;
                                num1251  = (int)Main.player[npc.target].Center.Y / 16;
                                num1250 += Main.rand.Next(-50, 51);
                                num1251 += Main.rand.Next(-50, 51);
                                if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                                {
                                    break;
                                }
                                if (num1249 > 100)
                                {
                                    //return;
                                }
                            }
                            npc.ai[1]     = 1f;
                            npc.ai[2]     = (float)num1250;
                            npc.ai[3]     = (float)num1251;
                            npc.netUpdate = true;
                            //return;
                        }
                    }
                }
                else if (npc.ai[1] == 1f)
                {
                    npc.alpha += 3;
                    if (npc.alpha >= 255)
                    {
                        npc.alpha      = 255;
                        npc.position.X = npc.ai[2] * 16f - (float)(npc.width / 2);
                        npc.position.Y = npc.ai[3] * 16f - (float)(npc.height / 2);
                        npc.ai[1]      = 2f;
                        //return;
                    }
                }
                else if (npc.ai[1] == 2f)
                {
                    npc.alpha -= 3;
                    if (npc.alpha <= 0)
                    {
                        npc.alpha = 0;
                        npc.ai[1] = 0f;
                        //return;
                    }
                }
            }

            if (NPC.AnyNPCs(mod.NPCType("SoulofHope")) || NPC.AnyNPCs(mod.NPCType("SoulofTrust")))
            {
                npc.dontTakeDamage = true;
            }
            if (NPC.AnyNPCs(mod.NPCType("SoulofHope")) || NPC.AnyNPCs(mod.NPCType("SoulofTrust")))
            {
                npc.dontTakeDamage = false;
            }

            if (Main.expertMode && Main.rand.Next(4500) == 0)
            {
                NPC.NewNPC((int)npc.position.X - 100, (int)npc.position.Y - 50, 418);
                NPC.NewNPC((int)npc.position.X + 100, (int)npc.position.Y - 50, 418);
            }

            if (Main.rand.Next(2) == 0)
            {
                int num706 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 200, npc.color, 0.5f);
                Main.dust[num706].velocity *= 0.6f;
            }


            if (npc.target != -1 && !RunAway)                                                             //если(пнс.цель не варно -1 И не убегать)
            {
                if (!Main.player[npc.target].active)                                                      //если (не мой.игрок[нпс.цель].активный)
                {
                    if (Helper2.GetNearestAlivePlayer(npc) == -1)                                         //если (Помощьник.ПолучитьКоординатыИгрока(нпс) присвоить -1)
                    {
                        RunAway = true;                                                                   //Убегает = да
                    }
                    else                                                                                  //или
                    {
                        if (Main.player[Helper2.GetNearestAlivePlayer(npc)].Distance(npc.Center) > 2500f) //если(Мой.игрок[Помощьник.ПолучитьКоординатыИгрока(нпс)].Дистанция(нпс.Центр) больше 2500фунтов)
                        {
                            RunAway = true;                                                               //Убегает = да
                        }
                        else                                                                              //или...
                        {
                            npc.target = Helper2.GetNearestAlivePlayer(npc);                              //нпс.цель равно Помощьник.ПолучитьКоординатыИгрока(нпс)
                        }
                    }
                }
            }
            if (Main.dayTime || RunAway || npc.localAI[3] == 1)                                                               //если(Мой.День или Убегать или нпс.местный ИИ 3 к 1)
            {
                npc.localAI[3] = 1;                                                                                           //нпс.местный ИИ[3] равен 3
                if (Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofHope") && Main.npc[(int)npc.ai[2]].active == true)    //если(Мой.нпс[(значение)нпс.ИИ[2]].тип равен мод.НПС Тип("МОБ") и Мой.нпс[(значение)нпс.ИИ[2]].активен равен да)
                {
                    Main.npc[(int)npc.ai[2]].localAI[3] = 1;                                                                  //Мой.нпс[(значение)нпс.ИИ[2]].местный ИИ[3] варно 1
                }
                if (Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTruth") && Main.npc[(int)npc.ai[3]].active == true)   //если(Мой.нпс[(значение)нпс.ИИ[2]].тип равен мод.НПС Тип("МОБ") и Мой.нпс[(значение)нпс.ИИ[2]].активен равен да)
                {
                    Main.npc[(int)npc.ai[3]].localAI[3] = 1;                                                                  //Мой.нпс[(значение)нпс.ИИ[2]].местный ИИ[3] варно 1
                }
                npc.life    += 11;                                                                                            //нпс.жизнь прибавить
                npc.aiStyle  = 0;                                                                                             //нпс.ИИ Стиль - 0
                npc.rotation = 0;
                npc.velocity = Helper2.VelocityFPTP(npc.Center, new Vector2(npc.Center.X, npc.Center.Y - 4815162342), 30.0f); //нпс.поворот = Помощьник.ПоворотФПТП(нпс.Центр, новый Вектор2(нпс.Центр.X, нпс.Центр.Y - 4815162342))
                CreateDust();
                return;
            }
            if (StateFlag)
            {
                if (
                    !((Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofHope") && Main.npc[(int)npc.ai[2]].active == true)) ||
                    !((Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTruth") && Main.npc[(int)npc.ai[3]].active == true))
                    )
                {
                    StateFlag = false;
                    OnlyPower = true;
                }
            }
            if (OnlyPower)
            {
                SetStage(true);
            }
            else
            {
                CurrentPower += Step;
                if (CurrentPower <= 0 || CurrentPower >= PowerTime)
                {
                    Step *= -1;
                    SetStage(!Power);
                }
            }
            SetRotation();
            CreateDust();
            TimeToShoot--;
            if (TimeToShoot <= 0 && !Power)
            {
                TimeToShoot = NormalShootRate;
                Shoot();
                return;
            }
            if (TimeToShoot <= 0 && Power)
            {
                TimeToShoot = PowerShootRate;
                npc.target  = Helper2.GetNearestPlayer(npc);
                if (npc.target != -1)
                {
                    for (int a = 0; a < 5; a++)
                    {
                        Vector2 velocity   = Helper2.VelocityFPTP(npc.Center, Main.player[npc.target].Center, PowerBulletSpeed);
                        int     spread     = 65;
                        float   spreadMult = 0.05f;
                        velocity.X = velocity.X + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
                        velocity.Y = velocity.Y + (float)Main.rand.Next(-spread, spread + 1) * spreadMult;
                        int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, PowerShootType, PowerBulletDamage, PowerBulletKB);
                        Main.projectile[i].hostile  = true;
                        Main.projectile[i].friendly = true;
                    }
                }
                return;
            }
        }
Exemplo n.º 27
0
        private void SetupSortsAndCategories()
        {
            var tileUsageCounts = new Dictionary <int, int>();
            int currentCount;

            for (int i = 0; i < Recipe.numRecipes; i++)
            {
                for (int j = 0; j < 15; j++)
                {
                    if (Main.recipe[i].requiredTile[j] == -1)
                    {
                        break;
                    }
                    tileUsageCounts.TryGetValue(Main.recipe[i].requiredTile[j], out currentCount);
                    tileUsageCounts[Main.recipe[i].requiredTile[j]] = currentCount + 1;
                }
            }
            craftingTiles = tileUsageCounts.Select(x => x.Key).ToList();

            Texture2D terrariaSort = ResizeImage(Main.inventorySortTexture[1], 24, 24);
            Texture2D rarity       = ResizeImage(Main.itemTexture[ItemID.MetalDetector], 24, 24);

            sorts = new List <Sort>()
            {
                new Sort("ItemID", "Images/sortItemID", (x, y) => x.type.CompareTo(y.type), x => x.type.ToString()),
                new Sort("Value", "Images/sortValue", (x, y) => x.value.CompareTo(y.value), x => x.value.ToString()),
                new Sort("Alphabetical", "Images/sortAZ", (x, y) => x.Name.CompareTo(y.Name), x => x.Name.ToString()),
                new Sort("Rarity", rarity, (x, y) => x.rare == y.rare ? x.value.CompareTo(y.value) : Math.Abs(x.rare).CompareTo(Math.Abs(y.rare)), x => x.rare.ToString()),
                new Sort("Terraria Sort", terrariaSort, (x, y) => - ItemChecklistUI.vanillaIDsInSortOrder[x.type].CompareTo(ItemChecklistUI.vanillaIDsInSortOrder[y.type]), x => ItemChecklistUI.vanillaIDsInSortOrder[x.type].ToString()),
            };

            Texture2D materialsIcon = Utilities.StackResizeImage(new Texture2D[] { Main.itemTexture[ItemID.SpellTome] }, 24, 24);

            filters = new List <Filter>()
            {
                new Filter("Materials", x => ItemID.Sets.IsAMaterial[x.type], materialsIcon),
            };

            // TODOS: Vanity armor, grapple, cart, potions buffs
            // 24x24 pixels

            List <int> yoyos = new List <int>();

            for (int i = 0; i < ItemID.Sets.Yoyo.Length; ++i)
            {
                if (ItemID.Sets.Yoyo[i])
                {
                    yoyos.Add(i);
                }
            }

            Texture2D smallMelee           = ResizeImage(Main.itemTexture[ItemID.GoldBroadsword], 24, 24);
            Texture2D smallYoyo            = ResizeImage(Main.itemTexture[Main.rand.Next(yoyos)], 24, 24);  //Main.rand.Next(ItemID.Sets.Yoyo) ItemID.Yelets
            Texture2D smallMagic           = ResizeImage(Main.itemTexture[ItemID.GoldenShower], 24, 24);
            Texture2D smallRanged          = ResizeImage(Main.itemTexture[ItemID.FlintlockPistol], 24, 24);
            Texture2D smallThrown          = ResizeImage(Main.itemTexture[ItemID.Shuriken], 24, 24);
            Texture2D smallSummon          = ResizeImage(Main.itemTexture[ItemID.SlimeStaff], 24, 24);
            Texture2D smallSentry          = ResizeImage(Main.itemTexture[ItemID.DD2LightningAuraT1Popper], 24, 24);
            Texture2D smallHead            = ResizeImage(Main.itemTexture[ItemID.SilverHelmet], 24, 24);
            Texture2D smallBody            = ResizeImage(Main.itemTexture[ItemID.SilverChainmail], 24, 24);
            Texture2D smallLegs            = ResizeImage(Main.itemTexture[ItemID.SilverGreaves], 24, 24);
            Texture2D smallTiles           = ResizeImage(Main.itemTexture[ItemID.Sign], 24, 24);
            Texture2D smallCraftingStation = ResizeImage(Main.itemTexture[ItemID.IronAnvil], 24, 24);
            Texture2D smallWalls           = ResizeImage(Main.itemTexture[ItemID.PearlstoneBrickWall], 24, 24);
            Texture2D smallExpert          = ResizeImage(Main.itemTexture[ItemID.EoCShield], 24, 24);
            Texture2D smallPets            = ResizeImage(Main.itemTexture[ItemID.ZephyrFish], 24, 24);
            Texture2D smallLightPets       = ResizeImage(Main.itemTexture[ItemID.FairyBell], 24, 24);
            Texture2D smallBossSummon      = ResizeImage(Main.itemTexture[ItemID.MechanicalSkull], 24, 24);
            Texture2D smallMounts          = ResizeImage(Main.itemTexture[ItemID.SlimySaddle], 24, 24);
            Texture2D smallDyes            = ResizeImage(Main.itemTexture[ItemID.OrangeDye], 24, 24);
            Texture2D smallHairDye         = ResizeImage(Main.itemTexture[ItemID.BiomeHairDye], 24, 24);
            Texture2D smallQuestFish       = ResizeImage(Main.itemTexture[ItemID.FallenStarfish], 24, 24);
            Texture2D smallAccessories     = ResizeImage(Main.itemTexture[ItemID.HermesBoots], 24, 24);
            Texture2D smallWings           = ResizeImage(Main.itemTexture[ItemID.LeafWings], 24, 24);
            Texture2D smallCarts           = ResizeImage(Main.itemTexture[ItemID.Minecart], 24, 24);
            Texture2D smallHealth          = ResizeImage(Main.itemTexture[ItemID.HealingPotion], 24, 24);
            Texture2D smallMana            = ResizeImage(Main.itemTexture[ItemID.ManaPotion], 24, 24);
            Texture2D smallBuff            = ResizeImage(Main.itemTexture[ItemID.RagePotion], 24, 24);
            Texture2D smallAll             = ResizeImage(Main.itemTexture[ItemID.AlphabetStatueA], 24, 24);
            Texture2D smallContainer       = ResizeImage(Main.itemTexture[ItemID.GoldChest], 24, 24);
            Texture2D smallPaintings       = ResizeImage(Main.itemTexture[ItemID.PaintingMartiaLisa], 24, 24);
            Texture2D smallStatue          = ResizeImage(Main.itemTexture[ItemID.HeartStatue], 24, 24);
            Texture2D smallWiring          = ResizeImage(Main.itemTexture[ItemID.Wire], 24, 24);
            Texture2D smallConsumables     = ResizeImage(Main.itemTexture[ItemID.PurificationPowder], 24, 24);
            Texture2D smallExtractinator   = ResizeImage(Main.itemTexture[ItemID.Extractinator], 24, 24);
            Texture2D smallOther           = ResizeImage(Main.itemTexture[ItemID.UnicornonaStick], 24, 24);

            Texture2D smallArmor         = StackResizeImage(new Texture2D[] { Main.itemTexture[ItemID.SilverHelmet], Main.itemTexture[ItemID.SilverChainmail], Main.itemTexture[ItemID.SilverGreaves] }, 24, 24);
            Texture2D smallPetsLightPets = StackResizeImage(new Texture2D[] { Main.itemTexture[ItemID.ZephyrFish], Main.itemTexture[ItemID.FairyBell] }, 24, 24);
            Texture2D smallPlaceables    = StackResizeImage(new Texture2D[] { Main.itemTexture[ItemID.Sign], Main.itemTexture[ItemID.PearlstoneBrickWall] }, 24, 24);
            Texture2D smallWeapons       = StackResizeImage(new Texture2D[] { smallMelee, smallMagic, smallThrown }, 24, 24);
            Texture2D smallTools         = StackResizeImage(new Texture2D[] { ItemChecklist.instance.GetTexture("Images/sortPick"), ItemChecklist.instance.GetTexture("Images/sortAxe"), ItemChecklist.instance.GetTexture("Images/sortHammer") }, 24, 24);
            Texture2D smallFishing       = StackResizeImage(new Texture2D[] { ItemChecklist.instance.GetTexture("Images/sortFish"), ItemChecklist.instance.GetTexture("Images/sortBait"), Main.itemTexture[ItemID.FallenStarfish] }, 24, 24);
            Texture2D smallPotions       = StackResizeImage(new Texture2D[] { Main.itemTexture[ItemID.HealingPotion], Main.itemTexture[ItemID.ManaPotion], Main.itemTexture[ItemID.RagePotion] }, 24, 24);
            Texture2D smallBothDyes      = StackResizeImage(new Texture2D[] { Main.itemTexture[ItemID.OrangeDye], Main.itemTexture[ItemID.BiomeHairDye] }, 24, 24);
            Texture2D smallSortTiles     = StackResizeImage(new Texture2D[] { Main.itemTexture[ItemID.Candelabra], Main.itemTexture[ItemID.GrandfatherClock] }, 24, 24);

            // Potions, other?
            // should inherit children?
            // should have other category?
            if (WorldGen.statueList == null)
            {
                WorldGen.SetupStatueList();
            }

            categories = new List <Category>()
            {
                new Category("All", x => true, smallAll),
                new Category("Weapons" /*, x=>x.damage>0*/, x => false, smallWeapons)                 //"Images/sortDamage"
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Melee", x => x.melee, smallMelee),
                        new Category("Yoyo", x => ItemID.Sets.Yoyo[x.type], smallYoyo),
                        new Category("Magic", x => x.magic, smallMagic),
                        new Category("Ranged", x => x.ranged && x.ammo == 0, smallRanged)                       // TODO and ammo no
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Use Ammo Type", "Images/sortAmmo", (x, y) => x.useAmmo.CompareTo(y.useAmmo), x => x.useAmmo.ToString()),
                            }
                        },
                        new Category("Throwing", x => x.thrown, smallThrown),
                        new Category("Summon", x => x.summon && !x.sentry, smallSummon),
                        new Category("Sentry", x => x.summon && x.sentry, smallSentry),
                    },
                    sorts = new List <Sort>()
                    {
                        new Sort("Damage", "Images/sortDamage", (x, y) => x.damage.CompareTo(y.damage), x => x.damage.ToString()),
                    }                                                                                                                                                        // ascending
                },
                new Category("Tools" /*,x=>x.pick>0||x.axe>0||x.hammer>0*/, x => false, smallTools)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Pickaxes", x => x.pick > 0, "Images/sortPick")
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Pick Power", "Images/sortPick", (x, y) => x.pick.CompareTo(y.pick), x => x.pick.ToString()),
                            }
                        },
                        new Category("Axes", x => x.axe > 0, "Images/sortAxe")
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Axe Power", "Images/sortAxe", (x, y) => x.axe.CompareTo(y.axe), x => (x.axe * 5).ToString()),
                            }
                        },
                        new Category("Hammers", x => x.hammer > 0, "Images/sortHammer")
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Hammer Power", "Images/sortHammer", (x, y) => x.hammer.CompareTo(y.hammer), x => x.hammer.ToString()),
                            }
                        },
                    },
                },
                new Category("Armor" /*,  x=>x.headSlot!=-1||x.bodySlot!=-1||x.legSlot!=-1*/, x => false, smallArmor)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Head", x => x.headSlot != -1, smallHead),
                        new Category("Body", x => x.bodySlot != -1, smallBody),
                        new Category("Legs", x => x.legSlot != -1, smallLegs),
                    },
                    sorts = new List <Sort>()
                    {
                        new Sort("Defense", "Images/sortDefense", (x, y) => x.defense.CompareTo(y.defense), x => x.defense.ToString()),
                    }
                },
                new Category("Tiles", x => x.createTile != -1, smallTiles)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Crafting Stations", x => craftingTiles.Contains(x.createTile), smallCraftingStation),
                        new Category("Containers", x => x.createTile != -1 && Main.tileContainer[x.createTile], smallContainer),
                        new Category("Wiring", x => ItemID.Sets.SortingPriorityWiring[x.type] > -1, smallWiring),
                        new Category("Statues", x => WorldGen.statueList.Any(point => point.X == x.createTile && point.Y == x.placeStyle), smallStatue),
                        //new Category("Paintings", x=>ItemID.Sets.SortingPriorityPainting[x.type] > -1, smallPaintings), // oops, this is painting tools not painting tiles
                        //new Category("5x4", x=>{
                        //	if(x.createTile!=-1)
                        //	{
                        //		var tod = Terraria.ObjectData.TileObjectData.GetTileData(x.createTile, x.placeStyle);
                        //		return tod != null && tod.Width == 5 && tod.Height == 4;
                        //	}
                        //	return false;
                        //} , smallContainer),
                    },
                    // wires

                    // Banners
                    sorts = new List <Sort>()
                    {
                        new Sort("Place Tile", smallSortTiles, (x, y) => x.createTile == y.createTile ? x.placeStyle.CompareTo(y.placeStyle) : x.createTile.CompareTo(y.createTile), x => $"{x.createTile},{x.placeStyle}"),
                    }
                },
                new Category("Walls", x => x.createWall != -1, smallWalls),
                new Category("Accessories", x => x.accessory, smallAccessories)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Wings", x => x.wingSlot > 0, smallWings)
                    }
                },
                new Category("Ammo", x => x.ammo != 0, ItemChecklist.instance.GetTexture("Images/sortAmmo"))
                {
                    sorts = new List <Sort>()
                    {
                        new Sort("Ammo Type", "Images/sortAmmo", (x, y) => x.ammo.CompareTo(y.ammo), x => $"{x.ammo}"),
                    }
                    // TODO: Filters/Subcategories for all ammo types?
                },
                new Category("Potions", x => (x.UseSound != null && x.UseSound.Style == 3), smallPotions)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Health Potions", x => x.healLife > 0, smallHealth)
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Heal Life", smallHealth, (x, y) => x.healLife.CompareTo(y.healLife), x => $"{x.healLife}"),
                            }
                        },
                        new Category("Mana Potions", x => x.healMana > 0, smallMana)
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Heal Mana", smallMana, (x, y) => x.healMana.CompareTo(y.healMana), x => $"{x.healMana}"),
                            }
                        },
                        new Category("Buff Potions", x => (x.UseSound != null && x.UseSound.Style == 3) && x.buffType > 0, smallBuff),
                        // Todo: Automatic other category?
                    }
                },
                new Category("Expert", x => x.expert, smallExpert),
                new Category("Pets" /*, x=> x.buffType > 0 && (Main.vanityPet[x.buffType] || Main.lightPet[x.buffType])*/, x => false, smallPetsLightPets)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Pets", x => Main.vanityPet[x.buffType], smallPets),
                        new Category("Light Pets", x => Main.lightPet[x.buffType], smallLightPets),
                    }
                },
                new Category("Mounts", x => x.mountType != -1, smallMounts)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Carts", x => x.mountType != -1 && MountID.Sets.Cart[x.mountType], smallCarts)                       // TODO: need mountType check? inherited parent logic or parent unions children?
                    }
                },
                new Category("Dyes", x => false, smallBothDyes)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Dyes", x => x.dye != 0, smallDyes),
                        new Category("Hair Dyes", x => x.hairDye != -1, smallHairDye),
                    }
                },
                new Category("Boss Summons", x => ItemID.Sets.SortingPriorityBossSpawns[x.type] != -1 && x.type != ItemID.LifeCrystal && x.type != ItemID.ManaCrystal && x.type != ItemID.CellPhone && x.type != ItemID.IceMirror && x.type != ItemID.MagicMirror && x.type != ItemID.LifeFruit && x.netID != ItemID.TreasureMap || x.netID == ItemID.PirateMap, smallBossSummon)                 // vanilla bug.
                {
                    sorts = new List <Sort>()
                    {
                        new Sort("Progression Order", "Images/sortDamage", (x, y) => ItemID.Sets.SortingPriorityBossSpawns[x.type].CompareTo(ItemID.Sets.SortingPriorityBossSpawns[y.type]), x => $"{ItemID.Sets.SortingPriorityBossSpawns[x.type]}"),
                    }
                },
                new Category("Consumables", x => x.consumable, smallConsumables),
                new Category("Fishing" /*, x=> x.fishingPole > 0 || x.bait>0|| x.questItem*/, x => false, smallFishing)
                {
                    subCategories = new List <Category>()
                    {
                        new Category("Poles", x => x.fishingPole > 0, "Images/sortFish")
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Pole Power", "Images/sortFish", (x, y) => x.fishingPole.CompareTo(y.fishingPole), x => $"{x.fishingPole}"),
                            }
                        },
                        new Category("Bait", x => x.bait > 0, "Images/sortBait")
                        {
                            sorts = new List <Sort>()
                            {
                                new Sort("Bait Power", "Images/sortBait", (x, y) => x.bait.CompareTo(y.bait), x => $"{x.bait}"),
                            }
                        },
                        new Category("Quest Fish", x => x.questItem, smallQuestFish),
                    }
                },
                new Category("Extractinator", x => ItemID.Sets.ExtractinatorMode[x.type] > -1, smallExtractinator),
                //modCategory,
                new Category("Other", x => BelongsInOther(x), smallOther),
            };

            /* Think about this one.
             * foreach (var modCategory in RecipeBrowser.instance.modCategories)
             * {
             *      if (string.IsNullOrEmpty(modCategory.parent))
             *      {
             *              categories.Insert(categories.Count - 2, new Category(modCategory.name, modCategory.belongs, modCategory.icon));
             *      }
             *      else
             *      {
             *              foreach (var item in categories)
             *              {
             *                      if (item.name == modCategory.parent)
             *                      {
             *                              item.subCategories.Add(new Category(modCategory.name, modCategory.belongs, modCategory.icon));
             *                      }
             *              }
             *      }
             * }
             *
             * foreach (var modCategory in RecipeBrowser.instance.modFilters)
             * {
             *      filters.Add(new Filter(modCategory.name, modCategory.belongs, modCategory.icon));
             * }
             */

            foreach (var parent in categories)
            {
                foreach (var child in parent.subCategories)
                {
                    child.parent = parent;                     // 3 levels?
                }
            }

            SelectedSort     = sorts[0];
            SelectedCategory = categories[0];
        }
Exemplo n.º 28
0
        public override void AI()
        {
            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            if (npc.ai[2] < 400)
            {
                if (npc.Center.X < P.Center.X)
                {
                    npc.direction = 1;
                }
                else
                {
                    npc.direction = -1;
                }
            }
            npc.spriteDirection = npc.direction;
            npc.netUpdate       = true;
            npc.rotation       += (npc.velocity.X * 0.0174f * 2.5f);
            if (Main.expertMode)
            {
                npc.ai[1]++;
                if (npc.velocity.Y == 0 && npc.ai[1] > 300 && npc.ai[2] < 1 && Collision.CanHitLine(npc.Center, 1, 1, P.Center, 1, 1))
                {
                    npc.ai[2] = 1;
                }
                if (npc.ai[2] > 0)
                {
                    npc.knockBackResist = 0f;
                    npc.aiStyle         = -1;
                    npc.ai[2]++;
                    npc.rotation += (npc.direction * 0.0174f * npc.ai[2]);
                    int freq = (int)((100 - npc.ai[2]) / 10) + 10;
                    if (npc.ai[2] == 90)
                    {
                        Main.PlaySound(2, (int)npc.Center.X, (int)npc.Center.Y, 22, 0.5f, -0.1f);
                    }
                    if (npc.ai[2] == 100)
                    {
                        if (npc.Center.Y > P.Center.Y + 100 && Math.Abs(npc.Center.X - P.Center.X) < 400)
                        {
                            npc.velocity.Y = -4;
                            npc.ai[2]      = 300;
                        }
                        else
                        {
                            npc.velocity.X = 15 * npc.direction;
                        }
                    }
                    if (npc.ai[2] >= 300)
                    {
                        if (npc.velocity.Y == 0 && npc.oldVelocity.Y > 0)
                        {
                            if (npc.ai[2] < 400)
                            {
                                npc.velocity.X = 5 * npc.direction;
                                npc.velocity.Y = -18;
                                npc.ai[2]      = 400;
                            }
                            else if (npc.ai[2] < 600)
                            {
                                npc.velocity.X = 4 * npc.direction;
                                npc.velocity.Y = -14;
                                npc.ai[2]      = 600;
                            }
                            else if (npc.ai[2] < 800)
                            {
                                npc.velocity.X = 3 * npc.direction;
                                npc.velocity.Y = -10;
                                npc.ai[2]      = 800;
                            }
                            else
                            {
                                npc.ai[1] = 0;
                                npc.ai[2] = 0;
                            }
                            Main.PlaySound(SoundID.Item10, npc.Center);
                        }
                        if (npc.velocity.X == 0 && npc.oldVelocity.X != 0)
                        {
                            npc.velocity.X = -npc.oldVelocity.X;
                            npc.direction  = Math.Sign(npc.velocity.X);
                            Main.PlaySound(2, (int)npc.Center.X, (int)npc.Center.Y, 10, 0.5f);
                        }
                    }
                    else if (npc.ai[2] >= 100)
                    {
                        if (Collision.SolidCollision(npc.position + new Vector2(npc.velocity.X, 0), npc.width, npc.height))
                        {
                            npc.velocity.Y = -15;
                            Main.PlaySound(SoundID.Item10, npc.Center);
                        }
                        if (npc.ai[2] > 200 || npc.velocity.X == 0)
                        {
                            npc.ai[1]      = 0;
                            npc.ai[2]      = 0;
                            npc.velocity.X = -npc.oldVelocity.X;
                            npc.velocity.Y = -8;
                            Main.PlaySound(SoundID.Item10, npc.Center);
                        }
                    }
                    else
                    {
                        npc.velocity = Vector2.Zero;
                        if (npc.ai[2] % freq == 0)
                        {
                            Main.PlaySound(2, (int)npc.Center.X, (int)npc.Center.Y, 23, 0.5f, -0.2f);
                        }
                        Vector2 posi = new Vector2(npc.Center.X, npc.position.Y + npc.height + 4);
                        Point   pos  = posi.ToTileCoordinates();
                        Tile    tile = Framing.GetTileSafely(pos.X, pos.Y);
                        if (tile.active())
                        {
                            Dust dust = Main.dust[WorldGen.KillTile_MakeTileDust(pos.X, pos.Y, tile)];
                            dust.velocity.Y = -npc.ai[2] / 30;
                            dust.velocity.X = -npc.direction * npc.ai[2] / 10;
                        }
                    }
                }
                else
                {
                    npc.aiStyle         = 26;
                    npc.knockBackResist = 0.05f;
                }
            }
            npc.velocity.Y += 0.2f;
        }
        public override void Kill(int timeLeft)
        {
            Player player = Main.player[projectile.owner];


            Vector2 position = projectile.Center;

            Main.PlaySound(SoundID.Item14, (int)position.X, (int)position.Y);
            int radius = 5;     //this is the explosion radius, the highter is the value the bigger is the explosion

            Vector2 vel;
            int     spedX;
            int     spedY;
            int     cntr = 0;

            for (int x = -radius; x <= radius; x++)
            {
                for (int y = -radius; y <= radius; y++)
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(y + position.Y / 16.0f);

                    if (Math.Sqrt(x * x + y * y) <= radius + 0.5)   //this make so the explosion radius is a circle
                    {
                        if (WorldGen.TileEmpty(xPosition, yPosition))
                        {
                            spedX = Main.rand.Next(15) - 7;
                            spedY = Main.rand.Next(15) - 7;
                            if (spedX == 0)
                            {
                                spedX = 1;
                            }
                            if (spedY == 0)
                            {
                                spedY = 1;
                            }
                            if (++cntr <= 100)
                            {
                                Projectile.NewProjectile(position.X + x, position.Y + y, spedX, spedY, CalamityMod.ProjectileType("MortarRoundProj"), 140, 20, projectile.owner, 0.0f, 0);
                            }
                        }
                        else
                        {
                            spedX = Main.rand.Next(15) - 7;
                            spedY = Main.rand.Next(15) - 7;
                            if (spedX == 0)
                            {
                                spedX = 1;
                            }
                            if (spedY == 0)
                            {
                                spedY = 1;
                            }
                            if (++cntr <= 100)
                            {
                                Projectile.NewProjectile(position.X + x, position.Y + y, spedX, spedY, CalamityMod.ProjectileType("MortarRoundProj"), 140, 20, projectile.owner, 0.0f, 0);
                            }
                        }
                    }
                }
            }

            Dust dust1;
            Dust dust2;

            // You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle.
            for (int i = 0; i < 100; i++)
            {
                if (Main.rand.NextFloat() < ExtraExplosives.dustAmount)
                {
                    Vector2 position1 = new Vector2(position.X - 100 / 2, position.Y - 100 / 2);
                    dust1           = Main.dust[Terraria.Dust.NewDust(position1, 100, 100, 0, 0f, 0f, 171, new Color(33, 0, 255), 4.0f)];
                    dust1.noGravity = true;
                    dust1.noLight   = true;
                }
            }

            for (int i = 0; i < 100; i++)
            {
                if (Main.rand.NextFloat() < ExtraExplosives.dustAmount)
                {
                    Vector2 position2 = new Vector2(position.X - 80 / 2, position.Y - 80 / 2);
                    dust2           = Main.dust[Terraria.Dust.NewDust(position2, 80, 80, 6 /*35*/, 0f, 0f, 0, new Color(240, 240, 240), 4.0f)];
                    dust2.noGravity = true;
                }
            }
        }
Exemplo n.º 30
0
        public override void AI()
        {
            if (--TimeToAnimation <= 0)
            {
                if (++CurrentFrame > 2)
                {
                    CurrentFrame = 1;
                }
                TimeToAnimation = 4;
                npc.frame       = GetFrame(CurrentFrame + 0);
            }
            Player player  = Main.player[npc.target];
            int    num1305 = 3;

            npc.noTileCollide = false;
            npc.noGravity     = true;
            npc.damage        = npc.defDamage;
            if (npc.target < 0 || player.dead || !player.active)
            {
                npc.TargetClosest(true);
                if (player.dead)
                {
                    npc.ai[0] = -1f;
                }
            }
            else
            {
                Vector2 vector205 = player.Center - npc.Center;
                if (npc.ai[0] > 1f && vector205.Length() > 1000f)
                {
                    npc.ai[0] = 1f;
                }
            }
            if (npc.ai[0] == -1f)
            {
                Vector2 value50 = new Vector2(0f, -8f);
                npc.velocity       = (npc.velocity * 9f + value50) / 10f;
                npc.noTileCollide  = true;
                npc.dontTakeDamage = true;
                return;
            }
            if (npc.ai[0] == 0f)
            {
                npc.TargetClosest(true);
                if (npc.Center.X < player.Center.X - 2f)
                {
                    npc.direction = 1;
                }
                if (npc.Center.X > player.Center.X + 2f)
                {
                    npc.direction = -1;
                }
                npc.spriteDirection = npc.direction;
                npc.rotation        = (npc.rotation * 9f + npc.velocity.X * 0.1f) / 10f;
                if (npc.collideX)
                {
                    npc.velocity.X = npc.velocity.X * (-npc.oldVelocity.X * 0.5f);
                    if (npc.velocity.X > 16f)
                    {
                        npc.velocity.X = 16f;
                    }
                    if (npc.velocity.X < -16f)
                    {
                        npc.velocity.X = -16f;
                    }
                }
                if (npc.collideY)
                {
                    npc.velocity.Y = npc.velocity.Y * (-npc.oldVelocity.Y * 0.5f);
                    if (npc.velocity.Y > 16f)
                    {
                        npc.velocity.Y = 16f;
                    }
                    if (npc.velocity.Y < -16f)
                    {
                        npc.velocity.Y = -16f;
                    }
                }
                Vector2 value51 = player.Center - npc.Center;
                value51.Y -= 200f;
                if (value51.Length() > 800f)
                {
                    npc.ai[0] = 1f;
                    npc.ai[1] = 0f;
                    npc.ai[2] = 0f;
                    npc.ai[3] = 0f;
                }
                else if (value51.Length() > 80f)
                {
                    float scaleFactor15 = 12f;
                    float num1306       = 60f;
                    value51.Normalize();
                    value51     *= scaleFactor15;
                    npc.velocity = (npc.velocity * (num1306 - 1f) + value51) / num1306;
                }
                else if (npc.velocity.Length() > 2f)
                {
                    npc.velocity *= 0.95f;
                }
                else if (npc.velocity.Length() < 1f)
                {
                    npc.velocity *= 1.05f;
                }
                npc.ai[1] += 1f;
                if (npc.justHit)
                {
                    npc.ai[1] += Main.rand.Next(10, 30);
                }
                if (npc.ai[1] >= 180f && Main.netMode != 1)
                {
                    npc.ai[1]     = 0f;
                    npc.ai[2]     = 0f;
                    npc.ai[3]     = 0f;
                    npc.netUpdate = true;
                    while (npc.ai[0] == 0f)
                    {
                        int num1307 = Main.rand.Next(3);
                        if (num1307 == 0 && Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1))
                        {
                            npc.ai[0] = 2f;
                        }
                        else if (num1307 == 1)
                        {
                            npc.ai[0] = 3f;
                        }
                        else if (num1307 == 2 && NPC.CountNPCS(mod.NPCType("DesertPrincess2")) < num1305)
                        {
                            npc.ai[0] = 4f;
                        }
                    }
                }
            }
            else
            {
                if (npc.ai[0] == 1f)
                {
                    npc.collideX      = false;
                    npc.collideY      = false;
                    npc.noTileCollide = true;
                    if (npc.target < 0 || !player.active || player.dead)
                    {
                        npc.TargetClosest(true);
                    }
                    if (npc.velocity.X < 0f)
                    {
                        npc.direction = -1;
                    }
                    else if (npc.velocity.X > 0f)
                    {
                        npc.direction = 1;
                    }
                    npc.spriteDirection = npc.direction;
                    npc.rotation        = (npc.rotation * 9f + npc.velocity.X * 0.08f) / 10f;
                    Vector2 value52 = player.Center - npc.Center;
                    if (value52.Length() < 300f && !Collision.SolidCollision(npc.position, npc.width, npc.height))
                    {
                        npc.ai[0] = 0f;
                        npc.ai[1] = 0f;
                        npc.ai[2] = 0f;
                        npc.ai[3] = 0f;
                    }
                    float scaleFactor16 = 14f + value52.Length() / 100f;
                    float num1308       = 25f;
                    value52.Normalize();
                    value52     *= scaleFactor16;
                    npc.velocity = (npc.velocity * (num1308 - 1f) + value52) / num1308;
                    return;
                }
                if (npc.ai[0] == 2f)
                {
                    npc.damage = (int)(npc.defDamage * 0.85);
                    if (npc.target < 0 || !player.active || player.dead)
                    {
                        npc.TargetClosest(true);
                        npc.ai[0] = 0f;
                        npc.ai[1] = 0f;
                        npc.ai[2] = 0f;
                        npc.ai[3] = 0f;
                    }
                    if (player.Center.X - 10f < npc.Center.X)
                    {
                        npc.direction = -1;
                    }
                    else if (player.Center.X + 10f > npc.Center.X)
                    {
                        npc.direction = 1;
                    }
                    npc.spriteDirection = npc.direction;
                    npc.rotation        = (npc.rotation * 4f + npc.velocity.X * 0.1f) / 5f;
                    if (npc.collideX)
                    {
                        npc.velocity.X = npc.velocity.X * (-npc.oldVelocity.X * 0.5f);
                        if (npc.velocity.X > 16f)
                        {
                            npc.velocity.X = 16f;
                        }
                        if (npc.velocity.X < -16f)
                        {
                            npc.velocity.X = -16f;
                        }
                    }
                    if (npc.collideY)
                    {
                        npc.velocity.Y = npc.velocity.Y * (-npc.oldVelocity.Y * 0.5f);
                        if (npc.velocity.Y > 16f)
                        {
                            npc.velocity.Y = 16f;
                        }
                        if (npc.velocity.Y < -16f)
                        {
                            npc.velocity.Y = -16f;
                        }
                    }
                    Vector2 value53 = player.Center - npc.Center;
                    value53.Y -= 20f;
                    npc.ai[2] += 0.0222222228f;
                    if (Main.expertMode)
                    {
                        npc.ai[2] += 0.0166666675f;
                    }
                    float scaleFactor17 = 4f + npc.ai[2] + value53.Length() / 120f;
                    float num1309       = 20f;
                    value53.Normalize();
                    value53     *= scaleFactor17;
                    npc.velocity = (npc.velocity * (num1309 - 1f) + value53) / num1309;
                    npc.ai[1]   += 1f;
                    if (npc.ai[1] > 240f || !Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1))
                    {
                        npc.ai[0] = 0f;
                        npc.ai[1] = 0f;
                        npc.ai[2] = 0f;
                        npc.ai[3] = 0f;
                    }
                }
                else
                {
                    if (npc.ai[0] == 3f)
                    {
                        npc.noTileCollide = true;
                        if (npc.velocity.X < 0f)
                        {
                            npc.direction = -1;
                        }
                        else
                        {
                            npc.direction = 1;
                        }
                        npc.spriteDirection = npc.direction;
                        npc.rotation        = (npc.rotation * 4f + npc.velocity.X * 0.07f) / 5f;
                        Vector2 value54 = player.Center - npc.Center;
                        value54.Y -= 12f;
                        if (npc.Center.X > player.Center.X)
                        {
                            value54.X += 400f;
                        }
                        else
                        {
                            value54.X -= 400f;
                        }
                        if (Math.Abs(npc.Center.X - player.Center.X) > 350f && Math.Abs(npc.Center.Y - player.Center.Y) < 20f)
                        {
                            npc.ai[0] = 3.1f;
                            npc.ai[1] = 0f;
                        }
                        npc.ai[1] += 0.0333333351f;
                        float scaleFactor18 = 8f + npc.ai[1];
                        float num1310       = 8f;
                        value54.Normalize();
                        value54     *= scaleFactor18;
                        npc.velocity = (npc.velocity * (num1310 - 1f) + value54) / num1310;
                        return;
                    }
                    if (npc.ai[0] == 3.1f)
                    {
                        npc.noTileCollide = true;
                        npc.rotation      = (npc.rotation * 4f + npc.velocity.X * 0.07f) / 5f;
                        Vector2 vector206 = player.Center - npc.Center;
                        vector206.Y -= 12f;
                        float scaleFactor19 = 16f;
                        float num1311       = 32f;
                        vector206.Normalize();
                        vector206   *= scaleFactor19;
                        npc.velocity = (npc.velocity * (num1311 - 1f) + vector206) / num1311;
                        if (npc.velocity.X < 0f)
                        {
                            npc.direction = -1;
                        }
                        else
                        {
                            npc.direction = 1;
                        }
                        npc.spriteDirection = npc.direction;
                        npc.ai[1]          += 1f;
                        if (npc.ai[1] > 10f)
                        {
                            npc.velocity = vector206;
                            if (npc.velocity.X < 0f)
                            {
                                npc.direction = -1;
                            }
                            else
                            {
                                npc.direction = 1;
                            }
                            npc.ai[0] = 3.2f;
                            npc.ai[1] = 0f;
                            npc.ai[1] = npc.direction;
                        }
                    }
                    else
                    {
                        if (npc.ai[0] == 3.2f)
                        {
                            npc.damage        = (int)(npc.defDamage * 1.3);
                            npc.collideX      = false;
                            npc.collideY      = false;
                            npc.noTileCollide = true;
                            npc.ai[2]        += 0.0333333351f;
                            npc.velocity.X    = (16f + npc.ai[2]) * npc.ai[1];
                            if ((npc.ai[1] > 0f && npc.Center.X > player.Center.X + 260f) || (npc.ai[1] < 0f && npc.Center.X < player.Center.X - 260f))
                            {
                                if (!Collision.SolidCollision(npc.position, npc.width, npc.height))
                                {
                                    npc.ai[0] = 0f;
                                    npc.ai[1] = 0f;
                                    npc.ai[2] = 0f;
                                    npc.ai[3] = 0f;
                                }
                                else if (Math.Abs(npc.Center.X - player.Center.X) > 800f)
                                {
                                    npc.ai[0] = 1f;
                                    npc.ai[1] = 0f;
                                    npc.ai[2] = 0f;
                                    npc.ai[3] = 0f;
                                }
                            }
                            npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.07f) / 5f;
                            return;
                        }
                        if (npc.ai[0] == 4f)
                        {
                            npc.ai[0] = 0f;
                            npc.TargetClosest(true);
                            if (Main.netMode != 1)
                            {
                                npc.ai[1] = -1f;
                                npc.ai[2] = -1f;
                                for (int num1312 = 0; num1312 < 1000; num1312++)
                                {
                                    int num1313 = (int)player.Center.X / 16;
                                    int num1314 = (int)player.Center.Y / 16;
                                    int num1315 = 30 + num1312 / 50;
                                    int num1316 = 20 + num1312 / 75;
                                    num1313 += Main.rand.Next(-num1315, num1315 + 1);
                                    num1314 += Main.rand.Next(-num1316, num1316 + 1);
                                    if (!WorldGen.SolidTile(num1313, num1314))
                                    {
                                        while (!WorldGen.SolidTile(num1313, num1314) && num1314 < Main.worldSurface)
                                        {
                                            num1314++;
                                        }
                                        if ((new Vector2(num1313 * 16 + 8, num1314 * 16 + 8) - player.Center).Length() < 600f)
                                        {
                                            npc.ai[0] = 4.1f;
                                            npc.ai[1] = num1313;
                                            npc.ai[2] = num1314;
                                            break;
                                        }
                                    }
                                }
                            }
                            npc.netUpdate = true;
                            return;
                        }
                        if (npc.ai[0] == 4.1f)
                        {
                            if (npc.velocity.X < -2f)
                            {
                                npc.direction = -1;
                            }
                            else if (npc.velocity.X > 2f)
                            {
                                npc.direction = 1;
                            }
                            npc.spriteDirection = npc.direction;
                            npc.rotation        = (npc.rotation * 9f + npc.velocity.X * 0.1f) / 10f;
                            npc.noTileCollide   = true;
                            int     num1317   = (int)npc.ai[1];
                            int     num1318   = (int)npc.ai[2];
                            float   x2        = num1317 * 16 + 8;
                            float   y2        = num1318 * 16 - 20;
                            Vector2 vector207 = new Vector2(x2, y2);
                            vector207 -= npc.Center;
                            float num1319 = 6f + vector207.Length() / 150f;
                            if (num1319 > 10f)
                            {
                                num1319 = 10f;
                            }
                            float num1320 = 40f;
                            if (vector207.Length() < 10f)
                            {
                                npc.ai[0] = 4.2f;
                            }
                            vector207.Normalize();
                            vector207   *= num1319;
                            npc.velocity = (npc.velocity * (num1320 - 1f) + vector207) / num1320;
                            return;
                        }
                        if (npc.ai[0] == 4.2f)
                        {
                            npc.rotation      = (npc.rotation * 9f + npc.velocity.X * 0.1f) / 10f;
                            npc.noTileCollide = true;
                            int     num1321   = (int)npc.ai[1];
                            int     num1322   = (int)npc.ai[2];
                            float   x3        = num1321 * 16 + 8;
                            float   y3        = num1322 * 16 - 20;
                            Vector2 vector208 = new Vector2(x3, y3);
                            vector208 -= npc.Center;
                            float num1323 = 4f;
                            float num1324 = 2f;
                            if (Main.netMode != 1 && vector208.Length() < 4f)
                            {
                                int num1325 = 70;
                                if (Main.expertMode)
                                {
                                    num1325 = (int)(num1325 * 0.75);
                                }
                                npc.ai[3] += 1f;
                                if (npc.ai[3] == num1325)
                                {
                                    NPC.NewNPC(num1321 * 16 + 8, num1322 * 16, mod.NPCType("DesertPrincess2"), npc.whoAmI, 0f, 0f, 0f, 0f, 255);
                                }
                                else if (npc.ai[3] == num1325 * 2)
                                {
                                    npc.ai[0] = 0f;
                                    npc.ai[1] = 0f;
                                    npc.ai[2] = 0f;
                                    npc.ai[3] = 0f;
                                    if (NPC.CountNPCS(mod.NPCType("DesertPrincess2")) < num1305 && Main.rand.Next(3) != 0)
                                    {
                                        npc.ai[0] = 4f;
                                    }
                                    else if (Collision.SolidCollision(npc.position, npc.width, npc.height))
                                    {
                                        npc.ai[0] = 1f;
                                    }
                                }
                            }
                            if (vector208.Length() > num1323)
                            {
                                vector208.Normalize();
                                vector208 *= num1323;
                            }
                            npc.velocity = (npc.velocity * (num1324 - 1f) + vector208) / num1324;
                        }
                    }
                }
            }
        }
 public override bool Apply(Point origin, int x, int y, params object[] args)
 {
     WorldGen.PlaceTight(x, y, (ushort)165, false);
     return(this.UnitApply(origin, x, y, args));
 }
Exemplo n.º 32
0
        public override void AI()
        {
            npc.AddBuff(mod.BuffType("Vampire"), 2);
            if (npc.HasBuff(mod.BuffType("Sunburn")))
            {
                npc.defense = 0;
                npc.damage  = 0;
                npc.ai[2]   = 1f;
            }

            Player target = Main.player[npc.target];

            if (target.dead || npc.target == -1)
            {
                npc.TargetClosest();
            }

            if (npc.ai[2] == 1f)
            {
                Dust.NewDust(npc.position, npc.width, npc.height, DustID.Smoke, Main.rand.NextFloat(-0.6f, 0.6f + 1f), Main.rand.NextFloat(-0.6f, 1f));
                return;
            }

            if (npc.ai[1] > 0)
            {
                npc.ai[1] -= 1;
            }
            if (npc.velocity.Y < 3f)
            {
                npc.velocity.Y += 0.05f;
            }

            if (Main.rand.Next(0, 251) <= 2)
            {
                Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, 1, 1f, -1.6f);
            }

            float targetDistance = 0f;

            if (npc.target != -1)
            {
                targetDistance = Vector2.Distance(npc.Center, Main.player[npc.target].Center);
            }

            if (targetDistance > 28f)
            {
                float direction = npc.position.X - target.position.X;
                if (direction < 0)
                {
                    npc.direction  = 1;
                    npc.velocity.X = MoveSpeed;
                }
                else
                {
                    npc.direction  = -1;
                    npc.velocity.X = -MoveSpeed;
                }
                if (WorldGen.SolidOrSlopedTile((int)(npc.position.X / 16) + (int)Math.Ceiling(npc.width / 16f) + 1, (int)(npc.position.Y / 16f) + (int)Math.Ceiling(npc.height / 16f) - 1) && npc.ai[1] <= 0f)
                {
                    npc.velocity.Y   = -6f;
                    npc.frameCounter = -40;     //This is to delay animations
                    npc.ai[1]        = 60f;
                }
            }
            else
            {
                npc.velocity.X = 0f;
            }
        }
Exemplo n.º 33
0
        private void NetHooks_GetData(GetDataEventArgs e)
        {
            var player = Players[e.Msg.whoAmI];

            PacketTypes type = e.MsgID;

            if (type == PacketTypes.PlayerDamage)
            {
                if (player == null)
                {
                    e.Handled = true;
                    return;
                }

                if (player.IsInvincible)
                {
                    if (player.Player.TPlayer.statLife < player.Player.TPlayer.statLifeMax)
                    {
                        int deficit = player.Player.TPlayer.statLifeMax - player.Player.TPlayer.statLife;

                        int heartNum = (deficit / 20) + 4;

                        var heart = TShock.Utils.GetItemById(58);

                        for (int i = 0; i < heartNum; i++)
                        {
                            player.Player.GiveItem(heart.type, heart.name, heart.width, heart.height, 1);
                        }
                    }
                }
            }
            else if (type == PacketTypes.DoorUse)
            {
                if (player == null)
                {
                    e.Handled = false;
                    return;
                }

                using (MemoryStream ms = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
                {
                    bool closed = ms.ReadBoolean();
                    int  x      = ms.ReadInt32();
                    int  y      = ms.ReadInt32();

                    RegionHelperManager regionHelper = new RegionHelperManager(TShock.DB);

                    if (!player.Player.Group.HasPermission(Permissions.editspawn) && !TShock.Regions.CanBuild(x, y, player.Player) && TShock.Regions.InArea(x, y) && regionHelper.GetRegionHelperByRegion(TShock.Regions.InAreaRegionName(x, y)).ContainsProperty(r => r.IsLocked))
                    {
                        int size = 10;

                        NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 1, x, y);

                        TSPlayer.All.SendTileSquare(x, y, size);
                        WorldGen.RangeFrame(x, y, x + size, y + size);

                        int warpX = player.Player.TileX > x ? player.Player.TileX + 3 : player.Player.TileX - 3;

                        player.Player.Teleport(warpX, player.Player.TileY + 3);

                        player.Player.SendMessage(string.Format("Doors in region name: {0} are locked.", string.Join(", ", TShock.Regions.InAreaRegionName(x, y))), Color.Red);

                        e.Handled = true;
                    }
                }
            }
            else if (type == PacketTypes.PlayerUpdate)
            {
                using (MemoryStream ms = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
                {
                    if (player.PrisonRecord != null)
                    {
                        if (!player.PrisonRecord.Released && player.PrisonRecord.Until <= DateTime.Now)
                        {
                            CommandHandlers.ReleaseFromPrison(new CommandArgs("releaseprisoner", null, new List <string>()
                            {
                                player.Player.UserAccountName
                            }));

                            player.PrisonRecord = null;
                        }
                        else
                        {
                            var plr     = ms.ReadInt8();
                            var control = ms.ReadInt8();
                            var item    = ms.ReadInt8();
                            var pos     = new Vector2(ms.ReadSingle(), ms.ReadSingle());
                            var vel     = new Vector2(ms.ReadSingle(), ms.ReadSingle());

                            var warp = TShock.Warps.FindWarp(Config.PrisonWarp);

                            float tilex;
                            float tiley;

                            if (warp.WarpPos != Vector2.Zero)
                            {
                                tilex = (int)(warp.WarpPos.X);
                                tiley = (int)(warp.WarpPos.Y);
                            }
                            else
                            {
                                tilex = Main.spawnTileX;
                                tiley = Main.spawnTileY;
                            }

                            float distance = Vector2.Distance(new Vector2((pos.X / 16f), (pos.Y / 16f)), new Vector2(tilex, tiley));
                            if (distance > TShock.Config.MaxRangeForDisabled)
                            {
                                if (warp.WarpPos != Vector2.Zero)
                                {
                                    player.Player.Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3);
                                }
                                else
                                {
                                    player.Player.Spawn();
                                }

                                TimeSpan remaining = player.PrisonRecord.Until - DateTime.Now;

                                player.Player.SendMessage(string.Format("You are still serving your prison sentence. {0} hour(s) {1} minute(s) remain.", (int)remaining.TotalHours, remaining.Minutes), Color.Yellow);
                            }
                        }
                    }
                    else
                    {
                        if (player.Player.Group.Name == Config.PrisonGroup)
                        {
                            CommandHandlers.ReleaseFromPrison(new CommandArgs("releaseprisoner", null, new List <string>()
                            {
                                player.Player.UserAccountName
                            }));
                        }
                    }
                }
            }
        }
Exemplo n.º 34
0
        private unsafe void InternalUpdate(Rectangle drawArea)
        {
            Rectangle rectangle = new Rectangle(drawArea.X - 2, drawArea.Y - 2, drawArea.Width + 4, drawArea.Height + 4);

            _drawArea = drawArea;
            Tile tile = null;

            fixed(LiquidCache *ptr = &_cache[0])
            {
                LiquidCache *ptr2 = ptr;
                int          num  = rectangle.Height * 2 + 2;

                ptr2 = ptr;
                for (int i = rectangle.X; i < rectangle.X + rectangle.Width; i++)
                {
                    for (int j = rectangle.Y; j < rectangle.Y + rectangle.Height; j++)
                    {
                        tile = _tiles[i, j];
                        if (tile == null)
                        {
                            tile = EMPTY_TILE;
                        }
                        ptr2->LiquidLevel        = (float)(int)tile.liquid / 255f;
                        ptr2->IsHalfBrick        = (tile.halfBrick() && ptr2[-1].HasLiquid);
                        ptr2->IsSolid            = (WorldGen.SolidOrSlopedTile(tile) && !ptr2->IsHalfBrick);
                        ptr2->HasLiquid          = (tile.liquid != 0);
                        ptr2->VisibleLiquidLevel = 0f;
                        ptr2->HasWall            = (tile.wall != 0);
                        ptr2->Type = tile.liquidType();
                        if (ptr2->IsHalfBrick && !ptr2->HasLiquid)
                        {
                            ptr2->Type = ptr2[-1].Type;
                        }
                        ptr2++;
                    }
                }
                ptr2 = ptr;
                float num2 = 0f;

                ptr2 += num;
                for (int k = 2; k < rectangle.Width - 2; k++)
                {
                    for (int l = 2; l < rectangle.Height - 2; l++)
                    {
                        num2 = 0f;
                        if (ptr2->IsHalfBrick && ptr2[-1].HasLiquid)
                        {
                            num2 = 1f;
                        }
                        else if (!ptr2->HasLiquid)
                        {
                            LiquidCache liquidCache  = ptr2[-rectangle.Height];
                            LiquidCache liquidCache2 = ptr2[rectangle.Height];
                            LiquidCache liquidCache3 = ptr2[-1];
                            LiquidCache liquidCache4 = ptr2[1];
                            if (liquidCache.HasLiquid && liquidCache2.HasLiquid && liquidCache.Type == liquidCache2.Type)
                            {
                                num2       = liquidCache.LiquidLevel + liquidCache2.LiquidLevel;
                                ptr2->Type = liquidCache.Type;
                            }
                            if (liquidCache3.HasLiquid && liquidCache4.HasLiquid && liquidCache3.Type == liquidCache4.Type)
                            {
                                num2       = Math.Max(num2, liquidCache3.LiquidLevel + liquidCache4.LiquidLevel);
                                ptr2->Type = liquidCache3.Type;
                            }
                            num2 *= 0.5f;
                        }
                        else
                        {
                            num2 = ptr2->LiquidLevel;
                        }
                        ptr2->VisibleLiquidLevel = num2;
                        ptr2->HasVisibleLiquid   = (num2 != 0f);
                        ptr2++;
                    }
                    ptr2 += 4;
                }
                ptr2 = ptr;
                for (int m = 0; m < rectangle.Width; m++)
                {
                    for (int n = 0; n < rectangle.Height - 10; n++)
                    {
                        if (ptr2->HasVisibleLiquid && !ptr2->IsSolid)
                        {
                            ptr2->Opacity     = 1f;
                            ptr2->VisibleType = ptr2->Type;
                            float num3 = 1f / (float)(WATERFALL_LENGTH[ptr2->Type] + 1);
                            float num4 = 1f;
                            for (int num5 = 1; num5 <= WATERFALL_LENGTH[ptr2->Type]; num5++)
                            {
                                num4 -= num3;
                                if (ptr2[num5].IsSolid)
                                {
                                    break;
                                }
                                ptr2[num5].VisibleLiquidLevel = Math.Max(ptr2[num5].VisibleLiquidLevel, ptr2->VisibleLiquidLevel * num4);
                                ptr2[num5].Opacity            = num4;
                                ptr2[num5].VisibleType        = ptr2->Type;
                            }
                        }
                        if (ptr2->IsSolid)
                        {
                            ptr2->VisibleLiquidLevel = 1f;
                            ptr2->HasVisibleLiquid   = false;
                        }
                        else
                        {
                            ptr2->HasVisibleLiquid = (ptr2->VisibleLiquidLevel != 0f);
                        }
                        ptr2++;
                    }
                    ptr2 += 10;
                }
                ptr2  = ptr;
                ptr2 += num;
                for (int num6 = 2; num6 < rectangle.Width - 2; num6++)
                {
                    for (int num7 = 2; num7 < rectangle.Height - 2; num7++)
                    {
                        if (!ptr2->HasVisibleLiquid || ptr2->IsSolid)
                        {
                            ptr2->HasLeftEdge   = false;
                            ptr2->HasTopEdge    = false;
                            ptr2->HasRightEdge  = false;
                            ptr2->HasBottomEdge = false;
                        }
                        else
                        {
                            LiquidCache liquidCache        = ptr2[-1];
                            LiquidCache liquidCache2       = ptr2[1];
                            LiquidCache liquidCache3       = ptr2[-rectangle.Height];
                            LiquidCache liquidCache4       = ptr2[rectangle.Height];
                            float       num8               = 0f;
                            float       num9               = 1f;
                            float       num10              = 0f;
                            float       num11              = 1f;
                            float       visibleLiquidLevel = ptr2->VisibleLiquidLevel;
                            if (!liquidCache.HasVisibleLiquid)
                            {
                                num10 += liquidCache2.VisibleLiquidLevel * (1f - visibleLiquidLevel);
                            }
                            if (!liquidCache2.HasVisibleLiquid && !liquidCache2.IsSolid && !liquidCache2.IsHalfBrick)
                            {
                                num11 -= liquidCache.VisibleLiquidLevel * (1f - visibleLiquidLevel);
                            }
                            if (!liquidCache3.HasVisibleLiquid && !liquidCache3.IsSolid && !liquidCache3.IsHalfBrick)
                            {
                                num8 += liquidCache4.VisibleLiquidLevel * (1f - visibleLiquidLevel);
                            }
                            if (!liquidCache4.HasVisibleLiquid && !liquidCache4.IsSolid && !liquidCache4.IsHalfBrick)
                            {
                                num9 -= liquidCache3.VisibleLiquidLevel * (1f - visibleLiquidLevel);
                            }
                            ptr2->LeftWall   = num8;
                            ptr2->RightWall  = num9;
                            ptr2->BottomWall = num11;
                            ptr2->TopWall    = num10;
                            Point zero = Point.Zero;
                            ptr2->HasTopEdge    = ((!liquidCache.HasVisibleLiquid && !liquidCache.IsSolid) || num10 != 0f);
                            ptr2->HasBottomEdge = ((!liquidCache2.HasVisibleLiquid && !liquidCache2.IsSolid) || num11 != 1f);
                            ptr2->HasLeftEdge   = ((!liquidCache3.HasVisibleLiquid && !liquidCache3.IsSolid) || num8 != 0f);
                            ptr2->HasRightEdge  = ((!liquidCache4.HasVisibleLiquid && !liquidCache4.IsSolid) || num9 != 1f);
                            if (!ptr2->HasLeftEdge)
                            {
                                if (ptr2->HasRightEdge)
                                {
                                    zero.X += 32;
                                }
                                else
                                {
                                    zero.X += 16;
                                }
                            }
                            if (ptr2->HasLeftEdge && ptr2->HasRightEdge)
                            {
                                zero.X  = 16;
                                zero.Y += 32;
                                if (ptr2->HasTopEdge)
                                {
                                    zero.Y = 16;
                                }
                            }
                            else if (!ptr2->HasTopEdge)
                            {
                                if (!ptr2->HasLeftEdge && !ptr2->HasRightEdge)
                                {
                                    zero.Y += 48;
                                }
                                else
                                {
                                    zero.Y += 16;
                                }
                            }
                            if (zero.Y == 16 && (ptr2->HasLeftEdge ^ ptr2->HasRightEdge) && num7 + rectangle.Y % 2 == 0)
                            {
                                zero.Y += 16;
                            }
                            ptr2->FrameOffset = zero;
                        }
                        ptr2++;
                    }
                    ptr2 += 4;
                }
                ptr2  = ptr;
                ptr2 += num;
                for (int num12 = 2; num12 < rectangle.Width - 2; num12++)
                {
                    for (int num13 = 2; num13 < rectangle.Height - 2; num13++)
                    {
                        if (ptr2->HasVisibleLiquid)
                        {
                            LiquidCache liquidCache  = ptr2[-1];
                            LiquidCache liquidCache2 = ptr2[1];
                            LiquidCache liquidCache3 = ptr2[-rectangle.Height];
                            LiquidCache liquidCache4 = ptr2[rectangle.Height];
                            ptr2->VisibleLeftWall   = ptr2->LeftWall;
                            ptr2->VisibleRightWall  = ptr2->RightWall;
                            ptr2->VisibleTopWall    = ptr2->TopWall;
                            ptr2->VisibleBottomWall = ptr2->BottomWall;
                            if (liquidCache.HasVisibleLiquid && liquidCache2.HasVisibleLiquid)
                            {
                                if (ptr2->HasLeftEdge)
                                {
                                    ptr2->VisibleLeftWall = (ptr2->LeftWall * 2f + liquidCache.LeftWall + liquidCache2.LeftWall) * 0.25f;
                                }
                                if (ptr2->HasRightEdge)
                                {
                                    ptr2->VisibleRightWall = (ptr2->RightWall * 2f + liquidCache.RightWall + liquidCache2.RightWall) * 0.25f;
                                }
                            }
                            if (liquidCache3.HasVisibleLiquid && liquidCache4.HasVisibleLiquid)
                            {
                                if (ptr2->HasTopEdge)
                                {
                                    ptr2->VisibleTopWall = (ptr2->TopWall * 2f + liquidCache3.TopWall + liquidCache4.TopWall) * 0.25f;
                                }
                                if (ptr2->HasBottomEdge)
                                {
                                    ptr2->VisibleBottomWall = (ptr2->BottomWall * 2f + liquidCache3.BottomWall + liquidCache4.BottomWall) * 0.25f;
                                }
                            }
                        }
                        ptr2++;
                    }
                    ptr2 += 4;
                }
                ptr2  = ptr;
                ptr2 += num;
                for (int num14 = 2; num14 < rectangle.Width - 2; num14++)
                {
                    for (int num15 = 2; num15 < rectangle.Height - 2; num15++)
                    {
                        if (ptr2->HasLiquid)
                        {
                            LiquidCache liquidCache  = ptr2[-1];
                            LiquidCache liquidCache2 = ptr2[1];
                            LiquidCache liquidCache3 = ptr2[-rectangle.Height];
                            LiquidCache liquidCache4 = ptr2[rectangle.Height];
                            if (ptr2->HasTopEdge && !ptr2->HasBottomEdge && (ptr2->HasLeftEdge ^ ptr2->HasRightEdge))
                            {
                                if (ptr2->HasRightEdge)
                                {
                                    ptr2->VisibleRightWall = liquidCache2.VisibleRightWall;
                                    ptr2->VisibleTopWall   = liquidCache3.VisibleTopWall;
                                }
                                else
                                {
                                    ptr2->VisibleLeftWall = liquidCache2.VisibleLeftWall;
                                    ptr2->VisibleTopWall  = liquidCache4.VisibleTopWall;
                                }
                            }
                            else if (liquidCache2.FrameOffset.X == 16 && liquidCache2.FrameOffset.Y == 32)
                            {
                                if (ptr2->VisibleLeftWall > 0.5f)
                                {
                                    ptr2->VisibleLeftWall = 0f;
                                    ptr2->FrameOffset     = new Point(0, 0);
                                }
                                else if (ptr2->VisibleRightWall < 0.5f)
                                {
                                    ptr2->VisibleRightWall = 1f;
                                    ptr2->FrameOffset      = new Point(32, 0);
                                }
                            }
                        }
                        ptr2++;
                    }
                    ptr2 += 4;
                }
                ptr2  = ptr;
                ptr2 += num;
                for (int num16 = 2; num16 < rectangle.Width - 2; num16++)
                {
                    for (int num17 = 2; num17 < rectangle.Height - 2; num17++)
                    {
                        if (ptr2->HasLiquid)
                        {
                            LiquidCache liquidCache  = ptr2[-1];
                            LiquidCache liquidCache2 = ptr2[1];
                            LiquidCache liquidCache3 = ptr2[-rectangle.Height];
                            LiquidCache liquidCache4 = ptr2[rectangle.Height];
                            if (!ptr2->HasBottomEdge && !ptr2->HasLeftEdge && !ptr2->HasTopEdge && !ptr2->HasRightEdge)
                            {
                                if (liquidCache3.HasTopEdge && liquidCache.HasLeftEdge)
                                {
                                    ptr2->FrameOffset.X     = Math.Max(4, (int)(16f - liquidCache.VisibleLeftWall * 16f)) - 4;
                                    ptr2->FrameOffset.Y     = 48 + Math.Max(4, (int)(16f - liquidCache3.VisibleTopWall * 16f)) - 4;
                                    ptr2->VisibleLeftWall   = 0f;
                                    ptr2->VisibleTopWall    = 0f;
                                    ptr2->VisibleRightWall  = 1f;
                                    ptr2->VisibleBottomWall = 1f;
                                }
                                else if (liquidCache4.HasTopEdge && liquidCache.HasRightEdge)
                                {
                                    ptr2->FrameOffset.X     = 32 - Math.Min(16, (int)(liquidCache.VisibleRightWall * 16f) - 4);
                                    ptr2->FrameOffset.Y     = 48 + Math.Max(4, (int)(16f - liquidCache4.VisibleTopWall * 16f)) - 4;
                                    ptr2->VisibleLeftWall   = 0f;
                                    ptr2->VisibleTopWall    = 0f;
                                    ptr2->VisibleRightWall  = 1f;
                                    ptr2->VisibleBottomWall = 1f;
                                }
                            }
                        }
                        ptr2++;
                    }
                    ptr2 += 4;
                }
                ptr2  = ptr;
                ptr2 += num;
                fixed(LiquidDrawCache *ptr3 = &_drawCache[0])
                {
                    LiquidDrawCache *ptr4 = ptr3;

                    for (int num18 = 2; num18 < rectangle.Width - 2; num18++)
                    {
                        for (int num19 = 2; num19 < rectangle.Height - 2; num19++)
                        {
                            if (ptr2->HasVisibleLiquid)
                            {
                                float num20 = Math.Min(0.75f, ptr2->VisibleLeftWall);
                                float num21 = Math.Max(0.25f, ptr2->VisibleRightWall);
                                float num22 = Math.Min(0.75f, ptr2->VisibleTopWall);
                                float num23 = Math.Max(0.25f, ptr2->VisibleBottomWall);
                                if (ptr2->IsHalfBrick && num23 > 0.5f)
                                {
                                    num23 = 0.5f;
                                }
                                ptr4->IsVisible       = (ptr2->HasWall || !ptr2->IsHalfBrick || !ptr2->HasLiquid);
                                ptr4->SourceRectangle = new Rectangle((int)(16f - num21 * 16f) + ptr2->FrameOffset.X, (int)(16f - num23 * 16f) + ptr2->FrameOffset.Y, (int)Math.Ceiling((num21 - num20) * 16f), (int)Math.Ceiling((num23 - num22) * 16f));
                                ptr4->IsSurfaceLiquid = (ptr2->FrameOffset.X == 16 && ptr2->FrameOffset.Y == 0 && (double)(num19 + rectangle.Y) > Main.worldSurface - 40.0);
                                ptr4->Opacity         = ptr2->Opacity;
                                ptr4->LiquidOffset    = new Vector2((float)Math.Floor(num20 * 16f), (float)Math.Floor(num22 * 16f));
                                ptr4->Type            = ptr2->VisibleType;
                                ptr4->HasWall         = ptr2->HasWall;
                            }
                            else
                            {
                                ptr4->IsVisible = false;
                            }
                            ptr2++;
                            ptr4++;
                        }
                        ptr2 += 4;
                    }
                }

                ptr2 = ptr;
                for (int num24 = rectangle.X; num24 < rectangle.X + rectangle.Width; num24++)
                {
                    for (int num25 = rectangle.Y; num25 < rectangle.Y + rectangle.Height; num25++)
                    {
                        if (ptr2->VisibleType == 1 && ptr2->HasVisibleLiquid && Dust.lavaBubbles < 200)
                        {
                            if (_random.Next(700) == 0)
                            {
                                Dust.NewDust(new Vector2(num24 * 16, num25 * 16), 16, 16, 35, 0f, 0f, 0, Color.White);
                            }
                            if (_random.Next(350) == 0)
                            {
                                int num26 = Dust.NewDust(new Vector2(num24 * 16, num25 * 16), 16, 8, 35, 0f, 0f, 50, Color.White, 1.5f);
                                Main.dust[num26].velocity   *= 0.8f;
                                Main.dust[num26].velocity.X *= 2f;
                                Main.dust[num26].velocity.Y -= (float)_random.Next(1, 7) * 0.1f;
                                if (_random.Next(10) == 0)
                                {
                                    Main.dust[num26].velocity.Y *= _random.Next(2, 5);
                                }
                                Main.dust[num26].noGravity = true;
                            }
                        }
                        ptr2++;
                    }
                }
            }
        }
Exemplo n.º 35
0
        public static void StructureGen(int xPosO, int yPosO, bool mirrored)
        {
            //Obsidium Heart

            /**
             * 0 = Do Nothing
             * 1 = Obsidium Rock
             * 2 = Obsidium Brick
             * 3 = Lava
             * 4 = Obsidium Ore
             * 9 = Kill tile
             * */
            int[,] StructureGen = new int[, ]
            {
                { 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0 },
                { 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0 },
                { 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 9, 9, 9, 9, 0, 0, 0 },
                { 0, 9, 9, 9, 9, 1, 2, 2, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 2, 2, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 9, 9, 9, 9, 9, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 2, 1, 1, 2, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 2, 2, 2, 2, 1, 2, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 2, 2, 2, 1, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 2, 2, 1, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 4, 4, 4, 3, 3, 3, 4, 4, 4, 4, 3, 4, 4, 3, 3, 4, 4, 4, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0 },
                { 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 1, 1, 2, 2, 2, 2, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0 },
                { 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0 },
                { 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 1, 1, 1, 2, 2, 2, 2, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0 },
                { 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0 },
                { 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0 },
                { 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0 },
                { 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0 },
                { 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 2, 9, 9, 2, 2, 1, 2, 2, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
                { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            };

            for (int i = 0; i < StructureGen.GetLength(1); i++)
            {
                for (int j = 0; j < StructureGen.GetLength(0); j++)
                {
                    if (mirrored)
                    {
                        if (TileCheckSafe((int)(xPosO + StructureGen.GetLength(1) - i), (int)(yPosO + j)))
                        {
                            if (StructureGen[j, i] == 1)
                            {
                                WorldGen.KillTile(xPosO + StructureGen.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + StructureGen.GetLength(1) - i, yPosO + j, Laugicality.instance.TileType("ObsidiumRock"), true, true);
                            }
                            if (StructureGen[j, i] == 2)
                            {
                                WorldGen.KillTile(xPosO + StructureGen.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + StructureGen.GetLength(1) - i, yPosO + j, 56, true, true);
                            }
                            if (StructureGen[j, i] == 3)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                Main.tile[xPosO + StructureGen.GetLength(1) - i, yPosO + j].lava(true);
                                Main.tile[xPosO + StructureGen.GetLength(1) - i, yPosO + j].liquid = 255;
                            }
                            if (StructureGen[j, i] == 4)
                            {
                                WorldGen.KillTile(xPosO + StructureGen.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + StructureGen.GetLength(1) - i, yPosO + j, Laugicality.instance.TileType("ObsidiumOreBlock"), true, true);
                            }
                            if (StructureGen[j, i] == 9)
                            {
                                WorldGen.KillTile(xPosO + StructureGen.GetLength(1) - i, yPosO + j);
                            }
                        }
                    }
                    else
                    {
                        if (TileCheckSafe((int)(xPosO + i), (int)(yPosO + j)))
                        {
                            if (StructureGen[j, i] == 1)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + i, yPosO + j, Laugicality.instance.TileType("ObsidiumRock"), true, true);
                            }
                            if (StructureGen[j, i] == 2)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + i, yPosO + j, 56, true, true);
                            }
                            if (StructureGen[j, i] == 3)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                Main.tile[xPosO + i, yPosO + j].lava(true);
                                Main.tile[xPosO + i, yPosO + j].liquid = 255;
                            }
                            if (StructureGen[j, i] == 4)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + i, yPosO + j, Laugicality.instance.TileType("ObsidiumOreBlock"), true, true);
                            }
                            if (StructureGen[j, i] == 9)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 36
0
        private void TrySpawningWind(int x, int y)
        {
            if (!WorldGen.InWorld(x, y, 10) || Main.tile[x, y] == null)
            {
                return;
            }
            this.TestAirCloud(x, y);
            Tile tile = Main.tile[x, y];

            if (!tile.active() || tile.slope() > (byte)0 || (tile.halfBrick() || !Main.tileSolid[(int)tile.type]) || (WorldGen.SolidTile(Main.tile[x, y - 1]) || this._random.Next(120) != 0))
            {
                return;
            }
            this.SpawnFloorCloud(x, y);
            if (this._random.Next(3) != 0)
            {
                return;
            }
            this.SpawnFloorCloud(x, y - 1);
        }
Exemplo n.º 37
0
 void Awake()
 {
     inst = this;
 }
Exemplo n.º 38
0
        public override void Kill(int timeLeft)
        {
            #region Updated WorldGen Convert
            Vector2 position = projectile.Center;
            Main.PlaySound(SoundID.Item14, (int)position.X, (int)position.Y);

            int radius = 60;
            //float[] speedX = { 0, 0, 5, 5, 5, -5, -5, -5 };
            //float[] speedY = { 5, -5, 0, 5, -5, 0, 5, -5 };

            for (int i = 0; i < 58; i++)
            {
                float speedX = Main.rand.NextFloat(-12, 12);
                float speedY = Main.rand.NextFloat(-10, 10);
                //Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX[i], speedY[i], ProjectileID.PureSpray, 0, 0, Main.myPlayer);
                Dust.NewDust(projectile.position, projectile.width, projectile.height, 16, speedX, speedY, 100, new Color(), 1.5f);
            }

            for (int x = -radius; x <= radius; x++)
            {
                for (int y = -radius; y <= radius; y++)
                {
                    int xPosition = (int)(x + (position.X / 16.0f));
                    int yPosition = (int)(y + (position.Y / 16.0f));

                    if (Math.Sqrt(x * x + y * y) <= radius + 0.5)   //circle
                    {
                        #region Bomb Conversion
                        #region Border Saftey Checks
                        if (xPosition < 0 && yPosition < 0)//top left
                        {
                            xPosition = 0;
                            yPosition = 0;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2)                     //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2 || wall == 59)      //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        if ((xPosition >= Main.maxTilesX - 43) && yPosition < 0)//top right
                        {
                            xPosition = Main.maxTilesX - 43;
                            yPosition = 0;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2)                     //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2 || wall == 59)      //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        if (xPosition < 0 && yPosition >= Main.maxTilesY - 44)//bottom left
                        {
                            xPosition = 0;
                            yPosition = Main.maxTilesY - 44;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2 || wall == 59)       //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2)                    //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        if ((xPosition >= Main.maxTilesX - 43) && yPosition >= Main.maxTilesY - 44)//bottom right
                        {
                            xPosition = Main.maxTilesX - 43;
                            yPosition = Main.maxTilesY - 44;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2 || wall == 59)       //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2)                    //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        if (xPosition < 0)//left wall
                        {
                            xPosition = 0;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2)                     //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2 || wall == 59)      //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        if (xPosition >= Main.maxTilesX - 43)//right wall MaxX
                        {
                            xPosition = Main.maxTilesX - 43;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2)                     //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2 || wall == 59)      //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        if (yPosition < 0)//top
                        {
                            yPosition = 0;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2)                     //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2 || wall == 59)      //Stone, Dirt, Dirt with Stones
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        if (yPosition >= Main.maxTilesY - 44)//bottom
                        {
                            yPosition = Main.maxTilesY - 44;
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2 || wall == 59)       //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2)                    //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion
                            }
                        }
                        #endregion

                        else
                        {
                            Tile tile = Main.tile[xPosition, yPosition];
                            int  type = Main.tile[xPosition, yPosition].type;
                            int  wall = Main.tile[xPosition, yPosition].wall;
                            if (tile != null)
                            {
                                #region Blocks Snow and Ice
                                if (type == 0 || type == 2)                     //Dirt, Grass
                                {
                                    Main.tile[xPosition, yPosition].type = 147; //Snow block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (type == 1)                                  //Stone
                                {
                                    Main.tile[xPosition, yPosition].type = 161; //Ice block
                                    WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                #region Walls Snow and Ice Walls
                                if (wall == 1 || wall == 2)                    //Stone, Dirt
                                {
                                    Main.tile[xPosition, yPosition].wall = 40; //Snow Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                if (wall > 195 && wall < 200)                  //Dirt Cavern
                                {
                                    Main.tile[xPosition, yPosition].wall = 71; //Ice Unsafe
                                    WorldGen.SquareWallFrame(xPosition, yPosition, true);
                                    NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                                }
                                #endregion

                                //Main.tile[xPosition, yPosition].lava(false);
                                //Main.tile[xPosition, yPosition].liquid = 0;
                                //WorldGen.SquareTileFrame(xPosition, yPosition, true);
                                //NetMessage.SendTileSquare(-1, xPosition, yPosition, 1);
                            }
                        }
                        #endregion
                    }
                }
            }
            #endregion
        }
Exemplo n.º 39
0
 // Use this for initialization
 void Start()
 {
     wg = GameObject.FindGameObjectWithTag("world").GetComponent<WorldGen>();
 }
Exemplo n.º 40
0
        private void ConvertTiles()
        {
            int minX = (int)(projectile.position.X / 16) - 2;
            int maxX = (int)((projectile.position.X + projectile.width) / 16) + 2;

            int minY = (int)(projectile.position.Y / 16) - 2;
            int maxY = (int)((projectile.position.Y + projectile.height) / 16) + 2;

            if (minX < 0)
            {
                minX = 0;
            }
            if (maxX > Main.maxTilesX)
            {
                maxX = Main.maxTilesX;
            }

            if (minY < 0)
            {
                minY = 0;
            }
            if (maxY > Main.maxTilesY)
            {
                maxY = Main.maxTilesY;
            }

            for (int x = minX; x <= maxX; ++x)
            {
                for (int y = minY; y <= maxY; ++y)
                {
                    if (Main.myPlayer == projectile.owner && Main.tile[x, y] != null)
                    {
                        if (Main.tile[x, y].type == TileID.CorruptGrass || Main.tile[x, y].type == TileID.FleshGrass || Main.tile[x, y].type == TileID.Grass)
                        {
                            Main.tile[x, y].type = TileID.HallowedGrass;
                            WorldGen.SquareTileFrame(x, y);
                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                NetMessage.SendTileSquare(-1, x, y, 1);
                            }
                        }
                        else if (Main.tile[x, y].type == TileID.Ebonsand || Main.tile[x, y].type == TileID.Crimsand || Main.tile[x, y].type == TileID.Sand)
                        {
                            Main.tile[x, y].type = TileID.Pearlsand;
                            WorldGen.SquareTileFrame(x, y);
                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                NetMessage.SendTileSquare(-1, x, y, 1);
                            }
                        }
                        else if (Main.tile[x, y].type == TileID.Ebonstone || Main.tile[x, y].type == TileID.Crimstone || Main.tile[x, y].type == TileID.Stone)
                        {
                            Main.tile[x, y].type = TileID.Pearlstone;
                            WorldGen.SquareTileFrame(x, y);
                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                NetMessage.SendTileSquare(-1, x, y, 1);
                            }
                        }
                        else if (Main.tile[x, y].type == TileID.CorruptIce || Main.tile[x, y].type == TileID.FleshIce || Main.tile[x, y].type == TileID.IceBlock)
                        {
                            Main.tile[x, y].type = TileID.HallowedIce;
                            WorldGen.SquareTileFrame(x, y);
                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                NetMessage.SendTileSquare(-1, x, y, 1);
                            }
                        }
                        else if (Main.tile[x, y].type == TileID.CorruptHardenedSand || Main.tile[x, y].type == TileID.CrimsonHardenedSand || Main.tile[x, y].type == TileID.HardenedSand)
                        {
                            Main.tile[x, y].type = TileID.HallowHardenedSand;
                            WorldGen.SquareTileFrame(x, y);
                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                NetMessage.SendTileSquare(-1, x, y, 1);
                            }
                        }
                        else if (Main.tile[x, y].type == TileID.CorruptSandstone || Main.tile[x, y].type == TileID.CrimsonSandstone || Main.tile[x, y].type == TileID.Sandstone)
                        {
                            Main.tile[x, y].type = TileID.HallowSandstone;
                            WorldGen.SquareTileFrame(x, y);
                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                NetMessage.SendTileSquare(-1, x, y, 1);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 41
0
    void Awake()
    {
        // creat collision efets
        mWorldGen = transform.Find("WorldGen").GetComponent<WorldGen>();
        mBgGen = transform.Find("BgGen").GetComponent<WorldGen>();

        GameObject playerObj = GameObject.Find("Player");
        if (playerObj == null)
        {
            playerObj = GameObject.Instantiate(mPlayerPrefab);
            playerObj.name = mPlayerPrefab.name;
        }
        mPlayer = playerObj.GetComponent<Player>();

        GameObject dirLightObj = GameObject.Find("InGame DirectionalLight");
        if (dirLightObj == null)
        {
            dirLightObj = GameObject.Instantiate(mDirectionalLightPrefab);
            dirLightObj.name = mDirectionalLightPrefab.name;
        }
        mDirectionalLight = dirLightObj;

        GameObject deathMenuObj = GameObject.Find("pop_up_menu_results");
        if (deathMenuObj == null)
        {
            deathMenuObj = GameObject.Instantiate(mDeathMenuPrefab);
            deathMenuObj.name = mDeathMenuPrefab.name;
        }
        mDeathMenu = deathMenuObj;
        mDeathMenu.SetActive(false);

        fmodMusic = AudioManager.Instance.GetMusicEvent("AsteroidLevelMusic/AsteroidMusicPrototype", false);
        fmodPerfect = AudioManager.Instance.GetSoundsEvent("PerfectDistance/PerfectDistance", true, 3);

        mPerfectDistanceMid = GameObject.Instantiate(mPerfectDistanceMidPrefab);

        // creat collision efets
        mAstCollParticle1Manager = GetComponents<ParticleManager>()[0];
        mAstCollParticle2Manager = GetComponents<ParticleManager>()[1];
        mBulletCollParticleManager = GetComponents<ParticleManager>()[2];
        mMissileCollParticleManager = GetComponents<ParticleManager>()[3];
        mLightningCollParticleManager = GetComponents<ParticleManager>()[4];
    }
Exemplo n.º 42
0
        public bool PlaceWell(int i, int j)
        {
            if (!WorldGen.SolidTile(i, j + 1))
            {
                return(false);
            }
            if (Main.tile[i, j].active())
            {
                return(false);
            }
            if (j < 150)
            {
                return(false);
            }

            for (int y = 0; y < _wellshape.GetLength(0); y++)
            {
                for (int x = 0; x < _wellshape.GetLength(1); x++)
                {
                    int k = i - 3 + x;
                    int l = j - 6 + y;
                    if (WorldGen.InWorld(k, l, 30))
                    {
                        Tile tile = Framing.GetTileSafely(k, l);
                        switch (_wellshape[y, x])
                        {
                        case 1:
                            tile.type = TileID.RedBrick;
                            tile.active(true);
                            break;

                        case 2:
                            tile.type = TileID.RedBrick;
                            tile.active(true);
                            tile.halfBrick(true);
                            break;

                        case 3:
                            tile.type = TileID.RedBrick;
                            tile.active(true);
                            tile.slope(2);
                            break;

                        case 4:
                            tile.type = TileID.RedBrick;
                            tile.active(true);
                            tile.slope(1);
                            break;

                        case 5:
                            tile.active(false);
                            break;

                        case 6:
                            tile.type = TileID.Rope;
                            tile.active(true);
                            break;
                        }
                        switch (_wellshapeWall[y, x])
                        {
                        case 1:
                            tile.wall = WallID.RedBrick;
                            break;
                        }
                        switch (_wellshapeWater[y, x])
                        {
                        case 1:
                            tile.liquid = 255;
                            break;
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 43
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>();

            WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[2]
            {
                (ushort)0,
                (ushort)1
            }).Output(resultsOutput));
            if (resultsOutput[(ushort)0] + resultsOutput[(ushort)1] < 1250)
            {
                return(false);
            }
            Point result;
            bool  flag = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result);

            if (WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(origin.Y - result.Y), (GenCondition) new Conditions.IsTile(new ushort[1]
            {
                (ushort)53
            })), out Point _) || !flag)
            {
                return(false);
            }
            result.Y += 50;
            ShapeData data1     = new ShapeData();
            ShapeData shapeData = new ShapeData();
            Point     point1    = new Point(origin.X, origin.Y + 20);
            Point     point2    = new Point(origin.X, origin.Y + 30);

            bool[] validTiles = new bool[TileID.Sets.GeneralPlacementTiles.Length];
            for (int index = 0; index < validTiles.Length; ++index)
            {
                validTiles[index] = TileID.Sets.GeneralPlacementTiles[index];
            }
            validTiles[21]  = false;
            validTiles[467] = false;
            float xScale = (float)(0.800000011920929 + (double)GenBase._random.NextFloat() * 0.5);

            if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), validTiles, 0) || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), validTiles, 2))
            {
                return(false);
            }
            WorldUtils.Gen(point1, (GenShape) new Shapes.Slime(20, xScale, 1f), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(true).Output(data1)));
            WorldUtils.Gen(point2, (GenShape) new Shapes.Mound(14, 14), Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8), (GenAction) new Actions.SetTile((ushort)0, false, true), new Actions.SetFrames(true).Output(shapeData)));
            data1.Subtract(shapeData, point1, point2);
            WorldUtils.Gen(point1, (GenShape) new ModShapes.InnerOutline(data1, true), Actions.Chain((GenAction) new Actions.SetTile((ushort)2, false, true), (GenAction) new Actions.SetFrames(true)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid(0, byte.MaxValue)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.PlaceWall((ushort)68, true), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5, 382)));
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfEntrance)
            {
                ShapeData data2 = new ShapeData();
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.2), (GenAction) new Modifiers.SkipTiles(new ushort[2]
                {
                    (ushort)191,
                    (ushort)192
                }), new Actions.ClearTile(false).Output(data2), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
                {
                    (ushort)53
                }), new Actions.SetTile((ushort)397, false, true).Output(data2)));
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new ModShapes.All(data2), (GenAction) new Actions.SetFrames(true));
            }
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfRealSword)
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, false, -1, 15);
            }
            WorldUtils.Gen(point2, (GenShape) new ModShapes.All(shapeData), Actions.Chain((GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass()));
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), 10);
            return(true);
        }
Exemplo n.º 44
0
Arquivo: Hawk.cs Projeto: 9volt/ld29
 // Use this for initialization
 void Start()
 {
     wg = GameObject.FindGameObjectWithTag("world").GetComponent<WorldGen>();
     speed = Random.Range(5,12);
 }