- Timestamp:
- 2015-06-26 11:31:56 (8 years ago)
- Location:
- 2015/26/FransM/Pixels
- Files:
-
- 3 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/26/FransM/Pixels/Pixels/Pixels/Pixels.cs
r6270 r6448 9 9 public class Pixels : PhysicsGame 10 10 { 11 int ruudunkoko = 60; 11 12 Image taustakuva = LoadImage("Taustakuva"); 12 13 Image tasoKuva = LoadImage("Maa"); … … 20 21 Image alinkuva = LoadImage("Alin"); 21 22 Image ruohokuva = LoadImage("Maapalaruoholla"); 22 Image alempikuva = LoadImage("Alempi"); 23 23 Image alempikuva = LoadImage("Alempi"); 24 Image kivi3kuva = LoadImage("Kivi3"); 25 Image pommikuva = LoadImage("TNT"); 26 Image plutoniumkuva = LoadImage("plutonium"); 27 Image kukkakuva = LoadImage("Kukka"); 28 Image seinakuva2 = LoadImage(""); 29 30 Inventory inventory; 24 31 25 32 public override void Begin() … … 28 35 29 36 SmoothTextures = false; 30 31 //Inventory test = new Inventory(); 32 //test.AddItem(new PhysicsObject(porakuva), porakuva); 33 //Add(test); 37 38 inventory = new Inventory(); 39 inventory.Left = Screen.Left+ 100; 40 Add(inventory); 41 42 for (int i = 0; i < 10; i++) 43 { 44 inventory.AddItem(new PhysicsObject(pommikuva), pommikuva); 45 } 34 46 35 47 MediaPlayer.Play("CaveMusicX"); … … 52 64 ruudut.SetTileMethod(Color.FromHexCode("00FF21"), LuoTaso6); 53 65 ruudut.SetTileMethod(Color.FromHexCode("FF6A00"), LuoTaso7); 54 //ruudut.SetTileMethod(Color.FromHexCode("7F3300"), LuoTaso8);55 56 57 ruudut.Execute( 60, 60);66 ruudut.SetTileMethod(Color.FromHexCode("7F3300"), LuoTaso8); 67 ruudut.SetTileMethod(Color.FromHexCode("B6FF00"), LuoTaso9); 68 69 ruudut.Execute(ruudunkoko, ruudunkoko); 58 70 Level.Background.FitToLevel(); 59 71 … … 70 82 } 71 83 }, ""); 84 72 85 IsFullScreen = true; 73 74 75 } 86 } 87 76 88 void EsineValitsin(Vector paikka) 77 89 { … … 79 91 if (arpa <= 50) 80 92 { 81 EsineLuoja(paikka, "Pora"); 93 EsineLuoja(paikka, "TNT"); 94 } 95 else if (arpa <= 70) 96 { 97 EsineLuoja(paikka, "plutonium"); 82 98 } 83 99 else 84 100 { 85 86 } 87 } 101 EsineLuoja(paikka, "Kukka"); 102 } 103 104 105 } 106 88 107 void EsineLuoja(Vector paikka, String tag) 89 108 { 90 GameObject esine = new GameObject(LoadImage(tag));109 PhysicsObject esine = PhysicsObject.CreateStaticObject(LoadImage(tag)); 91 110 esine.Position = paikka; 111 esine.Tag = "esine"; 92 112 Add(esine, 1); 113 } 114 115 void rajayta(PhysicsObject taso) 116 { 117 bool voikaivaa = false; 118 Vector[] suunnat = { new Vector(-1, 0), new Vector(1, 0), new Vector(0, -1), new Vector(0, 1) }; 119 120 foreach (var suunta in suunnat) 121 { 122 GameObject palikka = GetObjectAt(taso.Position + suunta * ruudunkoko); 123 if (palikka == null) 124 { 125 voikaivaa = true; 126 break; 127 } 128 129 130 } 131 132 if (voikaivaa && inventory.Objects.Count > 0) 133 { 134 inventory.Objects.Remove(inventory.Objects[0]); 135 136 Explosion rajahdys = new Explosion(ruudunkoko); 137 rajahdys.Position = taso.Position; 138 rajahdys.ShockwaveReachesObject += PaineaaltoOsuu; 139 Add(rajahdys); 140 taso.Destroy(); 141 } 142 } 143 144 void PaineaaltoOsuu(IPhysicsObject olio, Vector shokki) 145 { 146 if (olio.Tag.Equals("esine") && !olio.IsDestroyed) 147 { 148 inventory.AddItem((PhysicsObject)olio, olio.Image); 149 } 150 151 olio.Destroy(); 93 152 } 94 153 … … 100 159 taso.CollisionIgnoreGroup = 1; 101 160 Add(taso); 161 162 Mouse.ListenOn(taso, MouseButton.Left, ButtonState.Pressed, delegate { rajayta(taso); }, null); 102 163 } 103 164 … … 114 175 EsineValitsin(paikka); 115 176 } 177 178 Mouse.ListenOn(taso2, MouseButton.Left, ButtonState.Pressed, delegate { rajayta(taso2); }, null); 116 179 } 117 180 … … 123 186 taso3.CollisionIgnoreGroup = 1; 124 187 Add(taso3); 188 189 if (RandomGen.NextInt(0, 100) < 20) 190 { 191 EsineValitsin(paikka); 192 } 193 194 Mouse.ListenOn(taso3, MouseButton.Left, ButtonState.Pressed, delegate { rajayta(taso3); }, null); 125 195 } 126 196 … … 128 198 { 129 199 PhysicsObject taso4 = PhysicsObject.CreateStaticObject(leveys, korkeus); 200 taso4.IgnoresExplosions = true; 130 201 taso4.Position = paikka; 131 202 taso4.Image = seinakuva; 132 203 taso4.CollisionIgnoreGroup = 1; 133 204 Add(taso4); 205 206 134 207 } 135 208 … … 141 214 taso5.CollisionIgnoreGroup = 1; 142 215 Add(taso5); 216 217 Mouse.ListenOn(taso5, MouseButton.Left, ButtonState.Pressed, delegate { rajayta(taso5); }, null); 143 218 } 144 219 … … 151 226 taso6.CollisionIgnoreGroup = 1; 152 227 Add(taso6); 228 229 Mouse.ListenOn(taso6, MouseButton.Left, ButtonState.Pressed, delegate { rajayta(taso6); }, null); 153 230 } 154 231 … … 160 237 taso7.CollisionIgnoreGroup = 1; 161 238 Add(taso7); 162 } 239 240 Mouse.ListenOn(taso7, MouseButton.Left, ButtonState.Pressed, delegate { rajayta(taso7); }, null); 241 } 242 243 void LuoTaso8(Vector paikka, double leveys, double korkeus) 244 { 245 PhysicsObject taso8 = PhysicsObject.CreateStaticObject(leveys, korkeus); 246 taso8.Position = paikka; 247 taso8.Image = kivi3kuva; 248 taso8.CollisionIgnoreGroup = 1; 249 Add(taso8); 250 251 Mouse.ListenOn(taso8, MouseButton.Left, ButtonState.Pressed, delegate { rajayta(taso8); }, null); 252 } 253 254 void LuoTaso9(Vector paikka, double leveys, double korkeus) 255 { 256 PhysicsObject taso9 = PhysicsObject.CreateStaticObject(leveys, korkeus); 257 taso9.Position = paikka; 258 taso9.Image = kivi3kuva; 259 taso9.CollisionIgnoreGroup = 1; 260 Add(taso9); 261 } 262 163 263 } 164 264 165 166 /// <summary>167 /// Esinevalikko.168 /// </summary>169 265 class Inventory : Widget 170 266 { … … 178 274 /// </summary> 179 275 public Inventory() 180 : base(new HorizontalLayout())276 : base(new VerticalLayout()) 181 277 { 182 278 } … … 186 282 /// </summary> 187 283 /// <param name="item">Lisättävä esine.</param> 188 /// 284 ///<param name="kuva">Esineen ikoni, joka näkyy valikossa.</param> 189 285 public void AddItem(PhysicsObject item, Image kuva) 190 286 { 191 PushButton icon = new PushButton(kuva); 287 PushButton icon = new PushButton(100, 100, kuva); 288 192 289 Add(icon); 193 290 icon.Clicked += delegate() { SelectItem(item); }; -
2015/26/FransM/Pixels/Pixels/Pixels/Pixels.csproj.Debug.cachefile
r6270 r6448 14 14 Content\CaveMusicX.xnb 15 15 Content\Kivi3.xnb 16 Content\Kukka.xnb 16 17 Content\CaveMusicX.wma -
2015/26/FransM/Pixels/Pixels/Pixels/obj/x86/Debug/ContentPipeline-{23DE9823-17E1-4AFC-BB04-6AA018C329F7}.xml
r6270 r6448 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\Taustakuva.xnb</Output> 11 <Time>2015-06-2 4T14:12:49.0725085+03:00</Time>11 <Time>2015-06-26T10:43:21.851757+03:00</Time> 12 12 </Item> 13 13 <Item> … … 18 18 <Options>None</Options> 19 19 <Output>C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\Maa.xnb</Output> 20 <Time>2015-06-2 4T14:27:19.3271527+03:00</Time>20 <Time>2015-06-26T11:31:16.561157+03:00</Time> 21 21 </Item> 22 22 <Item> … … 72 72 <Options>None</Options> 73 73 <Output>C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\Kivi.xnb</Output> 74 <Time>2015-06-2 3T13:41:05.0241499+03:00</Time>74 <Time>2015-06-26T11:03:08.055357+03:00</Time> 75 75 </Item> 76 76 <Item> … … 136 136 <Options>None</Options> 137 137 <Output>C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\Kivi3.xnb</Output> 138 <Time>2015-06-24T14:29:42.0358536+03:00</Time> 138 <Time>2015-06-26T09:13:47.1790065+03:00</Time> 139 </Item> 140 <Item> 141 <Source>Kukka.png</Source> 142 <Name>Kukka</Name> 143 <Importer>TextureImporter</Importer> 144 <Processor>TextureProcessor</Processor> 145 <Options>None</Options> 146 <Output>C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\Kukka.xnb</Output> 147 <Time>2015-06-26T11:11:34.598157+03:00</Time> 139 148 </Item> 140 149 <BuildSuccessful>true</BuildSuccessful> -
2015/26/FransM/Pixels/Pixels/Pixels/obj/x86/Debug/Pixels.csproj.FileListAbsolute.txt
r6270 r6448 23 23 C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\CaveMusicX.wma 24 24 C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\Kivi3.xnb 25 C:\MyTemp\FransM\Pixels\Pixels\Pixels\bin\x86\Debug\Content\Kukka.xnb -
2015/26/FransM/Pixels/Pixels/Pixels/obj/x86/Debug/cachefile-{23DE9823-17E1-4AFC-BB04-6AA018C329F7}-targetpath.txt
r6270 r6448 15 15 Content\CaveMusicX.wma 16 16 Content\Kivi3.xnb 17 Content\Kukka.xnb -
2015/26/FransM/Pixels/Pixels/PixelsContent/PixelsContent.contentproj
r6270 r6448 150 150 </Compile> 151 151 </ItemGroup> 152 <ItemGroup> 153 <Compile Include="Kukka.png"> 154 <Name>Kukka</Name> 155 <Importer>TextureImporter</Importer> 156 <Processor>TextureProcessor</Processor> 157 </Compile> 158 </ItemGroup> 152 159 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 153 160 <!-- 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.