- Timestamp:
- 2015-06-30 17:38:02 (8 years ago)
- Location:
- 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs
r6617 r6619 178 178 public Monocle(Player player) : base(player) 179 179 { 180 InventoryImage = TheLegendOfGabriel.MonocleImage; 180 181 } 181 182 -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs
r6617 r6619 60 60 player.Sword = new Sword(player); 61 61 player.Inventory.Add(new Pistol(player)); 62 62 player.Inventory.Add(new Monocle(player)); 63 63 64 64 AddCollisionHandler(player, "exit", CollidesWithExit); -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Player.cs
r6617 r6619 19 19 } 20 20 return null; 21 } 22 } 23 24 public Item NextItem 25 { 26 get 27 { 28 return Inventory.Count > 1 ? GetItem(activeItemIndex + 1) : null; 29 } 30 } 31 32 public Item PrevItem 33 { 34 get 35 { 36 return Inventory.Count > 1 ? GetItem(activeItemIndex - 1) : null; 21 37 } 22 38 } … … 44 60 } 45 61 62 private Item GetItem(int index) 63 { 64 if (index < 0) 65 { 66 index += Inventory.Count; 67 } 68 if (index >= Inventory.Count) 69 { 70 index -= Inventory.Count; 71 } 72 return Inventory[index]; 73 } 74 46 75 protected override void UpdateAnimations() 47 76 { 48 if (!(ActiveItem != null && ActiveItem.OverrideAnimation)) 77 bool itemBlocksAnimation = ActiveItem != null && ActiveItem.OverrideAnimation; 78 bool swordBlocksAnimation = Sword != null && Sword.OverrideAnimation; 79 if (!(itemBlocksAnimation || swordBlocksAnimation)) 49 80 { 50 base.UpdateAnimations(); 81 base.UpdateAnimations(); 51 82 } 52 83 } … … 55 86 { 56 87 if (ActiveItem != null) 57 ActiveItem.UpdateItem(time); 88 { 89 ActiveItem.UpdateItem(time); 90 } 91 if (Sword != null) 92 { 93 Sword.UpdateItem(time); 94 } 58 95 base.UpdateCreature(time); 59 96 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs
r6618 r6619 42 42 StoryItem[] storyItem = new StoryItem[3]; 43 43 44 private Label currentItem; 45 private Label nextItem; 46 private Label prevItem; 47 44 48 #region Resources 45 49 … … 47 51 public static Image LetterImage = LoadImage("letter"); 48 52 public static Image SmallSwordImage = LoadImage("smallsword"); 53 public static Image MonocleImage = LoadImage("monocle"); 49 54 50 55 public static Image FrameImage = LoadImage("frame"); … … 85 90 LoadAnimations(); 86 91 StartGame(); 87 Intro();92 //Intro(); 88 93 BuildRightBar(); 94 BuildInventoryCycle(); 95 UpdateItemCycleImages(); 96 } 97 98 void BuildInventoryCycle() 99 { 100 const int spacing = 20; 101 102 prevItem = new Label(); 103 prevItem.Size = new Vector(60, 40); 104 prevItem.X = Screen.Left + 100; 105 prevItem.Y = Screen.Top - 50; 106 Add(prevItem); 107 108 currentItem = new Label(); 109 currentItem.Size = prevItem.Size; 110 currentItem.Left = prevItem.Right + spacing; 111 currentItem.Y = prevItem.Y; 112 Add(currentItem); 113 114 nextItem = new Label(); 115 nextItem.Size = prevItem.Size; 116 nextItem.Left = currentItem.Right + spacing; 117 nextItem.Y = prevItem.Y; 118 Add(nextItem); 89 119 } 90 120 … … 186 216 Keyboard.Listen(Key.Down, ButtonState.Down, player.Move, null, Direction.Down); 187 217 188 Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyPressed(); }, null); 189 Keyboard.Listen(Key.Space, ButtonState.Released, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyReleased(); }, null); 190 Keyboard.Listen(Key.Space, ButtonState.Down, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyDown(); }, null); 218 Keyboard.Listen(Key.X, ButtonState.Pressed, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyPressed(); }, null); 219 Keyboard.Listen(Key.X, ButtonState.Released, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyReleased(); }, null); 220 Keyboard.Listen(Key.X, ButtonState.Down, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyDown(); }, null); 221 222 Keyboard.Listen(Key.Z, ButtonState.Pressed, delegate { if (player.Sword != null) player.Sword.UseKeyPressed(); }, null); 223 Keyboard.Listen(Key.Z, ButtonState.Released, delegate { if (player.Sword != null) player.Sword.UseKeyReleased(); }, null); 224 Keyboard.Listen(Key.Z, ButtonState.Down, delegate { if (player.Sword != null) player.Sword.UseKeyDown(); }, null); 225 226 Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate { player.CycleItems(); UpdateItemCycleImages(); }, null); 191 227 192 228 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 229 } 230 231 void UpdateItemCycleImages() 232 { 233 if (player.PrevItem != null) prevItem.Image = player.PrevItem.InventoryImage; 234 if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage; 235 if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage; 193 236 } 194 237 -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj
r6618 r6619 179 179 </Compile> 180 180 </ItemGroup> 181 <ItemGroup> 182 <Compile Include="monocle.png"> 183 <Name>monocle</Name> 184 <Importer>TextureImporter</Importer> 185 <Processor>TextureProcessor</Processor> 186 </Compile> 187 </ItemGroup> 181 188 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 182 189 <!-- 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.