public GameMatrix() { rnd = new Random(); AGameObject left = null; AGameObject current = null; gFactory = GameObjectFactory.GetInstance(); for (int i = 0; i < w; i++) { current = gFactory.GetGameObject(Rectangle.Empty, this, null, null, current); current.Value = new Point(i, 0); left = current; if (i == 0) { first = current; } for (int j = 1; j < h; j++) { var top = (left.Top != null && left.Top.Right != null) ? left.Top.Right : null; var ni = gFactory.GetGameObject(Rectangle.Empty, this, left, null, top); ni.Value = new Point(i, j); left = ni; } } }
public GameMatrix(Rectangle[,] regions, int w, int h) { rnd = new Random(); this.w = w; this.h = h; AGameObject left = null; AGameObject current = null; gFactory = GameObjectFactory.GetInstance(); for (int i = 0; i < w; i++) { current = gFactory.GetGameObject(regions[i, 0], this, null, null, current); left = current; if (i == 0) { first = current; } for (int j = 1; j < h; j++) { var top = (left.Top != null && left.Top.Right != null) ? left.Top.Right : null; var ni = gFactory.GetGameObject(regions[i, j], this, left, null, top); ni.Value = new Point(i, j); left = ni; } } }
public void ReplaceItem(AGameObject replaced, BonusEffect bonus = BonusEffect.NONE) { AGameObject ni = null; switch (bonus) { case BonusEffect.LINE_V: ni = gFactory.GetGameObject(replaced, LineType.V); break; case BonusEffect.LINE_H: ni = gFactory.GetGameObject(replaced, LineType.H); break; default: ni = gFactory.GetGameObject(replaced, bonus); break; } if (replaced.Left == null && replaced.Top == null) { first = ni; } if (OnItemKilled != null) { OnItemKilled(); } }