Changeset 6548 for 2015/27/ohjaajat


Ignore:
Timestamp:
2015-06-30 00:00:15 (4 years ago)
Author:
sieerinn
Message:

Miekan (tai toistaiseksi pistoolin) heiluttelu.

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  
    3939    void CreatePlayer(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 
    4040    { 
    41         player = new Creature(TILE_SIZE, TILE_SIZE); 
     41        player = new Player(); 
    4242        player.CanRotate = false; 
    4343        player.MovementSpeed = 2300; 
     
    4747        player.MoveAnimations[Direction.Up] = playerWalkUp; 
    4848        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; 
    5054        Add(player, 1); 
    5155 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs

    r6547 r6548  
    99using Jypeli.Widgets; 
    1010 
    11 sealed class Exit : PhysicsObject 
    12 { 
    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 : PhysicsObject 
    38 { 
    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 } 
    8511 
    8612public partial class TheLegendOfGabriel : PhysicsGame 
     
    8814    public const int TILE_SIZE = 20; 
    8915 
    90     private Creature player; 
     16    private Player player; 
    9117 
    9218    private bool transition; 
     
    9521 
    9622    #region Resources 
     23 
     24    public static Image gunImage = LoadImage("gun"); 
    9725 
    9826    [AssetName("walkright")] 
     
    10533    private Animation playerWalkDown; 
    10634 
     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 
    10744    #endregion 
    10845 
    109     public override void Begin()         
     46    public override void Begin() 
    11047    { 
    11148        SmoothTextures = false; 
     
    14279        ClearAll(); 
    14380        CreateLevel("level1"); 
    144         //CreatePlayer(new Vector(-Level.Width/3, Level.Bottom + TILE_SIZE * 2)); 
     81        //CreatePlayer(new Vector(-Level.Width/3, Level.Bottom + TILE_SIZE * 2)); 
    14582        SetControls(); 
    14683        Camera.ZoomToLevel(); 
     
    15390        Keyboard.Listen(Key.Up, ButtonState.Down, player.Move, null, Direction.Up); 
    15491        Keyboard.Listen(Key.Down, ButtonState.Down, player.Move, null, Direction.Down); 
     92 
     93        Keyboard.Listen(Key.Space, ButtonState.Pressed, player.SwingSword, null); 
    15594 
    15695        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 
     
    298237    protected override void Update(Time time) 
    299238    { 
    300         player.Update(time); 
     239        player.UpdateCreature(time); 
    301240        base.Update(time); 
    302241    } 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.csproj

    r6545 r6548  
    112112  <ItemGroup> 
    113113    <Compile Include="AssetNameAttribute.cs" /> 
     114    <Compile Include="Creature.cs" /> 
     115    <Compile Include="Exit.cs" /> 
    114116    <Compile Include="LevelCreation.cs" /> 
    115117    <Compile Include="Ohjelma.cs" /> 
     118    <Compile Include="Player.cs" /> 
    116119    <Compile Include="TheLegendOfGabriel.cs" /> 
    117120    <Compile Include="Properties\AssemblyInfo.cs" /> 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj

    r6547 r6548  
    110110  </ItemGroup> 
    111111  <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> 
    112129    <Compile Include="gran.png"> 
    113130      <Name>gran</Name> 
Note: See TracChangeset for help on using the changeset viewer.