Changeset 2565
- Timestamp:
- 2011-08-04 15:01:12 (11 years ago)
- Location:
- 2011/31/RobertJ/Miner/Miner
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/31/RobertJ/Miner/Miner/Miner/Peli.cs
r2530 r2565 9 9 public class Peli : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200);12 Vector nopeusAlas = new Vector(0, - 200);11 Vector nopeusYlos = new Vector(0, 90); 12 Vector nopeusAlas = new Vector(0, -90); 13 13 Vector nopeusStop = new Vector(0, 0); 14 Vector nopeusVasen = new Vector(-200, 0); 15 Vector nopeusOikea = new Vector(200, 0); 16 Vector viholinen = new Vector(); 14 Vector nopeusVasen = new Vector(-90, 0); 15 Vector nopeusOikea = new Vector(90, 0); 16 //Vector viholinen = new Vector(); 17 18 AssaultRifle isoase; 19 20 Inventory inventory; 21 Image puukuva = LoadImage("puu"); 22 Image kultakuva = LoadImage("kulta2"); 23 Image ironkuva = LoadImage("iron2"); 24 Image timantikuva = LoadImage("timanti3"); 17 25 18 26 PhysicsObject Miner; 19 Image olionKuva = LoadImage("player 1 standing");20 Image[] KavelyKuvat = LoadImages("player 1" 27 Image olionKuva = LoadImage("player 1 version 2"); 28 Image[] KavelyKuvat = LoadImages("player 1", "player 1 frame2"); 21 29 22 30 Image[] zombiekavelykuvat = LoadImages("zombie animatio osa 1", "zombie animatio osa 2"); 23 31 Image olionKuva1 = LoadImage("zombie seiso"); 24 32 25 Image[] KavelyKuvatPeilattu;33 //Image[] KavelyKuvatPeilattu; 26 34 public override void Begin() 27 35 { 36 28 37 TileMap ruudut = TileMap.FromLevelAsset("kentaa"); 29 //ruudut.SetTileMethod('=', ); 38 ruudut.SetTileMethod('=', LouPuu); 39 ruudut.SetTileMethod('$', Loukulta); 30 40 ruudut.SetTileMethod('*', LouPuu); 31 ruudut.Execute(); 41 ruudut.SetTileMethod('P', LouMiner); 42 ruudut.SetTileMethod('#', Louiron); 43 ruudut.SetTileMethod('T', Loutimanti); 44 ruudut.SetTileMethod('z', Louzombie); 45 ruudut.Execute(50, 50); 46 47 inventory = new Inventory(); 48 inventory.Left = Screen.Left; 49 inventory.Top = Screen.Top; 50 Add(inventory); 51 52 FollowerBrain zombinAivot = (FollowerBrain)zombie.Brain; 53 zombinAivot.Target = Miner; 32 54 //Camera.ZoomToLevel(); 33 //KavelyKuvatPeilattu = Image.Mirror(KavelyKuvat);55 //KavelyKuvatPeilattu = Image.Mirror(KavelyKuvat); 34 56 35 57 // TODO: Kirjoita ohjelmakoodisi tähän 36 Miner = new PhysicsObject(40.0, 40.0); 58 59 Level.BackgroundColor = Color.ForestGreen; 60 61 Camera.Follow(Miner); 62 Camera.Zoom(9.0); 63 64 AsetaOhjaimet(); 65 //Louzombie(); 66 } 67 void AsetaOhjaimet() 68 { 69 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaaMinerYlos, "Pelaaja 1: Liikuta Miner ylös"); 70 Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaMiner, null); 71 72 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaaMinerAlas, "Pelaaja 1: Liikuta Miner Alas"); 73 Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaMiner, null); 74 75 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaaMinerVasen, "Pelaaja 1: Liikuta Miner Vasemalle"); 76 Keyboard.Listen(Key.Left, ButtonState.Released, PysaytaMiner, null); 77 78 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaaMinerOikea, "Pelaaja 1: Liikuta Miner Oikealle"); 79 Keyboard.Listen(Key.Right, ButtonState.Released, PysaytaMiner, null); 80 81 Keyboard.Listen(Key.Space, ButtonState.Released, rikkokivi, "Pelaaja 1: rikko kiven"); 82 Keyboard.Listen(Key.Space, ButtonState.Released, rikkokulta, "Pelaaja 1: rikko kultan"); 83 Keyboard.Listen(Key.Space, ButtonState.Released, rikkotimanti, "Pelaaja 1: rikko timantin"); 84 85 Keyboard.Listen(Key.K, ButtonState.Released, tekasiase, "Pelaaja 1: teke kasiasen"); 86 Keyboard.Listen(Key.O, ButtonState.Released, teisoase, "Pelaaja 1: teke isonasen"); 87 88 Keyboard.Listen(Key.Space, ButtonState.Down, ammu, "Pelaaja 1: ammpu"); 89 //Keyboard.Listen(Key.Space, ButtonState.Released, alaammu, "Pelaaja 1: loppeta ampumisen"); 90 91 92 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 93 } 94 void PysaytaMiner() 95 { 96 Miner.Velocity = nopeusStop; 97 Miner.Animation.Stop(); 98 } 99 void LiikutaaMinerYlos() 100 { 101 Miner.Velocity = nopeusYlos; 102 Miner.Animation.Resume(); 103 Miner.Angle = Angle.FromDegrees(90); 104 } 105 void LiikutaaMinerAlas() 106 { 107 Miner.Velocity = nopeusAlas; 108 Miner.Animation.Resume(); 109 //Miner.Animation.FPS = 10; 110 Miner.Angle = Angle.FromDegrees(-90); 111 } 112 void LiikutaaMinerVasen() 113 { 114 Miner.Velocity = nopeusVasen; 115 Miner.Animation.Resume(); 116 Miner.Angle = Angle.FromDegrees(180); 117 118 } 119 void LiikutaaMinerOikea() 120 { 121 Miner.Velocity = nopeusOikea; 122 Miner.Animation.Resume(); 123 Miner.Angle = Angle.FromDegrees(0); 124 } 125 void Louzombie(Vector paikka, double leveys, double korkeus) 126 { 127 zombie = new PhysicsObject(10, 10); 128 Add(zombie); 129 zombie.Image = olionKuva1; 130 zombie.Position = paikka; 131 FollowerBrain seuraajanAivot = new FollowerBrain(Miner, 20); 132 seuraajanAivot.Target = Miner; 133 zombie.Brain = seuraajanAivot; 134 } 135 void LouPuu(Vector paikka, double leveys, double korkeus) 136 { 137 PhysicsObject Puu = PhysicsObject.CreateStaticObject(leveys, korkeus); 138 Puu.Position = paikka; 139 Puu.Shape = Shape.Circle; 140 Puu.Color = Color.Green; 141 Add(Puu); 142 Puu.Image = puukuva; 143 144 145 } 146 void LouMiner(Vector paikka, double leveys, double korkeus) 147 { 148 Miner = new PhysicsObject(10.0, 10.0); 37 149 Add(Miner); 38 150 Miner.Shape = Shape.Rectangle; 39 151 Miner.Color = Color.Black; 40 152 Miner.Image = olionKuva; 41 Miner.Animation = new Animation(KavelyKuvat);153 //Miner.Animation = new Animation(KavelyKuvat); 42 154 Miner.Animation.FPS = 2; 43 Level.BackgroundColor = Color.ForestGreen; 44 45 Camera.Follow(Miner); 46 Camera.Zoom(4.0); 47 48 AsetaOhjaimet(); 49 Louzombie(); 50 } 51 void AsetaOhjaimet() 52 { 53 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaaMinerYlos, "Pelaaja 1: Liikuta Miner ylös"); 54 Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaMiner, null ); 55 56 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaaMinerAlas, "Pelaaja 1: Liikuta Miner Alas"); 57 Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaMiner, null); 58 59 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaaMinerVasen, "Pelaaja 1: Liikuta Miner Vasemalle"); 60 Keyboard.Listen(Key.Left, ButtonState.Released, PysaytaMiner, null); 61 62 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaaMinerOikea, "Pelaaja 1: Liikuta Miner Oikealle"); 63 Keyboard.Listen(Key.Right, ButtonState.Released, PysaytaMiner, null); 64 65 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 66 } 67 void PysaytaMiner() 68 { 69 Miner.Velocity = nopeusStop; 70 Miner.Animation.Stop(); 71 } 72 void LiikutaaMinerYlos() 73 { 74 Miner.Velocity = nopeusYlos; 75 Miner.Animation.Start(); 76 } 77 void LiikutaaMinerAlas() 78 { 79 Miner.Velocity = nopeusAlas; 80 Miner.Animation.Start(); 81 } 82 void LiikutaaMinerVasen() 83 { 84 Miner.Velocity = nopeusVasen; 85 Miner.Animation.Start(); 86 } 87 void LiikutaaMinerOikea() 88 { 89 Miner.Velocity = nopeusOikea; 90 Miner.Animation.Start(); 91 } 92 void Louzombie() 93 { 94 PhysicsObject zombie = new PhysicsObject(40, 40); 95 Add(zombie); 96 zombie.Image = olionKuva1; 97 zombie.X = RandomGen.NextDouble(Level.Left, Level.Right); 98 } 99 void LouPuu(Vector paikka, double leveys, double korkeus) 100 { 101 PhysicsObject Puu = PhysicsObject.CreateStaticObject( leveys, korkeus); 102 Puu.Position = paikka; 103 Puu.Shape = Shape.Circle; 104 Puu.Color = Color.Green; 105 Add(Puu); 106 107 } 108 155 Miner.Position = paikka; 156 Miner.Restitution = 0.0; 157 Miner.CanRotate = false; 158 } 159 void Loukulta(Vector paikka, double leveys, double korkeus) 160 { 161 PhysicsObject kulta = PhysicsObject.CreateStaticObject(20, 20); 162 kulta.Position = paikka; 163 kullat.Add(kulta); 164 Add(kulta); 165 kulta.Image = kultakuva; 166 167 } 168 void Louiron(Vector paikka, double leveys, double korkeus) 169 { 170 PhysicsObject iron = PhysicsObject.CreateStaticObject(20, 20); 171 iron.Position = paikka; 172 irons.Add(iron); 173 Add(iron); 174 iron.Image = ironkuva; 175 } 176 void Loutimanti(Vector paikka, double leveys, double korkeus) 177 { 178 PhysicsObject timanti = PhysicsObject.CreateStaticObject(20, 20); 179 timanti.Position = paikka; 180 timantit.Add(timanti); 181 Add(timanti); 182 timanti.Image = timantikuva; 183 184 } 185 PhysicsObject zombie; 186 List<PhysicsObject> irons = new List<PhysicsObject>(); 187 List<PhysicsObject> kullat = new List<PhysicsObject>(); 188 List<PhysicsObject> timantit = new List<PhysicsObject>(); 189 void rikkokivi() 190 { 191 foreach (var iron in irons) 192 { 193 194 if (Vector.Distance(iron.Position, Miner.Position) < 22 && !iron.IsDestroyed) 195 { 196 iron.Destroy(); 197 198 inventory.AddItem( iron, ironkuva ); 199 200 } 201 202 } 203 } 204 void rikkokulta() 205 { 206 foreach (var kulta in kullat ) 207 { 208 209 if (Vector.Distance(kulta.Position, Miner.Position) < 22 &&! kulta.IsDestroyed) 210 { 211 kulta.Destroy(); 212 213 inventory.AddItem(kulta, kultakuva); 214 } 215 } 216 } 217 void rikkotimanti() 218 { 219 foreach (var timanti in timantit ) 220 { 221 222 if (Vector.Distance(timanti.Position, Miner.Position) < 22 && !timanti.IsDestroyed) 223 { 224 timanti.Destroy(); 225 226 inventory.AddItem(timanti, timantikuva); 227 } 228 } 229 } 230 void teisoase() 231 { 232 if (inventory.inventlaskin(ironkuva) >= 3) 233 { 234 isoase = new AssaultRifle(20, 5); 235 Miner.Add(isoase); 236 } 237 } 238 void tekasiase() 239 { 240 241 } 242 void ammu() 243 { 244 if (isoase != null) 245 { 246 247 248 PhysicsObject ammus = isoase.Shoot(); 249 250 if (ammus != null) 251 { 252 ammus.Size *= 0.1; 253 } 254 } 255 } 256 void alaammu() 257 { 258 259 } 260 } 261 262 class Inventory : Widget 263 { 264 List<Widget> Items = new List<Widget>(); 265 266 /// <summary> 267 /// Tapahtuma, kun esine on valittu. 268 /// </summary> 269 public event Action<PhysicsObject> ItemSelected; 270 271 /// <summary> 272 /// Luo uuden esinevalikon. 273 /// </summary> 274 public Inventory() 275 : base(new HorizontalLayout()) 276 { 277 } 278 279 /// <summary> 280 /// Lisää esineen. 281 /// </summary> 282 /// <param name="item">Lisättävä esine.</param> 283 /// <param name="kuva">Esineen ikoni, joka näkyy valikossa.</param> 284 public void AddItem(PhysicsObject item, Image kuva) 285 { 286 PushButton icon = new PushButton(kuva); 287 Add(icon); 288 Items.Add(icon); 289 icon.Clicked += delegate() { SelectItem(item); }; 290 } 291 292 void SelectItem(PhysicsObject item) 293 { 294 if (ItemSelected != null) 295 { 296 ItemSelected(item); 297 } 298 } 299 300 public int inventlaskin( Image itemType ) 301 { 302 int laskuri = 0; 303 304 foreach (var item in Items) 305 { 306 if (item.Image == itemType) 307 laskuri++; 308 } 309 310 return laskuri; 311 } 109 312 } -
2011/31/RobertJ/Miner/Miner/MinerContent/MinerContent.contentproj
r2530 r2565 83 83 </ItemGroup> 84 84 <ItemGroup> 85 <Compile Include="iron.png">86 <Name>iron</Name>87 <Importer>TextureImporter</Importer>88 <Processor>TextureProcessor</Processor>89 </Compile>90 85 <Compile Include="kentaa.txt"> 91 86 <Name>kentaa</Name> … … 94 89 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 95 90 </Compile> 96 <Compile Include=" timanti.png">97 <Name> timanti</Name>91 <Compile Include="puu.png"> 92 <Name>puu</Name> 98 93 <Importer>TextureImporter</Importer> 99 94 <Processor>TextureProcessor</Processor> 100 95 </Compile> 101 <Compile Include="kulta.png"> 102 <Name>kulta</Name> 96 </ItemGroup> 97 <ItemGroup> 98 <Compile Include="timanti3.png"> 99 <Name>timanti3</Name> 103 100 <Importer>TextureImporter</Importer> 104 101 <Processor>TextureProcessor</Processor> 105 102 </Compile> 106 <Compile Include="puu.png"> 107 <Name>puu</Name> 103 </ItemGroup> 104 <ItemGroup> 105 <Compile Include="iron2.png"> 106 <Name>iron2</Name> 107 <Importer>TextureImporter</Importer> 108 <Processor>TextureProcessor</Processor> 109 </Compile> 110 <Compile Include="kulta2.png"> 111 <Name>kulta2</Name> 112 <Importer>TextureImporter</Importer> 113 <Processor>TextureProcessor</Processor> 114 </Compile> 115 </ItemGroup> 116 <ItemGroup> 117 <Compile Include="player 1 version 2.png"> 118 <Name>player 1 version 2</Name> 108 119 <Importer>TextureImporter</Importer> 109 120 <Processor>TextureProcessor</Processor> -
2011/31/RobertJ/Miner/Miner/MinerContent/kentaa.txt
r2530 r2565 1 1 ======================================================= 2 * #******* * $ * * * ** ##### $ * * * * * 3 ** * * ** **** $ * ## ** $ **** ** ** 4 * * * # # ** $ $$ **** ***** *** * 5 *** $$ *** ** *** ## *** ** *** *** ** $$ 6 $$ $$ *** ## * ** *** ** 7 ** ** ## ** P * * * $ ** ** ** ** $ 8 ** ### ## ** ** **** *** ** ** ** $$ # $$ 9 *** ## ** $ *** ** ***** *** #### **** *** 10 ** $ ## ** $ *** *** ** #### *** *** 11 ** ## ** ** ** ** $ #### ##### **** 12 * * * # # ** $ $$ **** ***** *** * $ 13 *** *** ### $$ ## ***** ** $$ ** *** * * * * 14 ** ## ** $ ** ** ### ***** ***** ** ** 15 *** * ****** ** ******** ** *** ****** * * * * ** 16 ## $ ### *** * * ** * * * ## $$$ ## *** *** 17 $$ *** ** * * * * * * # ** ** ##### *** $ ***£ 2 * #* * * * * $ * * * ** ##### $ * * * * * * * T * * * * * * ** ** * * * * * * * * * * * * * * * * * * * * * * * * 3 ** * * ** * * * * $ * ## * * $ * * * * * * * * T $ * * * * * * T * * * * * # # # # ** * * * * * $ 4 * * * # # ** $ $$ * * * * T * * * * * * * * * 5 * * $$ * * ** * * ## *** * * * * * * * * * * $$ # ** * * * $ * * * * * * * * $ 6 * * ### ## ** ** * * * * * * * * * * * * $$ # $$ 7 * * ## ** $ * * * * * * * * * * * * #### * * * * * * 8 ** $ ## ** $ z * * * * * * * * * * * * * * * * * * * * ### ## ** ** * * * * * * * * * * * * $$ # $$ 9 $$ $$ * * T ## * * * *** * * 10 * * ** ## ** P * * * $ * * * * * * * * $ T $ * * * * * * T * * * * * # # # # ** * * * * * $ 11 * * ### ## ** ** * * * * * * * * * * * * $$ # $$ 12 * * ## ** $ * * * * * * * * * * * * #### * * * * * * 13 ** $ ## ** $ * * * * * * ** #### *** * * * 14 ** ## ** ** * * * * $ #### ##### **** *** * ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 15 * * * # # ** $ $$ **** ***** *** * $ * * * * * * * * * * * * * * $ * * * * * * $ * * * * * * * * * * * 16 *** *** ### $$ ## ***** ** $$ ** *** * * * * *** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 17 ** ## ** $ ** ** ### * * * * ** ** * * * * * * * * *$$* * * * * * * * * * * * * * * * * * * * * * * * 18 *** * ****** ** ******** ** *** ****** * * * * ** * * * * * * * * * * * * * * * * * * * # * * * * # * * * * * * * * 19 ## $ ### *** * * ** * * * ## $$$ ## *** *** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 20 $$ *** ** * * * * * * # ** ** ##### ** T * $ * * T * * * * * * ** ** * * * * * * * * * * * * * * * * * * * * * * * * 18 21 =======================================================
Note: See TracChangeset
for help on using the changeset viewer.