- MVCBricks_WEB.zip
- MVCBricks_WEB
- bin
- Content
- images
- Blue.png
- Board.png
- Bob.png
- Cyan.png
- Green.png
- None.png
- Orange.png
- Purple.png
- Red.png
- Thumbs.db
- Title.png
- Yellow.png
- Site.css
- themes
- base
- images
- ui-bg_flat_0_aaaaaa_40x100.png
- ui-bg_flat_75_ffffff_40x100.png
- ui-bg_glass_55_fbf9ee_1x400.png
- ui-bg_glass_65_ffffff_1x400.png
- ui-bg_glass_75_dadada_1x400.png
- ui-bg_glass_75_e6e6e6_1x400.png
- ui-bg_glass_95_fef1ec_1x400.png
- ui-bg_highlight-soft_75_cccccc_1x100.png
- ui-icons_222222_256x240.png
- ui-icons_2e83ff_256x240.png
- ui-icons_454545_256x240.png
- ui-icons_888888_256x240.png
- ui-icons_cd0a0a_256x240.png
- jquery-ui.css
- Controllers
- Global.asax
- Global.asax.cs
- Properties
- Scripts
- Views
- Web.config
- Web.Debug.config
- Web.Release.config
- MVCBricks_SRC.zip
- MVCBricks.Core
- MVCBricks.sln
- MVCBricks
- Content
- images
- Blue.png
- Board.png
- Bob.png
- Cyan.png
- Green.png
- None.png
- Orange.png
- Purple.png
- Red.png
- Thumbs.db
- Title.png
- Yellow.png
- Site.css
- themes
- base
- images
- ui-bg_flat_0_aaaaaa_40x100.png
- ui-bg_flat_75_ffffff_40x100.png
- ui-bg_glass_55_fbf9ee_1x400.png
- ui-bg_glass_65_ffffff_1x400.png
- ui-bg_glass_75_dadada_1x400.png
- ui-bg_glass_75_e6e6e6_1x400.png
- ui-bg_glass_95_fef1ec_1x400.png
- ui-bg_highlight-soft_75_cccccc_1x100.png
- ui-icons_222222_256x240.png
- ui-icons_2e83ff_256x240.png
- ui-icons_454545_256x240.png
- ui-icons_888888_256x240.png
- ui-icons_cd0a0a_256x240.png
- jquery-ui.css
- Controllers
- Global.asax
- Global.asax.cs
- MVCBricks.csproj
- MVCBricks.csproj.user
- MVCBricks.sln
- MVCBricks.suo
- Properties
- Scripts
- Views
- Web.config
- Web.Debug.config
- Web.Release.config
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MVCBricks.Core
{
public class GameManager : MVCBricks.Core.IView
{
private static GameManager instance = null;
private static BricksPresenter presenter = null;
private static BoardViewModel currentBoard = null;
private GameManager()
{
currentBoard = new BoardViewModel();
currentBoard.Bricks = new BrickViewModel[] { };
presenter = new BricksPresenter(this);
presenter.InitializeBoard();
presenter.Tick();
}
public static GameManager Instance
{
get
{
if (instance == null)
{
instance = new GameManager();
}
return instance;
}
}
public BricksPresenter Presenter
{
get { return presenter; }
}
public BoardViewModel CurrentBoard
{
get { return currentBoard; }
}
public void InitializeBoard()
{
presenter.InitializeBoard();
currentBoard.IsGameOver = false;
}
public void DisplayBoard(string arrayString, IBrick[,] brickArray, int width, int height)
{
currentBoard.Bricks = GetBricksArray(height, width, brickArray);
}
public void DisplayScore(int score, int hiScore, int lines, int level, MVCBricks.Core.Shapes.IShape next)
{
currentBoard.Score = score;
currentBoard.HiScore = hiScore;
currentBoard.Lines = lines;
currentBoard.Level = level;
currentBoard.Next = GetBricksArray(next.ShapeArray.GetUpperBound(1) + 1, next.ShapeArray.GetUpperBound(0) + 1, next.ShapeArray);
}
private BrickViewModel[] GetBricksArray(int rowCount, int colCount, IBrick[,] array)
{
var bricksList = new List<BrickViewModel>();
for (var row = 0; row < rowCount; row++)
{
for (var col = 0; col < colCount; col++)
{
var b = array[col, row];
if (b != null)
{
bricksList.Add(new BrickViewModel()
{
Row = row,
Col = col,
Color = b.Color.ToString().Replace("Color [", "").Replace("]", "")
});
}
else
{
bricksList.Add(new BrickViewModel()
{
Row = row,
Col = col,
Color = "rgba(0, 0, 0, 1.0)"
});
}
}
}
return bricksList.ToArray();
}
public void GameOver()
{
currentBoard.IsGameOver = true;
}
public void HighlightCompletedRow(int row)
{
//throw new NotImplementedException();
}
}
public class BrickViewModel
{
public int Row { get; set; }
public int Col { get; set; }
public string Color { get; set; }
}
public class BoardViewModel
{
public BoardViewModel()
{
IsGameOver = false;
}
public BrickViewModel[] Bricks { get; set; }
public int Score { get; set; }
public int HiScore { get; set; }
public int Lines { get; set; }
public int Level { get; set; }
public BrickViewModel[] Next { get; set; }
public bool IsGameOver { get; set; }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.