Example #1
0
        public static void ApplyFromCharCell(CellManager manager, Point offset, string text, CharCell charCell, int space)
        {
            var id = offset;

            for (var i = 0; i < text.Length; ++i)
            {
                var message = charCell.GetMessage(text[i]);
                Apply(message, manager, id);
                id += new Point(GetBundle(message).Max.x + space, 0);
            }
        }
Example #2
0
            public void Apply(CellManager manager, Point offset)
            {
                var targetId = offset + this.Id;

                if (this.IsAlive && !manager.CellDictionary.ContainsKey(targetId))
                {
                    manager.CreateCell(targetId);
                }
                else if (!this.IsAlive && manager.CellDictionary.ContainsKey(targetId))
                {
                    manager.RemoveCell(targetId);
                }
            }
Example #3
0
        public void NextGeneration(CellManager manager)
        {
            var min = new Point {
                x = this.id.x - 1, y = this.id.y - 1
            };
            var max = new Point {
                x = this.id.x + 1, y = this.id.y + 1
            };

            for (var y = min.y; y <= max.y; ++y)
            {
                for (var x = min.x; x <= max.x; ++x)
                {
                    var targetId = new Point {
                        x = x, y = y
                    };
                    if (manager.ProcessedCells.ContainsKey(targetId))
                    {
                        continue;
                    }

                    var adjacentNumber = manager.GetAdjacentNumber(targetId);
                    var isAlive        = manager.CellDictionary.ContainsKey(targetId);
                    if (isAlive && (adjacentNumber <= 1 || adjacentNumber >= 4))
                    {
                        manager.DeathCells.Add(targetId);
                    }
                    else if (!isAlive && adjacentNumber == 3)
                    {
                        manager.NewCells.Add(targetId);
                    }

                    manager.ProcessedCells.Add(targetId, false);
                }
            }
        }
Example #4
0
 public static void Apply(string text, CellManager manager, Point offset)
 {
     GetBundle(text).Elements.ForEach(r => r.Apply(manager, offset));
 }