- Timestamp:
- 2015-06-30 18:34:26 (8 years ago)
- Location:
- 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs
r6619 r6623 176 176 class Monocle : Item 177 177 { 178 private GameObject bigMonocle; 179 178 180 public Monocle(Player player) : base(player) 179 181 { … … 183 185 public override void UpdateItem(Time time) 184 186 { 187 if (bigMonocle != null) 188 bigMonocle.Position = player.Position; 185 189 base.UpdateItem(time); 186 190 } 187 191 192 public override void UseKeyPressed() 193 { 194 InUse = false; 195 CreateMonocle(); 196 base.UseKeyPressed(); 197 } 198 188 199 public override void UseKeyReleased() 189 200 { 190 201 InUse = true; 202 if (bigMonocle != null) 203 { 204 bigMonocle.Destroy(); 205 bigMonocle = null; 206 } 191 207 base.UseKeyReleased(); 192 208 } 193 209 194 public override void UseKeyPressed() 195 { 196 InUse = false; 197 base.UseKeyPressed(); 198 } 199 } 210 private void CreateMonocle() 211 { 212 bigMonocle = new GameObject(150, 150); 213 bigMonocle.Image = TheLegendOfGabriel.BigMonocleImage; 214 bigMonocle.Position = player.Position; 215 Game.Instance.Add(bigMonocle, 3); 216 } 217 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs
r6621 r6623 45 45 private Label nextItem; 46 46 private Label prevItem; 47 private Label swordFrame; 47 48 48 49 #region Resources … … 52 53 public static Image SmallSwordImage = LoadImage("smallsword"); 53 54 public static Image MonocleImage = LoadImage("monocle"); 55 public static Image BigMonocleImage = LoadImage("bigmonocle"); 56 public static Image BigSwordImage = LoadImage("bigsword"); 54 57 55 58 public static Image FrameImage = LoadImage("frame"); 59 public static Image ActiveItemFrameImageX = LoadImage("activeitemframe"); 60 public static Image ActiveItemFrameImageZ = LoadImage("activeitemframez"); 56 61 57 62 [AssetName("walkright")] … … 96 101 } 97 102 98 void BuildInventoryCycle()103 void BuildInventoryCycle() 99 104 { 100 105 const int spacing = 20; … … 117 122 nextItem.Y = prevItem.Y; 118 123 Add(nextItem); 124 125 var frame = new Label(); 126 frame.Size = new Vector(60, 60); 127 frame.Image = ActiveItemFrameImageX; 128 frame.X = currentItem.X; 129 frame.Top = currentItem.Top; 130 Add(frame); 131 132 swordFrame = new Label(); 133 swordFrame.Size = prevItem.Size; 134 swordFrame.Left = nextItem.Right + spacing * 2; 135 swordFrame.Top = currentItem.Top; 136 Add(swordFrame); 137 138 var frame2 = new Label(); 139 frame2.Size = new Vector(60, 60); 140 frame2.Image = ActiveItemFrameImageZ; 141 frame2.X = swordFrame.X; 142 frame2.Top = swordFrame.Top; 143 Add(frame2); 119 144 } 120 145 … … 223 248 Keyboard.Listen(Key.Z, ButtonState.Down, delegate { UseItem(player.Sword, player.ActiveItem, () => player.Sword.UseKeyDown()); }, null); 224 249 225 Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate { player.CycleItems(); UpdateItemCycleImages(); }, null);250 Keyboard.Listen(Key.Space, ButtonState.Pressed, CycleItems, null); 226 251 227 252 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); … … 240 265 action(); 241 266 } 267 } 268 269 void CycleItems() 270 { 271 // Kaman vaihtossa simuloidaan että oltaisiin laskettu irti käyttönäppäimestä. 272 if (player.ActiveItem != null) 273 { 274 player.ActiveItem.UseKeyReleased(); 275 } 276 277 player.CycleItems(); 278 UpdateItemCycleImages(); 242 279 } 243 280 … … 247 284 if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage; 248 285 if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage; 286 287 if (player.Sword != null) 288 { 289 swordFrame.Image = BigSwordImage; 290 } 249 291 } 250 292 -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj
r6619 r6623 186 186 </Compile> 187 187 </ItemGroup> 188 <ItemGroup> 189 <Compile Include="bigmonocle.png"> 190 <Name>bigmonocle</Name> 191 <Importer>TextureImporter</Importer> 192 <Processor>TextureProcessor</Processor> 193 </Compile> 194 </ItemGroup> 195 <ItemGroup> 196 <Compile Include="activeitemframe.png"> 197 <Name>activeitemframe</Name> 198 <Importer>TextureImporter</Importer> 199 <Processor>TextureProcessor</Processor> 200 </Compile> 201 </ItemGroup> 202 <ItemGroup> 203 <Compile Include="activeitemframez.png"> 204 <Name>activeitemframez</Name> 205 <Importer>TextureImporter</Importer> 206 <Processor>TextureProcessor</Processor> 207 </Compile> 208 </ItemGroup> 209 <ItemGroup> 210 <Compile Include="bigsword.png"> 211 <Name>bigsword</Name> 212 <Importer>TextureImporter</Importer> 213 <Processor>TextureProcessor</Processor> 214 </Compile> 215 </ItemGroup> 188 216 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 189 217 <!-- 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.