Changeset 9125 for 2017/30


Ignore:
Timestamp:
2017-07-26 13:52:18 (2 years ago)
Author:
npo17_65
Message:

pyssyt toimivat ja liikkeet sekä animaatiot

Location:
2017/30/HugoE/HanniAndHoo/HanniAndHoo/HanniAndHoo
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 2017/30/HugoE/HanniAndHoo/HanniAndHoo/HanniAndHoo/HanniAndHoo.cs

    r9119 r9125  
    1212     Image HoonKuva = LoadImage("Hoo"); 
    1313 
    14     AssaultRifle HanninAse; 
    1514 
     15    PlasmaCannon HanninAse;     
    1616    Cannon HoonAse; 
    1717     
    18  
    19      
     18         
    2019    PlatformCharacter Hanni; 
    21     PhysicsObject Hoo; 
     20    PlatformCharacter Hoo; 
    2221     
    2322    public override void Begin() 
    2423    { 
    2524        LuoKentta(); 
     25        LuoPelaajat(); 
    2626        LuoNappaimet(); 
    27         LuoPelaajat(); 
    28  
    29         AmmuAseella(HanninAse); 
    30         AmmuAseella2(HoonAse); 
    31  
    32  
    33  
    34  
    35  
    36  
    3727    } 
    3828 
    3929    void LuoPelaajat() 
    4030    { 
    41  
    4231        Hanni = new PlatformCharacter(80.0, 80.0); 
    4332        Hanni.X = Level.Left + 100.0; 
     
    4635        Hanni.Color = Color.Blue; 
    4736        Hanni.Image = HanninKuva; 
    48         Hanni.CanRotate = false; 
     37        Hanni.CanRotate = false;        
    4938        Add(Hanni); 
    50         HanninAse = new AssaultRifle(60, 20); 
     39        HanninAse = new PlasmaCannon(60, 20); 
    5140        HanninAse.ProjectileCollision = AmmusOsui; 
    5241        HanninAse.X += 50; 
    53         Hanni.Add(HanninAse); 
    54  
    55                  
     42        Keyboard.Listen(Key.S, ButtonState.Pressed, AmmuAseella, "Ammu", HanninAse); 
     43        Hanni.Weapon = HanninAse;                 
    5644        Hoo = new PlatformCharacter (100.0, 100.0); 
    5745        Hoo.X = Level.Right - 100.0; 
     
    6149        Hoo.Image = HoonKuva; 
    6250        Hoo.CanRotate = false; 
    63         Add(Hoo); 
     51        Add(Hoo);        
    6452        HoonAse = new Cannon (90, 30); 
    6553        HoonAse.ProjectileCollision = AmmusOsui; 
    6654        HoonAse.X += 80; 
    67         Hoo.Add(HoonAse); 
     55        Hoo.Weapon = HoonAse; 
     56        Keyboard.Listen(Key.Down, ButtonState.Pressed, AmmuAseella2, "Ammu2", HoonAse); 
    6857        HoonAse.Power.DefaultValue = 20000; 
     58        AddCollisionHandler(Hoo, Hanni, Tormaa); 
     59    } 
     60    void Tormaa(PhysicsObject tormaaja, PhysicsObject kohde) 
     61    { 
     62        kohde.Destroy(); 
    6963    } 
    7064 
     
    7266    { 
    7367        Ammus.Destroy(); 
    74  
    7568    } 
    7669    void LuoNappaimet() 
    7770    { 
    78         Keyboard.Listen(Key.W, ButtonState.Pressed, LiikutaHannia, null, new Vector(0, 700)); 
    79         Keyboard.Listen(Key.D, ButtonState.Down, LiikutaHannia, null, new Vector(500.0, 0.0)); 
    80         Keyboard.Listen(Key.D, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0)); 
    81         Keyboard.Listen(Key.A, ButtonState.Down, LiikutaHannia, null, new Vector(-500, 0)); 
    82         Keyboard.Listen(Key.A, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0)); 
    83  
    84  
    85         Keyboard.Listen(Key.Up, ButtonState.Pressed, LiikutaHoota, null, new Vector(0, 700)); 
    86         Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaHoota, null, new Vector(500.0, 0.0)); 
    87         Keyboard.Listen(Key.Right, ButtonState.Released, LiikutaHoota, null, new Vector(0, 0)); 
    88         Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaHoota, null, new Vector(-500, 0)); 
    89         Keyboard.Listen(Key.Left, ButtonState.Released, LiikutaHoota, null, new Vector(0, 0)); 
    90  
    91  
    92  
     71        Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppy, null, Hanni, 1000.0); 
     72        Keyboard.Listen(Key.D, ButtonState.Down, Kavely, null, Hanni, 500.0);        
     73        Keyboard.Listen(Key.A, ButtonState.Down, Kavely, null, Hanni, -500.0); 
     74        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppy, null, Hoo, 1000.0); 
     75        Keyboard.Listen(Key.Right, ButtonState.Down, Kavely, null, Hoo, 500.0); 
     76        Keyboard.Listen(Key.Left, ButtonState.Down, Kavely, null, Hoo, -500.0);     
    9377        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    9478 
     
    10791 
    10892 
    109     void LiikutaHannia(Vector vektori) 
     93    void Kavely(PlatformCharacter tyyppi, double liikkumisenMaara) 
    11094    { 
    111         Hanni.Velocity = (vektori); 
    11295         
     96        tyyppi.Walk(liikkumisenMaara); 
    11397 
    11498    } 
    115     void LiikutaHoota(Vector vektori) 
     99    void Hyppy(PlatformCharacter tyyppi, double hypynMaara) 
    116100    { 
    117         Hoo.Velocity = (vektori); 
     101        tyyppi.Jump(hypynMaara); 
    118102    } 
    119103 
    120     void AmmuAseella(AssaultRifle HanninAse) 
     104    void AmmuAseella(PlasmaCannon HanninAse) 
    121105    { 
    122         PhysicsObject Ammus = HanninAse.Shoot(); 
    123         Keyboard.Listen(Key.S, ButtonState.Pressed, AmmuAseella, "Ammu", HanninAse); 
    124         HanninAse.FireRate = 0.25; 
    125  
     106        PhysicsObject Ammus = HanninAse.Shoot();       
     107        HanninAse.FireRate = 2; 
    126108        if (Ammus != null) 
    127109        { 
    128110            Ammus.Size *= 3; 
    129111            Ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
    130  
    131112        } 
    132113 
     
    136117    { 
    137118        PhysicsObject Ammus = HoonAse.Shoot(); 
    138         Keyboard.Listen(Key.Down, ButtonState.Pressed, AmmuAseella2, "Ammu2", HoonAse); 
    139         HoonAse.FireRate = 0.25; 
    140          
    141  
     119        HoonAse.FireRate = 1; 
    142120        if (Ammus != null) 
    143121        { 
    144122            Ammus.Size *= 4; 
    145123            Ammus.MaximumLifetime = TimeSpan.FromSeconds(4.0); 
    146  
    147124        } 
    148125 
     126    } 
     127     
     128    class Hyvis : PhysicsObject 
     129    { 
     130        private IntMeter elamaLaskuri = new IntMeter(3, 0, 3); 
     131        public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 
    149132 
     133        public Hyvis(double leveys, double korkeus) 
     134        : base(leveys, korkeus) 
     135    { 
     136            elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 
     137        } 
    150138 
    151139    } 
     
    154142 
    155143} 
     144    
     145    
     146 
     147    
     148 
Note: See TracChangeset for help on using the changeset viewer.