Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameItem
- {
- private int[] DirectionVector;
- private Tile[,] ItemTiles;
- private readonly Color[] TileColors = { Color.Crimson, Color.Aqua, Color.ForestGreen, Color.Indigo, Color.Yellow, Color.Chocolate };
- public GameItem()
- {
- int random = new Random(DateTime.Now.Millisecond).Next(0,2);
- if (random == 0)
- {
- this.DirectionVector = new int[2] { 1, 0 };
- }
- else
- {
- this.DirectionVector = new int[2] { 0, 1 };
- }
- int x = 0;
- int y = 0;
- int colorSelector = new Random(DateTime.Now.Millisecond).Next(0, 6);
- this.ItemTiles = new Tile[DirectionVector[0]*2, DirectionVector[1]*2];
- for (int i = 0; i < 3; i++)
- {
- Tile tile = new Tile(x, y);
- tile.SetColor(this.TileColors[colorSelector]);
- this.ItemTiles[x, y] = tile; // INDEX OUT OF RANGE
- x += this.DirectionVector[0];
- y += this.DirectionVector[1];
- }
- }
- public int[] GetVector()
- {
- return this.DirectionVector;
- }
- public Color GetColor(int x, int y)
- {
- return this.ItemTiles[x, y].BackColor;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement