- Timestamp:
- 2015-06-30 00:00:15 (6 years ago)
- Location:
- 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
- Files:
-
- 24 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs
r6547 r6548 39 39 void CreatePlayer(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 40 40 { 41 player = new Creature(TILE_SIZE, TILE_SIZE);41 player = new Player(); 42 42 player.CanRotate = false; 43 43 player.MovementSpeed = 2300; … … 47 47 player.MoveAnimations[Direction.Up] = playerWalkUp; 48 48 player.MoveAnimations[Direction.Down] = playerWalkDown; 49 player.Image = playerWalkDown.CurrentFrame; 49 player.SwingAnimations[Direction.Left] = playerSwingLeft; 50 player.SwingAnimations[Direction.Right] = playerSwingRight; 51 player.SwingAnimations[Direction.Up] = playerSwingUp; 52 player.SwingAnimations[Direction.Down] = playerSwingDown; 53 player.Image = playerWalkDown.CurrentFrame; 50 54 Add(player, 1); 51 55 -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs
r6547 r6548 9 9 using Jypeli.Widgets; 10 10 11 sealed class Exit : PhysicsObject12 {13 /// <summary>14 /// Kentän nimi johon siirrytään.15 /// </summary>16 public string TargetLevel { get; set; }17 18 /// <summary>19 /// Kohdekentässä olevan exitin nimi jonka päältä aloitetaan.20 /// </summary>21 public string TargetExitName { get; set; }22 23 /// <summary>24 /// Tämän uloskäynnin nimi.25 /// </summary>26 public string Name { get; set; }27 28 public Exit(double width, double height)29 : base(width, height)30 {31 Color = new Color(255, 0, 0, 60); // Debuggausta varten jotta näkee uloskäynnit.32 IgnoresCollisionResponse = true;33 Tag = "exit";34 }35 }36 37 class Creature : PhysicsObject38 {39 public double MovementSpeed { get; set; }40 41 public Dictionary<Direction, Animation> MoveAnimations { get; set; }42 43 public Creature(double width, double height)44 : base(width, height)45 {46 MoveAnimations = new Dictionary<Direction, Animation>();47 LinearDamping = 0.5;48 }49 50 public void Move(Direction direction)51 {52 if (!Game.IsPaused)53 {54 Push(direction.GetVector() * MovementSpeed);55 }56 }57 58 public override void Update(Time time)59 {60 if (Velocity.MagnitudeSquared > 10.0)61 {62 // Animaation vaihto nopeuden suunnan perusteella.63 Animation newAnim;64 var dir = Velocity.Angle.MainDirection;65 if (MoveAnimations.TryGetValue(dir, out newAnim))66 {67 if (Animation != newAnim)68 {69 Animation = newAnim;70 }71 }72 73 // Käynnistetään animaatio jos se ei ole jo käynnissä.74 if (!Animation.IsPlaying)75 Animation.Resume();76 }77 else if (Animation != null && Animation.IsPlaying)78 {79 // Paikallaan ollessa pysäytetään animaatio.80 Animation.Pause();81 }82 base.Update(time);83 }84 }85 11 86 12 public partial class TheLegendOfGabriel : PhysicsGame … … 88 14 public const int TILE_SIZE = 20; 89 15 90 private Creatureplayer;16 private Player player; 91 17 92 18 private bool transition; … … 95 21 96 22 #region Resources 23 24 public static Image gunImage = LoadImage("gun"); 97 25 98 26 [AssetName("walkright")] … … 105 33 private Animation playerWalkDown; 106 34 35 [AssetName("swingup")] 36 private Animation playerSwingUp; 37 [AssetName("swingright")] 38 private Animation playerSwingRight; 39 [AssetName("swingright", mirror: true)] 40 private Animation playerSwingLeft; 41 [AssetName("swingdown")] 42 private Animation playerSwingDown; 43 107 44 #endregion 108 45 109 public override void Begin() 46 public override void Begin() 110 47 { 111 48 SmoothTextures = false; … … 142 79 ClearAll(); 143 80 CreateLevel("level1"); 144 81 //CreatePlayer(new Vector(-Level.Width/3, Level.Bottom + TILE_SIZE * 2)); 145 82 SetControls(); 146 83 Camera.ZoomToLevel(); … … 153 90 Keyboard.Listen(Key.Up, ButtonState.Down, player.Move, null, Direction.Up); 154 91 Keyboard.Listen(Key.Down, ButtonState.Down, player.Move, null, Direction.Down); 92 93 Keyboard.Listen(Key.Space, ButtonState.Pressed, player.SwingSword, null); 155 94 156 95 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); … … 298 237 protected override void Update(Time time) 299 238 { 300 player.Update (time);239 player.UpdateCreature(time); 301 240 base.Update(time); 302 241 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.csproj
r6545 r6548 112 112 <ItemGroup> 113 113 <Compile Include="AssetNameAttribute.cs" /> 114 <Compile Include="Creature.cs" /> 115 <Compile Include="Exit.cs" /> 114 116 <Compile Include="LevelCreation.cs" /> 115 117 <Compile Include="Ohjelma.cs" /> 118 <Compile Include="Player.cs" /> 116 119 <Compile Include="TheLegendOfGabriel.cs" /> 117 120 <Compile Include="Properties\AssemblyInfo.cs" /> -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj
r6547 r6548 110 110 </ItemGroup> 111 111 <ItemGroup> 112 <Compile Include="swingdown.anim"> 113 <Name>swingdown</Name> 114 <Importer>AnimationImporter</Importer> 115 <Processor>AnimationContentProcessor</Processor> 116 </Compile> 117 <Compile Include="swingright.anim"> 118 <Name>swingright</Name> 119 <Importer>AnimationImporter</Importer> 120 <Processor>AnimationContentProcessor</Processor> 121 </Compile> 122 <Compile Include="swingup.anim"> 123 <Name>swingup</Name> 124 <Importer>AnimationImporter</Importer> 125 <Processor>AnimationContentProcessor</Processor> 126 </Compile> 127 </ItemGroup> 128 <ItemGroup> 112 129 <Compile Include="gran.png"> 113 130 <Name>gran</Name>
Note: See TracChangeset
for help on using the changeset viewer.