Changeset 6908 for 2015/30/MarkusS/git_gud_the_game
- Timestamp:
- 2015-07-22 11:45:57 (5 years ago)
- Location:
- 2015/30/MarkusS/git_gud_the_game
- Files:
-
- 6 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/30/MarkusS/git_gud_the_game/git_gud_the_game/git_gud_the_game/git_gud_the_game.cs
r6877 r6908 16 16 public Pelaaja(Image pelaajanKuva) : base(pelaajanKuva) 17 17 { 18 this.KineticFriction = 1.0; 19 this.LinearDamping = 0.9; 20 21 18 22 this.ase = new AssaultRifle(100, 100); 19 23 //((git_gud_the_game)Game.Instance).Add(this.ase); … … 38 42 } 39 43 44 public class Vihollinen : PhysicsObject 45 { 46 public AssaultRifle ase; 47 private IntMeter elamaLaskuri = new IntMeter(3, 0, 3); 48 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 49 50 public Vihollinen(Image vihollisenKuva) 51 : base(vihollisenKuva) 52 { 53 this.KineticFriction = 1.0; 54 this.LinearDamping = 0.9; 55 56 57 this.ase = new AssaultRifle(100, 100); 58 //((git_gud_the_game)Game.Instance).Add(this.ase); 59 60 //this.ase.Image = null; 61 //this.ase.Color = Color.Transparent; 62 //Timer aseenPaikka = new Timer(); 63 //aseenPaikka.Interval = 0.01; 64 //aseenPaikka.Timeout += delegate 65 //{ 66 // this.ase.Position = this.Position; 67 //}; 68 69 //aseenPaikka.Start(); 70 this.Add(this.ase); 71 72 ase.FireRate = 1; 73 ase.CanHitOwner = false; 74 elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 75 76 } 77 } 78 40 79 public class git_gud_the_game : PhysicsGame 41 80 { … … 44 83 Image pelaajanKuva = LoadImage("pelaajankuva"); 45 84 Image SeinanKuva = LoadImage("Seina"); 46 85 Image vihollisenKuva = LoadImage("vihollisenKuva"); 86 Image taustaKuva = LoadImage("Tausta"); 47 87 public override void Begin() 48 88 { … … 57 97 void LuoKentta() 58 98 { 59 99 Level.Background.Image = taustaKuva; 60 100 ColorTileMap ruudut = ColorTileMap.FromLevelAsset("kentta1"); 61 101 ruudut.SetTileMethod(Color.Cyan, LuoPelaaja1); 62 102 ruudut.SetTileMethod(Color.Gold, LuoPelaaja2); 63 103 ruudut.SetTileMethod(Color.Black, LuoSeinä); 104 ruudut.SetTileMethod(Color.Red, LuoVihollinen); 64 105 ruudut.Execute(20, 20); 65 Camera.ZoomToLevel();106 //Camera.ZoomToLevel(); 66 107 Camera.Follow(pelaaja1); 67 108 … … 74 115 pelaaja1.ase.Ammo.Value = 1000; 75 116 pelaaja1.ase.ProjectileCollision = AmmusOsui; 117 pelaaja1.CanRotate = false; 76 118 77 119 pelaaja1.AngularDamping = 0.5; 78 120 79 121 AddCollisionHandler(pelaaja1, "ammus", AmmusOsuuPelaajaan); 122 pelaaja1.Tag = "pelaaja"; 80 123 } 81 124 … … 91 134 92 135 AddCollisionHandler(pelaaja2, "ammus", AmmusOsuuPelaajaan); 136 pelaaja1.Tag = "pelaaja"; 93 137 } 94 138 … … 101 145 102 146 } 147 void LuoVihollinen(Vector paikka, double leveys, double korkeus) 148 { 149 Vihollinen vihollinen = new Vihollinen(vihollisenKuva); 150 vihollinen.Position = paikka; 151 Add(vihollinen); 152 vihollinen.ase.Ammo.Value = 1000; 153 vihollinen.ase.ProjectileCollision = AmmusOsui; 154 FollowerBrain seuraajanAivot = new FollowerBrain("pelaaja"); 155 seuraajanAivot.Speed = 300; // Millä nopeudella kohdetta seurataan 156 seuraajanAivot.DistanceFar = 600; // Etäisyys jolla aletaan seurata kohdetta 157 seuraajanAivot.DistanceClose = 200; // Etäisyys jolloin ollaan lähellä kohdetta 158 seuraajanAivot.StopWhenTargetClose = true; // Pysähdytään kun ollaan lähellä kohdetta 159 seuraajanAivot.Active = true; 160 vihollinen.Brain = seuraajanAivot; 161 162 Timer ajastin = new Timer(); 163 ajastin.Interval = 1.5; 164 ajastin.Timeout += delegate { 165 int satunnainenLuku = RandomGen.NextInt(2); 166 Pelaaja valittuPelaaja = pelaaja1; 167 if (satunnainenLuku == 0) valittuPelaaja = pelaaja1; 168 if (satunnainenLuku == 1) valittuPelaaja = pelaaja2; 169 Vector suunta = (valittuPelaaja.Position - vihollinen.ase.AbsolutePosition).Normalize(); 170 vihollinen.ase.Angle = suunta.Angle; 171 PhysicsObject ammus = vihollinen.ase.Shoot(); 172 if (ammus != null) 173 { 174 ammus.Tag = "ammus"; 175 } 176 }; 177 ajastin.Start(); 178 179 vihollinen.AngularDamping = 0.5; 180 181 AddCollisionHandler(vihollinen, "ammus", AmmusOsuuViholliseen); 182 } 103 183 104 184 void PelinControllit() … … 114 194 void LiikutaPelaajaa(AnalogState tatinTila, Pelaaja pelaaja) 115 195 { 116 pelaaja.Push(Vector.FromLengthAndAngle(tatinTila.StateVector.Magnitude * 200, tatinTila.StateVector.Angle)); 196 if (tatinTila.StateVector.Angle.MainDirection == Direction.Right) 197 { 198 pelaaja.Move(new Vector(200, 0)); 199 } 200 else if (tatinTila.StateVector.Angle.MainDirection == Direction.Left) 201 { 202 pelaaja.Move(new Vector(-200, 0)); 203 } 204 else if (tatinTila.StateVector.Angle.MainDirection == Direction.Down) 205 { 206 pelaaja.Move(new Vector(0, -200)); 207 } 208 else if (tatinTila.StateVector.Angle.MainDirection == Direction.Up) 209 { 210 pelaaja.Move(new Vector(0, 200)); 211 } 212 //pelaaja.Move(Vector.FromLengthAndAngle(tatinTila.StateVector.Magnitude * 200, tatinTila.StateVector.Angle)); 117 213 } 118 214 void Tahtays(AnalogState tatinTila, Pelaaja pelaaja) … … 137 233 ((Pelaaja)pelaaja).ElamaLaskuri.Value--; 138 234 } 235 void AmmusOsuuViholliseen(PhysicsObject vihu, PhysicsObject kohde) 236 { 237 ((Vihollinen)vihu).ElamaLaskuri.Value--; 238 } 139 239 } -
2015/30/MarkusS/git_gud_the_game/git_gud_the_game/git_gud_the_game/git_gud_the_game.csproj.Debug.cachefile
r6877 r6908 2 2 Content\PelaajanKuva.xnb 3 3 Content\Seina.xnb 4 Content\Huutaa.xnb 5 Content\vihollisenKuva.xnb 6 Content\Tausta.xnb -
2015/30/MarkusS/git_gud_the_game/git_gud_the_game/git_gud_the_game/obj/x86/Debug/cachefile-{1C03E4EE-ABF7-43AF-8443-48178D554BFA}-targetpath.txt
r6877 r6908 2 2 Content\PelaajanKuva.xnb 3 3 Content\Seina.xnb 4 Content\Huutaa.xnb 5 Content\vihollisenKuva.xnb 6 Content\Tausta.xnb -
2015/30/MarkusS/git_gud_the_game/git_gud_the_game/git_gud_the_game/obj/x86/Debug/git_gud_the_game.csproj.FileListAbsolute.txt
r6877 r6908 10 10 C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\PelaajanKuva.xnb 11 11 C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\Seina.xnb 12 C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\Huutaa.xnb 13 C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\vihollisenKuva.xnb 14 C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\Tausta.xnb -
2015/30/MarkusS/git_gud_the_game/git_gud_the_game/git_gud_the_gameContent/git_gud_the_gameContent.contentproj
r6877 r6908 66 66 </Compile> 67 67 </ItemGroup> 68 <ItemGroup> 69 <Compile Include="Huutaa.wav"> 70 <Name>Huutaa</Name> 71 <Importer>WavImporter</Importer> 72 <Processor>SoundEffectProcessor</Processor> 73 </Compile> 74 </ItemGroup> 75 <ItemGroup> 76 <Compile Include="vihollisenKuva.png"> 77 <Name>vihollisenKuva</Name> 78 <Importer>TextureImporter</Importer> 79 <Processor>TextureProcessor</Processor> 80 </Compile> 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="Tausta.jpg"> 84 <Name>Tausta</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 68 89 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 69 90 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2015/30/MarkusS/git_gud_the_game/git_gud_the_game/git_gud_the_gameContent/obj/x86/Debug/ContentPipeline.xml
r6877 r6908 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\kentta1.xnb</Output> 11 <Time>2015-07-2 1T11:27:09.5309873+03:00</Time>11 <Time>2015-07-22T10:54:16.4573097+03:00</Time> 12 12 </Item> 13 13 <Item> … … 28 28 <Output>C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\Seina.xnb</Output> 29 29 <Time>2015-07-21T13:31:11.2021375+03:00</Time> 30 </Item> 31 <Item> 32 <Source>Huutaa.wav</Source> 33 <Name>Huutaa</Name> 34 <Importer>WavImporter</Importer> 35 <Processor>SoundEffectProcessor</Processor> 36 <Options>None</Options> 37 <Output>C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\Huutaa.xnb</Output> 38 <Time>2015-07-22T10:45:16.5894112+03:00</Time> 39 </Item> 40 <Item> 41 <Source>vihollisenKuva.png</Source> 42 <Name>vihollisenKuva</Name> 43 <Importer>TextureImporter</Importer> 44 <Processor>TextureProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\vihollisenKuva.xnb</Output> 47 <Time>2015-07-22T11:00:00.2302191+03:00</Time> 48 </Item> 49 <Item> 50 <Source>Tausta.jpg</Source> 51 <Name>Tausta</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\MarkusS\git_gud_the_game\git_gud_the_game\git_gud_the_game\bin\x86\Debug\Content\Tausta.xnb</Output> 56 <Time>2015-07-22T11:39:12.8182632+03:00</Time> 30 57 </Item> 31 58 <BuildSuccessful>true</BuildSuccessful>
Note: See TracChangeset
for help on using the changeset viewer.