Ejemplo n.º 1
0
    IEnumerator SmokeLoop()
    {
        while (truckManager.truckState == TruckState.ALMOST_LOAD)
        {
            switch (smokeState)
            {
            case SmokeState.NONE:
                smokeState = SmokeState.SMALL;
                break;

            case SmokeState.SMALL:
                smokeState = SmokeState.LARGE;
                break;

            case SmokeState.LARGE:
                smokeState = SmokeState.NONE;
                break;
            }
            yield return(new WaitForSeconds(gameManager.gameLoopSpeed / 4));
        }

        smokeState = SmokeState.NONE;
    }
Ejemplo n.º 2
0
 public void UpdateBurning(int material, FireState state, SmokeState smoke)
 {
     Material = material;
     State    = state;
     Smoke    = smoke;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Advances the simulation one time step.
        /// </summary>
        public static void Step(Tile[,] map)
        {
            int width  = map.GetLength(0);
            int height = map.GetLength(1);

            int[,] material     = new int[width, height];
            FireState[,] state  = new FireState[width, height];
            SmokeState[,] smoke = new SmokeState[width, height];

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    // Set new material and state equal to present by default (nothing happens)
                    material[x, y] = map[x, y].Material;
                    state[x, y]    = map[x, y].State;
                    smoke[x, y]    = map[x, y].Smoke;

                    switch (map[x, y].State)
                    {
                    case FireState.Nonflammable:
                        break;

                    case FireState.Unburned:
                        // If so, this cell may start burning based on its flammability
                        if (HasNeighbor(x, y, map, t => t.State == FireState.Burning) &&
                            Global.rand.NextDouble() < map[x, y].Flammability)
                        {
                            state[x, y] = FireState.Burning;
                        }
                        break;

                    case FireState.Burning:
                        material[x, y]--;
                        if (material[x, y] <= 0)
                        {
                            state[x, y] = FireState.Burnt;
                        }
                        break;

                    case FireState.Burnt:
                        break;
                    }

                    switch (map[x, y].Smoke)
                    {
                    case SmokeState.WithSmoke:
                        break;

                    case SmokeState.WithoutSmoke:
                        if (((HasNeighbor(x, y, map, t => t.Smoke == SmokeState.WithSmoke) &&
                              Global.rand.NextDouble() < Global.SmokeSpread) ||
                             state[x, y] == FireState.Burning) &&
                            !map[x, y].Solid)
                        {
                            smoke[x, y] = SmokeState.WithSmoke;
                        }
                        break;
                    }
                }
            }

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    map[x, y].UpdateBurning(material[x, y], state[x, y], smoke[x, y]);
                }
            }
        }