Changeset 7217
- Timestamp:
- 2016-06-09 21:12:07 (7 years ago)
- Location:
- 2016/23/ohjaajat/Punasininen/Punasininen
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Punasininen.cs
r7216 r7217 13 13 private const double JUMPSPEED = 1250; 14 14 private const int TILE_SIZE = 60; 15 private const int MATCH_LENGTH = 30;15 private const int MATCH_LENGTH = 60; 16 16 17 17 private Player blue; … … 37 37 DoubleMeter percentageTracker; 38 38 39 Dictionary<Vector, WeaponCrate> cratePositions = new Dictionary<Vector, WeaponCrate>(); 40 39 41 private Shader shader; 40 42 … … 63 65 64 66 ColorTileMap map = ColorTileMap.FromLevelAsset("dungeon1"); 65 map.SetTileMethod(Color.Black, AddPlatform);66 map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate 67 map.SetTileMethod(Color.FromHexCode("FFD800"), CreateWeaponCrate);68 map.SetTileMethod(Color.Red, delegate 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); }); 69 71 map.Execute(TILE_SIZE, TILE_SIZE); 70 72 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); 74 74 bottom.Tag = "death"; 75 bottom.Color = Color.HanPurple; //terveisin76 75 Add(bottom); 77 76 … … 96 95 }); 97 96 97 Timer spawnTimer = new Timer() { }; 98 98 99 Camera.ZoomToLevel(); 99 100 Level.Background.Color = Color.Black; … … 146 147 } 147 148 148 voidCreateWeaponCrate(Vector place, double width, double height)149 WeaponCrate CreateWeaponCrate(Vector place, double width, double height) 149 150 { 150 151 WeaponCrate crate = new WeaponCrate(width, height); … … 156 157 157 158 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) 161 164 { 162 165 Tile platform = new Tile(leveys, korkeus, paikka); … … 165 168 platform.Tag = "platform"; 166 169 Add(platform); 170 return platform; 167 171 } 168 172 … … 181 185 AttackSound = null, 182 186 MaxAmmoLifetime = TimeSpan.FromSeconds(8), 183 ProjectileCollision = BulletHitsSomething, 187 ProjectileCollision = delegate(PhysicsObject a, PhysicsObject b) { ColorTile(a, b); a.Destroy(); }, 188 // ProjectileCollision = BulletHitsSomething, 184 189 Image = pistolPic, 185 190 Y = 5 186 191 }; 187 192 188 AddCollisionHandler(player, "platform", delegate 193 AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 189 194 { 190 195 ColorTile(a, b); 191 196 }); 192 AddCollisionHandler(player, "crate", delegate 197 AddCollisionHandler(player, "crate", delegate(PhysicsObject a, PhysicsObject b) 193 198 { 194 199 GunLottery(player); 195 200 b.Destroy(); 196 201 }); 197 AddCollisionHandler(player, "death", delegate 202 AddCollisionHandler(player, "death", delegate(PhysicsObject a, PhysicsObject b) 198 203 { 199 204 Restore((Player)a); … … 208 213 } 209 214 210 void BulletHitsSomething(PhysicsObject bullet, PhysicsObject target)211 {212 if (target.Tag.ToString() == "platform")213 {214 // TODO bullet must know its owner215 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 227 215 void GunLottery(Player player) 228 216 { 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 230 250 } 231 251 … … 258 278 zoomTimer.IgnorePause = true; 259 279 zoomTimer.Start(); 280 281 cratePositions.Clear(); 260 282 } 261 283 … … 265 287 var glowImg = player.Color == blueColor ? blueGlow : orangeGlow; 266 288 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 } 268 293 } 269 294 -
2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/WeaponCrate.cs
r7211 r7217 20 20 public Player Owner; 21 21 22 public Game MyGame;23 24 22 protected override PhysicsObject CreateProjectile() 25 23 { 26 24 Grenade test = new Grenade(10, TimeSpan.FromSeconds(1)); 27 25 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 }; 28 35 return test; 29 36 } 30 37 31 public ColorGun(double leveys, double korkeus, Image image, Player owner , Game game)38 public ColorGun(double leveys, double korkeus, Image image, Player owner) 32 39 : base(leveys, korkeus) 33 40 { … … 35 42 AttackSound = null; 36 43 FireRate = 1; 37 Power.DefaultValue = 15000;44 Power.DefaultValue = 30000; 38 45 Owner = owner; 39 MyGame = game;40 46 41 47 } -
2016/23/ohjaajat/Punasininen/Punasininen/PunasininenContent/PunasininenContent.contentproj
r7216 r7217 16 16 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> 17 17 <PlatformTarget>x86</PlatformTarget> 18 <UseVSHostingProcess>true</UseVSHostingProcess> 18 19 </PropertyGroup> 19 20 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
Note: See TracChangeset
for help on using the changeset viewer.