- Timestamp:
- 2015-06-30 20:07:55 (6 years ago)
- Location:
- 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
- Files:
-
- 24 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs
r6625 r6626 13 13 public Image InventoryImage { get; set; } 14 14 15 public IntMeter Usages { get; set; } 16 15 17 // Onko kama tällä hetkellä aktiivisessa käytössä. 16 18 public virtual bool InUse { get; set; } … … 31 33 public virtual void UseKeyReleased() { } 32 34 35 public virtual void CancelUse() { } 36 33 37 protected Item(Player player) 34 38 { 39 Usages = new IntMeter(0, 0, 0); 35 40 this.player = player; 36 41 } … … 69 74 if (SwordObject != null && InUse) 70 75 { 71 var dir = SwingDirection; 72 var swordAngle = swordAngles[player.Animation.CurrentFrameIndex]; 73 if (dir == Direction.Left) 74 swordAngle = Angle.FromDegrees(swordAngle.Degrees * -1); 75 SwordObject.Position = player.Position + (dir.Angle + swordAngle).GetVector() * 15; 76 SwordObject.Angle = swordAngle + Angle.FromDegrees(dir == Direction.Left || dir == Direction.Right ? 90 : 0); 77 SwordObject.Angle += Angle.FromDegrees(dir == Direction.Right || dir == Direction.Down ? 180 : 0); 76 if (player.Animation.CurrentFrameIndex < swordAngles.Length) 77 { 78 var dir = SwingDirection; 79 var swordAngle = swordAngles[player.Animation.CurrentFrameIndex]; 80 if (dir == Direction.Left) 81 swordAngle = Angle.FromDegrees(swordAngle.Degrees * -1); 82 SwordObject.Position = player.Position + (dir.Angle + swordAngle).GetVector() * 15; 83 SwordObject.Angle = swordAngle + Angle.FromDegrees(dir == Direction.Left || dir == Direction.Right ? 90 : 0); 84 SwordObject.Angle += Angle.FromDegrees(dir == Direction.Right || dir == Direction.Down ? 180 : 0); 85 } 78 86 } 79 87 base.UpdateItem(time); … … 106 114 base.UseKeyPressed(); 107 115 } 116 117 public override void CancelUse() 118 { 119 InUse = false; 120 player.SetWalkAnimation(); 121 if (SwordObject != null) 122 { 123 SwordObject.Destroy(); 124 SwordObject = null; 125 } 126 } 108 127 } 109 128 … … 125 144 : base(player) 126 145 { 146 Usages.MaxValue = 15; 147 Usages.Value = 15; 127 148 Charge = new DoubleMeter(0, 0, 4); 128 149 InventoryImage = TheLegendOfGabriel.GunImage; … … 140 161 public override void UseKeyPressed() 141 162 { 163 if (Usages.Value == 0) 164 { 165 base.UseKeyPressed(); 166 return; 167 } 168 142 169 InUse = true; 143 170 isCharging = true; // Ase alkaa latautumaan. … … 159 186 if (player.Animation.CurrentFrameIndex == player.Animation.FrameCount - 1) 160 187 { 188 Usages.Value--; 189 161 190 var bullet = new PhysicsObject(4, 4); 162 191 bullet.Position = player.Position + ShootDirection.GetVector() * player.Width * 0.7; … … 164 193 Game.Instance.Add(bullet); 165 194 } 166 195 CancelUse(); 196 197 base.UseKeyReleased(); 198 } 199 200 public override void CancelUse() 201 { 167 202 InUse = false; 168 203 isCharging = false; 169 204 player.MovementSpeed.Value = player.MovementSpeed.MaxValue; 170 205 player.SetWalkAnimation(); 171 172 base.UseKeyReleased(); 206 base.CancelUse(); 173 207 } 174 208 } … … 199 233 public override void UseKeyReleased() 200 234 { 235 CancelUse(); 236 base.UseKeyReleased(); 237 } 238 239 public override void CancelUse() 240 { 201 241 InUse = false; 202 242 if (bigMonocle != null) … … 205 245 bigMonocle = null; 206 246 } 207 base. UseKeyReleased();247 base.CancelUse(); 208 248 } 209 249 -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs
r6624 r6626 30 30 level.SetObjectMethod("player", CreatePlayer); 31 31 level.SetObjectMethod("blockade", CreateBlock); 32 // level.SetObjectMethod("coyote", CreateEnemy);32 // level.SetObjectMethod("coyote", CreateEnemy); 33 33 level.Execute(); 34 34 … … 57 57 player.MovementSpeed = new DoubleMeter(2300, 0, 2300); 58 58 player.Position = position; 59 player.MoveAnimations[Direction.Left] = playerWalkLeft; 60 player.MoveAnimations[Direction.Right] = playerWalkRight; 61 player.MoveAnimations[Direction.Up] = playerWalkUp; 62 player.MoveAnimations[Direction.Down] = playerWalkDown; 63 player.SwingAnimations[Direction.Left] = playerSwingLeft; 64 player.SwingAnimations[Direction.Right] = playerSwingRight; 65 player.SwingAnimations[Direction.Up] = playerSwingUp; 66 player.SwingAnimations[Direction.Down] = playerSwingDown; 67 player.ShootAnimations[Direction.Left] = playerShootLeft; 68 player.ShootAnimations[Direction.Right] = playerShootRight; 69 player.ShootAnimations[Direction.Up] = playerShootUp; 70 player.ShootAnimations[Direction.Down] = playerShootDown; 59 player.MoveAnimations = DirectionalAnimations(playerWalkLeft, playerWalkRight, playerWalkUp, playerWalkDown); 60 player.SwingAnimations = DirectionalAnimations(playerSwingLeft, playerSwingRight, playerSwingUp, playerSwingDown); 61 player.ShootAnimations = DirectionalAnimations(playerShootLeft, playerShootRight, playerShootUp, playerShootDown); 71 62 player.Image = playerWalkDown.CurrentFrame; 72 63 Add(player, 1); … … 95 86 } 96 87 97 88 /// <summary> 98 89 /// Pelaajan päällä näkyvä tiili. 99 90 /// </summary> … … 108 99 void CreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties) 109 100 { 110 var tile = properties.ContainsKey("collide") ? new PhysicsObject(width, height) : new GameObject(width, height);101 var tile = properties.ContainsKey("collide") ? new PhysicsObject(width, height) : new GameObject(width, height); 111 102 tile.Image = image; 112 103 tile.Position = position; -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs
r6624 r6626 23 23 } 24 24 25 class CycleSlot : Label 26 { 27 public Label UsageLabel { get; set; } 28 29 public CycleSlot(double left, double top) 30 { 31 this.Left = left; 32 this.Top = top; 33 this.Size = new Vector(60, 40); 34 35 UsageLabel = new Label("10"); 36 UsageLabel.IsVisible = false; 37 UsageLabel.TextColor = Color.White; 38 UsageLabel.X = this.X + 10; 39 UsageLabel.Top = this.Bottom; 40 UsageLabel.Font = Font.DefaultSmallBold; 41 } 42 43 public void UpdateImage(Item item) 44 { 45 if (item != null) 46 { 47 this.Image = item.InventoryImage; 48 UsageLabel.IsVisible = false; 49 if (item.Usages.MaxValue > 0) 50 { 51 UsageLabel.IsVisible = true; 52 UsageLabel.BindTo(item.Usages); 53 } 54 } 55 } 56 } 57 25 58 public partial class TheLegendOfGabriel : PhysicsGame 26 59 { … … 42 75 StoryItem[] storyItem = new StoryItem[3]; 43 76 44 private Label currentItem;45 private Label nextItem;46 private Label prevItem;47 private Label sword Frame;77 private CycleSlot currentItem; // Laatikossa näkyvä nykyinen kama. 78 private CycleSlot nextItem; // Seuraavan kaman kuva. 79 private CycleSlot prevItem; // Edellisen kaman kuva. 80 private Label swordItem; // Laatikossa näkyvä miekka. 48 81 49 82 #region Resources … … 87 120 private Animation playerShootDown; 88 121 122 [AssetName("coyoteup")] 123 private Animation coyoteUp; 124 [AssetName("coyoteright")] 125 private Animation coyoteRight; 126 [AssetName("coyoteright", mirror: true)] 127 private Animation coyoteLeft; 128 [AssetName("coyotedown")] 129 private Animation coyoteDown; 130 89 131 #endregion 90 132 … … 105 147 const int spacing = 20; 106 148 107 prevItem = new Label(); 108 prevItem.Size = new Vector(60, 40); 109 prevItem.X = Screen.Left + 100; 110 prevItem.Y = Screen.Top - 50; 149 prevItem = new CycleSlot(Screen.Left + 50, Screen.Top - 30); 111 150 Add(prevItem); 112 113 currentItem = new Label(); 114 currentItem.Size = prevItem.Size; 115 currentItem.Left = prevItem.Right + spacing; 116 currentItem.Y = prevItem.Y; 151 Add(prevItem.UsageLabel); 152 153 currentItem = new CycleSlot(prevItem.Right + spacing, prevItem.Top); 117 154 Add(currentItem); 118 119 nextItem = new Label(); 120 nextItem.Size = prevItem.Size; 121 nextItem.Left = currentItem.Right + spacing; 122 nextItem.Y = prevItem.Y; 155 Add(currentItem.UsageLabel); 156 157 nextItem = new CycleSlot(currentItem.Right + spacing, prevItem.Top); 123 158 Add(nextItem); 124 159 Add(nextItem.UsageLabel); 160 161 // Ruutu jonka sisällä käytössä oleva kama on. 125 162 var frame = new Label(); 126 163 frame.Size = new Vector(60, 60); … … 130 167 Add(frame); 131 168 132 swordFrame = new Label(); 133 swordFrame.Size = prevItem.Size; 134 swordFrame.Left = nextItem.Right + spacing * 2; 135 swordFrame.Top = currentItem.Top; 169 // Miekan kuva. 170 swordItem = new Label(); 171 swordItem.Size = prevItem.Size; 172 swordItem.Left = nextItem.Right + spacing * 2; 173 swordItem.Top = currentItem.Top; 174 Add(swordItem); 175 176 // Miekan kuvan ympärillä oleva ruutu. 177 var swordFrame = new Label(); 178 swordFrame.Size = new Vector(60, 60); 179 swordFrame.Image = ActiveItemFrameImageZ; 180 swordFrame.X = swordItem.X; 181 swordFrame.Top = swordItem.Top; 136 182 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);144 183 } 145 184 … … 176 215 field.SetValue(this, assetAttr.Mirror ? MirrorAnimation(anim) : anim); 177 216 } 217 } 218 219 Dictionary<Direction, Animation> DirectionalAnimations(Animation left, Animation right, Animation up, Animation down) 220 { 221 var dict = new Dictionary<Direction, Animation>(); 222 dict[Direction.Left] = left; 223 dict[Direction.Right] = right; 224 dict[Direction.Up] = up; 225 dict[Direction.Down] = down; 226 return dict; 178 227 } 179 228 … … 272 321 if (player.ActiveItem != null) 273 322 { 274 player.ActiveItem.UseKeyReleased(); 323 player.ActiveItem.CancelUse(); 324 } 325 if (player.Sword != null) 326 { 327 player.Sword.CancelUse(); 275 328 } 276 329 … … 281 334 void UpdateItemCycleImages() 282 335 { 336 prevItem.UpdateImage(player.PrevItem); 337 currentItem.UpdateImage(player.ActiveItem); 338 nextItem.UpdateImage(player.NextItem); 339 /* 283 340 if (player.PrevItem != null) prevItem.Image = player.PrevItem.InventoryImage; 284 341 if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage; 285 342 if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage; 343 */ 286 344 287 345 if (player.Sword != null) 288 346 { 289 sword Frame.Image = BigSwordImage;347 swordItem.Image = BigSwordImage; 290 348 } 291 349 } … … 426 484 } 427 485 oldObjects.Clear(); 486 487 BuildRightBar(); 488 BuildInventoryCycle(); 489 UpdateItemCycleImages(); 428 490 } 429 491 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj
r6623 r6626 214 214 </Compile> 215 215 </ItemGroup> 216 <ItemGroup> 217 <Compile Include="coyotedown.anim"> 218 <Name>coyotedown</Name> 219 <Importer>AnimationImporter</Importer> 220 <Processor>AnimationContentProcessor</Processor> 221 </Compile> 222 <Compile Include="coyoteright.anim"> 223 <Name>coyoteright</Name> 224 <Importer>AnimationImporter</Importer> 225 <Processor>AnimationContentProcessor</Processor> 226 </Compile> 227 <Compile Include="coyoteup.anim"> 228 <Name>coyoteup</Name> 229 <Importer>AnimationImporter</Importer> 230 <Processor>AnimationContentProcessor</Processor> 231 </Compile> 232 </ItemGroup> 216 233 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 217 234 <!-- 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.