- Timestamp:
- 2015-07-03 11:29:58 (8 years ago)
- Location:
- 2015/27/MiroS/Raiskintapeli
- Files:
-
- 15 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/TankkiPeli.cs
r6757 r6780 11 11 Image tankkikuva = LoadImage("Tankki"); 12 12 Image Vihulainen = LoadImage("Vihulainen"); 13 Image rajahdys = LoadImage("Rajahdys");14 Image pommi1 = LoadImage("Pommi");15 13 16 14 PhysicsObject tankki; 17 15 IntMeter healthit; 16 public IntMeter tuhotutTankit; 17 int vaikeusaste = 1; 18 int tankkienLkm = 4; 19 String kentanNimi = "kentta1"; 18 20 19 21 public override void Begin() … … 21 23 22 24 //IsFullScreen = true; 23 24 25 ClearAll(); 25 26 26 27 Level.Width = Screen.Width; … … 28 29 29 30 //Level.CreateBorders(); 30 LuoKentta( );31 LuoKentta(kentanNimi); 31 32 LisaaOhjaimet(); 32 33 33 34 Camera.Follow(tankki); 34 35 LuoMappi(1); 35 LuoMappi(vaikeusaste); 36 36 } 37 37 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) … … 42 42 tankki.LinearDamping = 0.1; 43 43 tankki.AngularDamping = 0.1; 44 healthit = new IntMeter(400, 0, 400); 44 tankki.Tag = "tankki"; 45 healthit = new IntMeter(500, 0, 500); 45 46 healthit.LowerLimit += delegate { 46 47 tankki.Destroy(); 48 Explosion raj = new Explosion(100.0); 49 raj.Position = tankki.Position; 50 Add(raj); 47 51 ClearControls(); 48 52 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); … … 50 54 Add(tankki); 51 55 } 52 56 53 57 void LuoVihulainen() 54 58 { 55 PhysicsObject vihu = new PhysicsObject(Vihulainen);59 Vihu vihu = new Vihu(Vihulainen.Width,Vihulainen.Height); 56 60 vihu.Size = vihu.Size * 0.1; 57 61 vihu.Position = new Vector(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 58 62 vihu.CanRotate = false; 59 Add(vihu); 63 vihu.Image = Vihulainen; 64 vihu.Tag = "vihu"; 65 Add(vihu,1); 60 66 61 67 RandomMoverBrain aivot = new RandomMoverBrain(); 62 68 aivot.WanderRadius = 200.0; 63 aivot.ChangeMovementSeconds = 40.0;69 aivot.ChangeMovementSeconds = 10.0; 64 70 vihu.Brain = aivot; 71 65 72 66 73 AssaultRifle vihunAse = new AssaultRifle(20.0, 20.0); … … 68 75 vihunAse.IsVisible = false; 69 76 vihu.Add(vihunAse); 70 77 71 78 Timer vihunAjastin = new Timer(); 72 79 vihunAjastin.Interval = 1.0; 73 80 vihunAjastin.Timeout += delegate { VihuAmpuu(vihunAse); }; 74 81 vihunAjastin.Start(); 75 76 healthit = new IntMeter(40, 0, 40); 77 healthit.LowerLimit += delegate { 78 vihu.Destroy(); 79 ClearControls(); 80 81 } 82 vihu.Ajastin = vihunAjastin; 83 84 85 86 87 88 } 89 public void LuoRajahdys(Vector paikka) 90 { 91 Explosion rajahdys = new Explosion(100); 92 rajahdys.Position = paikka; 93 Add(rajahdys); 94 95 96 } 97 82 98 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 83 99 { … … 87 103 healthit.Value -= 50; 88 104 } 105 else if (kohde.Tag.ToString() == "vihu") 106 { 107 ((Vihu)kohde).ElamaLaskuri.Value--; 108 109 } 89 110 90 111 } … … 92 113 void JättääPommin(PhysicsObject tankki) 93 114 { 94 PhysicsObject pommi = new PhysicsObject( 30.0, 30.0);115 PhysicsObject pommi = new PhysicsObject(10.0, 10.0); 95 116 pommi.Position = tankki.Position; 96 117 Add(pommi); 97 118 pommi.Color = Color.Blue; 98 119 pommi.CanRotate = false; 99 pommi.Image = pommi1;100 120 Timer.SingleShot(2.0, delegate 101 { 102 pommi.Destroy(); 121 { 103 122 Explosion raj = new Explosion(300.0); 104 123 raj.Speed = 900.0; 124 raj.Tag = "pommi"; 105 125 raj.Position = pommi.Position; 106 raj.Image = rajahdys; 126 127 raj.AddShockwaveHandler("tankki", delegate(IPhysicsObject olio, Vector shokki) 128 { 129 healthit.Value -= 1; 130 }); 131 132 raj.AddShockwaveHandler("vihu", delegate(IPhysicsObject olio, Vector shokki) 133 { 134 ((Vihu)olio).ElamaLaskuri.Value-=3; 135 }); 136 pommi.Destroy(); 107 137 Add(raj); 108 138 }); … … 121 151 122 152 }); 123 124 153 154 AddCollisionHandler(ammus, AmmusOsui); 125 155 126 156 } 127 157 void LuoMappi(int vaikeusaste) 128 158 { 129 for (int i = 0; i < 3*vaikeusaste; i++)159 for (int i = 0; i < tankkienLkm * vaikeusaste; i++) 130 160 { 131 161 LuoVihulainen(); 162 } 163 164 this.tuhotutTankit = new IntMeter(0, 0, vaikeusaste * 1); 165 166 //this.tuhotutTankit.UpperLimit += delegate { 167 // SeuraavaKentta(); 168 // vaikeusaste++; 169 // Begin(); 170 //}; 171 172 tuhotutTankit.AddTrigger(vaikeusaste * (tankkienLkm - 1), TriggerDirection.Up, delegate (int arvo) { 173 SeuraavaKentta(); 174 vaikeusaste++; 175 Begin(); 176 }); 177 } 178 void SeuraavaKentta() 179 { 180 if (kentanNimi == "kentta1") 181 { 182 kentanNimi = "kentta2"; 183 } 184 else if (kentanNimi == "kentta2") 185 { 186 kentanNimi = "kentta3"; 187 } 188 else 189 { 190 Exit(); 132 191 } 133 192 } … … 163 222 164 223 } 165 void LuoKentta( )166 { 167 ColorTileMap kentta = ColorTileMap.FromLevelAsset( "kentta1");224 void LuoKentta(String kentanNimi) 225 { 226 ColorTileMap kentta = ColorTileMap.FromLevelAsset(kentanNimi); 168 227 169 228 kentta.SetTileMethod(Color.Black, LuoSeina); … … 174 233 175 234 176 Level.Background.Color = Color. Black;235 Level.Background.Color = Color.Orange; 177 236 178 237 … … 182 241 PhysicsObject seina = PhysicsObject.CreateStaticObject(leveys, korkeus); 183 242 seina.Position = paikka; 243 seina.Color = Color.Blue; 184 244 Add(seina); 185 245 } 186 246 } 247 class Vihu : PhysicsObject 248 { 249 private IntMeter elamaLaskuri = new IntMeter(3, 0, 3); 250 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 251 252 public Timer Ajastin { get; set; } 253 public Vihu(double leveys, double korkeus) 254 : base(leveys, korkeus) 255 { 256 elamaLaskuri.LowerLimit += delegate { 257 this.Ajastin.Stop(); 258 ((TankkiPeli)Game.Instance).LuoRajahdys(this.Position); 259 this.Destroy(); 260 ((TankkiPeli)Game.Instance).tuhotutTankit.Value++; 261 }; 262 263 } 264 } -
2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/TankkiPeli.csproj.Debug.cachefile
r6757 r6780 4 4 Content\Pommi.xnb 5 5 Content\kentta1.xnb 6 Content\Kentta2.xnb -
2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/obj/x86/Debug/ContentPipeline-{81739508-248F-43AA-A768-73E659A05863}.xml
r6757 r6780 46 46 <Output>C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\kentta1.xnb</Output> 47 47 <Time>2015-07-02T14:34:55.6913156+03:00</Time> 48 </Item> 49 <Item> 50 <Source>Kentta2.png</Source> 51 <Name>Kentta2</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\Kentta2.xnb</Output> 56 <Time>2015-07-03T10:50:40.6513553+03:00</Time> 48 57 </Item> 49 58 <BuildSuccessful>true</BuildSuccessful> -
2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/obj/x86/Debug/TankkiPeli.csproj.FileListAbsolute.txt
r6757 r6780 12 12 C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\Pommi.xnb 13 13 C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\kentta1.xnb 14 C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\Kentta2.xnb -
2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/obj/x86/Debug/cachefile-{81739508-248F-43AA-A768-73E659A05863}-targetpath.txt
r6757 r6780 4 4 Content\Pommi.xnb 5 5 Content\kentta1.xnb 6 Content\Kentta2.xnb -
2015/27/MiroS/Raiskintapeli/Raiskintapeli/RaiskintapeliContent/TankkiPeliContent.contentproj
r6757 r6780 80 80 </Compile> 81 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="Kentta2.png"> 84 <Name>Kentta2</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 82 89 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 83 90 <!-- 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.