Changeset 6623 for 2015/27


Ignore:
Timestamp:
2015-06-30 18:34:26 (4 years ago)
Author:
sieerinn
Message:

Inventoryjuttua päivitetty.

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  
    176176class Monocle : Item 
    177177{ 
     178    private GameObject bigMonocle; 
     179 
    178180    public Monocle(Player player) : base(player) 
    179181    { 
     
    183185    public override void UpdateItem(Time time) 
    184186    { 
     187        if (bigMonocle != null) 
     188            bigMonocle.Position = player.Position; 
    185189        base.UpdateItem(time); 
    186190    } 
    187191 
     192    public override void UseKeyPressed() 
     193    { 
     194        InUse = false; 
     195        CreateMonocle(); 
     196        base.UseKeyPressed(); 
     197    } 
     198 
    188199    public override void UseKeyReleased() 
    189200    { 
    190201        InUse = true; 
     202        if (bigMonocle != null) 
     203        { 
     204            bigMonocle.Destroy(); 
     205            bigMonocle = null; 
     206        } 
    191207        base.UseKeyReleased(); 
    192208    } 
    193209 
    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  
    4545    private Label nextItem; 
    4646    private Label prevItem; 
     47    private Label swordFrame; 
    4748 
    4849    #region Resources 
     
    5253    public static Image SmallSwordImage = LoadImage("smallsword"); 
    5354    public static Image MonocleImage = LoadImage("monocle"); 
     55    public static Image BigMonocleImage = LoadImage("bigmonocle"); 
     56    public static Image BigSwordImage = LoadImage("bigsword"); 
    5457 
    5558    public static Image FrameImage = LoadImage("frame"); 
     59    public static Image ActiveItemFrameImageX = LoadImage("activeitemframe"); 
     60    public static Image ActiveItemFrameImageZ = LoadImage("activeitemframez"); 
    5661 
    5762    [AssetName("walkright")] 
     
    96101    } 
    97102 
    98 void BuildInventoryCycle() 
     103    void BuildInventoryCycle() 
    99104    { 
    100105        const int spacing = 20; 
     
    117122        nextItem.Y = prevItem.Y; 
    118123        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); 
    119144    } 
    120145 
     
    223248        Keyboard.Listen(Key.Z, ButtonState.Down, delegate { UseItem(player.Sword, player.ActiveItem, () => player.Sword.UseKeyDown()); }, null); 
    224249 
    225         Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate { player.CycleItems(); UpdateItemCycleImages(); }, null); 
     250        Keyboard.Listen(Key.Space, ButtonState.Pressed, CycleItems, null); 
    226251 
    227252        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 
     
    240265            action(); 
    241266        } 
     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(); 
    242279    } 
    243280 
     
    247284        if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage; 
    248285        if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage; 
     286 
     287        if (player.Sword != null) 
     288        { 
     289            swordFrame.Image = BigSwordImage; 
     290        } 
    249291    } 
    250292 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj

    r6619 r6623  
    186186    </Compile> 
    187187  </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> 
    188216  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    189217  <!--  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.