I'm developing a 3D Board Game based on the World of Warcraft miniatures board game.
I don't know what's wrong ... the game runs and the system is like this
I have a model that can move in a map through Cells
I made a procedure so you click and move but there is a problem when you return to the CellSpace[1,1] it calls a NullReference for gameobject.model.mesh in RayIntersectsModel(Ray ray, GameObject gameobject);
anyone can help me finding a solution for this please?
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace WoWminis
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public MouseState cursorstate;
GameObject terrain = new GameObject();
GameObject BaseTop = new GameObject();
GameObject BaseBottom = new GameObject();
Vector3 cameraPosition = new Vector3(0.0f, 130.0f, 50.0f);
Vector3 cameraLookAt = new Vector3(0.0f, 0.0f, 7.5f);
Matrix cameraProjectionMatrix;
Matrix cameraViewMatrix;
KeyboardState oldState;
SpriteFont font;
double posX;
double posZ;
Vector2 debugDrawpointX = new Vector2(0.01f, 0.01f);
Vector2 debugDrawpointZ = new Vector2(0.01f, 0.05f);
Rectangle viewportRect;
BoardCells[,] Cell = new BoardCells[11, 12];
sprite2D cursor;
GameObject[,] CellSpace = new GameObject[11, 12];
Ubase BASE = new Ubase();
bool click = false;
bool pressed = false;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
this.graphics.PreferredBackBufferWidth = 1280;
this.graphics.PreferredBackBufferHeight = 720;
//this.graphics.IsFullScreen = true;
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
terrain.model = Content.Load<Model>("Models\\Map");
terrain.rotation = new Vector3(-1 * MathHelper.ToRadians(90.0f), 0.0f, -1 * MathHelper.ToRadians(90.0f));
BaseTop.model = Content.Load<Model>("Models\\BaseTop");
BaseTop.rotation = new Vector3(-1 * MathHelper.ToRadians(90.0f), 0.0f, -1 * MathHelper.ToRadians(0.0f));
BaseTop.scale = 0.15f;
BaseBottom.model = Content.Load<Model>("Models\\BaseBottom");
BaseBottom.rotation = new Vector3(-1 * MathHelper.ToRadians(90.0f), 0.0f, -1 * MathHelper.ToRadians(90.0f));
BaseBottom.scale = 0.15f;
BaseTop.position = new Vector3(0.0f, 1.0f, 0.0f);
BaseBottom.position = new Vector3(0.0f, 1.0f, 0.0f);
font = Content.Load<SpriteFont>("Fonts\\GameFont");
viewportRect = new Rectangle(0, 0,
graphics.GraphicsDevice.Viewport.Width,
graphics.GraphicsDevice.Viewport.Height);
LoadBoard();
BaseTop.position = Cell[1, 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseBottom.position = Cell[1, 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posX = 1;
BASE.posZ = 1;
BASE.name = "Test";
BASE.turn = 1;
cursor = new sprite2D(Content.Load<Texture2D>("Sprites\\Cursor"));
cursor.position = Vector2.Zero;
//test
for (int i = 1; i < 11; i++)
{
for (int x = 1; x < 12; x++)
{
CellSpace[i, x] = new GameObject();
CellSpace[i, x].model = Content.Load<Model>("Models\\CellSpace");
CellSpace[i, x].rotation = new Vector3(-1 * MathHelper.ToRadians(90.0f), 0.0f, -1 * MathHelper.ToRadians(90.0f));
CellSpace[i, x].position = Cell[i, x].position - new Vector3(0.0f, 1.0f, 0.0f);
CellSpace[i, x].scale = 0.4f;
}
}
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
//cursor
mouseload();
cursorstate = Mouse.GetState();
cursor.position.X = cursorstate.X;
cursor.position.Y = cursorstate.Y;
//camera
cameraViewMatrix = Matrix.CreateLookAt(
cameraPosition,
cameraLookAt,
Vector3.Up);
cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45.0f),
graphics.GraphicsDevice.Viewport.AspectRatio,
1.0f,
10000.0f);
// Debug
posX = Math.Round(BaseTop.position.X, 3);
posZ = Math.Round(BaseTop.position.Z, 3);
//keys
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyUp(Keys.C))
{
cameraPosition = new Vector3(0.0f, 130.0f, 50.0f);
cameraLookAt = new Vector3(0.0f, 0.0f, 7.5f);
}
if (keyboardState.IsKeyDown(Keys.C))
{
cameraPosition = new Vector3(0.0f, 10.0f, BaseTop.position.Z + 20f);
cameraLookAt = BaseTop.position;
}
if (keyboardState.IsKeyDown(Keys.Escape))
{
this.Exit();
}
UpdateInput();
base.Update(gameTime);
}
private void UpdateInput()
{
KeyboardState newState = Keyboard.GetState();
// Is the SPACE key down?
if (newState.IsKeyDown(Keys.Space))
{
// If not down last update, key has just been pressed.
if (!oldState.IsKeyDown(Keys.Space))
{
BaseBottom.rotation.Z += MathHelper.ToRadians(36.0f);
}
}
/*else if (oldState.IsKeyDown(Keys.Space))
{
// Key was down last update, but not down now, so
// it has just been released.
}*/
// Update saved state.
oldState = newState;
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
DrawGameObject(terrain);
DrawGameObject(BaseTop);
DrawGameObject(BaseBottom);
for (int i = 1; i < 11; i++)
{
for (int x = 1; x < 12; x++)
{
DrawGameObject(CellSpace[i, x]);
}
}
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);
spriteBatch.DrawString(font, " PositionX: " + BASE.posX.ToString(),
new Vector2(
debugDrawpointX.X * viewportRect.Width,
debugDrawpointX.Y * viewportRect.Height),
Color.Yellow);
spriteBatch.DrawString(font, " PositionZ: " + BASE.posZ.ToString(),
new Vector2(
debugDrawpointZ.X * viewportRect.Width,
debugDrawpointZ.Y * viewportRect.Height),
Color.Yellow);
spriteBatch.DrawString(font, " Debug: " + Cell[1, 1].position.X.ToString(),
new Vector2(
debugDrawpointZ.X * viewportRect.Width,
(debugDrawpointZ.Y + 0.1f) * viewportRect.Height),
Color.Yellow);
spriteBatch.Draw(cursor.sprite,
cursor.position,
null,
Color.White,
cursor.rotation,
cursor.center, 1.0f,
SpriteEffects.None, 0
);
spriteBatch.End();
// TODO: Add your drawing code here
DrawModelNames();
base.Draw(gameTime);
}
void DrawGameObject(GameObject gameobject)
{
foreach (ModelMesh mesh in gameobject.model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
effect.FogEnabled = false;
effect.World = Matrix.CreateFromYawPitchRoll(
gameobject.rotation.Y,
gameobject.rotation.X,
gameobject.rotation.Z) *
Matrix.CreateScale(gameobject.scale) *
Matrix.CreateTranslation(gameobject.position);
effect.Projection = cameraProjectionMatrix;
effect.View = cameraViewMatrix;
}
mesh.Draw();
}
}
private static bool RayIntersectsModel(Ray ray, GameObject gameobject)
{
foreach (ModelMesh mesh in gameobject.model.Meshes)
{
Matrix world = Matrix.CreateFromYawPitchRoll(
gameobject.rotation.Y,
gameobject.rotation.X,
gameobject.rotation.Z) *
Matrix.CreateScale(gameobject.scale) *
Matrix.CreateTranslation(gameobject.position);
BoundingSphere sphere =
TransformBoundingSphere(mesh.BoundingSphere, world);
if (sphere.Intersects(ray) != null)
{
return true;
}
}
return false;
}
private static BoundingSphere TransformBoundingSphere(BoundingSphere sphere,
Matrix transform)
{
BoundingSphere transformedSphere;
Vector3 scale3 = new Vector3(sphere.Radius, sphere.Radius, sphere.Radius);
scale3 = Vector3.TransformNormal(scale3, transform);
transformedSphere.Radius = Math.Max(scale3.X, Math.Max(scale3.Y, scale3.Z));
transformedSphere.Center = Vector3.Transform(sphere.Center, transform);
return transformedSphere;
}
public Ray CalculateCursorRay(Matrix projectionMatrix, Matrix viewMatrix)
{
Vector3 nearSource = new Vector3(cursorstate.X, cursorstate.Y, 0f);
Vector3 farSource = new Vector3(cursorstate.X, cursorstate.Y, 1f);
Vector3 nearPoint = GraphicsDevice.Viewport.Unproject(nearSource,
projectionMatrix, viewMatrix, Matrix.Identity);
Vector3 farPoint = GraphicsDevice.Viewport.Unproject(farSource,
projectionMatrix, viewMatrix, Matrix.Identity);
Vector3 direction = farPoint - nearPoint;
direction.Normalize();
return new Ray(nearPoint, direction);
}
private void DrawModelNames()
{
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);
Ray cursorRay = CalculateCursorRay(cameraProjectionMatrix, cameraViewMatrix);
if (RayIntersectsModel(cursorRay, BaseTop))
{
Matrix world = Matrix.CreateFromYawPitchRoll(
BaseTop.rotation.Y,
BaseTop.rotation.X,
BaseTop.rotation.Z) *
Matrix.CreateScale(BaseTop.scale) *
Matrix.CreateTranslation(BaseTop.position);
Vector2 textPosition =
new Vector2(cursorstate.X, cursorstate.Y - 60);
Vector2 stringCenter =
font.MeasureString("test") / 2;
Vector2 shadowOffset = new Vector2(3, 2);
spriteBatch.DrawString(font, "Test",
textPosition + shadowOffset, Color.Black, 0.0f,
stringCenter, 1.0f, SpriteEffects.None, 1.0f);
spriteBatch.DrawString(font, "Test",
textPosition, Color.White, 0.0f,
stringCenter, 1.0f, SpriteEffects.None, 0.0f);
if (BASE.posZ == 1)
{
if (BASE.posX == 1 & BASE.posZ == 1)
{
resetcells();
CellSpace[BASE.posX, BASE.posZ + 1].position = Cell[BASE.posX,
BASE.posZ + 1].position + new Vector3(0.0f, 0.1f, 0.0f);
CellSpace[BASE.posX + 1, BASE.posZ].position = Cell[BASE.posX + 1,
BASE.posZ].position + new Vector3(0.0f, 0.1f, 0.0f);
}
if (BASE.posX == 10)
{
resetcells();
CellSpace[BASE.posX, BASE.posZ + 1].position = Cell[BASE.posX,
BASE.posZ + 1].position + new Vector3(0.0f, 0.1f, 0.0f);
CellSpace[BASE.posX - 1, BASE.posZ].position = Cell[BASE.posX - 1,
BASE.posZ].position + new Vector3(0.0f, 0.1f, 0.0f);
CellSpace[BASE.posX - 1, BASE.posZ + 1].position = Cell[BASE.posX - 1,
BASE.posZ + 1].position + new Vector3(0.0f, 0.1f, 0.0f);
}
if (BASE.posX >= 2 & BASE.posX <= 9)
{
resetcells();
CellSpace[BASE.posX - 1, BASE.posZ + 1].position = Cell[BASE.posX - 1,
BASE.posZ + 1].position + new Vector3(0.0f, 0.1f, 0.0f);
CellSpace[BASE.posX - 1, BASE.posZ].position = Cell[BASE.posX - 1,
BASE.posZ].position + new Vector3(0.0f, 0.1f, 0.0f);
CellSpace[BASE.posX, BASE.posZ + 1].position = Cell[BASE.posX,
BASE.posZ + 1].position + new Vector3(0.0f, 0.1f, 0.0f);
CellSpace[BASE.posX + 1, BASE.posZ].position = Cell[BASE.posX + 1,
BASE.posZ].position + new Vector3(0.0f, 0.1f, 0.0f);
}
}
else
{
//
}
}
if (click == true)
{
if (BASE.posZ == 1)
{
if (BASE.posX == 1)
{
//C
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX, BASE.posZ + 1]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posZ = BASE.posZ + 1;
}
//D
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX + 1, BASE.posZ]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX + 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX + 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posX = BASE.posX + 1;
}
else
{
click = false;
}
}
if (BASE.posX == 10)
{
//A
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX - 1, BASE.posZ]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX - 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX - 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posX = BASE.posX - 1;
}
//B
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX - 1, BASE.posZ + 1]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX - 1, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX - 1, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posX = BASE.posX - 1;
BASE.posZ = BASE.posZ + 1;
}
//C
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX, BASE.posZ + 1]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posZ = BASE.posZ + 1;
}
else
{
click = false;
}
}
if (BASE.posX >= 2 & BASE.posX <= 9)
{
//A
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX - 1, BASE.posZ]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX - 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX - 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posX = BASE.posX - 1;
}
//B
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX - 1, BASE.posZ + 1]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX - 1, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX - 1, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posX = BASE.posX - 1;
BASE.posZ = BASE.posZ + 1;
}
//C
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX, BASE.posZ + 1]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX, BASE.posZ + 1].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posZ = BASE.posZ + 1;
}
//D
if (RayIntersectsModel(cursorRay, CellSpace[BASE.posX + 1, BASE.posZ]))
{
resetcells();
click = false;
BaseBottom.position = Cell[BASE.posX + 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BaseTop.position = Cell[BASE.posX + 1, BASE.posZ].position + new Vector3(0.0f, 1.0f, 0.0f);
BASE.posX = BASE.posX + 1;
}
else
{
click = false;
}
}
}
}
spriteBatch.End();
}
void mouseload()
{
if (cursorstate.LeftButton == ButtonState.Pressed)
pressed = true;
if (cursorstate.LeftButton == ButtonState.Released && pressed)
{
click = true;
pressed = false;
}
}
void resetcells()
{
for (int i = 1; i < 11; i++)
{
for (int x = 1; x < 12; x++)
{
if (CellSpace[i, x] == null)
{
CellSpace[i, x] = new GameObject();
CellSpace[i, x].model = Content.Load<Model>("Models\\CellSpace");
CellSpace[i, x].rotation = new Vector3(-1 * MathHelper.ToRadians(90.0f), 0.0f, -1 * MathHelper.ToRadians(90.0f));
CellSpace[i, x].position = Cell[i, x].position - new Vector3(0.0f, 1.0f, 0.0f);
CellSpace[i, x].scale = 0.4f;
}
CellSpace[i, x].position = Cell[i, x].position - new Vector3(0.0f, 1.0f, 0.0f);
}
}
}
void LoadBoard()
{
//I know I should use loops but trust me.. I need it like this right now, and making it a loop wont improve the processing, is the same thing.
//Board positions
Cell[1, 1] = new BoardCells();
Cell[1, 2] = new BoardCells();
Cell[1, 3] = new BoardCells();
Cell[1, 4] = new BoardCells();
Cell[1, 5] = new BoardCells();
Cell[1, 6] = new BoardCells();
Cell[1, 7] = new BoardCells();
Cell[1, 8] = new BoardCells();
Cell[1, 9] = new BoardCells();
Cell[1, 10] = new BoardCells();
Cell[1, 11] = new BoardCells();
Cell[2, 1] = new BoardCells();
Cell[2, 2] = new BoardCells();
Cell[2, 3] = new BoardCells();
Cell[2, 4] = new BoardCells();
Cell[2, 5] = new BoardCells();
Cell[2, 6] = new BoardCells();
Cell[2, 7] = new BoardCells();
Cell[2, 8] = new BoardCells();
Cell[2, 9] = new BoardCells();
Cell[2, 10] = new BoardCells();
Cell[2, 11] = new BoardCells();
Cell[3, 1] = new BoardCells();
Cell[3, 2] = new BoardCells();
Cell[3, 3] = new BoardCells();
Cell[3, 4] = new BoardCells();
Cell[3, 5] = new BoardCells();
Cell[3, 6] = new BoardCells();
Cell[3, 7] = new BoardCells();
Cell[3, 8] = new BoardCells();
Cell[3, 9] = new BoardCells();
Cell[3, 10] = new BoardCells();
Cell[3, 11] = new BoardCells();
Cell[4, 1] = new BoardCells();
Cell[4, 2] = new BoardCells();
Cell[4, 3] = new BoardCells();
Cell[4, 4] = new BoardCells();
Cell[4, 5] = new BoardCells();
Cell[4, 6] = new BoardCells();
Cell[4, 7] = new BoardCells();
Cell[4, 8] = new BoardCells();
Cell[4, 9] = new BoardCells();
Cell[4, 10] = new BoardCells();
Cell[4, 11] = new BoardCells();
Cell[5, 1] = new BoardCells();
Cell[5, 2] = new BoardCells();
Cell[5, 3] = new BoardCells();
Cell[5, 4] = new BoardCells();
Cell[5, 5] = new BoardCells();
Cell[5, 6] = new BoardCells();
Cell[5, 7] = new BoardCells();
Cell[5, 8] = new BoardCells();
Cell[5, 9] = new BoardCells();
Cell[5, 10] = new BoardCells();
Cell[5, 11] = new BoardCells();
Cell[6, 1] = new BoardCells();
Cell[6, 2] = new BoardCells();
Cell[6, 3] = new BoardCells();
Cell[6, 4] = new BoardCells();
Cell[6, 5] = new BoardCells();
Cell[6, 6] = new BoardCells();
Cell[6, 7] = new BoardCells();
Cell[6, 8] = new BoardCells();
Cell[6, 9] = new BoardCells();
Cell[6, 10] = new BoardCells();
Cell[6, 11] = new BoardCells();
Cell[7, 1] = new BoardCells();
Cell[7, 2] = new BoardCells();
Cell[7, 3] = new BoardCells();
Cell[7, 4] = new BoardCells();
Cell[7, 5] = new BoardCells();
Cell[7, 6] = new BoardCells();
Cell[7, 7] = new BoardCells();
Cell[7, 8] = new BoardCells();
Cell[7, 9] = new BoardCells();
Cell[7, 10] = new BoardCells();
Cell[7, 11] = new BoardCells();
Cell[8, 1] = new BoardCells();
Cell[8, 2] = new BoardCells();
Cell[8, 3] = new BoardCells();
Cell[8, 4] = new BoardCells();
Cell[8, 5] = new BoardCells();
Cell[8, 6] = new BoardCells();
Cell[8, 7] = new BoardCells();
Cell[8, 8] = new BoardCells();
Cell[8, 9] = new BoardCells();
Cell[8, 10] = new BoardCells();
Cell[8, 11] = new BoardCells();
Cell[9, 1] = new BoardCells();
Cell[9, 2] = new BoardCells();
Cell[9, 3] = new BoardCells();
Cell[9, 4] = new BoardCells();
Cell[9, 5] = new BoardCells();
Cell[9, 6] = new BoardCells();
Cell[9, 7] = new BoardCells();
Cell[9, 8] = new BoardCells();
Cell[9, 9] = new BoardCells();
Cell[9, 10] = new BoardCells();
Cell[9, 11] = new BoardCells();
Cell[10, 1] = new BoardCells();
Cell[10, 2] = new BoardCells();
Cell[10, 3] = new BoardCells();
Cell[10, 4] = new BoardCells();
Cell[10, 5] = new BoardCells();
Cell[10, 6] = new BoardCells();
Cell[10, 7] = new BoardCells();
Cell[10, 8] = new BoardCells();
Cell[10, 9] = new BoardCells();
Cell[10, 10] = new BoardCells();
Cell[10, 11] = new BoardCells();
Cell[1, 1].position = new Vector3(-42.5f, 0.1f, 50.3f);
Cell[1, 2].position = new Vector3(-36.75f, 0.1f, 40.3f);
Cell[1, 3].position = new Vector3(-42.5f, 0.1f, 30.3f);
Cell[1, 4].position = new Vector3(-36.75f, 0.1f, 20.3f);
Cell[1, 5].position = new Vector3(-42.5f, 0.1f, 10.3f);
Cell[1, 6].position = new Vector3(-36.75f, 0.1f, 0.3f);
Cell[1, 7].position = new Vector3(-42.5f, 0.1f, -10.3f);
Cell[1, 8].position = new Vector3(-36.75f, 0.1f, -20.3f);
Cell[1, 9].position = new Vector3(-42.5f, 0.1f, -30.3f);
Cell[1, 10].position = new Vector3(-36.75f, 0.1f, -40.3f);
Cell[1, 11].position = new Vector3(-42.5f, 0.1f, -50.3f);
Cell[2, 1].position = new Vector3(-31f, 0.1f, 50.3f);
Cell[2, 2].position = new Vector3(-25.25f, 0.1f, 40.3f);
Cell[2, 3].position = new Vector3(-31f, 0.1f, 30.3f);
Cell[2, 4].position = new Vector3(-25.25f, 0.1f, 20.3f);
Cell[2, 5].position = new Vector3(-31f, 0.1f, 10.3f);
Cell[2, 6].position = new Vector3(-25.25f, 0.1f, 0.3f);
Cell[2, 7].position = new Vector3(-31f, 0.1f, -10.3f);
Cell[2, 8].position = new Vector3(-25.25f, 0.1f, -20.3f);
Cell[2, 9].position = new Vector3(-31f, 0.1f, -30.3f);
Cell[2, 10].position = new Vector3(-25.25f, 0.1f, -40.3f);
Cell[2, 11].position = new Vector3(-31f, 0.1f, -50.3f);
Cell[3, 1].position = new Vector3(-19.5f, 0.1f, 50.3f);
Cell[3, 2].position = new Vector3(-13.5f, 0.1f, 40.3f);
Cell[3, 3].position = new Vector3(-19.5f, 0.1f, 30.3f);
Cell[3, 4].position = new Vector3(-13.5f, 0.1f, 20.3f);
Cell[3, 5].position = new Vector3(-19.5f, 0.1f, 10.3f);
Cell[3, 6].position = new Vector3(-13.5f, 0.1f, 0.3f);
Cell[3, 7].position = new Vector3(-19.5f, 0.1f, -10.3f);
Cell[3, 8].position = new Vector3(-13.5f, 0.1f, -20.3f);
Cell[3, 9].position = new Vector3(-19.5f, 0.1f, -30.3f);
Cell[3, 10].position = new Vector3(-13.5f, 0.1f, -40.3f);
Cell[3, 11].position = new Vector3(-19.5f, 0.1f, -50.3f);
Cell[4, 1].position = new Vector3(-7.5f, 0.1f, 50.3f);
Cell[4, 2].position = new Vector3(-1.75f, 0.1f, 40.3f);
Cell[4, 3].position = new Vector3(-7.5f, 0.1f, 30.3f);
Cell[4, 4].position = new Vector3(-1.75f, 0.1f, 20.3f);
Cell[4, 5].position = new Vector3(-7.5f, 0.1f, 10.3f);
Cell[4, 6].position = new Vector3(-1.75f, 0.1f, 0.3f);
Cell[4, 7].position = new Vector3(-7.5f, 0.1f, -10.3f);
Cell[4, 8].position = new Vector3(-1.75f, 0.1f, -20.3f);
Cell[4, 9].position = new Vector3(-7.5f, 0.1f, -30.3f);
Cell[4, 10].position = new Vector3(-1.75f, 0.1f, -40.3f);
Cell[4, 11].position = new Vector3(-7.5f, 0.1f, -50.3f);
Cell[5, 1].position = new Vector3(4f, 0.1f, 50.3f);
Cell[5, 2].position = new Vector3(10f, 0.1f, 40.3f);
Cell[5, 3].position = new Vector3(4f, 0.1f, 30.3f);
Cell[5, 4].position = new Vector3(10f, 0.1f, 20.3f);
Cell[5, 5].position = new Vector3(4f, 0.1f, 10.3f);
Cell[5, 6].position = new Vector3(10f, 0.1f, 0.3f);
Cell[5, 7].position = new Vector3(4f, 0.1f, -10.3f);
Cell[5, 8].position = new Vector3(10f, 0.1f, -20.3f);
Cell[5, 9].position = new Vector3(4f, 0.1f, -30.3f);
Cell[5, 10].position = new Vector3(10f, 0.1f, -40.3f);
Cell[5, 11].position = new Vector3(4f, 0.1f, -50.3f);
Cell[6, 1].position = new Vector3(15.75f, 0.1f, 50.3f);
Cell[6, 2].position = new Vector3(21.75f, 0.1f, 40.3f);
Cell[6, 3].position = new Vector3(15.75f, 0.1f, 30.3f);
Cell[6, 4].position = new Vector3(21.75f, 0.1f, 20.3f);
Cell[6, 5].position = new Vector3(15.75f, 0.1f, 10.3f);
Cell[6, 6].position = new Vector3(21.75f, 0.1f, 0.3f);
Cell[6, 7].position = new Vector3(15.75f, 0.1f, -10.3f);
Cell[6, 8].position = new Vector3(21.75f, 0.1f, -20.3f);
Cell[6, 9].position = new Vector3(15.75f, 0.1f, -30.3f);
Cell[6, 10].position = new Vector3(21.75f, 0.1f, -40.3f);
Cell[6, 11].position = new Vector3(15.75f, 0.1f, -50.3f);
Cell[7, 1].position = new Vector3(27.5f, 0.1f, 50.3f);
Cell[7, 2].position = new Vector3(33.5f, 0.1f, 40.3f);
Cell[7, 3].position = new Vector3(27.5f, 0.1f, 30.3f);
Cell[7, 4].position = new Vector3(33.5f, 0.1f, 20.3f);
Cell[7, 5].position = new Vector3(27.5f, 0.1f, 10.3f);
Cell[7, 6].position = new Vector3(33.5f, 0.1f, 0.3f);
Cell[7, 7].position = new Vector3(27.5f, 0.1f, -10.3f);
Cell[7, 8].position = new Vector3(33.5f, 0.1f, -20.3f);
Cell[7, 9].position = new Vector3(27.5f, 0.1f, -30.3f);
Cell[7, 10].position = new Vector3(33.5f, 0.1f, -40.3f);
Cell[7, 11].position = new Vector3(27.5f, 0.1f, -50.3f);
Cell[8, 1].position = new Vector3(39.25f, 0.1f, 50.3f);
Cell[8, 2].position = new Vector3(45f, 0.1f, 40.3f);
Cell[8, 3].position = new Vector3(39.25f, 0.1f, 30.3f);
Cell[8, 4].position = new Vector3(45f, 0.1f, 20.3f);
Cell[8, 5].position = new Vector3(39.25f, 0.1f, 10.3f);
Cell[8, 6].position = new Vector3(45f, 0.1f, 0.3f);
Cell[8, 7].position = new Vector3(39.25f, 0.1f, -10.3f);
Cell[8, 8].position = new Vector3(45f, 0.1f, -20.3f);
Cell[8, 9].position = new Vector3(39.25f, 0.1f, -30.3f);
Cell[8, 10].position = new Vector3(45f, 0.1f, -40.3f);
Cell[8, 11].position = new Vector3(39.25f, 0.1f, -50.3f);
Cell[9, 1].position = new Vector3(51f, 0.1f, 50.3f);
Cell[9, 2].position = new Vector3(56.75f, 0.1f, 40.3f);
Cell[9, 3].position = new Vector3(51f, 0.1f, 30.3f);
Cell[9, 4].position = new Vector3(56.75f, 0.1f, 20.3f);
Cell[9, 5].position = new Vector3(51f, 0.1f, 10.3f);
Cell[9, 6].position = new Vector3(56.75f, 0.1f, 0.3f);
Cell[9, 7].position = new Vector3(51f, 0.1f, -10.3f);
Cell[9, 8].position = new Vector3(56.75f, 0.1f, -20.3f);
Cell[9, 9].position = new Vector3(51f, 0.1f, -30.3f);
Cell[9, 10].position = new Vector3(56.75f, 0.1f, -40.3f);
Cell[9, 11].position = new Vector3(51f, 0.1f, -50.3f);
Cell[10, 1].position = new Vector3(62.6f, 0.1f, 50.3f);
Cell[10, 2].position = new Vector3(68.5f, 0.1f, 40.3f);
Cell[10, 3].position = new Vector3(62.6f, 0.1f, 30.3f);
Cell[10, 4].position = new Vector3(68.5f, 0.1f, 20.3f);
Cell[10, 5].position = new Vector3(62.6f, 0.1f, 10.3f);
Cell[10, 6].position = new Vector3(68.5f, 0.1f, 0.3f);
Cell[10, 7].position = new Vector3(62.6f, 0.1f, -10.3f);
Cell[10, 8].position = new Vector3(68.5f, 0.1f, -20.3f);
Cell[10, 9].position = new Vector3(62.6f, 0.1f, -30.3f);
Cell[10, 10].position = new Vector3(68.5f, 0.1f, -40.3f);
Cell[10, 11].position = new Vector3(62.6f, 0.1f, -50.3f);
//Board Mountains
Cell[1, 1].isMountain = false;
Cell[1, 2].isMountain = false;
Cell[1, 3].isMountain = false;
Cell[1, 4].isMountain = false;
Cell[1, 5].isMountain = false;
Cell[1, 6].isMountain = false;
Cell[1, 7].isMountain = false;
Cell[1, 8].isMountain = false;
Cell[1, 9].isMountain = false;
Cell[1, 10].isMountain = false;
Cell[1, 11].isMountain = false;
Cell[2, 1].isMountain = false;
Cell[2, 2].isMountain = false;
Cell[2, 3].isMountain = false;
Cell[2, 4].isMountain = false;
Cell[2, 5].isMountain = false;
Cell[2, 6].isMountain = false;
Cell[2, 7].isMountain = false;
Cell[2, 8].isMountain = false;
Cell[2, 9].isMountain = false;
Cell[2, 10].isMountain = false;
Cell[2, 11].isMountain = false;
Cell[3, 1].isMountain = false;
Cell[3, 2].isMountain = false;
Cell[3, 3].isMountain = false;
Cell[3, 4].isMountain = false;
Cell[3, 5].isMountain = false;
Cell[3, 6].isMountain = false;
Cell[3, 7].isMountain = false;
Cell[3, 8].isMountain = false;
Cell[3, 9].isMountain = false;
Cell[3, 10].isMountain = false;
Cell[3, 11].isMountain = false;
Cell[4, 1].isMountain = false;
Cell[4, 2].isMountain = false;
Cell[4, 3].isMountain = false;
Cell[4, 4].isMountain = false;
Cell[4, 5].isMountain = false;
Cell[4, 6].isMountain = false;
Cell[4, 7].isMountain = false;
Cell[4, 8].isMountain = false;
Cell[4, 9].isMountain = false;
Cell[4, 10].isMountain = false;
Cell[4, 11].isMountain = false;
Cell[5, 1].isMountain = false;
Cell[5, 2].isMountain = false;
Cell[5, 3].isMountain = false;
Cell[5, 4].isMountain = false;
Cell[5, 5].isMountain = false;
Cell[5, 6].isMountain = false;
Cell[5, 7].isMountain = false;
Cell[5, 8].isMountain = false;
Cell[5, 9].isMountain = false;
Cell[5, 10].isMountain = false;
Cell[5, 11].isMountain = false;
Cell[6, 1].isMountain = false;
Cell[6, 2].isMountain = false;
Cell[6, 3].isMountain = false;
Cell[6, 4].isMountain = false;
Cell[6, 5].isMountain = false;
Cell[6, 6].isMountain = false;
Cell[6, 7].isMountain = false;
Cell[6, 8].isMountain = false;
Cell[6, 9].isMountain = false;
Cell[6, 10].isMountain = false;
Cell[6, 11].isMountain = false;
Cell[7, 1].isMountain = false;
Cell[7, 2].isMountain = false;
Cell[7, 3].isMountain = false;
Cell[7, 4].isMountain = false;
Cell[7, 5].isMountain = false;
Cell[7, 6].isMountain = false;
Cell[7, 7].isMountain = false;
Cell[7, 8].isMountain = false;
Cell[7, 9].isMountain = false;
Cell[7, 10].isMountain = false;
Cell[7, 11].isMountain = false;
Cell[8, 1].isMountain = false;
Cell[8, 2].isMountain = false;
Cell[8, 3].isMountain = false;
Cell[8, 4].isMountain = false;
Cell[8, 5].isMountain = false;
Cell[8, 6].isMountain = false;
Cell[8, 7].isMountain = false;
Cell[8, 8].isMountain = false;
Cell[8, 9].isMountain = false;
Cell[8, 10].isMountain = false;
Cell[8, 11].isMountain = false;
Cell[9, 1].isMountain = false;
Cell[9, 2].isMountain = false;
Cell[9, 3].isMountain = false;
Cell[9, 4].isMountain = false;
Cell[9, 5].isMountain = false;
Cell[9, 6].isMountain = false;
Cell[9, 7].isMountain = false;
Cell[9, 8].isMountain = false;
Cell[9, 9].isMountain = false;
Cell[9, 10].isMountain = false;
Cell[9, 11].isMountain = false;
Cell[10, 1].isMountain = false;
Cell[10, 2].isMountain = false;
Cell[10, 3].isMountain = false;
Cell[10, 4].isMountain = false;
Cell[10, 5].isMountain = false;
Cell[10, 6].isMountain = false;
Cell[10, 7].isMountain = false;
Cell[10, 8].isMountain = false;
Cell[10, 9].isMountain = false;
Cell[10, 10].isMountain = false;
Cell[10, 11].isMountain = false;
//Board Forest
Cell[1, 1].isForest = false;
Cell[1, 2].isForest = false;
Cell[1, 3].isForest = false;
Cell[1, 4].isForest = false;
Cell[1, 5].isForest = false;
Cell[1, 6].isForest = false;
Cell[1, 7].isForest = false;
Cell[1, 8].isForest = false;
Cell[1, 9].isForest = false;
Cell[1, 10].isForest = false;
Cell[1, 11].isForest = false;
Cell[2, 1].isForest = false;
Cell[2, 2].isForest = false;
Cell[2, 3].isForest = false;
Cell[2, 4].isForest = false;
Cell[2, 5].isForest = false;
Cell[2, 6].isForest = false;
Cell[2, 7].isForest = false;
Cell[2, 8].isForest = false;
Cell[2, 9].isForest = false;
Cell[2, 10].isForest = false;
Cell[2, 11].isForest = false;
Cell[3, 1].isForest = false;
Cell[3, 2].isForest = false;
Cell[3, 3].isForest = false;
Cell[3, 4].isForest = false;
Cell[3, 5].isForest = false;
Cell[3, 6].isForest = false;
Cell[3, 7].isForest = false;
Cell[3, 8].isForest = false;
Cell[3, 9].isForest = false;
Cell[3, 10].isForest = false;
Cell[3, 11].isForest = false;
Cell[4, 1].isForest = false;
Cell[4, 2].isForest = false;
Cell[4, 3].isForest = false;
Cell[4, 4].isForest = false;
Cell[4, 5].isForest = false;
Cell[4, 6].isForest = false;
Cell[4, 7].isForest = false;
Cell[4, 8].isForest = false;
Cell[4, 9].isForest = false;
Cell[4, 10].isForest = false;
Cell[4, 11].isForest = false;
Cell[5, 1].isForest = false;
Cell[5, 2].isForest = false;
Cell[5, 3].isForest = false;
Cell[5, 4].isForest = false;
Cell[5, 5].isForest = false;
Cell[5, 6].isForest = false;
Cell[5, 7].isForest = false;
Cell[5, 8].isForest = false;
Cell[5, 9].isForest = false;
Cell[5, 10].isForest = false;
Cell[5, 11].isForest = false;
Cell[6, 1].isForest = false;
Cell[6, 2].isForest = false;
Cell[6, 3].isForest = false;
Cell[6, 4].isForest = false;
Cell[6, 5].isForest = false;
Cell[6, 6].isForest = false;
Cell[6, 7].isForest = false;
Cell[6, 8].isForest = false;
Cell[6, 9].isForest = false;
Cell[6, 10].isForest = false;
Cell[6, 11].isForest = false;
Cell[7, 1].isForest = false;
Cell[7, 2].isForest = false;
Cell[7, 3].isForest = false;
Cell[7, 4].isForest = false;
Cell[7, 5].isForest = false;
Cell[7, 6].isForest = false;
Cell[7, 7].isForest = false;
Cell[7, 8].isForest = false;
Cell[7, 9].isForest = false;
Cell[7, 10].isForest = false;
Cell[7, 11].isForest = false;
Cell[8, 1].isForest = false;
Cell[8, 2].isForest = false;
Cell[8, 3].isForest = false;
Cell[8, 4].isForest = false;
Cell[8, 5].isForest = false;
Cell[8, 6].isForest = false;
Cell[8, 7].isForest = false;
Cell[8, 8].isForest = false;
Cell[8, 9].isForest = false;
Cell[8, 10].isForest = false;
Cell[8, 11].isForest = false;
Cell[9, 1].isForest = false;
Cell[9, 2].isForest = false;
Cell[9, 3].isForest = false;
Cell[9, 4].isForest = false;
Cell[9, 5].isForest = false;
Cell[9, 6].isForest = false;
Cell[9, 7].isForest = false;
Cell[9, 8].isForest = false;
Cell[9, 9].isForest = false;
Cell[9, 10].isForest = false;
Cell[9, 11].isForest = false;
Cell[10, 1].isForest = false;
Cell[10, 2].isForest = false;
Cell[10, 3].isForest = false;
Cell[10, 4].isForest = false;
Cell[10, 5].isForest = false;
Cell[10, 6].isForest = false;
Cell[10, 7].isForest = false;
Cell[10, 8].isForest = false;
Cell[10, 9].isForest = false;
Cell[10, 10].isForest = false;
Cell[10, 11].isForest = false;
for (int i = 1; i < 11; i++)
{
for (int x = 1; x < 12; x++)
{
Cell[i, x].posX = i;
Cell[i, x].posZ = x;
}
}
}
}
}