Changeset 6619 for 2015/27


Ignore:
Timestamp:
2015-06-30 17:38:02 (4 years ago)
Author:
sieerinn
Message:

Aktiivisen kaman vaihto toimii.

Location:
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs

    r6617 r6619  
    178178    public Monocle(Player player) : base(player) 
    179179    { 
     180        InventoryImage = TheLegendOfGabriel.MonocleImage; 
    180181    } 
    181182 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs

    r6617 r6619  
    6060        player.Sword = new Sword(player); 
    6161        player.Inventory.Add(new Pistol(player)); 
    62  
     62        player.Inventory.Add(new Monocle(player)); 
    6363 
    6464        AddCollisionHandler(player, "exit", CollidesWithExit); 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Player.cs

    r6617 r6619  
    1919            } 
    2020            return null; 
     21        } 
     22    } 
     23 
     24    public Item NextItem 
     25    { 
     26        get 
     27        { 
     28            return Inventory.Count > 1 ? GetItem(activeItemIndex + 1) : null; 
     29        } 
     30    } 
     31 
     32    public Item PrevItem 
     33    { 
     34        get 
     35        { 
     36            return Inventory.Count > 1 ? GetItem(activeItemIndex - 1) : null; 
    2137        } 
    2238    } 
     
    4460    } 
    4561 
     62    private Item GetItem(int index) 
     63    { 
     64        if (index < 0) 
     65        { 
     66            index += Inventory.Count; 
     67        } 
     68        if (index >= Inventory.Count) 
     69        { 
     70            index -= Inventory.Count; 
     71        } 
     72        return Inventory[index]; 
     73    } 
     74 
    4675    protected override void UpdateAnimations() 
    4776    { 
    48         if (!(ActiveItem != null && ActiveItem.OverrideAnimation)) 
     77        bool itemBlocksAnimation = ActiveItem != null && ActiveItem.OverrideAnimation; 
     78        bool swordBlocksAnimation = Sword != null && Sword.OverrideAnimation; 
     79        if (!(itemBlocksAnimation || swordBlocksAnimation)) 
    4980        { 
    50             base.UpdateAnimations();    
     81            base.UpdateAnimations(); 
    5182        } 
    5283    } 
     
    5586    { 
    5687        if (ActiveItem != null) 
    57             ActiveItem.UpdateItem(time); 
     88        { 
     89            ActiveItem.UpdateItem(time);    
     90        } 
     91        if (Sword != null) 
     92        { 
     93            Sword.UpdateItem(time); 
     94        } 
    5895        base.UpdateCreature(time); 
    5996    } 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs

    r6618 r6619  
    4242    StoryItem[] storyItem = new StoryItem[3]; 
    4343 
     44    private Label currentItem; 
     45    private Label nextItem; 
     46    private Label prevItem; 
     47 
    4448    #region Resources 
    4549 
     
    4751    public static Image LetterImage = LoadImage("letter"); 
    4852    public static Image SmallSwordImage = LoadImage("smallsword"); 
     53    public static Image MonocleImage = LoadImage("monocle"); 
    4954 
    5055    public static Image FrameImage = LoadImage("frame"); 
     
    8590        LoadAnimations(); 
    8691        StartGame(); 
    87         Intro(); 
     92        //Intro(); 
    8893        BuildRightBar(); 
     94        BuildInventoryCycle(); 
     95        UpdateItemCycleImages(); 
     96    } 
     97 
     98    void BuildInventoryCycle() 
     99    { 
     100        const int spacing = 20; 
     101 
     102        prevItem = new Label(); 
     103        prevItem.Size = new Vector(60, 40); 
     104        prevItem.X = Screen.Left + 100; 
     105        prevItem.Y = Screen.Top - 50; 
     106        Add(prevItem); 
     107 
     108        currentItem = new Label(); 
     109        currentItem.Size = prevItem.Size; 
     110        currentItem.Left = prevItem.Right + spacing; 
     111        currentItem.Y = prevItem.Y; 
     112        Add(currentItem); 
     113 
     114        nextItem = new Label(); 
     115        nextItem.Size = prevItem.Size; 
     116        nextItem.Left = currentItem.Right + spacing; 
     117        nextItem.Y = prevItem.Y; 
     118        Add(nextItem); 
    89119    } 
    90120 
     
    186216        Keyboard.Listen(Key.Down, ButtonState.Down, player.Move, null, Direction.Down); 
    187217 
    188         Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyPressed(); }, null); 
    189         Keyboard.Listen(Key.Space, ButtonState.Released, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyReleased(); }, null); 
    190         Keyboard.Listen(Key.Space, ButtonState.Down, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyDown(); }, null); 
     218        Keyboard.Listen(Key.X, ButtonState.Pressed, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyPressed(); }, null); 
     219        Keyboard.Listen(Key.X, ButtonState.Released, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyReleased(); }, null); 
     220        Keyboard.Listen(Key.X, ButtonState.Down, delegate { if (player.ActiveItem != null) player.ActiveItem.UseKeyDown(); }, null); 
     221 
     222        Keyboard.Listen(Key.Z, ButtonState.Pressed, delegate { if (player.Sword != null) player.Sword.UseKeyPressed(); }, null); 
     223        Keyboard.Listen(Key.Z, ButtonState.Released, delegate { if (player.Sword != null) player.Sword.UseKeyReleased(); }, null); 
     224        Keyboard.Listen(Key.Z, ButtonState.Down, delegate { if (player.Sword != null) player.Sword.UseKeyDown(); }, null); 
     225 
     226        Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate { player.CycleItems(); UpdateItemCycleImages(); }, null); 
    191227 
    192228        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 
     229    } 
     230 
     231    void UpdateItemCycleImages() 
     232    { 
     233        if (player.PrevItem != null) prevItem.Image = player.PrevItem.InventoryImage; 
     234        if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage; 
     235        if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage; 
    193236    } 
    194237 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj

    r6618 r6619  
    179179    </Compile> 
    180180  </ItemGroup> 
     181  <ItemGroup> 
     182    <Compile Include="monocle.png"> 
     183      <Name>monocle</Name> 
     184      <Importer>TextureImporter</Importer> 
     185      <Processor>TextureProcessor</Processor> 
     186    </Compile> 
     187  </ItemGroup> 
    181188  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    182189  <!--  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.