Changeset 6626 for 2015/27


Ignore:
Timestamp:
2015-06-30 20:07:55 (4 years ago)
Author:
sieerinn
Message:

Kamoissa näkyy käyttökerrat. Kamasysteemin toimivuutta paranneltu. Kojootin kuvat.

Location:
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
Files:
24 added
4 edited

Legend:

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

    r6625 r6626  
    1313    public Image InventoryImage { get; set; } 
    1414 
     15    public IntMeter Usages { get; set; } 
     16 
    1517    // Onko kama tällä hetkellä aktiivisessa käytössä. 
    1618    public virtual bool InUse { get; set; } 
     
    3133    public virtual void UseKeyReleased() { } 
    3234 
     35    public virtual void CancelUse() { } 
     36 
    3337    protected Item(Player player) 
    3438    { 
     39        Usages = new IntMeter(0, 0, 0); 
    3540        this.player = player; 
    3641    } 
     
    6974        if (SwordObject != null && InUse) 
    7075        { 
    71             var dir = SwingDirection; 
    72             var swordAngle = swordAngles[player.Animation.CurrentFrameIndex]; 
    73             if (dir == Direction.Left) 
    74                 swordAngle = Angle.FromDegrees(swordAngle.Degrees * -1); 
    75             SwordObject.Position = player.Position + (dir.Angle + swordAngle).GetVector() * 15; 
    76             SwordObject.Angle = swordAngle + Angle.FromDegrees(dir == Direction.Left || dir == Direction.Right ? 90 : 0); 
    77             SwordObject.Angle += Angle.FromDegrees(dir == Direction.Right || dir == Direction.Down ? 180 : 0); 
     76            if (player.Animation.CurrentFrameIndex < swordAngles.Length) 
     77            { 
     78                var dir = SwingDirection; 
     79                var swordAngle = swordAngles[player.Animation.CurrentFrameIndex]; 
     80                if (dir == Direction.Left) 
     81                    swordAngle = Angle.FromDegrees(swordAngle.Degrees * -1); 
     82                SwordObject.Position = player.Position + (dir.Angle + swordAngle).GetVector() * 15; 
     83                SwordObject.Angle = swordAngle + Angle.FromDegrees(dir == Direction.Left || dir == Direction.Right ? 90 : 0); 
     84                SwordObject.Angle += Angle.FromDegrees(dir == Direction.Right || dir == Direction.Down ? 180 : 0);    
     85            } 
    7886        } 
    7987        base.UpdateItem(time); 
     
    106114        base.UseKeyPressed(); 
    107115    } 
     116 
     117    public override void CancelUse() 
     118    { 
     119        InUse = false; 
     120        player.SetWalkAnimation(); 
     121        if (SwordObject != null) 
     122        { 
     123            SwordObject.Destroy(); 
     124            SwordObject = null; 
     125        } 
     126    } 
    108127} 
    109128 
     
    125144        : base(player) 
    126145    { 
     146        Usages.MaxValue = 15; 
     147        Usages.Value = 15; 
    127148        Charge = new DoubleMeter(0, 0, 4); 
    128149        InventoryImage = TheLegendOfGabriel.GunImage; 
     
    140161    public override void UseKeyPressed() 
    141162    { 
     163        if (Usages.Value == 0) 
     164        { 
     165            base.UseKeyPressed(); 
     166            return; 
     167        } 
     168 
    142169        InUse = true; 
    143170        isCharging = true; // Ase alkaa latautumaan. 
     
    159186        if (player.Animation.CurrentFrameIndex == player.Animation.FrameCount - 1) 
    160187        { 
     188            Usages.Value--; 
     189 
    161190            var bullet = new PhysicsObject(4, 4); 
    162191            bullet.Position = player.Position + ShootDirection.GetVector() * player.Width * 0.7; 
     
    164193            Game.Instance.Add(bullet); 
    165194        } 
    166  
     195        CancelUse(); 
     196 
     197        base.UseKeyReleased(); 
     198    } 
     199 
     200    public override void CancelUse() 
     201    { 
    167202        InUse = false; 
    168203        isCharging = false; 
    169204        player.MovementSpeed.Value = player.MovementSpeed.MaxValue; 
    170205        player.SetWalkAnimation(); 
    171  
    172         base.UseKeyReleased(); 
     206        base.CancelUse(); 
    173207    } 
    174208} 
     
    199233    public override void UseKeyReleased() 
    200234    { 
     235        CancelUse(); 
     236        base.UseKeyReleased(); 
     237    } 
     238 
     239    public override void CancelUse() 
     240    { 
    201241        InUse = false; 
    202242        if (bigMonocle != null) 
     
    205245            bigMonocle = null; 
    206246        } 
    207         base.UseKeyReleased(); 
     247        base.CancelUse(); 
    208248    } 
    209249 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs

    r6624 r6626  
    3030        level.SetObjectMethod("player", CreatePlayer); 
    3131        level.SetObjectMethod("blockade", CreateBlock); 
    32        // level.SetObjectMethod("coyote", CreateEnemy); 
     32        // level.SetObjectMethod("coyote", CreateEnemy); 
    3333        level.Execute(); 
    3434 
     
    5757        player.MovementSpeed = new DoubleMeter(2300, 0, 2300); 
    5858        player.Position = position; 
    59         player.MoveAnimations[Direction.Left] = playerWalkLeft; 
    60         player.MoveAnimations[Direction.Right] = playerWalkRight; 
    61         player.MoveAnimations[Direction.Up] = playerWalkUp; 
    62         player.MoveAnimations[Direction.Down] = playerWalkDown; 
    63         player.SwingAnimations[Direction.Left] = playerSwingLeft; 
    64         player.SwingAnimations[Direction.Right] = playerSwingRight; 
    65         player.SwingAnimations[Direction.Up] = playerSwingUp; 
    66         player.SwingAnimations[Direction.Down] = playerSwingDown; 
    67         player.ShootAnimations[Direction.Left] = playerShootLeft; 
    68         player.ShootAnimations[Direction.Right] = playerShootRight; 
    69         player.ShootAnimations[Direction.Up] = playerShootUp; 
    70         player.ShootAnimations[Direction.Down] = playerShootDown; 
     59        player.MoveAnimations = DirectionalAnimations(playerWalkLeft, playerWalkRight, playerWalkUp, playerWalkDown); 
     60        player.SwingAnimations = DirectionalAnimations(playerSwingLeft, playerSwingRight, playerSwingUp, playerSwingDown); 
     61        player.ShootAnimations = DirectionalAnimations(playerShootLeft, playerShootRight, playerShootUp, playerShootDown); 
    7162        player.Image = playerWalkDown.CurrentFrame; 
    7263        Add(player, 1); 
     
    9586    } 
    9687 
    97         /// <summary> 
     88    /// <summary> 
    9889    /// Pelaajan päällä näkyvä tiili. 
    9990    /// </summary> 
     
    10899    void CreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties) 
    109100    { 
    110         var tile = properties.ContainsKey("collide")? new PhysicsObject(width, height) : new GameObject(width, height); 
     101        var tile = properties.ContainsKey("collide") ? new PhysicsObject(width, height) : new GameObject(width, height); 
    111102        tile.Image = image; 
    112103        tile.Position = position; 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs

    r6624 r6626  
    2323} 
    2424 
     25class CycleSlot : Label 
     26{ 
     27    public Label UsageLabel { get; set; } 
     28 
     29    public CycleSlot(double left, double top) 
     30    { 
     31        this.Left = left; 
     32        this.Top = top; 
     33        this.Size = new Vector(60, 40); 
     34 
     35        UsageLabel = new Label("10"); 
     36        UsageLabel.IsVisible = false; 
     37        UsageLabel.TextColor = Color.White; 
     38        UsageLabel.X = this.X + 10; 
     39        UsageLabel.Top = this.Bottom; 
     40        UsageLabel.Font = Font.DefaultSmallBold; 
     41    } 
     42 
     43    public void UpdateImage(Item item) 
     44    { 
     45        if (item != null) 
     46        { 
     47            this.Image = item.InventoryImage; 
     48            UsageLabel.IsVisible = false; 
     49            if (item.Usages.MaxValue > 0) 
     50            { 
     51                UsageLabel.IsVisible = true; 
     52                UsageLabel.BindTo(item.Usages); 
     53            } 
     54        } 
     55    } 
     56} 
     57 
    2558public partial class TheLegendOfGabriel : PhysicsGame 
    2659{ 
     
    4275    StoryItem[] storyItem = new StoryItem[3]; 
    4376 
    44     private Label currentItem; 
    45     private Label nextItem; 
    46     private Label prevItem; 
    47     private Label swordFrame; 
     77    private CycleSlot currentItem; // Laatikossa näkyvä nykyinen kama. 
     78    private CycleSlot nextItem; // Seuraavan kaman kuva. 
     79    private CycleSlot prevItem; // Edellisen kaman kuva. 
     80    private Label swordItem; // Laatikossa näkyvä miekka. 
    4881 
    4982    #region Resources 
     
    87120    private Animation playerShootDown; 
    88121 
     122    [AssetName("coyoteup")] 
     123    private Animation coyoteUp; 
     124    [AssetName("coyoteright")] 
     125    private Animation coyoteRight; 
     126    [AssetName("coyoteright", mirror: true)] 
     127    private Animation coyoteLeft; 
     128    [AssetName("coyotedown")] 
     129    private Animation coyoteDown; 
     130 
    89131    #endregion 
    90132 
     
    105147        const int spacing = 20; 
    106148 
    107         prevItem = new Label(); 
    108         prevItem.Size = new Vector(60, 40); 
    109         prevItem.X = Screen.Left + 100; 
    110         prevItem.Y = Screen.Top - 50; 
     149        prevItem = new CycleSlot(Screen.Left + 50, Screen.Top - 30); 
    111150        Add(prevItem); 
    112  
    113         currentItem = new Label(); 
    114         currentItem.Size = prevItem.Size; 
    115         currentItem.Left = prevItem.Right + spacing; 
    116         currentItem.Y = prevItem.Y; 
     151        Add(prevItem.UsageLabel); 
     152 
     153        currentItem = new CycleSlot(prevItem.Right + spacing, prevItem.Top); 
    117154        Add(currentItem); 
    118  
    119         nextItem = new Label(); 
    120         nextItem.Size = prevItem.Size; 
    121         nextItem.Left = currentItem.Right + spacing; 
    122         nextItem.Y = prevItem.Y; 
     155        Add(currentItem.UsageLabel); 
     156 
     157        nextItem = new CycleSlot(currentItem.Right + spacing, prevItem.Top); 
    123158        Add(nextItem); 
    124  
     159        Add(nextItem.UsageLabel); 
     160 
     161        // Ruutu jonka sisällä käytössä oleva kama on. 
    125162        var frame = new Label(); 
    126163        frame.Size = new Vector(60, 60); 
     
    130167        Add(frame); 
    131168 
    132         swordFrame = new Label(); 
    133         swordFrame.Size = prevItem.Size; 
    134         swordFrame.Left = nextItem.Right + spacing * 2; 
    135         swordFrame.Top = currentItem.Top; 
     169        // Miekan kuva. 
     170        swordItem = new Label(); 
     171        swordItem.Size = prevItem.Size; 
     172        swordItem.Left = nextItem.Right + spacing * 2; 
     173        swordItem.Top = currentItem.Top; 
     174        Add(swordItem); 
     175 
     176        // Miekan kuvan ympärillä oleva ruutu. 
     177        var swordFrame = new Label(); 
     178        swordFrame.Size = new Vector(60, 60); 
     179        swordFrame.Image = ActiveItemFrameImageZ; 
     180        swordFrame.X = swordItem.X; 
     181        swordFrame.Top = swordItem.Top; 
    136182        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); 
    144183    } 
    145184 
     
    176215            field.SetValue(this, assetAttr.Mirror ? MirrorAnimation(anim) : anim); 
    177216        } 
     217    } 
     218 
     219    Dictionary<Direction, Animation> DirectionalAnimations(Animation left, Animation right, Animation up, Animation down) 
     220    { 
     221        var dict = new Dictionary<Direction, Animation>(); 
     222        dict[Direction.Left] = left; 
     223        dict[Direction.Right] = right; 
     224        dict[Direction.Up] = up; 
     225        dict[Direction.Down] = down; 
     226        return dict; 
    178227    } 
    179228 
     
    272321        if (player.ActiveItem != null) 
    273322        { 
    274             player.ActiveItem.UseKeyReleased(); 
     323            player.ActiveItem.CancelUse(); 
     324        } 
     325        if (player.Sword != null) 
     326        { 
     327            player.Sword.CancelUse(); 
    275328        } 
    276329 
     
    281334    void UpdateItemCycleImages() 
    282335    { 
     336        prevItem.UpdateImage(player.PrevItem); 
     337        currentItem.UpdateImage(player.ActiveItem); 
     338        nextItem.UpdateImage(player.NextItem); 
     339        /* 
    283340        if (player.PrevItem != null) prevItem.Image = player.PrevItem.InventoryImage; 
    284341        if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage; 
    285342        if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage; 
     343         */ 
    286344 
    287345        if (player.Sword != null) 
    288346        { 
    289             swordFrame.Image = BigSwordImage; 
     347            swordItem.Image = BigSwordImage; 
    290348        } 
    291349    } 
     
    426484                } 
    427485                oldObjects.Clear(); 
     486 
     487                BuildRightBar(); 
     488                BuildInventoryCycle(); 
     489                UpdateItemCycleImages(); 
    428490            } 
    429491        } 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj

    r6623 r6626  
    214214    </Compile> 
    215215  </ItemGroup> 
     216  <ItemGroup> 
     217    <Compile Include="coyotedown.anim"> 
     218      <Name>coyotedown</Name> 
     219      <Importer>AnimationImporter</Importer> 
     220      <Processor>AnimationContentProcessor</Processor> 
     221    </Compile> 
     222    <Compile Include="coyoteright.anim"> 
     223      <Name>coyoteright</Name> 
     224      <Importer>AnimationImporter</Importer> 
     225      <Processor>AnimationContentProcessor</Processor> 
     226    </Compile> 
     227    <Compile Include="coyoteup.anim"> 
     228      <Name>coyoteup</Name> 
     229      <Importer>AnimationImporter</Importer> 
     230      <Processor>AnimationContentProcessor</Processor> 
     231    </Compile> 
     232  </ItemGroup> 
    216233  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    217234  <!--  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.