Changeset 7219 for 2016/23/ohjaajat


Ignore:
Timestamp:
2016-06-09 22:20:43 (3 years ago)
Author:
sieerinn
Message:

Raketinheitin tehty

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

Legend:

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

    r7218 r7219  
    4141    private Shader shader; 
    4242 
     43    public void NewWave(Vector pos) 
     44    { 
     45        shader.NewWave(pos); 
     46    } 
     47 
    4348    public override void Begin() 
    4449    { 
     
    6570 
    6671        ColorTileMap map = ColorTileMap.FromLevelAsset("dungeon1"); 
    67         map.SetTileMethod(Color.Black, delegate(Vector vektori, double leveys, double korkeus) { AddPlatform(vektori, leveys, korkeus); }); 
    68         map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, blueColor, blueWalkImages, bluePistolpic); }); 
    69         map.SetTileMethod(Color.FromHexCode("FFD800"), delegate(Vector a, double b, double c) { cratePositions.Add(a, CreateWeaponCrate(a, b, c)); }); 
    70         map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redColor, orangeWalkImages, orangePistolpic); }); 
     72        map.SetTileMethod(Color.Black, delegate (Vector vektori, double leveys, double korkeus) { AddPlatform(vektori, leveys, korkeus); }); 
     73        map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate (Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, blueColor, blueWalkImages, bluePistolpic); }); 
     74        map.SetTileMethod(Color.FromHexCode("FFD800"), delegate (Vector a, double b, double c) { cratePositions.Add(a, CreateWeaponCrate(a, b, c)); }); 
     75        map.SetTileMethod(Color.Red, delegate (Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redColor, orangeWalkImages, orangePistolpic); }); 
    7176        map.Execute(TILE_SIZE, TILE_SIZE); 
    7277 
     
    185190            AttackSound = null, 
    186191            MaxAmmoLifetime = TimeSpan.FromSeconds(8), 
    187             ProjectileCollision = delegate(PhysicsObject a, PhysicsObject b) { ColorTile(a, b); a.Destroy(); }, 
     192            ProjectileCollision = delegate (PhysicsObject a, PhysicsObject b) { ColorTile(a, b); a.Destroy(); }, 
    188193            // ProjectileCollision = BulletHitsSomething, 
    189194            Image = pistolPic, 
     
    191196        }; 
    192197 
    193         AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 
     198        AddCollisionHandler(player, "platform", delegate (PhysicsObject a, PhysicsObject b) 
    194199        { 
    195200            ColorTile(a, b); 
    196201        }); 
    197         AddCollisionHandler(player, "crate", delegate(PhysicsObject a, PhysicsObject b) 
     202        AddCollisionHandler(player, "crate", delegate (PhysicsObject a, PhysicsObject b) 
    198203        { 
    199204            GunLottery(player); 
    200205            b.Destroy(); 
    201206        }); 
    202         AddCollisionHandler(player, "death", delegate(PhysicsObject a, PhysicsObject b) 
     207        AddCollisionHandler(player, "death", delegate (PhysicsObject a, PhysicsObject b) 
    203208        { 
    204209            Restore((Player)a); 
     
    220225        { 
    221226            case 0: 
    222                 player.Weapon = new AssaultRifle(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) }; 
     227                player.Weapon = new RocketLauncher(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, player); 
    223228                break; 
    224229            case 1: 
    225                 player.Weapon = new ColorGun(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, player); 
     230                player.Weapon = new GrenadeLauncher(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, player); 
    226231                break; 
    227232            case 2: 
    228                 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) }; 
     233                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) }; 
    229234                break; 
    230235            default: 
     
    233238 
    234239        Timer undo = new Timer() { Interval = 5 }; 
    235         undo.Timeout += delegate() 
     240        undo.Timeout += delegate () 
    236241        { 
    237242            undo.Stop(); 
    238243            player.Weapon = new AssaultRifle(player.Weapon.Width, player.Weapon.Height) 
    239         { 
    240             FireRate = 3, 
    241             AttackSound = null, 
    242             MaxAmmoLifetime = TimeSpan.FromSeconds(8), 
    243             Image = player.Weapon.Image, 
    244             ProjectileCollision = delegate(PhysicsObject a, PhysicsObject b) { ColorTile(a, b); a.Destroy(); }, 
    245             Y = 5, 
    246         }; 
     244            { 
     245                FireRate = 3, 
     246                AttackSound = null, 
     247                MaxAmmoLifetime = TimeSpan.FromSeconds(8), 
     248                Image = player.Weapon.Image, 
     249                ProjectileCollision = delegate (PhysicsObject a, PhysicsObject b) { ColorTile(a, b); a.Destroy(); }, 
     250                Y = 5, 
     251            }; 
    247252        }; 
    248253        undo.Start(); 
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/WeaponCrate.cs

    r7217 r7219  
    1616} 
    1717 
    18 class ColorGun : Weapon 
     18class RocketLauncher : AssaultRifle 
     19{ 
     20    public Player Owner; 
     21 
     22    public RocketLauncher(double leveys, double korkeus, Image image, Player owner) 
     23        : base(leveys, korkeus) 
     24    { 
     25        Image = image; 
     26        AttackSound = null; 
     27        FireRate = 0.5; 
     28        Power.Value = 15; 
     29        Power.DefaultValue = 15; 
     30        Owner = owner; 
     31    } 
     32 
     33    protected override PhysicsObject CreateProjectile() 
     34    { 
     35        var rocket = new Bullet(15); 
     36        rocket.Shape = Shape.Rectangle; 
     37        rocket.MaxVelocity = 1000; 
     38        rocket.Color = Owner.Color; 
     39 
     40        ((Punasininen)Game.Instance).AddCollisionHandler(rocket, (PhysicsObject a, PhysicsObject b) => 
     41        { 
     42            if (b is Tile) 
     43            { 
     44                ((Punasininen)Game).ColorTile(Owner, (Tile)b); 
     45            } 
     46        }); 
     47 
     48        var updateTimer = new Timer(); 
     49        updateTimer.Interval = 0.01; 
     50        updateTimer.Timeout += () => 
     51        { 
     52            rocket.Velocity *= 1.03; 
     53 
     54            var particle = new PhysicsObject(8, 8); 
     55            particle.IgnoresCollisionResponse = true; 
     56            particle.IgnoresGravity = true; 
     57            particle.Color = rocket.Color; 
     58            particle.Position = rocket.Position; 
     59            particle.LifetimeLeft = TimeSpan.FromSeconds(0.5); 
     60            particle.FadeColorTo(Color.Black, 0.5); 
     61            var angle = (-rocket.Velocity).Angle + Angle.FromDegrees(RandomGen.NextDouble(-30, 30)); 
     62            particle.Velocity = Vector.FromLengthAndAngle(RandomGen.NextDouble(50,300), angle); 
     63            Game.Instance.Add(particle); 
     64        }; 
     65        updateTimer.Start(); 
     66 
     67        var explosionTimer = new Timer(); 
     68        explosionTimer.Interval = 10; 
     69        explosionTimer.Timeout += () => 
     70        { 
     71            updateTimer.Stop(); 
     72            explosionTimer.Stop(); 
     73            rocket.Destroy(); 
     74 
     75            var explosion = new Explosion(100); 
     76            explosion.Position = rocket.Position; 
     77            explosion.ShockwaveColor = Owner.Color; 
     78            explosion.MaxRadius = 150; 
     79            explosion.Speed = 500; 
     80            explosion.Sound = null; 
     81            explosion.ShockwaveReachesObject += (IPhysicsObject a, Vector b) => 
     82            { 
     83                if (a is Tile) 
     84                { 
     85                    ((Punasininen)Game).ColorTile(Owner, (Tile)a); 
     86                } 
     87            }; 
     88            ((Punasininen)Game.Instance).Add(explosion); 
     89        }; 
     90        explosionTimer.Start(); 
     91 
     92        return rocket; 
     93    } 
     94} 
     95 
     96class GrenadeLauncher : Weapon 
    1997{ 
    2098    public Player Owner; 
     
    24102        Grenade test = new Grenade(10, TimeSpan.FromSeconds(1)); 
    25103        test.Explosion.ShockwaveColor = Owner.Color; 
    26         test.Explosion.Size *= 3; 
     104        test.Explosion.MaxRadius = 300; 
     105        test.Explosion.Speed = 1000; 
    27106        test.Explosion.Sound = null; 
    28107        test.Explosion.ShockwaveReachesObject += delegate(IPhysicsObject a, Vector b)  
     
    33112            } 
    34113        }; 
     114        Timer.SingleShot(1, () => ((Punasininen)Game.Instance).NewWave(test.Position)); 
    35115        return test; 
    36116    } 
    37117 
    38     public ColorGun(double leveys, double korkeus, Image image, Player owner) 
     118    public GrenadeLauncher(double leveys, double korkeus, Image image, Player owner) 
    39119        : base(leveys, korkeus) 
    40120    { 
Note: See TracChangeset for help on using the changeset viewer.