Changeset 5966 for 2015/24/ohjaajat/Dungeon/Dungeon
- Timestamp:
- 2015-06-09 20:27:58 (8 years ago)
- Location:
- 2015/24/ohjaajat/Dungeon/Dungeon
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.cs
r5965 r5966 20 20 public Dictionary<Direction, GameObject> Walls { get; set; } 21 21 22 public String Type { get; set; } 23 24 public int Damage { get; set; } 25 26 public int Culture { get; set; } 27 22 28 private bool dug; // Onko huone kaivettu? 23 29 public bool Dug … … 37 43 Location = paikka; 38 44 } 45 46 public int Hinta { get; set; } 47 39 48 } 40 49 … … 43 52 public const int RUUDUN_KOKO = 64; 44 53 54 #region Kuvat 45 55 Image lattiaKuva = LoadImage("floor"); 46 56 Image seinaKuva = LoadImage("wall"); 47 57 Image reikaSeinaKuva = LoadImage("wallhole"); 48 58 Image kiviKuva = LoadImage("rock"); 59 static Image kulttuuriKuva1 = LoadImage("es"); 60 static Image kulttuuriKuva2 = LoadImage("nyan"); 61 static Image kulttuuriKuva3 = LoadImage("spurdo"); 62 Image[] huoneKuvat = new Image[] { kulttuuriKuva1, kulttuuriKuva2, kulttuuriKuva3 }; 63 #endregion 64 65 int[] hinnat = new int[] { 100, 200, 300 }; 66 private int barbaariMaara = 3; 49 67 50 68 Room[,] huoneet; 69 Room spawn; 70 Timer barbaariAjastin = new Timer(); 71 Room ostettu; 51 72 Point digStart; // Huoneen sijainti, josta kaivuu aloitetaan. 52 73 bool digging = false; 53 74 75 IntMeter kulttuuri = new IntMeter(300, 0, 2000); 76 77 int vaakaHuoneet = 12; 78 int pystyHuoneet = 8; 79 54 80 public override void Begin() 55 81 { 56 82 ClearAll(); 57 IsMouseVisible = true; 83 Kontrollit(); 84 UlkoAsuRoskaa(); 85 Kauppa(); 58 86 59 87 // Luodaan huoneet ruutuihin. 60 huoneet = new Room[ 12, 8];88 huoneet = new Room[vaakaHuoneet, pystyHuoneet]; 61 89 foreach (var paikka in RuutujenPaikat()) 62 90 { … … 69 97 LuoSpawn(); 70 98 99 barbaariAjastin.Timeout += delegate { LuoBarbaareja(); }; 100 barbaariAjastin.Interval = 3; 101 } 102 103 void UlkoAsuRoskaa() 104 { 105 //Luodaan taustaolio 106 //GameObject tausta = new GameObject(vaakaHuoneet * RUUDUN_KOKO, pystyHuoneet * RUUDUN_KOKO); 107 //tausta.Color = Color.DarkBrown; 108 //tausta.Position -= new Vector(RUUDUN_KOKO * 0.5, RUUDUN_KOKO * 0.5); 109 //Add(tausta); 110 111 Level.Background.Color = Color.Black; 112 113 Label rahat = new Label(); 114 rahat.BindTo(kulttuuri); 115 rahat.Position = new Vector(Level.Right + Level.Width * 0.2, Level.Bottom + Level.Height * 0.1); 116 rahat.TextColor = Color.White; 117 rahat.IntFormatString = "Käytettävää kulttuuria: {0:D3}"; 118 Add(rahat); 119 } 120 121 void Kauppa() 122 { 123 for (int i = 0; i < huoneKuvat.Length; i++) 124 { 125 Point lokaatio = new Point(0, 0); 126 127 Room kuva = new Room(lokaatio); 128 kuva.Position = new Vector((Level.Right + Level.Width * 0.05), (Level.Top - Level.Height * 0.25 - (i * RUUDUN_KOKO))); 129 kuva.Image = huoneKuvat[i]; 130 kuva.Hinta = hinnat[i]; 131 Add(kuva); 132 133 Mouse.ListenOn(kuva, MouseButton.Left, ButtonState.Pressed, delegate(Room a) { ostettu = a; }, "Asetetaan ostettu huone paikoilleen", kuva); 134 135 Label teksti = new Label(); 136 teksti.Position = kuva.Position + new Vector((RUUDUN_KOKO * 1.2), 0); 137 teksti.TextColor = Color.White; 138 teksti.Text = hinnat[i].ToString(); 139 Add(teksti); 140 } 141 } 142 143 void LuoBarbaareja() 144 { 145 PhysicsObject barbaari = new PhysicsObject(RUUDUN_KOKO * 0.3, RUUDUN_KOKO * 0.3); 146 barbaari.Color = Color.Red; 147 //barbaari.Position = RandomGen.NextVector(Level.Right, Level.Bottom, Level.Left, Level.Top); 148 barbaari.Position = spawn.Position; 149 Add(barbaari); 150 } 151 152 void Kontrollit() 153 { 154 IsMouseVisible = true; 71 155 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 72 156 Keyboard.Listen(Key.F1, ButtonState.Pressed, Begin, null); 157 158 Keyboard.Listen(Key.Space, ButtonState.Pressed, SeuraavaAalto, "Anna kivan barbaariaallon tulla"); 159 } 160 161 void SeuraavaAalto() 162 { 163 barbaariMaara += 2; 164 barbaariAjastin.Start(barbaariMaara); 73 165 } 74 166 75 167 void LuoSpawn() 76 168 { 77 Room spawnHuone = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0]; 78 spawnHuone.Image = null; 79 spawnHuone.Dug = true; 80 81 Direction oviSuunta = ((spawnHuone.Position - new Vector(0, RUUDUN_KOKO * 0.5)).Angle.MainDirection); 82 spawnHuone.Walls[oviSuunta].Image = reikaSeinaKuva; 169 spawn = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0]; 170 spawn.Dug = true; 171 172 Direction oviSuunta = ((spawn.Position - new Vector(0, RUUDUN_KOKO * 0.5)).Angle.MainDirection); 173 spawn.Walls[oviSuunta].Image = reikaSeinaKuva; 174 175 Light valo = new Light(); 176 valo.Position = spawn.Position; 177 valo.Intensity = 1; 178 valo.Distance = 40; 179 Add(valo); 180 83 181 } 84 182 … … 118 216 huone.Roof.Position = huone.Position; 119 217 Add(huone.Roof, 2); 218 219 Mouse.ListenOn(huone, MouseButton.Left, ButtonState.Pressed, AsetaHuone, "Asetetaan ostettu huone paikoilleen", huone); 220 120 221 return huone; 222 } 223 224 void AsetaHuone(Room huone) 225 { 226 if(ostettu != null && huone.Dug && (kulttuuri.Value > huone.Hinta)) 227 { 228 huone.Damage = ostettu.Damage; 229 huone.Culture = ostettu.Culture; 230 huone.Image = ostettu.Image; 231 kulttuuri.Value -= ostettu.Hinta; 232 ostettu = null; 233 } 121 234 } 122 235 -
2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.csproj.Debug.cachefile
r5927 r5966 3 3 Content\rock.xnb 4 4 Content\wallhole.xnb 5 Content\es.xnb 6 Content\nyan.xnb 7 Content\spurdo.xnb -
2015/24/ohjaajat/Dungeon/Dungeon/DungeonContent/DungeonContent.contentproj
r5927 r5966 73 73 </Compile> 74 74 </ItemGroup> 75 <ItemGroup> 76 <Compile Include="es.jpg"> 77 <Name>es</Name> 78 <Importer>TextureImporter</Importer> 79 <Processor>TextureProcessor</Processor> 80 </Compile> 81 <Compile Include="nyan.png"> 82 <Name>nyan</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 85 </Compile> 86 <Compile Include="spurdo.jpg"> 87 <Name>spurdo</Name> 88 <Importer>TextureImporter</Importer> 89 <Processor>TextureProcessor</Processor> 90 </Compile> 91 </ItemGroup> 75 92 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 76 93 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.