Changeset 6241
- Timestamp:
- 2015-06-24 12:02:49 (8 years ago)
- Location:
- 2015/26/RasmusP/DungeonClasher
- Files:
-
- 18 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasher/DungeonClasher.cs
r6181 r6241 23 23 24 24 25 26 public class DungeonClasher : PhysicsGame 27 { 28 29 mob pelaaja; 30 31 DoubleMeter elamaLaskuri; 32 33 public override void Begin() 34 { 35 36 asetaNappaimet(); 37 LuoKentta(); 38 39 40 Mouse.IsCursorVisible = true; 41 42 Camera.ZoomToLevel(); 43 44 } 45 void LuoKentta() 46 { 47 TileMap ruudut = TileMap.FromLevelAsset("kentta1"); 48 ruudut.SetTileMethod('=', LuoHirvio); 49 ruudut.SetTileMethod('*', LisaaLattia); 50 ruudut.SetTileMethod('P', LuoPelaaja); 51 ruudut.Execute(40, 40); 52 53 Level.CreateBorders(); 54 55 } 56 57 void asetaNappaimet() 58 { 59 60 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 61 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-500, 0)); 62 Keyboard.Listen(Key.Left, ButtonState.Released, PysaytaPelaaja, null, new Vector()); 63 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(500, 0)); 64 Keyboard.Listen(Key.Right, ButtonState.Released, PysaytaPelaaja, null, new Vector()); 65 66 67 } 68 void LiikutaPelaajaa(Vector vektori) 69 { 70 pelaaja.Push(vektori); 71 } 72 void PysaytaPelaaja(Vector vektori) 73 { 74 pelaaja.Velocity = new Vector(0, 0); 75 } 76 77 void LuoHirvio(Vector paikka, double leveys, double korkeus) 78 { 79 //mob Hirvio = RandomGen.SelectOne(orc, darkKnight, giant); 80 mob Hirvio = new mob(20, 20); 81 int arvonta = RandomGen.NextInt(3); 82 83 if (arvonta == 1) 84 { 85 //orc 86 Hirvio = new mob(40.0, 40.0); 87 88 Hirvio.Elamat = 3; 89 Hirvio.Shape = Shape.Rectangle; 90 Hirvio.Color = Color.Yellow; 91 Hirvio.CollisionIgnoreGroup = 1; 92 Hirvio.Tag = "Enimy"; 93 94 95 } 96 else if (arvonta == 2) 97 { 98 //darkKnight 99 Hirvio = new mob(20, 60); 100 Hirvio.Elamat = 3; 101 Hirvio.Shape = Shape.Rectangle; 102 Hirvio.Color = Color.Black; 103 Hirvio.CollisionIgnoreGroup = 1; 104 Hirvio.Tag = "Enimy"; 105 } 106 else 107 { 108 //giant 109 Hirvio = new mob(75, 100); 110 Hirvio.Elamat = 3; 111 Hirvio.Shape = Shape.Rectangle; 112 Hirvio.Color = Color.Blue; 113 Hirvio.CollisionIgnoreGroup = 1; 114 Hirvio.Tag = "Enimy"; 115 116 } 117 118 Hirvio.Position = paikka; 119 Hirvio.Y -= 20 - Hirvio.Height * 0.5; 120 Add(Hirvio); 121 122 123 124 } 125 void LisaaLattia(Vector paikka, Double leveys, Double korkeus) 126 { 127 PhysicsObject lattia = PhysicsObject.CreateStaticObject(leveys, korkeus); 128 lattia.Position = paikka; 129 lattia.Color = Color.Brown; 130 Add(lattia); 131 132 133 } 134 void LuoPelaaja(Vector paikka, Double leveys, Double korkeus) 135 { 136 pelaaja = new mob(40.40, 40.0); 137 pelaaja.Elamat = 3; 138 Add(pelaaja); 139 140 pelaaja.MaxAngularVelocity = 0; 141 pelaaja.MaxVelocity = 500; 142 pelaaja.Mass = 2.5; 143 144 pelaaja.CollisionIgnoreGroup = 1; 145 146 pelaaja.Color = Color.Black; 147 pelaaja.Position = paikka; 148 149 } 150 151 152 153 154 155 } 156 157 25 public class DungeonClasher : PhysicsGame 26 { 27 Image tiiliskivi = LoadImage("Tiiliskivi"); 28 PlatformCharacter pelaaja; 29 PhysicsObject miekka; 30 31 private IntMeter elamaLaskuri = new IntMeter(10, 0, 10); 32 33 int kenttaNro = 1; 34 35 bool miekkaEsille = false; 36 int vihujenMaara = 0; 37 38 public override void Begin() 39 { 40 41 42 LuoKentta(); 43 //SeuraavaKentta(); 44 45 46 47 } 48 void SeuraavaKentta() 49 { 50 ClearAll(); 51 if (kenttaNro > 6) 52 { MessageDisplay.Add("voitit pelin"); } 53 else { LuoKentta(); } 54 55 56 } 57 void LuoKentta() 58 { 59 miekkaEsille = false; 60 61 TileMap ruudut = TileMap.FromLevelAsset("kentta" + kenttaNro ); 62 63 ruudut.SetTileMethod('=', LuoHirvio); 64 ruudut.SetTileMethod('*', LisaaLattia); 65 ruudut.SetTileMethod('P', LuoPelaaja); 66 ruudut.Execute(40, 40); 67 68 Gravity = new Vector(0.0, -1000); 69 70 Level.CreateBorders(); 71 asetaNappaimet(); 72 73 Mouse.IsCursorVisible = true; 74 75 Camera.ZoomToLevel(); 76 } 77 78 void asetaNappaimet() 79 { 80 81 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 82 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-500, 0)); 83 Keyboard.Listen(Key.Left, ButtonState.Released, PysaytaPelaaja, null, new Vector()); 84 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(500, 0)); 85 Keyboard.Listen(Key.Right, ButtonState.Released, PysaytaPelaaja, null, new Vector()); 86 Keyboard.Listen(Key.A, ButtonState.Pressed, IskeMiekalla, null); 87 //Keyboard.Listen(Key.A, ButtonState.Released, TuhoaMiekka, null); 88 89 } 90 void LiikutaPelaajaa(Vector vektori) 91 { 92 pelaaja.Walk(vektori.X); 93 } 94 void PysaytaPelaaja(Vector vektori) 95 { 96 pelaaja.Velocity = new Vector(0, 0); 97 } 98 99 void LuoHirvio(Vector paikka, double leveys, double korkeus) 100 { 101 //mob Hirvio = RandomGen.SelectOne(orc, darkKnight, giant); 102 mob Hirvio = new mob(20, 20); 103 int arvonta = RandomGen.NextInt(3); 104 105 if (arvonta == 1) 106 { 107 //orc 108 Hirvio = new mob(80.0, 80.0); 109 110 Hirvio.Elamat = 3; 111 Hirvio.Shape = Shape.Rectangle; 112 Hirvio.Color = Color.Yellow; 113 Hirvio.Mass = 1000; 114 Hirvio.MaxVelocity = 0; 115 Hirvio.MaxAngularVelocity = 0; 116 Hirvio.Tag = "Enimy"; 117 118 119 } 120 else if (arvonta == 2) 121 { 122 //darkKnight 123 Hirvio = new mob(40, 120); 124 Hirvio.Elamat = 3; 125 Hirvio.Shape = Shape.Rectangle; 126 Hirvio.Color = Color.Black; 127 Hirvio.Mass = 1000; 128 Hirvio.MaxVelocity = 0; 129 Hirvio.MaxAngularVelocity = 0; 130 Hirvio.Tag = "Enimy"; 131 } 132 else 133 { 134 //giant 135 Hirvio = new mob(150, 200); 136 Hirvio.Elamat = 3; 137 Hirvio.Shape = Shape.Rectangle; 138 Hirvio.Color = Color.Blue; 139 Hirvio.Mass = 1000; 140 Hirvio.MaxVelocity = 0; 141 Hirvio.MaxAngularVelocity = 0; 142 Hirvio.Tag = "Enimy"; 143 144 } 145 146 Hirvio.ElamaLaskuri.LowerLimit += delegate 147 { 148 vihujenMaara--; 149 if (vihujenMaara == 0) 150 { kenttaNro++; SeuraavaKentta(); } 151 }; 152 153 Hirvio.Position = paikka; 154 Hirvio.Y -= 20 - Hirvio.Height * 0.5; 155 Add(Hirvio); 156 vihujenMaara++; 157 158 159 160 } 161 void LisaaLattia(Vector paikka, Double leveys, Double korkeus) 162 { 163 PhysicsObject lattia = PhysicsObject.CreateStaticObject(leveys, korkeus); 164 lattia.Position = paikka; 165 lattia.Color = Color.Brown; 166 lattia.Image = tiiliskivi; 167 Add(lattia); 168 169 170 } 171 void LuoPelaaja(Vector paikka, Double leveys, Double korkeus) 172 { 173 pelaaja = new PlatformCharacter(40, 120); 174 pelaaja.Position = paikka; 175 pelaaja.Y -= 20 - pelaaja.Height * 0.5; 176 //pelaaja.Elamat = 3; 177 pelaaja.Color = Color.Black; 178 179 elamaLaskuri.LowerLimit += delegate { pelaaja.Destroy(); }; 180 181 ProgressBar elamaPalkki = new ProgressBar(150, 20); 182 elamaPalkki.X = Screen.Left + 150; 183 elamaPalkki.Y = Screen.Top - 20; 184 elamaPalkki.BindTo(elamaLaskuri); 185 Add(elamaPalkki); 186 187 Add(pelaaja); 188 189 pelaaja.MaxAngularVelocity = 0; 190 pelaaja.MaxVelocity = 500; 191 192 193 AddCollisionHandler(pelaaja, "Enimy", PelaajaOsui); 194 195 } 196 void PelaajaOsui(PhysicsObject pelaaja, PhysicsObject kohde) 197 { 198 elamaLaskuri.Value -= RandomGen.SelectOne(1, 2, 3, 4); 199 200 201 } 202 void IskeMiekalla() 203 { 204 if (!miekkaEsille) 205 { 206 miekkaEsille = true; 207 miekka = new PhysicsObject(70, 20); 208 miekka.X = pelaaja.X + pelaaja.Width / 2; 209 miekka.IgnoresCollisionResponse = true; 210 miekka.IgnoresGravity = true; 211 miekka.Y = pelaaja.Y; 212 Add(miekka); 213 Timer.SingleShot(1, delegate { miekka.Destroy(); miekkaEsille = false; }); 214 215 AddCollisionHandler(miekka, "Enimy", vahingoitaVihollista); 216 217 Timer MiekanLiikutus = new Timer(); 218 MiekanLiikutus.Interval = 0.01; 219 MiekanLiikutus.Timeout += delegate { miekka.Position = pelaaja.Position + pelaaja.FacingDirection.GetVector() * 33; }; 220 MiekanLiikutus.Start(); 221 222 223 224 225 226 } 227 } 228 void vahingoitaVihollista(PhysicsObject miekka, PhysicsObject vihollinen) 229 { 230 mob vihu = vihollinen as mob; 231 int pudotus = RandomGen.NextInt(5); 232 vihu.ElamaLaskuri.Value -= pudotus; 233 } 234 } -
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasher/DungeonClasher.csproj.Debug.cachefile
r6164 r6241 1 1 Content\kentta1.xnb 2 Content\Tiiliskivi.xnb 3 Content\kentta2.xnb 4 Content\kentta3.xnb 5 Content\kentta4.xnb 6 Content\kentta5.xnb 7 Content\kentta6.xnb 2 8 Content\kentta1.txt 9 Content\kentta2.txt 10 Content\kentta3.txt 11 Content\kentta4.txt 12 Content\kentta5.txt 13 Content\kentta6.txt -
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasher/bin/x86/Debug/Content/kentta1.txt
r6181 r6241 8 8 ............................................. 9 9 ............................................. 10 . P.........................=.......=.....=...10 ..P........................=.......=.....=... 11 11 ********************************************* -
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasher/obj/x86/Debug/ContentPipeline-{9E8A5BF1-0124-4B72-B960-7241168C215B}.xml
r6181 r6241 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta1.xnb</Output> 11 <Time>2015-06-23T12:25:39.0161491+03:00</Time> 11 <Time>2015-06-24T09:36:42.0426062+03:00</Time> 12 </Item> 13 <Item> 14 <Source>Tiiliskivi.png</Source> 15 <Name>Tiiliskivi</Name> 16 <Importer>TextureImporter</Importer> 17 <Processor>TextureProcessor</Processor> 18 <Options>None</Options> 19 <Output>C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\Tiiliskivi.xnb</Output> 20 <Time>2015-06-24T10:00:01.4024062+03:00</Time> 21 </Item> 22 <Item> 23 <Source>kentta2.txt</Source> 24 <Name>kentta2</Name> 25 <Importer>TextFileImporter</Importer> 26 <Processor>TextFileContentProcessor</Processor> 27 <Options>None</Options> 28 <Output>C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta2.xnb</Output> 29 <Time>2015-06-24T11:27:02.7486062+03:00</Time> 30 </Item> 31 <Item> 32 <Source>kentta3.txt</Source> 33 <Name>kentta3</Name> 34 <Importer>TextFileImporter</Importer> 35 <Processor>TextFileContentProcessor</Processor> 36 <Options>None</Options> 37 <Output>C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta3.xnb</Output> 38 <Time>2015-06-24T11:28:55.3406062+03:00</Time> 39 </Item> 40 <Item> 41 <Source>kentta4.txt</Source> 42 <Name>kentta4</Name> 43 <Importer>TextFileImporter</Importer> 44 <Processor>TextFileContentProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta4.xnb</Output> 47 <Time>2015-06-24T11:29:40.6816062+03:00</Time> 48 </Item> 49 <Item> 50 <Source>kentta5.txt</Source> 51 <Name>kentta5</Name> 52 <Importer>TextFileImporter</Importer> 53 <Processor>TextFileContentProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta5.xnb</Output> 56 <Time>2015-06-24T11:29:51.9146062+03:00</Time> 57 </Item> 58 <Item> 59 <Source>kentta6.txt</Source> 60 <Name>kentta6</Name> 61 <Importer>TextFileImporter</Importer> 62 <Processor>TextFileContentProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta6.xnb</Output> 65 <Time>2015-06-24T11:32:26.4526062+03:00</Time> 12 66 </Item> 13 67 <BuildSuccessful>true</BuildSuccessful> -
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasher/obj/x86/Debug/DungeonClasher.csproj.FileListAbsolute.txt
r6181 r6241 19 19 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\obj\x86\Debug\DungeonClasher.exe 20 20 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\obj\x86\Debug\DungeonClasher.pdb 21 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\Tiiliskivi.xnb 22 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta2.xnb 23 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta3.xnb 24 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta4.xnb 25 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta5.xnb 26 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta6.xnb 27 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta2.txt 28 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta3.txt 29 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta4.txt 30 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta5.txt 31 C:\MyTemp\RasmusP\Hi\DungeonClasher\DungeonClasher\DungeonClasher\bin\x86\Debug\Content\kentta6.txt -
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasher/obj/x86/Debug/cachefile-{9E8A5BF1-0124-4B72-B960-7241168C215B}-targetpath.txt
r6164 r6241 1 1 Content\kentta1.xnb 2 Content\Tiiliskivi.xnb 3 Content\kentta2.xnb 4 Content\kentta3.xnb 5 Content\kentta4.xnb 6 Content\kentta5.xnb 7 Content\kentta6.xnb 2 8 Content\kentta1.txt 9 Content\kentta2.txt 10 Content\kentta3.txt 11 Content\kentta4.txt 12 Content\kentta5.txt 13 Content\kentta6.txt -
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasherContent/DungeonClasherContent.contentproj
r6164 r6241 53 53 </Compile> 54 54 </ItemGroup> 55 <ItemGroup> 56 <Compile Include="Tiiliskivi.png"> 57 <Name>Tiiliskivi</Name> 58 <Importer>TextureImporter</Importer> 59 <Processor>TextureProcessor</Processor> 60 </Compile> 61 </ItemGroup> 62 <ItemGroup> 63 <Compile Include="kentta2.txt"> 64 <Name>kentta2</Name> 65 <Importer>TextFileImporter</Importer> 66 <Processor>TextFileContentProcessor</Processor> 67 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 68 </Compile> 69 <Compile Include="kentta3.txt"> 70 <Name>kentta3</Name> 71 <Importer>TextFileImporter</Importer> 72 <Processor>TextFileContentProcessor</Processor> 73 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 74 </Compile> 75 <Compile Include="kentta4.txt"> 76 <Name>kentta4</Name> 77 <Importer>TextFileImporter</Importer> 78 <Processor>TextFileContentProcessor</Processor> 79 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 80 </Compile> 81 <Compile Include="kentta5.txt"> 82 <Name>kentta5</Name> 83 <Importer>TextFileImporter</Importer> 84 <Processor>TextFileContentProcessor</Processor> 85 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 86 </Compile> 87 <Compile Include="kentta6.txt"> 88 <Name>kentta6</Name> 89 <Importer>TextFileImporter</Importer> 90 <Processor>TextFileContentProcessor</Processor> 91 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 92 </Compile> 93 </ItemGroup> 55 94 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 56 95 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2015/26/RasmusP/DungeonClasher/DungeonClasher/DungeonClasherContent/kentta1.txt
r6181 r6241 8 8 ............................................. 9 9 ............................................. 10 . P.........................=.......=.....=...10 ..P........................=.......=.....=... 11 11 *********************************************
Note: See TracChangeset
for help on using the changeset viewer.