public void AddAsteroidType(AsteroidType aNewType, double aChance = 0) { lock (mAsteroidsTypes) { mAsteroidsTypes.Add(aNewType, aChance); } }
public void SetChance(AsteroidType aType, double aNewChance) { lock (mAsteroidsTypes) { if (mAsteroidsTypes.ContainsKey(aType)) { mAsteroidsTypes[aType] = aNewChance; } } }
public void DeleteAsteroidType(AsteroidType aType) { lock (mAsteroidsTypes) { if (mAsteroidsTypes.ContainsKey(aType)) { mAsteroidsTypes.Remove(aType); } } }
private Asteroid CreateAsteroid(AsteroidType aType) { double lAsteroidX = 0; double lAsteroidY = 0; double lDirection = 0; double lAsteroidSize = aType.MinSize + mRandom.NextDouble() * (aType.MaxSize - aType.MinSize); //left /right if (mRandom.Next(2) == 0) { lAsteroidY = mRandom.Next((int)GameRoom.RoomHeight); //left if (mRandom.Next(2) == 0) { lAsteroidX = -lAsteroidSize / 2; lDirection = -90 + mRandom.Next(181); } else//right { lAsteroidX = (int)GameRoom.RoomWidth + lAsteroidSize / 2; lDirection = 90 + mRandom.Next(181); } } else //top/bottom { lAsteroidX = mRandom.Next((int)GameRoom.RoomWidth); //top if (mRandom.Next(2) == 0) { lAsteroidY = -lAsteroidSize / 2; lDirection = mRandom.Next(181); } else //bottom { lAsteroidY = (int)GameRoom.RoomHeight + lAsteroidSize / 2; lDirection = 180 + mRandom.Next(181); } } double lRotationSpeed = (mRandom.NextDouble() - .5) * 2 * aType.MaxRotationSpeed; AsteroidSettings lSettings = new AsteroidSettings() { MinSizeForChildren = aType.MinSizeForChildren, MissileDamage = aType.MissileDamage, ProjectileDamage = aType.ProjectileDamage, Size = lAsteroidSize, Strength = aType.Strength, TypeName = aType.TypeName, PointsMultiplier = aType.PointsMultiplier, RotationSpeed = lRotationSpeed }; double lSpeed = aType.MinSpeed + mRandom.NextDouble() * (aType.MaxSpeed - aType.MinSpeed); return(new Asteroid(aType.BitmapFrame, aType.ExplosionFrame, new Point(lAsteroidX, lAsteroidY), lDirection, lSpeed, lSettings)); }
private void GenerateAsteroidTypes() { AsteroidType lType1 = new AsteroidType() { BitmapFrame = mAsteroidBitmapFrame, ExplosionFrame = mExplosionBitmapFrame, MaxSize = 64, MinSize = 48, MinSizeForChildren = 16, MinSpeed = 2, MaxSpeed = 4, MissileDamage = 1, PointsMultiplier = 1, ProjectileDamage = 1, Strength = 1, TypeName = "Basic", MaxRotationSpeed = 4 }; ChancesLineConfiguration lChances1 = new ChancesLineConfiguration() { MaxChance = 0.18, MaxChanceScore = 18000, MinChance = 0.01, MinChanceScore = 0 }; AsteroidType lType2 = new AsteroidType() { BitmapFrame = mAsteroid2BitmapFrame, ExplosionFrame = mExplosionBitmapFrame, MaxSize = 128, MinSize = 80, MinSizeForChildren = 32, MinSpeed = 2, MaxSpeed = 3, MissileDamage = 0.5, PointsMultiplier = 2.5, ProjectileDamage = 0.2, Strength = 2, TypeName = "Advanced", MaxRotationSpeed = 1 }; ChancesLineConfiguration lChances2 = new ChancesLineConfiguration() { MaxChance = 0.02, MaxChanceScore = 50000, MinChance = 0.000, MinChanceScore = 4000 }; AsteroidType lType3 = new AsteroidType() { BitmapFrame = mAsteroid3BitmapFrame, ExplosionFrame = mExplosionBitmapFrame, MaxSize = 48, MinSize = 24, MinSizeForChildren = 96, MinSpeed = 8, MaxSpeed = 12, MissileDamage = 0.5, PointsMultiplier = 3.5, ProjectileDamage = 0.05, Strength = 8, TypeName = "Elite", MaxRotationSpeed = 0 }; ChancesLineConfiguration lChances3 = new ChancesLineConfiguration() { MaxChance = 0.015, MaxChanceScore = 40000, MinChance = 0.00, MinChanceScore = 10000 }; mAsteroidTypes.Add(lType1, lChances1); mAsteroidTypes.Add(lType2, lChances2); mAsteroidTypes.Add(lType3, lChances3); }