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

Aktiivisen kaman vaihto toimii.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.