public static bool Detect(out Combination combination, Cell input) { combination = new Combination(); if(!input.IsNotNullOrEmpty()) return false; combination.Cells = new Cell[0]; combination.Center = input; combination.Type = input.ChildItem.Type; if(Three.IsCombination(ref combination)) { var three = combination as Three; combination = three; if(Four.IsCombination(ref three)) { var four = three as Four; combination = four; if(Five.IsCombination(ref four)) { var five = four as Five; combination = five; } } three = combination as Three; if(combination.GetType() != typeof(Five) && Angle.IsCombination(ref three)) { var angle = three as Angle; combination = angle; } } var resultName = combination.GetType().Name; if(resultName != "Combination") Debug.Log(resultName); var result = combination.GetType() != typeof(Combination); if(!result) combination = null; return result; }
void Update() { if(RecentlyChangedCells.Count != RecentlyChangedCellsCount) { RecentlyChangedCellsCount = RecentlyChangedCells.Count; } else { var combination = new Combination(); foreach(var cell in RecentlyChangedCells) { if(Combination.Detect(out combination, cell)) combination.Remove(); } RecentlyChangedCells = new HashSet<Cell>(); RecentlyChangedCellsCount = 0; } }
public Combination(Combination combination) { Type = combination.Type; Center = combination.Center; Cells = combination.Cells; }