Changeset 7217


Ignore:
Timestamp:
2016-06-09 21:12:07 (7 years ago)
Author:
empaheik
Message:

ruma aseviritelmä ahoy

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

Legend:

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

    r7216 r7217  
    1313    private const double JUMPSPEED = 1250; 
    1414    private const int TILE_SIZE = 60; 
    15     private const int MATCH_LENGTH = 30; 
     15    private const int MATCH_LENGTH = 60; 
    1616 
    1717    private Player blue; 
     
    3737    DoubleMeter percentageTracker; 
    3838 
     39    Dictionary<Vector, WeaponCrate> cratePositions = new Dictionary<Vector, WeaponCrate>(); 
     40 
    3941    private Shader shader; 
    4042 
     
    6365 
    6466        ColorTileMap map = ColorTileMap.FromLevelAsset("dungeon1"); 
    65         map.SetTileMethod(Color.Black, AddPlatform); 
    66         map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate (Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, blueColor, blueWalkImages, bluePistolpic); }); 
    67         map.SetTileMethod(Color.FromHexCode("FFD800"), CreateWeaponCrate); 
    68         map.SetTileMethod(Color.Red, delegate (Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redColor, orangeWalkImages, orangePistolpic); }); 
     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); }); 
    6971        map.Execute(TILE_SIZE, TILE_SIZE); 
    7072 
    71         Surface bottom = Surface.CreateBottom(Level); 
    72         bottom.Width *= 5; 
    73         bottom.Y -= Level.Height / 2; 
     73        Tile bottom = AddPlatform(new Vector(0, Level.Bottom - 100), Level.Width * 4, 100); 
    7474        bottom.Tag = "death"; 
    75         bottom.Color = Color.HanPurple; //terveisin 
    7675        Add(bottom); 
    7776 
     
    9695        }); 
    9796 
     97        Timer spawnTimer = new Timer() { }; 
     98 
    9899        Camera.ZoomToLevel(); 
    99100        Level.Background.Color = Color.Black; 
     
    146147    } 
    147148 
    148     void CreateWeaponCrate(Vector place, double width, double height) 
     149    WeaponCrate CreateWeaponCrate(Vector place, double width, double height) 
    149150    { 
    150151        WeaponCrate crate = new WeaponCrate(width, height); 
     
    156157 
    157158        crate.Oscillate(Vector.UnitY, 10, 0.4); 
    158     } 
    159  
    160     void AddPlatform(Vector paikka, double leveys, double korkeus) 
     159 
     160        return crate; 
     161    } 
     162 
     163    Tile AddPlatform(Vector paikka, double leveys, double korkeus) 
    161164    { 
    162165        Tile platform = new Tile(leveys, korkeus, paikka); 
     
    165168        platform.Tag = "platform"; 
    166169        Add(platform); 
     170        return platform; 
    167171    } 
    168172 
     
    181185            AttackSound = null, 
    182186            MaxAmmoLifetime = TimeSpan.FromSeconds(8), 
    183             ProjectileCollision = BulletHitsSomething, 
     187            ProjectileCollision = delegate(PhysicsObject a, PhysicsObject b) { ColorTile(a, b); a.Destroy(); }, 
     188            // ProjectileCollision = BulletHitsSomething, 
    184189            Image = pistolPic, 
    185190            Y = 5 
    186191        }; 
    187192 
    188         AddCollisionHandler(player, "platform", delegate (PhysicsObject a, PhysicsObject b) 
     193        AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 
    189194        { 
    190195            ColorTile(a, b); 
    191196        }); 
    192         AddCollisionHandler(player, "crate", delegate (PhysicsObject a, PhysicsObject b) 
     197        AddCollisionHandler(player, "crate", delegate(PhysicsObject a, PhysicsObject b) 
    193198        { 
    194199            GunLottery(player); 
    195200            b.Destroy(); 
    196201        }); 
    197         AddCollisionHandler(player, "death", delegate (PhysicsObject a, PhysicsObject b) 
     202        AddCollisionHandler(player, "death", delegate(PhysicsObject a, PhysicsObject b) 
    198203        { 
    199204            Restore((Player)a); 
     
    208213    } 
    209214 
    210     void BulletHitsSomething(PhysicsObject bullet, PhysicsObject target) 
    211     { 
    212         if (target.Tag.ToString() == "platform") 
    213         { 
    214             // TODO bullet must know its owner 
    215             if (bullet.Color == blueColor) 
    216             { 
    217                 ColorTile(blue, target); 
    218             } 
    219             else if (bullet.Color == redColor) 
    220             { 
    221                 ColorTile(red, target); 
    222             } 
    223         } 
    224         bullet.Destroy(); 
    225     } 
    226  
    227215    void GunLottery(Player player) 
    228216    { 
    229         player.Weapon = new ColorGun(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, player, this); 
     217        int hurdur = RandomGen.NextInt(0, 3); 
     218 
     219        switch (hurdur) 
     220        { 
     221            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) }; 
     223                break; 
     224            case 1: 
     225                player.Weapon = new ColorGun(player.Weapon.Width, player.Weapon.Height, player.Weapon.Image, player); 
     226                break; 
     227            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) }; 
     229                break; 
     230            default: 
     231                break; 
     232        }; 
     233 
     234        Timer undo = new Timer() { Interval = 5 }; 
     235        undo.Timeout += delegate() 
     236        { 
     237            undo.Stop(); 
     238            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        }; 
     247        }; 
     248        undo.Start(); 
     249 
    230250    } 
    231251 
     
    258278        zoomTimer.IgnorePause = true; 
    259279        zoomTimer.Start(); 
     280 
     281        cratePositions.Clear(); 
    260282    } 
    261283 
     
    265287        var glowImg = player.Color == blueColor ? blueGlow : orangeGlow; 
    266288 
    267         ((Tile)platform).SetColor(imgs, glowImg, player.Color, UpdatePercentage); 
     289        if (platform is Tile) 
     290        { 
     291            ((Tile)platform).SetColor(imgs, glowImg, player.Color, UpdatePercentage); 
     292        } 
    268293    } 
    269294 
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/WeaponCrate.cs

    r7211 r7217  
    2020    public Player Owner; 
    2121 
    22     public Game MyGame; 
    23  
    2422    protected override PhysicsObject CreateProjectile() 
    2523    { 
    2624        Grenade test = new Grenade(10, TimeSpan.FromSeconds(1)); 
    2725        test.Explosion.ShockwaveColor = Owner.Color; 
     26        test.Explosion.Size *= 3; 
     27        test.Explosion.Sound = null; 
     28        test.Explosion.ShockwaveReachesObject += delegate(IPhysicsObject a, Vector b)  
     29        { 
     30            if (a is Tile) 
     31            { 
     32                ((Punasininen)Game).ColorTile(test, (Tile)a); 
     33            } 
     34        }; 
    2835        return test; 
    2936    } 
    3037 
    31     public ColorGun(double leveys, double korkeus, Image image, Player owner, Game game) 
     38    public ColorGun(double leveys, double korkeus, Image image, Player owner) 
    3239        : base(leveys, korkeus) 
    3340    { 
     
    3542        AttackSound = null; 
    3643        FireRate = 1; 
    37         Power.DefaultValue = 15000; 
     44        Power.DefaultValue = 30000; 
    3845        Owner = owner; 
    39         MyGame = game; 
    4046        
    4147    } 
  • 2016/23/ohjaajat/Punasininen/Punasininen/PunasininenContent/PunasininenContent.contentproj

    r7216 r7217  
    1616  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> 
    1717    <PlatformTarget>x86</PlatformTarget> 
     18    <UseVSHostingProcess>true</UseVSHostingProcess> 
    1819  </PropertyGroup> 
    1920  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> 
Note: See TracChangeset for help on using the changeset viewer.