Changeset 7224 for 2016/23/ohjaajat


Ignore:
Timestamp:
2016-06-10 09:30:50 (3 years ago)
Author:
sieerinn
Message:

Loppusäädöt

Location:
2016/23/ohjaajat/Punasininen/Punasininen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Punasininen.cs

    r7223 r7224  
    123123            Win(percentageTracker.Value >= 50 ? red : blue); 
    124124            var restart = new Timer() { Interval = 5, IgnorePause = true }; 
    125             restart.Timeout += () => { ClearAll(); Begin(); Pause(); }; 
     125            restart.Timeout += RestartGame; 
    126126            restart.Start(); 
    127127        }; 
     
    186186        Add(player); 
    187187 
     188        var glow = new GameObject(240, 240); 
     189        glow.Image = playersColor == redColor ? orangeGlow : blueGlow; 
     190        player.Add(glow); 
     191 
    188192        player.Weapon = new AssaultRifle(leveys * 1.5, korkeus * 1.5) 
    189193        { 
     
    222226    { 
    223227        int hurdur = RandomGen.NextInt(0, 3); 
     228        Image glow = player == red ? orangeGlow : blueGlow; 
    224229 
    225230        switch (hurdur) 
    226231        { 
    227232            case 0: 
    228                 player.Weapon = new RocketLauncher(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, player); 
     233                player.Weapon = new RocketLauncher(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, glow, player); 
    229234                break; 
    230235            case 1: 
    231                 player.Weapon = new GrenadeLauncher(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, player); 
     236                player.Weapon = new GrenadeLauncher(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, glow, player); 
    232237                break; 
    233238            case 2: 
    234                 player.Weapon = new LaserGun(player.Weapon.Width, player.Weapon.Height) { Image = player.Weapon.Image, ProjectileCollision = delegate (PhysicsObject a, PhysicsObject b) { ColorTile(a, b); a.Destroy(); }, AttackSound = null, MaxAmmoLifetime = TimeSpan.FromSeconds(4) }; 
     239                player.Weapon = new SprayGun(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, glow, player); 
    235240                break; 
    236241            default: 
     
    256261    } 
    257262 
     263    void RestartGame() 
     264    { 
     265        cratePositions.Clear(); 
     266        ClearAll(); 
     267        Begin(); 
     268        IsPaused = false; 
     269    } 
     270 
    258271    void Win(Player winner) 
    259272    { 
     
    285298        zoomTimer.IgnorePause = true; 
    286299        zoomTimer.Start(); 
    287  
    288         cratePositions.Clear(); 
    289300    } 
    290301 
     
    323334 
    324335        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Ohjeet"); 
     336        Keyboard.Listen(Key.F12, ButtonState.Pressed, RestartGame, null); 
    325337        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta"); 
    326338 
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/WeaponCrate.cs

    r7219 r7224  
    1616} 
    1717 
     18class SprayGun : LaserGun 
     19{ 
     20    private Image glowImage; 
     21 
     22    public SprayGun(double leveys, double korkeus, Image image, Image glowImage, Player owner) 
     23        : base(leveys, korkeus) 
     24    { 
     25        this.glowImage = glowImage; 
     26        Image = image; 
     27        ProjectileCollision = (PhysicsObject a, PhysicsObject b) => 
     28        { 
     29            ((Punasininen)Game).ColorTile(a, b); a.Destroy(); 
     30        }; 
     31        AttackSound = null; 
     32        MaxAmmoLifetime = TimeSpan.FromSeconds(4); 
     33    } 
     34 
     35    protected override PhysicsObject CreateProjectile() 
     36    { 
     37        var bullet = base.CreateProjectile(); 
     38        var glow = new GameObject(100, 100); 
     39        glow.Image = glowImage; 
     40        bullet.Add(glow); 
     41        return bullet; 
     42    } 
     43} 
     44 
    1845class RocketLauncher : AssaultRifle 
    1946{ 
    2047    public Player Owner; 
    2148 
    22     public RocketLauncher(double leveys, double korkeus, Image image, Player owner) 
     49    private Image glowImage; 
     50 
     51    public RocketLauncher(double leveys, double korkeus, Image image, Image glowImage, Player owner) 
    2352        : base(leveys, korkeus) 
    2453    { 
     54        this.glowImage = glowImage; 
    2555        Image = image; 
    2656        AttackSound = null; 
     
    3868        rocket.Color = Owner.Color; 
    3969 
     70        var rocketGlow = new GameObject(300, 300); 
     71        rocketGlow.Image = glowImage; 
     72        Game.Instance.Add(rocketGlow); 
     73 
    4074        ((Punasininen)Game.Instance).AddCollisionHandler(rocket, (PhysicsObject a, PhysicsObject b) => 
    4175        { 
     
    5084        updateTimer.Timeout += () => 
    5185        { 
     86            rocketGlow.Position = rocket.Position; 
    5287            rocket.Velocity *= 1.03; 
    5388 
     
    72107            explosionTimer.Stop(); 
    73108            rocket.Destroy(); 
     109            rocketGlow.Destroy(); 
    74110 
    75111            var explosion = new Explosion(100); 
     
    98134    public Player Owner; 
    99135 
    100     protected override PhysicsObject CreateProjectile() 
    101     { 
    102         Grenade test = new Grenade(10, TimeSpan.FromSeconds(1)); 
    103         test.Explosion.ShockwaveColor = Owner.Color; 
    104         test.Explosion.MaxRadius = 300; 
    105         test.Explosion.Speed = 1000; 
    106         test.Explosion.Sound = null; 
    107         test.Explosion.ShockwaveReachesObject += delegate(IPhysicsObject a, Vector b)  
    108         { 
    109             if (a is Tile) 
    110             { 
    111                 ((Punasininen)Game).ColorTile(test, (Tile)a); 
    112             } 
    113         }; 
    114         Timer.SingleShot(1, () => ((Punasininen)Game.Instance).NewWave(test.Position)); 
    115         return test; 
    116     } 
     136    private Image glowImage; 
    117137 
    118     public GrenadeLauncher(double leveys, double korkeus, Image image, Player owner) 
     138    public GrenadeLauncher(double leveys, double korkeus, Image image, Image glowImage, Player owner) 
    119139        : base(leveys, korkeus) 
    120140    { 
     141        this.glowImage = glowImage; 
    121142        Image = image; 
    122143        AttackSound = null; 
    123144        FireRate = 1; 
    124145        Power.DefaultValue = 30000; 
    125         Owner = owner; 
    126         
     146        Owner = owner;   
    127147    } 
     148 
     149    protected override PhysicsObject CreateProjectile() 
     150    { 
     151        Grenade grenade = new Grenade(10, TimeSpan.FromSeconds(1)); 
     152        grenade.Explosion.ShockwaveColor = Owner.Color; 
     153        grenade.Explosion.MaxRadius = 300; 
     154        grenade.Explosion.Speed = 1000; 
     155        grenade.Explosion.Sound = null; 
     156        grenade.Explosion.ShockwaveReachesObject += delegate(IPhysicsObject a, Vector b)  
     157        { 
     158            if (a is Tile) 
     159            { 
     160                ((Punasininen)Game).ColorTile(grenade, (Tile)a); 
     161            } 
     162        }; 
     163        Timer.SingleShot(1, () => ((Punasininen)Game.Instance).NewWave(grenade.Position)); 
     164 
     165        var glow = new GameObject(400, 400); 
     166        glow.Image = glowImage; 
     167        grenade.Add(glow); 
     168 
     169        return grenade; 
     170    } 
     171 
    128172} 
Note: See TracChangeset for help on using the changeset viewer.