Changeset 6550
- Timestamp:
- 2015-06-30 08:09:02 (6 years ago)
- Location:
- 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Creature.cs
r6549 r6550 4 4 class Creature : PhysicsObject 5 5 { 6 public doubleMovementSpeed { get; set; }6 public DoubleMeter MovementSpeed { get; set; } 7 7 8 8 public Dictionary<Direction, Animation> MoveAnimations { get; set; } … … 13 13 : base(width, height) 14 14 { 15 MovementSpeed = new DoubleMeter(2000, 0, 2000); 15 16 LastDirection = Direction.Down; 16 17 MoveAnimations = new Dictionary<Direction, Animation>(); -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs
r6549 r6550 106 106 } 107 107 } 108 109 class Pistol : Item 110 { 111 private bool isCharging; 112 113 public Direction ShootDirection { get; set; } 114 115 // Montako sekuntia pistoolilla on tähdätty. Täydellä latauksella voisi ampua isomman ammuksen. 116 public DoubleMeter Charge { get; set; } 117 118 public override bool OverrideAnimation 119 { 120 get { return InUse; } 121 } 122 123 public Pistol(Player player) 124 : base(player) 125 { 126 Charge = new DoubleMeter(0, 0, 4); 127 } 128 129 public override void UpdateItem(Time time) 130 { 131 if (isCharging) 132 { 133 Charge.Value += time.SinceLastUpdate.TotalSeconds; 134 } 135 base.UpdateItem(time); 136 } 137 138 public override void UseKeyPressed() 139 { 140 InUse = true; 141 isCharging = true; // Ase alkaa latautumaan. 142 Charge.Value = Charge.MinValue; // Aseen lataus aluksi nollaan. 143 144 // Hidastetaan pelaajaa samalla kun se tähtää. 145 player.MovementSpeed.Value = player.MovementSpeed.MaxValue * 0.333; 146 147 // TODO: Tee pistoolin ampumiselle animaatio. 148 ShootDirection = player.Velocity.Angle.MainDirection; 149 player.Animation = new Animation(player.SwingAnimations[ShootDirection]); 150 player.Animation.StopOnLastFrame = true; 151 player.Animation.Start(1); 152 base.UseKeyPressed(); 153 } 154 155 public override void UseKeyReleased() 156 { 157 // Pistoolilla voi ampua vain jos tähtäysanimaatio on ehtinyt loppuun. 158 if (player.Animation.CurrentFrameIndex == player.Animation.FrameCount - 1) 159 { 160 var bullet = new PhysicsObject(4, 4); 161 bullet.Position = player.Position + ShootDirection.GetVector() * player.Width * 0.7; 162 bullet.Hit(ShootDirection.GetVector() * 500); 163 Game.Instance.Add(bullet); 164 } 165 166 InUse = false; 167 isCharging = false; 168 player.MovementSpeed.Value = player.MovementSpeed.MaxValue; 169 player.SetWalkAnimation(); 170 171 base.UseKeyReleased(); 172 } 173 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs
r6549 r6550 41 41 player = new Player(); 42 42 player.CanRotate = false; 43 player.MovementSpeed = 2300;43 player.MovementSpeed = new DoubleMeter(2300, 0, 2300); 44 44 player.Position = position; 45 45 player.MoveAnimations[Direction.Left] = playerWalkLeft; … … 55 55 56 56 player.ActiveItem = new Sword(player); 57 //player.ActiveItem = new Pistol(player); 58 57 59 58 60 AddCollisionHandler(player, "exit", CollidesWithExit);
Note: See TracChangeset
for help on using the changeset viewer.