Changeset 6550 for 2015/27/ohjaajat


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

Pistoolia aloiteltu.

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

Legend:

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

    r6549 r6550  
    44class Creature : PhysicsObject 
    55{ 
    6     public double MovementSpeed { get; set; } 
     6    public DoubleMeter MovementSpeed { get; set; } 
    77 
    88    public Dictionary<Direction, Animation> MoveAnimations { get; set; } 
     
    1313        : base(width, height) 
    1414    { 
     15        MovementSpeed = new DoubleMeter(2000, 0, 2000); 
    1516        LastDirection = Direction.Down; 
    1617        MoveAnimations = new Dictionary<Direction, Animation>(); 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs

    r6549 r6550  
    106106    } 
    107107} 
     108 
     109class Pistol : Item 
     110{ 
     111    private bool isCharging; 
     112 
     113    public Direction ShootDirection { get; set; } 
     114 
     115    // Montako sekuntia pistoolilla on tähdätty. Täydellä latauksella voisi ampua isomman ammuksen. 
     116    public DoubleMeter Charge { get; set; } 
     117 
     118    public override bool OverrideAnimation 
     119    { 
     120        get { return InUse; } 
     121    } 
     122 
     123    public Pistol(Player player) 
     124        : base(player) 
     125    { 
     126        Charge = new DoubleMeter(0, 0, 4); 
     127    } 
     128 
     129    public override void UpdateItem(Time time) 
     130    { 
     131        if (isCharging) 
     132        { 
     133            Charge.Value += time.SinceLastUpdate.TotalSeconds; 
     134        } 
     135        base.UpdateItem(time); 
     136    } 
     137 
     138    public override void UseKeyPressed() 
     139    { 
     140        InUse = true; 
     141        isCharging = true; // Ase alkaa latautumaan. 
     142        Charge.Value = Charge.MinValue; // Aseen lataus aluksi nollaan. 
     143 
     144        // Hidastetaan pelaajaa samalla kun se tähtää. 
     145        player.MovementSpeed.Value = player.MovementSpeed.MaxValue * 0.333; 
     146 
     147        // TODO: Tee pistoolin ampumiselle animaatio. 
     148        ShootDirection = player.Velocity.Angle.MainDirection; 
     149        player.Animation = new Animation(player.SwingAnimations[ShootDirection]); 
     150        player.Animation.StopOnLastFrame = true; 
     151        player.Animation.Start(1); 
     152        base.UseKeyPressed(); 
     153    } 
     154 
     155    public override void UseKeyReleased() 
     156    { 
     157        // Pistoolilla voi ampua vain jos tähtäysanimaatio on ehtinyt loppuun. 
     158        if (player.Animation.CurrentFrameIndex == player.Animation.FrameCount - 1) 
     159        { 
     160            var bullet = new PhysicsObject(4, 4); 
     161            bullet.Position = player.Position + ShootDirection.GetVector() * player.Width * 0.7; 
     162            bullet.Hit(ShootDirection.GetVector() * 500); 
     163            Game.Instance.Add(bullet); 
     164        } 
     165 
     166        InUse = false; 
     167        isCharging = false; 
     168        player.MovementSpeed.Value = player.MovementSpeed.MaxValue; 
     169        player.SetWalkAnimation(); 
     170 
     171        base.UseKeyReleased(); 
     172    } 
     173} 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs

    r6549 r6550  
    4141        player = new Player(); 
    4242        player.CanRotate = false; 
    43         player.MovementSpeed = 2300; 
     43        player.MovementSpeed = new DoubleMeter(2300, 0, 2300); 
    4444        player.Position = position; 
    4545        player.MoveAnimations[Direction.Left] = playerWalkLeft; 
     
    5555 
    5656        player.ActiveItem = new Sword(player); 
     57        //player.ActiveItem = new Pistol(player); 
     58 
    5759 
    5860        AddCollisionHandler(player, "exit", CollidesWithExit); 
Note: See TracChangeset for help on using the changeset viewer.