- Timestamp:
- 2013-06-27 12:40:39 (10 years ago)
- Location:
- 2013/26/SakuK
- Files:
-
- 9 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/26/SakuK/SPY/SPY/SPY/SPY.cs
r4235 r4258 12 12 Image pelaajanKuva = LoadImage("hahmopaahenkilo"); 13 13 Image tahtiKuva = LoadImage("tahti"); 14 Image morkoKuva = LoadImage("morko"); 14 15 PlatformCharacter pelaaja; 15 AssaultRifle pelaajan1Ase;16 16 int kenttaNro = 1; 17 //AssaultRifle pelaajanAse; 18 19 17 20 18 21 public override void Begin() … … 26 29 "Aloita peli", "Parhaat pisteet", "Lopeta"); 27 30 Add(alkuValikko); 28 pelaajan1Ase = new AssaultRifle(30, 10);29 31 alkuValikko.AddItemHandler(0, AloitaPeli); 30 32 alkuValikko.AddItemHandler(1, ParhaatPisteet); … … 40 42 void AloitaPeli() 41 43 { 42 Gravity = new Vector(0, -150); 43 44 Keyboard.Listen(Key.Left, ButtonState.Down, 45 LiikutaPelaajaa, null, -100.0); 46 Keyboard.Listen(Key.Right, ButtonState.Down, 47 LiikutaPelaajaa, null, 100.0); 48 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Hyppää", 500.0); 49 ControllerOne.Listen(Button.X, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 50 ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.1, 51 LiikutaPelaajaa, "Liikuta pelaajaa tattia pyörittämällä."); 52 Keyboard.Listen(Key.Space, ButtonState.Released, Hyppaa, "Hyppää", 150.0); 44 Gravity = new Vector(0, -160); 45 46 47 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 48 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 49 50 ControllerOne.Vibrate(0.5, 0.5, 0.0, 0.0, 0.1); 51 LuoKentta("kenta"+kenttaNro); 52 53 } 54 55 56 void LuoKentta(string kentanNimi) 57 { 58 ColorTileMap ruudut = ColorTileMap.FromLevelAsset(kentanNimi); 59 ruudut.SetTileMethod("00FF00", LuoPelaaja); 60 ruudut.SetTileMethod(Color.Black, LuoTaso); 61 ruudut.SetTileMethod("FFE607", LuoTahti); 62 ruudut.SetTileMethod(Color.Red, LuoLaava); 63 ruudut.SetTileMethod("00FFF6", LuoMaali); 64 ruudut.SetTileMethod("FA00FF", LuoZombi); 65 ruudut.Execute(20, 20); 66 67 53 68 //Keyboard.Listen(Key.Up, ButtonState.Down, 54 69 // LiikutaPelaajaa, null, new Vector(0, 100)); … … 59 74 //Camera.ZoomFactor = 1.7; 60 75 Camera.ZoomToLevel(); 61 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 62 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 63 64 ControllerOne.Vibrate(0.5, 0.5, 0.0, 0.0, 0.1); 65 LuoKentta("kenta"+kenttaNro); 66 67 } 68 69 70 void LuoKentta(string kentanNimi) 71 { 72 ColorTileMap ruudut = ColorTileMap.FromLevelAsset(kentanNimi); 73 ruudut.SetTileMethod("00FF00", LuoPelaaja); 74 ruudut.SetTileMethod(Color.Black, LuoTaso); 75 ruudut.SetTileMethod("FFE607", LuoTahti); 76 ruudut.SetTileMethod(Color.Red, LuoLaava); 77 ruudut.SetTileMethod("AAFF2B", LuoMaali); 78 ruudut.Execute(20, 20); 79 80 } 76 AsetaOhjaimet(); 77 78 79 } 80 81 void AsetaOhjaimet() 82 { 83 Keyboard.Listen(Key.Left, ButtonState.Down, 84 LiikutaPelaajaa, null, -100.0); 85 Keyboard.Listen(Key.Right, ButtonState.Down, 86 LiikutaPelaajaa, null, 100.0); 87 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Hyppää", 500.0); 88 ControllerOne.Listen(Button.X, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 89 ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.1, 90 LiikutaPelaajaa, "Liikuta pelaajaa tattia pyörittämällä."); 91 Keyboard.Listen(Key.Space, ButtonState.Released, Hyppaa, "Hyppää", 150.0); 92 93 ControllerOne.Listen(Button.RightTrigger, ButtonState.Down, AmmuAseella, "ammu", pelaaja.Weapon); 94 } 95 96 void LuoZombi(Vector paikka, double leveys, double korkeus) 97 { 98 PlatformCharacter morko = new PlatformCharacter(20.0, 20.0); 99 morko.Image = morkoKuva; 100 morko.Position = paikka; 101 morko.Tag = "vihollinen"; 102 Add(morko); 103 104 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 105 tasoAivot.Speed = 100; 106 107 morko.Brain = tasoAivot; 108 tasoAivot.FallsOffPlatforms = false; 109 tasoAivot.JumpSpeed = 700; 110 tasoAivot.TriesToJump = false; 111 } 112 81 113 82 114 void LuoMaali(Vector paikka, double leveys, double korkeus) 83 115 { 116 PhysicsObject maali = PhysicsObject.CreateStaticObject(leveys, korkeus); 117 maali.Position = paikka; 118 maali.Color = Color.AshGray; 119 //taso.Image = groundImage 120 maali.Tag = "maali"; 121 maali.CollisionIgnoreGroup = 1; 122 Add(maali); 123 84 124 85 125 } … … 89 129 pelaaja = new PlatformCharacter(leveys, korkeus); 90 130 pelaaja.Position = paikka; 131 pelaaja.Destroyed += SeuraavaKentta; 91 132 pelaaja.Image = pelaajanKuva; 92 133 AddCollisionHandler(pelaaja, "tahti", TormaaTahteen); 93 134 AddCollisionHandler(pelaaja, "vihollinen", TormaaViholliseen); 94 135 AddCollisionHandler(pelaaja, "laava", TormaaLaavaan); 136 AddCollisionHandler(pelaaja, "maali", TormasiMaaliin); 95 137 Add(pelaaja); 96 138 139 AssaultRifle pelaajanAse = new AssaultRifle(30, 10); 140 pelaajanAse.Ammo.Value = 1000; 141 142 //Mitä tapahtuu kun ammus osuu johonkin? 143 pelaajanAse.ProjectileCollision = AmmusOsui; 144 145 pelaaja.Weapon = pelaajanAse; 146 97 147 } 98 148 99 149 void TormaaLaavaan(PhysicsObject pelaaja, PhysicsObject laava) 100 150 { 101 pelaaja.Hit(new Vector(0, 75)); 102 elamaLaskuri.Value -= 5; 151 elamaLaskuri.Value -= 100000; 103 152 } 104 153 … … 170 219 { 171 220 pelaaja.Walk(nopeus); 221 KaannaAse(pelaaja); 222 } 223 224 225 void KaannaAse(PlatformCharacter pelaaja) 226 { 227 if (pelaaja.Weapon == null) return; 228 if (pelaaja.FacingDirection.Equals(Direction.Right)) 229 pelaaja.Weapon.Angle = Angle.FromDegrees(0); 230 else 231 pelaaja.Weapon.Angle = Angle.FromDegrees(180); 172 232 } 173 233 … … 180 240 { 181 241 } 182 void LiikutaPelaajaa(Vector vektori, PhysicsObject pelaaja)183 {184 pelaaja.Move(vektori);185 }242 //void LiikutaPelaajaa(Vector vektori, PhysicsObject pelaaja) 243 //{ 244 // pelaaja.Move(vektori); 245 //} 186 246 187 247 void LiikutaPelaajaa(AnalogState tatinTila) … … 189 249 Vector tatinAsento = tatinTila.StateVector; 190 250 pelaaja.Walk(tatinAsento.X*100); 251 KaannaAse(pelaaja); 191 252 } 192 253 void SeuraavaKentta() … … 204 265 SeuraavaKentta(); 205 266 } 267 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 268 { 269 ammus.Destroy(); 270 } 271 void AmmuAseella(Weapon ase) 272 { 273 //if (!(ase is AssaultRifle)) return; 274 //AssaultRifle pyssy = (AssaultRifle)ase; 275 PhysicsObject ammus = ase.Shoot(); 276 277 if(ammus != null) 278 { 279 //ammus.Size *= 3; 280 //ammus.Image = ... 281 ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 282 } 206 283 } 284 285 } -
2013/26/SakuK/SPY/SPY/SPYContent/SPYContent.contentproj
r4235 r4258 58 58 </ItemGroup> 59 59 <ItemGroup> 60 <Compile Include="kenta1.png"> 61 <Name>kenta1</Name> 60 <Compile Include="kenta3.png"> 61 <Name>kenta3</Name> 62 <Importer>TextureImporter</Importer> 63 <Processor>TextureProcessor</Processor> 64 </Compile> 65 </ItemGroup> 66 <ItemGroup> 67 <Compile Include="kenta4.png"> 68 <Name>kenta4</Name> 69 <Importer>TextureImporter</Importer> 70 <Processor>TextureProcessor</Processor> 71 </Compile> 72 </ItemGroup> 73 <ItemGroup> 74 <Compile Include="kirves.png"> 75 <Name>kirves</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 </ItemGroup> 80 <ItemGroup> 81 <Compile Include="lamppu.png"> 82 <Name>lamppu</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 85 </Compile> 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="morko.png"> 89 <Name>morko</Name> 90 <Importer>TextureImporter</Importer> 91 <Processor>TextureProcessor</Processor> 92 </Compile> 93 </ItemGroup> 94 <ItemGroup> 95 <Compile Include="roskis.png"> 96 <Name>roskis</Name> 97 <Importer>TextureImporter</Importer> 98 <Processor>TextureProcessor</Processor> 99 </Compile> 100 </ItemGroup> 101 <ItemGroup> 102 <Compile Include="tietokone.png"> 103 <Name>tietokone</Name> 62 104 <Importer>TextureImporter</Importer> 63 105 <Processor>TextureProcessor</Processor> … … 67 109 <Compile Include="kenta2.png"> 68 110 <Name>kenta2</Name> 111 <Importer>TextureImporter</Importer> 112 <Processor>TextureProcessor</Processor> 113 </Compile> 114 </ItemGroup> 115 <ItemGroup> 116 <Compile Include="kenta5.png"> 117 <Name>kenta5</Name> 118 <Importer>TextureImporter</Importer> 119 <Processor>TextureProcessor</Processor> 120 </Compile> 121 </ItemGroup> 122 <ItemGroup> 123 <Compile Include="kenta1.png"> 124 <Name>kenta1</Name> 69 125 <Importer>TextureImporter</Importer> 70 126 <Processor>TextureProcessor</Processor>
Note: See TracChangeset
for help on using the changeset viewer.