public void CopyTo(MainField to, Rect rect) { for (int x = rect.Left; x <= rect.Right; x++) { for (int y = rect.Top; y <= rect.Bottom; y++) { to[x, y] = this[x, y]; } } for (int i = 0; i < Width; i++) { to.earthPoint[i] = earthPoint[i]; to.floatPoint[i] = floatPoint[i]; } }
private void CheckValidNumber(MainField field, int x, int y, long[] score) { score.Initialize(); for (int i = 0; i < 4; i++) { switch (i) { case 0: CacheLineSum(field, x, y, 1, 0, sumCache1); CacheLineSum(field, x, y, -1, 0, sumCache2); break; case 1: CacheLineSum(field, x, y, 1, 1, sumCache1); CacheLineSum(field, x, y, -1, -1, sumCache2); break; case 2: CacheLineSum(field, x, y, 0, 1, sumCache1); CacheLineSum(field, x, y, 0, -1, sumCache2); break; case 3: CacheLineSum(field, x, y, 1, -1, sumCache1); CacheLineSum(field, x, y, -1, 1, sumCache2); break; } for (int a = 0; a < S; a++) { if (sumCache1[a] >= S) break; for (int b = 0; b < S; b++) { int temp = sumCache1[a] + sumCache2[b]; if (temp >= S) break; temp = S - temp; score[temp] = int.MaxValue; } } } }
public GameModel(GameSetting setting, NextPacks next, MainField main) { Setting = setting; Next = next; Main = main; }
private void CacheLineSum(MainField field, int x, int y, int vx, int vy, int[] sumCache) { int sum = 0; for (int index = 0; index < S; index++) { sumCache[index] = sum; x += vx; y += vy; if (sum >= S) break; if (!field.IsInField(x, y)) { sum = S; continue; } int temp = field[x, y]; if (temp > 0) { sum += temp; } else { sum = S; } } }
public void CopyTo(MainField to) { Rect rect = new Rect() { Left = 0, Top = 0, Right = Width - 1, Bottom = Height - 1 }; CopyTo(to, rect); }
public MainField Clone() { MainField ret = new MainField(Width, Height, S); CopyTo(ret); return ret; }