 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Nov 12, 2009 7:53 pm Post subject: C# Help using arrays please |
|
|
k so I have a custom class I made and I want to make an array of that class
my custom class is BoardCells
| Code: |
namespace WoWminis
{
class BoardCells
{
public bool isMountain = false;
public bool isForest = false;
public Vector3 position;
}
}
|
so I have this at the begging of my public class
| Code: |
BoardCells [,]Cell = new BoardCells[10,11];
|
but when I want to write in the array
it says "
"NullReferenceException was unhandled"
"Object reference not set to an instance of an object."
| Code: |
//Board positions
[b]Cell[1, 1].position = new Vector3(-42.5f, 0.1f, 50.3f);[/b]
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(10f, 0.1f, 40.3f);
Cell[6, 3 ].position = new Vector3(15.75f, 0.1f, 30.3f);
Cell[6, 4].position = new Vector3(10f, 0.1f, 20.3f);
Cell[6, 5].position = new Vector3(15.75f, 0.1f, 10.3f);
Cell[6, 6].position = new Vector3(10f, 0.1f, 0.3f);
Cell[6, 7].position = new Vector3(15.75f, 0.1f, -10.3f);
Cell[6, 8].position = new Vector3(10f, 0.1f, -20.3f);
Cell[6, 9].position = new Vector3(15.75f, 0.1f, -30.3f);
Cell[6, 10].position = new Vector3(10f, 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(41f, 0.1f, 50.3f);
Cell[9, 2].position = new Vector3(56.75f, 0.1f, 40.3f);
Cell[9, 3].position = new Vector3(41f, 0.1f, 30.3f);
Cell[9, 4].position = new Vector3(56.75f, 0.1f, 20.3f);
Cell[9, 5].position = new Vector3(41f, 0.1f, 10.3f);
Cell[9, 6].position = new Vector3(56.75f, 0.1f, 0.3f);
Cell[9, 7].position = new Vector3(41f, 0.1f, -10.3f);
Cell[9, 8].position = new Vector3(56.75f, 0.1f, -20.3f);
Cell[9, 9].position = new Vector3(41f, 0.1f, -30.3f);
Cell[9, 10].position = new Vector3(56.75f, 0.1f, -40.3f);
Cell[9, 11].position = new Vector3(41f, 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;
|
any idea of what am I doing wrong ?
|
|
| Back to top |
|
 |
Fendaril Cheater
Reputation: 0
Joined: 08 Nov 2009 Posts: 27
|
Posted: Thu Nov 12, 2009 8:05 pm Post subject: |
|
|
Try declaring the multi-dimensional array correctly
BoardCell[][] Cell=new BoardCell[10][11];
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Nov 12, 2009 8:09 pm Post subject: |
|
|
BoardCells [][]Cell = new BoardCells[10][11];
Error 1 Invalid rank specifier: expected ',' or ']'
?? like this?
I though [,] was fine
|
|
| Back to top |
|
 |
Fendaril Cheater
Reputation: 0
Joined: 08 Nov 2009 Posts: 27
|
Posted: Thu Nov 12, 2009 8:10 pm Post subject: |
|
|
| [,] is invalid.
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
|
| Back to top |
|
 |
Fendaril Cheater
Reputation: 0
Joined: 08 Nov 2009 Posts: 27
|
Posted: Thu Nov 12, 2009 8:14 pm Post subject: |
|
|
| just use an array of arrays much easier. :/
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Nov 12, 2009 8:17 pm Post subject: |
|
|
just letting you know again:
BoardCells [][]Cell = new BoardCells[10][11];
is not working
|
|
| Back to top |
|
 |
Fendaril Cheater
Reputation: 0
Joined: 08 Nov 2009 Posts: 27
|
Posted: Thu Nov 12, 2009 8:20 pm Post subject: |
|
|
edit: check your vector3 class.
also can i see more code.
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Nov 12, 2009 8:28 pm Post subject: |
|
|
BoardCells [][]Cell = new BoardCells[10][]; (( works like this ))
Vector 3 is part of the XNA library
anyways after changing it it gives me the same NullReference error
I'm posting the code here wait.
Edit::
CLOSE THREAD PLEASE
I found out that I wasn't creating the items just making "space " for they
I had to add
Cell[1, 1] = new BoardCells();
Cell[1, 2] = new BoardCells();
............
going to use a loop for that
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Thu Nov 12, 2009 9:48 pm Post subject: |
|
|
| For the love of Christ use nested for loops to initialize that shit.
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Nov 12, 2009 10:10 pm Post subject: |
|
|
| Athaem wrote: | | For the love of Christ use nested for loops to initialize that shit. |
no need.
Loops are made for the sake of organization and ease of coding not for speed of processing and since the position values were extracted through a debug extraction I had it all pasted wit functions with an advanced notepad that let me find and replace with expressions.
also, just organized all in sub programs so its not messy.
right now I moved on and started working on the movement points and movement permissions interface
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Nov 12, 2009 11:16 pm Post subject: |
|
|
Oh my merciful christ that is fucking horrendous. Use a loop, please
I'd pretty much slash my throat if i came across that
|
|
| Back to top |
|
 |
NoManchesPuto I post too much
Reputation: 0
Joined: 24 Jan 2009 Posts: 2820
|
Posted: Thu Nov 12, 2009 11:31 pm Post subject: |
|
|
| slovach wrote: | Oh my merciful christ that is fucking horrendous. Use a loop, please
I'd pretty much slash my throat if i came across that |
Lol wow you're mean lol ^^
@OP: What are you making exactly?
_________________
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Fri Nov 13, 2009 12:36 am Post subject: |
|
|
(( a game, if you check Game Developing Section you will see what I'm doing ))
__ right now I'm working on making the mouse projection into the 3D world so I can select by clicking.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Nov 13, 2009 1:53 am Post subject: |
|
|
| Sounds like you want ray picking
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|