Changeset 4414
- Timestamp:
- 2013-07-03 15:06:53 (10 years ago)
- Location:
- 2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME.cs
r4374 r4414 14 14 15 15 PlatformCharacter pelaaja1; 16 16 Image VihunKuva = LoadImage("Vihu"); 17 17 Image[] seisomisanimaatio = LoadImages("Trollface"); 18 Image[] kävelykuvat = LoadImages("Trollface", "Trollface2");18 Image[] kävelykuvat = LoadImages("Trollface", "Trollface2"); 19 19 Image[] hyokkausanimaatio = LoadImages("Trollfaceampuu"); 20 20 … … 24 24 DoubleMeter energia; 25 25 DoubleMeter elamat; 26 IntMeter esLaskuri; 26 27 27 28 SoundEffect laaserAani = LoadSoundEffect("maali"); 29 int nykyinenKentta = 2; 30 28 31 29 32 public override void Begin() 30 33 { 34 AloitaKentta(nykyinenKentta); 35 } 36 37 38 void AloitaKentta( int kentanNro ) 39 { 31 40 Gravity = new Vector(0, -1000); 32 33 34 LuoKentta( );41 42 LisaaLaskuri(); 43 LuoKentta("kentta" + kentanNro); 35 44 LisaaNappaimet(); 36 45 … … 45 54 Camera.ZoomFactor = 1.2; 46 55 Camera.StayInLevel = true; 56 57 nykyinenKentta = kentanNro; 58 } 59 60 void SeuraavaKentta() 61 { 62 AloitaKentta(nykyinenKentta + 1); 47 63 } 48 64 … … 57 73 energiaPalkki.BindTo(energia); 58 74 Add(energiaPalkki); 59 75 60 76 } 61 77 void LisaaElamaPalkki() 62 78 { 63 79 elamat = new DoubleMeter(10, 0, 10); 80 elamat.LowerLimit += delegate { ClearAll(); AloitaKentta(nykyinenKentta); }; 64 81 65 82 ProgressBar ElamaPalkki = new ProgressBar(200, 35); … … 70 87 Add(ElamaPalkki); 71 88 } 72 void LuoKentta( )73 { 74 75 TileMap kentta = TileMap.FromLevelAsset( "kentta1");89 void LuoKentta(string kentanNimi) 90 { 91 92 TileMap kentta = TileMap.FromLevelAsset(kentanNimi); 76 93 kentta.SetTileMethod('#', LisaaTaso); 77 94 kentta.SetTileMethod('*', LisaaTahti); 78 95 kentta.SetTileMethod('N', LisaaPelaaja); 96 kentta.SetTileMethod('V', LisaaVihu); 79 97 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 80 98 Level.CreateBorders(); 81 Level.Background.Image = LoadImage("Tausta 2");99 Level.Background.Image = LoadImage("Tausta"); 82 100 Level.Background.FitToLevel(); 83 101 } 102 103 void LisaaVihu(Vector paikka, double leveys, double korkeus) 104 { 105 106 Vihu vihu = new Vihu(leveys * 1.5, korkeus * 1.5, 5); 107 vihu.Position = paikka; 108 //vihu.Color = Color.Red; 109 vihu.Image = VihunKuva; 110 vihu.MirrorImage(); 111 vihu.Tag = "Vihu"; 112 Add(vihu); 113 114 PlatformWandererBrain Aivot = new PlatformWandererBrain(); 115 Aivot.Speed = nopeus - 50; 116 vihu.Brain = Aivot; 117 118 GameObject palkinPaikka = new GameObject(50, 50); 119 palkinPaikka.Position = new Vector(0, 50); 120 palkinPaikka.IsVisible = false; 121 //Add(palkinPaikka); 122 vihu.Add(palkinPaikka); 123 124 ProgressBar vihunElamat = new ProgressBar(70, 30); 125 vihunElamat.IsVisible = true; 126 vihunElamat.BindTo(vihu.Elamat); 127 palkinPaikka.Add(vihunElamat); 128 129 130 } 131 void LisaaLaskuri() 132 { 133 esLaskuri = new IntMeter(0, 0, 6); 134 esLaskuri.UpperLimit += SeuraavaKentta; 135 136 Label pisteNaytto = new Label(); 137 pisteNaytto.Left = Screen.Left + 50; 138 pisteNaytto.Top = Screen.Top - 50; 139 pisteNaytto.TextColor = Color.White; 140 pisteNaytto.Color = Color.Black; 141 142 pisteNaytto.BindTo(esLaskuri); 143 Add(pisteNaytto); 144 } 84 145 85 146 void LisaaTaso(Vector paikka, double leveys, double korkeus) … … 109 170 pelaaja1.AnimIdle = new Animation(seisomisanimaatio); 110 171 AddCollisionHandler(pelaaja1, "es", TormaaTahteen); 111 172 AddCollisionHandler(pelaaja1, "Vihu", TormaaVihuun); 112 173 113 174 //pelaaja1 on PlatformCharacter-tyyppinen … … 124 185 } 125 186 187 void TormaaVihuun(PhysicsObject pelaaja, PhysicsObject vihu) 188 { 189 elamat.Value -= 3; 190 } 191 126 192 127 193 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 128 194 { 129 195 ammus.Destroy(); 196 197 if (kohde is Vihu) 198 { 199 ((Vihu)kohde).Elamat.Value -= 0.2; 200 } 130 201 } 131 202 … … 144 215 //ammus.MaximumLifetime = TimeSpan.FromSeconds(5.0) 145 216 } 146 217 218 } 219 220 void AloitaPeli() 221 { 147 222 } 148 223 … … 158 233 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 159 234 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 160 235 Keyboard.Listen(Key.R, ButtonState.Pressed, AloitaPeli, "Aloittaa pelin uudelleen"); 161 236 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 162 237 … … 181 256 { 182 257 MessageDisplay.Add("Keräsit es energia juoman!"); 258 esLaskuri.AddValue(1); 183 259 tahti.Destroy(); 184 260 } 185 261 186 187 188 189 190 191 262 192 263 } 264 265 public class Vihu : PlatformCharacter 266 { 267 DoubleMeter elamat; 268 public DoubleMeter Elamat { get{ return elamat; }} 269 public Vihu(double leveys, double korkeus, int elamia) 270 : base(leveys, korkeus) 271 { 272 elamat = new DoubleMeter(elamia, 0, elamia); 273 elamat.LowerLimit += delegate { this.Destroy(); }; 274 } 275 276 277 278 279 } -
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kentta1.txt
r4374 r4414 1 N ########################################### 2 # # 3 ####### # # 4 # # ### 5 # # ########################## # 6 # ####### # # 7 #### #* ##8 # # # # ## # 9 # # ##### # ## #10 # * # # ####################### 11 # ##### # # 12 ##### ##################### ####13 * ### #### #* # ##14 # #### ### ## #### #15 # # ###16 # # #########17 ##### ######## ##18 # ## # 19 # ##1 N ################################################################################################# 2 # # # 3 ####### # # ################# # V # # 4 # # ### # V # # ############################ ## 5 # # ########################## ################## #* ### 6 # ####### # # ### ### ### # 7 #### #* ### # # # V # ### # # 8 # # # # ## # #################### ### #### ### # 9 # # ##### # ## V # * # # 10 # * # # ############################################## # V # ##### # 11 # ##### # # # # ########## # 12 ##### ########################## #### # V # #### # 13 #* ### #### #* # # # ## ##### # V # 14 ## #### ### # ## ## ## # ## ## # # ######## # 15 # # # ## # ## V # ### ## # # V # # 16 # # V ## # ######## # ## ### # ############## ############# 17 # #################### ## #### ## # # 18 # # ## # ## # # V # # 19 # V # V # # V ######## ########################## 20 20 ######################################################## -
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kill_everypody_GAMEContent.contentproj
r4374 r4414 103 103 </ItemGroup> 104 104 <ItemGroup> 105 <Compile Include="Tausta 1.jpg">106 <Name>Tausta 1</Name>105 <Compile Include="Tausta.jpg"> 106 <Name>Tausta</Name> 107 107 <Importer>TextureImporter</Importer> 108 108 <Processor>TextureProcessor</Processor> … … 110 110 </ItemGroup> 111 111 <ItemGroup> 112 <Compile Include=" Tausta2.jpg">113 <Name> Tausta2</Name>112 <Compile Include="Vihu.png"> 113 <Name>Vihu</Name> 114 114 <Importer>TextureImporter</Importer> 115 115 <Processor>TextureProcessor</Processor> 116 </Compile> 117 </ItemGroup> 118 <ItemGroup> 119 <Compile Include="kentta2.txt"> 120 <Name>kentta2</Name> 121 <Importer>TextFileImporter</Importer> 122 <Processor>TextFileContentProcessor</Processor> 116 123 </Compile> 117 124 </ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.