Anonymous avatar Anonymous committed 380a7fa

Add Ice, Salt, and Soil particle types.

Comments (0)

Files changed (10)

FallingSand/FallingSand.csproj

     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="SoilP.cs" />
+    <Compile Include="SaltP.cs" />
+    <Compile Include="IceP.cs" />
     <Compile Include="PipeP.cs" />
     <Compile Include="LavaP.cs" />
     <Compile Include="WaxP.cs" />

FallingSand/FireP.cs

                     {
                         fireCount++;
                     }
-                    if (GameGrid.TestOdds(this[x, y].flammability, 1000))
+                    if (this[x, y] == ParticleType.Ice)
+                    {
+                        this[x, y] = new WaterP(grid, xLoc + x, yLoc + y);
+                    }
+                    else if (GameGrid.TestOdds(this[x, y].flammability, 1000))
                     {
                         this[x, y] = new FireP(grid, xLoc + x, yLoc + y, this[x,y].burntime, this[x,y].type);
                     }

FallingSand/Form1.cs

                                     case ParticleType.Pipe:
                                         par = new PipeP(grid, xPos, yPos);
                                         break;
+                                    case ParticleType.Salt:
+                                        par = new SaltP(grid, xPos, yPos);
+                                        break;
+                                    case ParticleType.Ice:
+                                        par = new IceP(grid, xPos, yPos);
+                                        break;
+                                    case ParticleType.Soil:
+                                        par = new SoilP(grid, xPos, yPos);
+                                        break;
                                 }
                                 grid[xPos, yPos] = par;
                             }

FallingSand/IceP.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FallingSand
+{
+    class IceP : Particle
+    {
+        public IceP(GameGrid grid, int x, int y)
+            : base(grid, x, y)
+        {
+            this.type = ParticleType.Ice;
+            this.density = 500;
+        }
+    }
+}

FallingSand/LavaP.cs

                     {
                         this[x, y] = new WallP(grid, xLoc + x, yLoc + y);
                     }
+                    else if(this[x,y] == ParticleType.Ice)
+                    {
+                        this[x, y] = new FireP(grid, xLoc + x, yLoc + y);
+                    }
                     else if (GameGrid.TestOdds(this[x, y].flammability, 1000))
                     {
                         this[x, y] = new FireP(grid, xLoc + x, yLoc + y, this[x, y].burntime, this[x, y].type);

FallingSand/Particle.cs

         Pipe = 0x222222,
         Weird = 0xFFFFFF,
         Weird2 = 0xFE0000,
-        Weird3 = 0xFF00FF
+        Weird3 = 0xFF00FF,
+        Ice = 0xCCCCFF,
+        Salt = 0xFEFEFE,
+        Soil = 0x673703
     }
 
     class Particle

FallingSand/PlantP.cs

                 {
                     if (x == 0 && y == 0)
                         continue;
-                    if (this[x, y] == ParticleType.Water)
+                    if (this[x, y] == ParticleType.Water || this[x,y] == ParticleType.Soil)
                     {
                         int count = 0;
                         for (int x2 = -1; x2 < 2; x2++)

FallingSand/SaltP.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FallingSand
+{
+    class SaltP : Particle
+    {
+        public SaltP(GameGrid grid, int x, int y)
+            : base(grid, x, y)
+        {
+            this.type = ParticleType.Salt;
+            this.density = 3;
+        }
+        public override void Tick()
+        {
+            for (int x = -1; x < 2; x++)
+            {
+                for (int y = -1; y < 2; y++)
+                {
+                    if (x == 0 && y == 0)
+                        continue;
+                    if (this[x, y].type == ParticleType.Ice && GameGrid.TestOdds(1,60))
+                    {
+                        this[x, y] = new WaterP(grid, xLoc + x, yLoc + y);
+                    }
+                }
+            }
+            if (this[0, -1].density < this.density)
+            {
+                Swap(this[0, -1]);
+            }
+            else if (GameGrid.TestOdds(2, 3))
+            {
+
+            }
+            else if (GameGrid.TestOdds(1, 2))
+            {
+                if (this[1, -1].density < this.density)
+                {
+                    if (this[1, -1].type == ParticleType.Ice)
+                    {
+                        this[1, -1] = new WaterP(grid, xLoc + 1, yLoc - 1);
+                    }
+                    Swap(this[1, -1]);
+                }
+                else if (this[-1, -1].density < this.density)
+                {
+                    if (this[-1, -1].type == ParticleType.Ice)
+                    {
+                        this[-1, -1] = new WaterP(grid, xLoc - 1, yLoc - 1);
+                    }
+                    Swap(this[-1, -1]);
+                }
+            }
+            else
+            {
+                if (this[-1, -1].density < this.density)
+                {
+                    if (this[-1, -1].type == ParticleType.Ice)
+                    {
+                        this[-1, -1] = new WaterP(grid, xLoc - 1, yLoc - 1);
+                    }
+                    Swap(this[-1, -1]);
+                }
+                else if (this[1, -1].density < this.density)
+                {
+                    if (this[1, -1].type == ParticleType.Ice)
+                    {
+                        this[1, -1] = new WaterP(grid, xLoc + 1, yLoc - 1);
+                    }
+                    Swap(this[1, -1]);
+                }
+            }
+        }
+    }
+}

FallingSand/SoilP.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FallingSand
+{
+    class SoilP : Particle
+    {
+        public SoilP(GameGrid grid, int x, int y)
+            : base(grid, x, y)
+        {
+            this.type = ParticleType.Soil;
+            this.density = 3;
+        }
+        public override void Tick()
+        {
+            if (this[0, -1].density < this.density)
+            {
+                Swap(this[0, -1]);
+            }
+            else if (GameGrid.TestOdds(2, 3))
+            {
+
+            }
+            else if (GameGrid.TestOdds(1, 2))
+            {
+                if (this[1, -1].density < this.density)
+                    Swap(this[1, -1]);
+                else if (this[-1, -1].density < this.density)
+                    Swap(this[-1, -1]);
+            }
+            else
+            {
+                if (this[-1, -1].density < this.density)
+                    Swap(this[-1, -1]);
+                else if (this[1, -1].density < this.density)
+                    Swap(this[1, -1]);
+            }
+        }
+    }
+}

FallingSand/SparkP.cs

                 {
                     if(x == 0 && y == 0)
                         continue;
-                    if (GameGrid.TestOdds(this[x, y].flammability, 2000))
+                    if (this[x, y] == ParticleType.Ice)
+                    {
+                        this[x, y] = new WaterP(grid, xLoc + x, yLoc + y);
+                    }
+                    else if (GameGrid.TestOdds(this[x, y].flammability, 2000))
                     {
                         this[x, y] = new FireP(grid, xLoc + x, yLoc + y);
                     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.