예제 #1
0
 public void Fire()
 {
     if (fireDelay.Check(0.5f - (0.05f * fireRate)))
     {
         for (int s = 1; s <= spread; s++)
         {
             damagers.Add(new Damager(0, s, this));
         }
     }
 }
예제 #2
0
        public static void Update()
        {
            if (ticker.Check(true))
            {
                Sprite updatedCells = new Sprite(Game.size, "  ", 0, deadColor);

                for (int y = 0; y < Game.size.y; y++)
                {
                    for (int x = 0; x < Game.size.x; x++)
                    {
                        int yMin = y - 1;
                        int yMax = y + 2;
                        int xMin = x - 1;
                        int xMax = x + 2;

                        if (yMin < 0)
                        {
                            yMin = 0;
                        }
                        if (yMax > Game.size.y)
                        {
                            yMax = Game.size.y;
                        }
                        if (xMin < 0)
                        {
                            xMin = 0;
                        }
                        if (xMax > Game.size.x)
                        {
                            xMax = Game.size.x;
                        }

                        int neighbors = 0;

                        for (int cy = yMin; cy < yMax; cy++)
                        {
                            for (int cx = xMin; cx < xMax; cx++)
                            {
                                if (cy != y | cx != x)
                                {
                                    if (cells.spriteSheet[0][0].grid[cy][cx].background == aliveColor)
                                    {
                                        neighbors += 1;
                                    }
                                }
                            }
                        }

                        if (CheckRules(cells.spriteSheet[0][0].grid[y][x].background == aliveColor, neighbors))
                        {
                            updatedCells.grid[y][x].background = aliveColor;
                        }
                        else
                        {
                            updatedCells.grid[y][x].background = deadColor;
                        }
                    }
                }

                cells.spriteSheet[0][0] = updatedCells;
                cells.Refresh();
            }
        }