1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using Microsoft.Xna.Framework; |
---|
5 | using Microsoft.Xna.Framework.Audio; |
---|
6 | using Microsoft.Xna.Framework.Content; |
---|
7 | using Microsoft.Xna.Framework.GamerServices; |
---|
8 | using Microsoft.Xna.Framework.Graphics; |
---|
9 | using Microsoft.Xna.Framework.Input; |
---|
10 | using Microsoft.Xna.Framework.Media; |
---|
11 | |
---|
12 | namespace WindowsGame1 |
---|
13 | { |
---|
14 | public class Map |
---|
15 | { |
---|
16 | //Lataa pelimapin sisäänsä |
---|
17 | public Vector2 Size; |
---|
18 | public Tile[,] Tiles; |
---|
19 | public List<MapObject> Objects = new List<MapObject>(); |
---|
20 | public List<Unit> Units = new List<Unit>(); |
---|
21 | Texture2D texture; |
---|
22 | uint[] colorMap; |
---|
23 | Dictionary<uint, int> levelBuildDict = new Dictionary<uint, int>(); |
---|
24 | public Map(Texture2D texture/*DEBUG DEBUG*/, int w, int h) |
---|
25 | { |
---|
26 | this.Size = new Vector2(w, h); |
---|
27 | this.colorMap = new uint[texture.Width * texture.Height]; |
---|
28 | |
---|
29 | this.texture = texture;//DEBUG |
---|
30 | |
---|
31 | this.Tiles = new Tile[w, h]; |
---|
32 | |
---|
33 | texture.GetData(colorMap); |
---|
34 | buildMap(); |
---|
35 | } |
---|
36 | void buildMap() |
---|
37 | { |
---|
38 | for (var x = 0; x < Size.X; x++) |
---|
39 | { |
---|
40 | for (var y = 0; y < Size.Y; y++) |
---|
41 | { |
---|
42 | Tiles[x, y] = new Tile("testitile");//jotain shittiä myöhemmin |
---|
43 | if (Pikseli.Instance.random.NextDouble() > 0.1) { continue; } |
---|
44 | |
---|
45 | string textureId = ""; float shadowOffset = 0; |
---|
46 | switch ((int)Math.Floor((double)(Pikseli.Instance.random.NextDouble() * 4))) |
---|
47 | { |
---|
48 | case 0: |
---|
49 | textureId = "puut/kuollut"; |
---|
50 | break; |
---|
51 | case 1: |
---|
52 | textureId = "puut/kuusi"; |
---|
53 | break; |
---|
54 | case 2: |
---|
55 | textureId = "puut/mänty"; |
---|
56 | break; |
---|
57 | case 3: |
---|
58 | textureId = "puut/ohut"; |
---|
59 | break; |
---|
60 | } |
---|
61 | Objects.Add(new MapObject(textureId, x, y, false, shadowOffset)); |
---|
62 | } |
---|
63 | } |
---|
64 | Objects.Add(new Unit("ukko", 1, 0)); |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|