- Timestamp:
- 2015-07-01 20:27:21 (8 years ago)
- Location:
- 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
- Files:
-
- 35 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs
r6701 r6705 260 260 expl.ShockwaveReachesObject += delegate(IPhysicsObject o, Vector vector) 261 261 { 262 if (o.Tag == "boss") 263 { 264 ((TheLegendOfGabriel)Game.Instance).BossHealth.Value--; 265 } 266 262 267 var cre = o as Creature; 263 268 if (cre != null) -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs
r6704 r6705 5 5 using Jypeli; 6 6 using Jypeli.Assets; 7 using Jypeli.Widgets; 7 8 8 9 /* … … 54 55 void CreateBoss(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 55 56 { 56 var bossHealth = new IntMeter(10); 57 57 BossHealth = new IntMeter(2, 0, 10); 58 59 var bar = new ProgressBar(Level.Width * 0.7, TILE_SIZE * 0.5); 60 bar.Y = Screen.Top - TILE_SIZE * 0.5; 61 bar.BindTo(BossHealth); 62 Add(bar); 63 64 // Juna ilmestyy välillä satunnaiseen spawniin. 58 65 var bossTimer = new Timer(); 59 bossTimer.Interval = 4;66 bossTimer.Interval = 8; 60 67 bossTimer.Timeout += delegate 61 68 { 62 Vector pos = RandomGen.SelectOne<Vector>(bossSpawnPositions); 63 //CreateBossTrainPart(pos, ); 69 // Luodaan päävaunu. 70 var pos = RandomGen.SelectOne<Vector>(bossSpawnPositions); 71 var train = CreateBossTrainPart(pos.X, pos.Y, trainAnimation); 72 double newPositionX = pos.X + train.Width; 73 74 // Luodaan muut vaunut. 75 int carriages = (int)(BossHealth.Value/(double)BossHealth.MaxValue * 6); 76 for (int i = 0; i < carriages; i++) 77 { 78 var part = CreateBossTrainPart(newPositionX, pos.Y, carriageAnimation); 79 newPositionX += part.Width; 80 } 64 81 }; 65 82 bossTimer.Start(); 66 } 67 68 void CreateBossTrainPart(Vector position, Animation anim) 69 { 70 var part = PhysicsObject.CreateStaticObject(150, 70); 71 part.Position = position; 83 84 BossHealth.LowerLimit += delegate 85 { 86 EnemyDieSound.Play(); 87 bossTimer.Stop(); 88 Timer.SingleShot(4.0, Victory); 89 90 foreach (var part in GetObjectsWithTag("boss")) 91 { 92 part.Destroy(); 93 var smoke = new GameObject(80, 160); 94 smoke.X = part.X; 95 smoke.Bottom = part.Bottom; 96 smoke.Animation = new Animation(smokeAnimation); 97 smoke.Animation.Start(1); 98 smoke.Animation.Played += () => smoke.Destroy(); 99 Add(smoke); 100 } 101 }; 102 } 103 104 PhysicsObject CreateBossTrainPart(double left, double y, Animation anim) 105 { 106 var part = PhysicsObject.CreateStaticObject(70, 40); 107 part.Left = left; 108 part.Y = y; 72 109 part.Animation = anim; 73 110 part.Animation.Start(); 74 part.Velocity = new Vector(-50, 0); 111 part.Velocity = new Vector(-80, 0); 112 part.Tag = "boss"; 113 part.CollisionIgnoreGroup = 3; 75 114 Add(part); 115 116 // Pala on näkyvillä vain kentän sisäpuolella. 117 var appearTimer = new Timer(); 118 appearTimer.Interval = 0.05; 119 appearTimer.Timeout += delegate 120 { 121 part.IsVisible = part.Left < Level.Right; 122 123 if (part.Right < Level.Left) 124 { 125 part.Destroy(); 126 appearTimer.Stop(); 127 } 128 }; 129 appearTimer.Start(); 130 131 // Palat luo vihollisia jatkuvasti. 132 var enemySpawnTimer = new Timer(); 133 enemySpawnTimer.Interval = 2.0; 134 enemySpawnTimer.Timeout += delegate 135 { 136 if (part.Right < Level.Right) 137 { 138 CreateCoyote(part.Position, TILE_SIZE, TILE_SIZE, Angle.Zero, Shape.Rectangle, "", null); 139 } 140 }; 141 enemySpawnTimer.Start(); 142 143 part.Destroyed += delegate 144 { 145 appearTimer.Stop(); 146 enemySpawnTimer.Stop(); 147 }; 148 149 return part; 76 150 } 77 151 … … 92 166 var enemy = new Creature(width, height, 1); 93 167 enemy.MoveAnimations = DirectionalAnimations(coyoteLeft, coyoteRight, coyoteUp, coyoteDown); 168 enemy.Image = enemy.MoveAnimations[Direction.Right].CurrentFrame; 94 169 enemy.Position = position; 95 170 enemy.Tag = "enemy"; 96 171 enemy.Brain = new FollowerBrain(player) { Speed = 50 }; 172 enemy.CollisionIgnoreGroup = 3; 97 173 Add(enemy, 1); 98 174 enemies.Add(enemy); … … 103 179 }); 104 180 105 enemy.Health.LowerLimit += enemy.Destroy; 181 enemy.Health.LowerLimit += delegate 182 { 183 enemy.Destroy(); 184 RandomItemDrop(enemy.Position); 185 186 EnemyDieSound.Play(); 187 188 var smoke = new GameObject(20, 40); 189 smoke.X = enemy.X; 190 smoke.Bottom = enemy.Bottom; 191 smoke.Animation = new Animation(smokeAnimation); 192 smoke.Animation.Start(1); 193 smoke.Animation.Played += () => smoke.Destroy(); 194 Add(smoke); 195 }; 196 } 197 198 void RandomItemDrop(Vector position) 199 { 200 var chance = RandomGen.NextDouble(0, 100); 201 if (chance < 20) 202 { 203 int itemType = RandomGen.NextInt(1, 3); 204 var item = PhysicsObject.CreateStaticObject(10, 10); 205 item.Position = position; 206 item.Image = itemType == 1 ? GrenadeBoxImage : AmmoBoxImage; 207 item.Tag = itemType == 1 ? "grenadebox" : "ammobox"; 208 item.IgnoresCollisionResponse = true; 209 Add(item); 210 } 106 211 } 107 212 … … 122 227 } 123 228 124 229 /// <summary> 125 230 /// Pelaajan päällä näkyvä tiili. 126 231 /// </summary> … … 142 247 /// Luo tavallisen tiilen. 143 248 /// </summary> 144 GameObjectCreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties)145 { 146 var tile = properties.ContainsKey("collide") ? new PhysicsObject(width, height) : new GameObject(width, height);249 void CreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties) 250 { 251 var tile = properties.ContainsKey("collide") ? PhysicsObject.CreateStaticObject(width, height) : new GameObject(width, height); 147 252 tile.Image = image; 148 253 tile.Position = position; 149 254 Add(tile, layer); 150 return tile;151 255 } 152 256 … … 156 260 void CreateExit(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 157 261 { 158 var target = properties["goto"] == "disabled" ? null : properties["goto"].Split('@'); // Jos peli kaatuu tälle riville niin joltain exitiltä puuttuu goto-property.262 var target = properties["goto"] == "disabled" ? null : properties["goto"].Split('@'); // Jos peli kaatuu tälle riville niin joltain exitiltä puuttuu goto-property. 159 263 var exit = new Exit(width, height); 160 264 exit.Position = position; … … 162 266 { 163 267 exit.TargetLevel = target[0]; 164 exit.TargetExitName = target[1]; 268 exit.TargetExitName = target[1]; 165 269 } 166 270 exit.Name = name; -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs
r6704 r6705 76 76 StoryItem[] storyItem = new StoryItem[3]; 77 77 78 public IntMeter BossHealth; 78 79 private List<Vector> bossSpawnPositions = new List<Vector>(); 79 80 … … 87 88 public static SoundEffect SwordSound = LoadSoundEffect("swordsound"); 88 89 public static SoundEffect GunSound = LoadSoundEffect("gunsound"); 90 public static SoundEffect EnemyDieSound = LoadSoundEffect("enemydie"); 89 91 90 92 public static Image GunImage = LoadImage("gun"); … … 98 100 public static Image GrenadeSmallImage = LoadImage("gransmall"); 99 101 102 public static Image GrenadeBoxImage = LoadImage("grenadebox"); 103 public static Image AmmoBoxImage = LoadImage("ammobox"); 104 100 105 public static Image FrameImage = LoadImage("frame"); 101 106 public static Image ActiveItemFrameImageX = LoadImage("activeitemframe"); … … 146 151 private Animation carriageAnimation; 147 152 153 [AssetName("smoke")] 154 private Animation smokeAnimation; 155 148 156 #endregion 149 157 … … 155 163 StartGame(); 156 164 Intro(); 165 BuildUI(); 166 } 167 168 void Victory() 169 { 170 ClearAll(); 171 Level.Background.Color = Color.Black; 172 173 var text = new Label("Voitit muutes belin."); // Tekstin voisi vaihtaa. 174 text.TextColor = Color.White; 175 Add(text); 176 } 177 178 void BuildUI() 179 { 157 180 BuildRightBar(); 158 181 BuildInventoryCycle(); … … 160 183 UpdateItemCycleImages(); 161 184 } 162 163 privatevoid BuildHealthBar()185 186 void BuildHealthBar() 164 187 { 165 188 var bar = new ProgressBar(32 * 10, 32); … … 358 381 player.Inventory.Add(new Grenade(player)); 359 382 360 player.Health.Value = 3; // Alkuun vain kolme sydäntä. 383 //player.Health.Value = 3; // Alkuun vain kolme sydäntä. 384 player.Health.Value = player.Health.MaxValue = 100; 361 385 362 386 AddCollisionHandler(player, "exit", CollidesWithExit); … … 365 389 player.Health.Value--; 366 390 }); 391 392 AddCollisionHandler(player, "ammobox", delegate(PhysicsObject p, PhysicsObject box) 393 { 394 box.Destroy(); 395 var gun = player.Inventory.FirstOrDefault(i => i is Pistol); 396 if (gun != null) 397 { 398 gun.Usages.Value += 5; 399 } 400 }); 401 402 AddCollisionHandler(player, "grenadebox", delegate(PhysicsObject p, PhysicsObject box) 403 { 404 box.Destroy(); 405 var grenades = player.Inventory.FirstOrDefault(i => i is Grenade); 406 if (grenades != null) 407 { 408 grenades.Usages.Value += 5; 409 } 410 }); 367 411 } 368 412 369 413 void UseItem(Item item, Item otherItem, Action action) 370 414 { 415 if (player.IsDestroyed) 416 return; 417 371 418 bool inUse = false; 372 419 if (otherItem != null) … … 402 449 currentItem.UpdateImage(player.ActiveItem); 403 450 nextItem.UpdateImage(player.NextItem); 404 /*405 if (player.PrevItem != null) prevItem.Image = player.PrevItem.InventoryImage;406 if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage;407 if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage;408 */409 451 410 452 if (player.Sword != null) … … 422 464 { 423 465 var oldExit = pExit as Exit; 424 if (oldExit == null || transition || oldExit.TargetLevel == null )466 if (oldExit == null || transition || oldExit.TargetLevel == null || pExit.IsDestroying || pExit.IsDestroyed) 425 467 return; 426 468 469 oldExit.Destroy(); 470 471 var oldExitDirection = GetExitDirection(oldExit); 427 472 transition = true; 428 473 … … 452 497 453 498 // Jompikumpi uloskäynti ei ole kentän laidalla, sulava siirtyminen ei ole mahdollista. 454 if (GetExitDirection(targetExit) == Direction.None || GetExitDirection(oldExit)== Direction.None)499 if (GetExitDirection(targetExit) == Direction.None || oldExitDirection == Direction.None) 455 500 { 456 501 transition = false; … … 458 503 oldObjects.Clear(); 459 504 460 BuildRightBar(); 461 BuildInventoryCycle(); 462 UpdateItemCycleImages(); 505 BuildUI(); 463 506 464 507 // Yritetään päätellä pelaajalle joku järkevä paikka. 465 508 player.Position = targetExit.Position + Direction.Inverse(targetExit.Position.Angle.MainDirection).GetVector() * TILE_SIZE * 2; 466 Camera.ZoomToLevel(); 509 510 Camera.Follow(player); 511 Camera.ZoomFactor = 2.0; 467 512 return; 468 513 } … … 497 542 Camera.Position += transitionVector; 498 543 Vector pos = Camera.Position; 499 Camera.ZoomToLevel(); 544 Camera.Follow(player); 545 Camera.ZoomFactor = 2.0; 500 546 Camera.Position = pos; 501 547 } … … 553 599 oldObjects.Clear(); 554 600 555 BuildRightBar(); 556 BuildInventoryCycle(); 557 UpdateItemCycleImages(); 601 BuildUI(); 558 602 } 559 603 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj
r6703 r6705 305 305 </Compile> 306 306 </ItemGroup> 307 <ItemGroup> 308 <Compile Include="goldenheart.png"> 309 <Name>goldenheart</Name> 310 <Importer>TextureImporter</Importer> 311 <Processor>TextureProcessor</Processor> 312 </Compile> 313 </ItemGroup> 314 <ItemGroup> 315 <Compile Include="ammobox.png"> 316 <Name>ammobox</Name> 317 <Importer>TextureImporter</Importer> 318 <Processor>TextureProcessor</Processor> 319 </Compile> 320 <Compile Include="grenadebox.png"> 321 <Name>grenadebox</Name> 322 <Importer>TextureImporter</Importer> 323 <Processor>TextureProcessor</Processor> 324 </Compile> 325 </ItemGroup> 326 <ItemGroup> 327 <Compile Include="enemydie.wav"> 328 <Name>enemydie</Name> 329 <Importer>WavImporter</Importer> 330 <Processor>SoundEffectProcessor</Processor> 331 </Compile> 332 </ItemGroup> 333 <ItemGroup> 334 <Compile Include="smoke.anim"> 335 <Name>smoke</Name> 336 <Importer>AnimationImporter</Importer> 337 <Processor>AnimationContentProcessor</Processor> 338 </Compile> 339 </ItemGroup> 340 <ItemGroup> 341 <Compile Include="level3.tmx"> 342 <Name>level3</Name> 343 <Importer>TextFileImporter</Importer> 344 <Processor>TextFileContentProcessor</Processor> 345 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 346 </Compile> 347 </ItemGroup> 307 348 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 308 349 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/level1.tmx
r6702 r6705 31 31 </properties> 32 32 </object> 33 <object id="28" x="480" y="460" width="20" height="60">33 <object id="28" name="right" x="480" y="460" width="20" height="60"> 34 34 <properties> 35 35 <property name="goto" value="level3@left"/>
Note: See TracChangeset
for help on using the changeset viewer.