public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { long operand1 = this.operand1.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long operand2 = this.operand2.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (this.changeUndefinedOutputToZero && operand1 == 0L && operand2 == 0L) { return(0); } return(DTMath.ArcTangentScaled(operand1, operand2)); }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { long value = this.operand.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (value == long.MinValue) { return(long.MinValue); } if (value < 0) { return(-value); } return(value); }
public InitialLoadingScreenFrame(int fps, IDTDeterministicRandom rng, GuidGenerator guidGenerator, bool debugMode) { this.fps = fps; this.rng = rng; this.guidGenerator = guidGenerator; this.debugMode = debugMode; }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { long operand1 = this.operand1.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long operand2 = this.operand2.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (operand2 == 0) { throw new Exception(); } return(unchecked (operand1 / operand2)); }
public GameOverFrame(int fps, IDTDeterministicRandom rng, GuidGenerator guidGenerator, int soundVolume, bool debugMode) { this.fps = fps; this.rng = rng; this.guidGenerator = guidGenerator; this.soundVolume = soundVolume; this.debugMode = debugMode; }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { long randomExclusiveBound = this.operand.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (randomExclusiveBound <= 0) { throw new Exception(); } long randomByte1 = rng.NextInt(128); long randomByte2 = rng.NextInt(256); long randomByte3 = rng.NextInt(256); long randomByte4 = rng.NextInt(256); long randomByte5 = rng.NextInt(256); long randomByte6 = rng.NextInt(256); long randomByte7 = rng.NextInt(256); long randomByte8 = rng.NextInt(256); long randomLong = (randomByte1 << 56) | (randomByte2 << 48) | (randomByte3 << 40) | (randomByte4 << 32) | (randomByte5 << 24) | (randomByte6 << 16) | (randomByte7 << 8) | (randomByte8); if (randomLong < 0) { randomLong = unchecked (-randomLong); } if (randomLong < 0) { randomLong = 0; } if (randomExclusiveBound == 1) { return(0); } // Note that this isn't perfectly uniform for large values of randomExclusiveBound // but it'll decent enough for now. long randomVal = randomLong % randomExclusiveBound; return(randomVal); }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { return(this.value); }
private bool isContinueSelected; // as opposed to "quit" being selected public GamePausedScreenFrame(GameInProgressFrame frame, int fps, IDTDeterministicRandom rng, GuidGenerator guidGenerator, int soundVolume, bool debugMode) { this.fps = fps; this.rng = rng; this.guidGenerator = guidGenerator; this.soundVolumePicker = new SoundVolumePicker(xPos: 0, yPos: 650, initialVolume: soundVolume); this.gameInProgressFrame = frame; this.isContinueSelected = true; this.debugMode = debugMode; }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { if (enemyObjectExpressionInfo == null) { throw new Exception(); } return(enemyObjectExpressionInfo.YMillis); }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { long operand = this.operand.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(DTMath.CosineScaled(operand)); }
public TitleScreenFrame( int fps, IDTDeterministicRandom rng, GuidGenerator guidGenerator, int?soundVolume, bool debugMode) { this.fps = fps; this.rng = rng; this.guidGenerator = guidGenerator; this.soundVolumePicker = soundVolume.HasValue ? new SoundVolumePicker(xPos: 0, yPos: 650, initialVolume: soundVolume.Value) : new SoundVolumePicker(xPos: 0, yPos: 650); this.debugMode = debugMode; }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { if (enemyObjectExpressionInfo == null) { throw new Exception(); } if (enemyObjectExpressionInfo.Parent == null) { throw new Exception(); } return(enemyObjectExpressionInfo.Parent.NumericVariables[this.variableName]); }
// Returns true if player still has at least one life remaining // Returns false if game over public bool DestroyPlayer( List <EnemyObject> enemyObjects, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { if (this.isDead) { throw new Exception(); } long playerXMillis = this.xMillis; long playerYMillis = this.yMillis; EnemyObjectTemplate template = EnemyObjectTemplate.Placeholder(action: ObjectAction.ConditionalNextAction( currentAction: this.playerDeathSpawnDestructionAnimationAction, condition: BooleanExpression.True(), nextAction: ObjectAction.Destroy())); enemyObjects.Add(new EnemyObject( template: template, initialXMillis: playerXMillis, initialYMillis: playerYMillis, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, isPlayerDestroyed: true, parent: null, initialNumericVariables: null, initialBooleanVariables: null, rng: rng)); this.isDead = true; if (this.numLivesLeft > 0) { this.numLivesLeft = this.numLivesLeft - 1; this.respawnTimeRemainingMillis = 750; return(true); } else { return(false); } }
public GameInProgressFrame( int fps, IDTDeterministicRandom rng, GuidGenerator guidGenerator, int soundVolume, bool debugMode) { this.fps = fps; this.rng = rng; this.guidGenerator = guidGenerator; this.gameLogic = new GameLogic( fps: fps, rng: rng, guidGenerator: guidGenerator, soundVolume: soundVolume, debugMode: debugMode); this.debugMode = debugMode; }
public long Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { long operand1 = this.operand1.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long operand2 = this.operand2.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(operand1 > operand2 ? operand1 : operand2); }
private static EnemyObject CreateActionExecutor( long millisecondsToWait, ObjectAction action, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng, GuidGenerator guidGenerator) { return(new EnemyObject( template: EnemyObjectTemplate.Placeholder( action: ObjectActionGenerator.Delay( action: ObjectAction.Union(action, ObjectAction.Destroy()), milliseconds: millisecondsToWait, guidGenerator: guidGenerator)), initialXMillis: 0, initialYMillis: 0, playerXMillis: 0, playerYMillis: 0, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, isPlayerDestroyed: false, parent: null, initialNumericVariables: null, initialBooleanVariables: null, rng: rng)); }
public static GenerateEnemiesResult GenerateEnemies( long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng, GuidGenerator guidGenerator) { List <EnemyObject> enemyObjects = new List <EnemyObject>(); Dictionary <string, DTDanmakuImage> spriteNameToImageDictionary = new Dictionary <string, DTDanmakuImage>(); Dictionary <string, EnemyObjectTemplate> enemyObjectTemplates = new Dictionary <string, EnemyObjectTemplate>(); Dictionary <string, DTDanmakuSound> soundNameToSoundDictionary = new Dictionary <string, DTDanmakuSound>(); ObjectAction spawnWave1Enemy = GenerateWave1Enemy( spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnWave2Enemy = GenerateWave2Enemy( spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnWave3Enemy = GenerateWave3Enemy( spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnWave4Enemy = GenerateWave4Enemy( spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnSniperEnemy = SniperEnemyGenerator.SpawnSniperEnemy( spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnEliteSniperEnemy = EliteSniperEnemyGenerator.SpawnEliteSniperEnemy( spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnOrbiterEnemy = OrbiterEnemyGenerator.SpawnOrbiterEnemy( xMillis: MathExpression.Add(MathExpression.Constant(300 * 1000), MathExpression.RandomInteger(400 * 1000)), spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnEliteOrbiterEnemy = EliteOrbiterEnemyGenerator.SpawnEliteOrbiterEnemy( xMillis: MathExpression.Add(MathExpression.Constant(300 * 1000), MathExpression.RandomInteger(400 * 1000)), spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnBarrageEnemy = BarrageEnemyGenerator.SpawnBarrageEnemy( xMillis: MathExpression.Add(MathExpression.Constant(300 * 1000), MathExpression.RandomInteger(400 * 1000)), spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnEliteBarrageEnemy = EliteBarrageEnemyGenerator.SpawnEliteBarrageEnemy( xMillis: MathExpression.Add(MathExpression.Constant(300 * 1000), MathExpression.RandomInteger(400 * 1000)), spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); ObjectAction spawnBoss = BossEnemyGenerator.SpawnBossEnemy( spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary, guidGenerator: guidGenerator); for (int i = 0; i < 10; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 1000 * i, action: spawnWave1Enemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 10; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 3000 + 1000 * i, action: spawnWave2Enemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 6; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 16000 + 1000 * i, action: spawnSniperEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 6; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 20000 + 6000 * i, action: spawnOrbiterEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 6; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 23000 + 1500 * i, action: spawnWave3Enemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 6; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 25500 + 1500 * i, action: spawnWave4Enemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 4; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 29000 + 1700 * i, action: spawnBarrageEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 7; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 33000 + 1250 * i, action: spawnEliteSniperEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 4; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 38000 + 2100 * i, action: spawnEliteBarrageEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 8; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 43000 + 500 * i, action: spawnSniperEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 8; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 43250 + 500 * i, action: spawnEliteSniperEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } for (int i = 0; i < 2; i++) { enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 56000 + 6000 * i, action: spawnEliteOrbiterEnemy, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); } enemyObjects.Add(CreateActionExecutor( millisecondsToWait: 82000, action: spawnBoss, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng, guidGenerator: guidGenerator)); return(new GenerateEnemiesResult( enemyObjects: enemyObjects, spriteNameToImageDictionary: spriteNameToImageDictionary, enemyObjectTemplates: enemyObjectTemplates, soundNameToSoundDictionary: soundNameToSoundDictionary)); }
private static ResultOfAction HandleAction( ObjectAction action, EnemyObject obj, long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, bool isPlayerDestroyed, Dictionary <string, EnemyObjectTemplate> enemyObjectTemplates, IDTDeterministicRandom rng) { bool?isParentDestroyed; if (obj.ParentObject == null) { isParentDestroyed = null; } else { isParentDestroyed = obj.ParentObject.IsDestroyed; } switch (action.ObjectActionType) { case ObjectAction.Type.Move: case ObjectAction.Type.StrafeMove: long desiredX = action.MoveToXMillis.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long desiredY = action.MoveToYMillis.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long?directionInMillidegrees = DTDanmakuMath.GetMovementDirectionInMillidegrees(currentX: obj.XMillis, currentY: obj.YMillis, desiredX: desiredX, desiredY: desiredY); if (directionInMillidegrees != null) { obj.MovementDirectionInMillidegrees = directionInMillidegrees.Value; if (action.ObjectActionType == ObjectAction.Type.Move) { obj.FacingDirectionInMillidegrees = directionInMillidegrees.Value; } else if (action.ObjectActionType == ObjectAction.Type.StrafeMove) { obj.FacingDirectionInMillidegrees = 180L * 1000L; } else { throw new Exception(); } } return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SetSpeed: case ObjectAction.Type.IncreaseSpeed: case ObjectAction.Type.DecreaseSpeed: long speed = action.SpeedInMillipixelsPerMillisecond.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (action.ObjectActionType == ObjectAction.Type.SetSpeed) { obj.SpeedInMillipixelsPerMillisecond = speed; } else if (action.ObjectActionType == ObjectAction.Type.IncreaseSpeed) { obj.SpeedInMillipixelsPerMillisecond += speed; } else if (action.ObjectActionType == ObjectAction.Type.DecreaseSpeed) { obj.SpeedInMillipixelsPerMillisecond -= speed; } else { throw new Exception(); } if (obj.SpeedInMillipixelsPerMillisecond < 0) { obj.SpeedInMillipixelsPerMillisecond = 0; } return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SetPosition: long newXMillisPosition = action.SetXMillisPosition.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long newYMillisPosition = action.SetYMillisPosition.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); obj.XMillis = newXMillisPosition; obj.YMillis = newYMillisPosition; return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SetFacingDirection: long newFacingDirection = action.SetFacingDirectionInMillidegrees.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); obj.FacingDirectionInMillidegrees = newFacingDirection; return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.Destroy: obj.IsDestroyed = true; return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.DestroyParent: if (obj.ParentObject == null) { throw new Exception(); } obj.ParentObject.IsDestroyed = true; return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SpawnChild: long childXMillis = action.SpawnChildXMillis.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long childYMillis = action.SpawnChildYMillis.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); EnemyObjectTemplate childObjectTemplate = enemyObjectTemplates[action.SpawnChildObjectTemplateName]; var childObjectNumericVariables = new Dictionary <string, IMathExpression>(); var childObjectBooleanVariables = new Dictionary <string, BooleanExpression>(); if (action.SpawnChildInitialChildNumericVariables != null) { for (int i = 0; i < action.SpawnChildInitialChildNumericVariables.Count; i++) { childObjectNumericVariables.Add(action.SpawnChildInitialChildNumericVariables[i].Name, action.SpawnChildInitialChildNumericVariables[i].Value); } } if (action.SpawnChildInitialChildBooleanVariables != null) { for (int i = 0; i < action.SpawnChildInitialChildBooleanVariables.Count; i++) { childObjectBooleanVariables.Add(action.SpawnChildInitialChildBooleanVariables[i].Name, action.SpawnChildInitialChildBooleanVariables[i].Value); } } var newEnemyObjects = new List <EnemyObject>(); newEnemyObjects.Add(new EnemyObject( template: childObjectTemplate, initialXMillis: childXMillis, initialYMillis: childYMillis, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, isPlayerDestroyed: isPlayerDestroyed, parent: obj, initialNumericVariables: childObjectNumericVariables, initialBooleanVariables: childObjectBooleanVariables, rng: rng)); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: newEnemyObjects, newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SpawnPowerUp: var powerUpList = new List <Tuple <long, long> >(); powerUpList.Add(new Tuple <long, long>(obj.XMillis, obj.YMillis)); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: powerUpList, newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SetNumericVariable: obj.NumericVariables[action.SetVariableName] = action.SetNumericVariableValue.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SetBooleanVariable: obj.BooleanVariables[action.SetVariableName] = action.SetBooleanVariableValue.Evaluate( obj.GetEnemyObjectExpressionInfo(), isParentDestroyed: isParentDestroyed, isPlayerDestroyed: isPlayerDestroyed, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SetParentNumericVariable: if (obj.ParentObject == null) { throw new Exception(); } obj.ParentObject.NumericVariables[action.SetVariableName] = action.SetNumericVariableValue.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.SetParentBooleanVariable: { if (obj.ParentObject == null) { throw new Exception(); } obj.ParentObject.BooleanVariables[action.SetVariableName] = action.SetBooleanVariableValue.Evaluate( obj.GetEnemyObjectExpressionInfo(), isParentDestroyed: obj.ParentObject.IsDestroyed, isPlayerDestroyed: isPlayerDestroyed, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); } case ObjectAction.Type.EndLevel: return(new ResultOfAction( newObjectAction: action, shouldEndLevel: true, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.PlaySoundEffect: { var newSoundEffectsToPlay = new List <string>(); newSoundEffectsToPlay.Add(action.SoundEffectName); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: newSoundEffectsToPlay, bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); } case ObjectAction.Type.DisplayBossHealthBar: { long bossHealthMeterNumber = action.BossHealthBarMeterNumber.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long bossHealthMeterMilliPercentage = action.BossHealthBarMilliPercentage.Evaluate( obj.GetEnemyObjectExpressionInfo(), playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: bossHealthMeterNumber, bossHealthMeterMilliPercentage: bossHealthMeterMilliPercentage)); } case ObjectAction.Type.SetSpriteName: obj.SpriteName = action.SpriteName; return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); case ObjectAction.Type.Conditional: bool shouldExecute = action.Conditional.Evaluate( obj.GetEnemyObjectExpressionInfo(), isParentDestroyed: isParentDestroyed, isPlayerDestroyed: isPlayerDestroyed, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (shouldExecute) { var a = HandleAction( action: action.ConditionalAction, obj: obj, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, isPlayerDestroyed: isPlayerDestroyed, enemyObjectTemplates: enemyObjectTemplates, rng: rng); return(new ResultOfAction( newObjectAction: ObjectAction.Condition(action.Conditional, a.NewObjectAction), shouldEndLevel: a.ShouldEndLevel, newEnemyObjects: a.NewEnemyObjects, newPowerUps: a.NewPowerUps, newSoundEffectsToPlay: a.NewSoundEffectsToPlay, bossHealthMeterNumber: a.BossHealthMeterNumber, bossHealthMeterMilliPercentage: a.BossHealthMeterMilliPercentage)); } else { return(new ResultOfAction( newObjectAction: action, shouldEndLevel: false, newEnemyObjects: new List <EnemyObject>(), newPowerUps: new List <Tuple <long, long> >(), newSoundEffectsToPlay: new List <string>(), bossHealthMeterNumber: null, bossHealthMeterMilliPercentage: null)); } case ObjectAction.Type.ConditionalNextAction: ResultOfAction actionResult = HandleAction( action: action.ConditionalNextActionCurrentAction, obj: obj, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, isPlayerDestroyed: isPlayerDestroyed, enemyObjectTemplates: enemyObjectTemplates, rng: rng); bool shouldMoveToNext = action.ConditionalNextActionConditional.Evaluate( obj.GetEnemyObjectExpressionInfo(), isParentDestroyed: isParentDestroyed, isPlayerDestroyed: isPlayerDestroyed, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); return(new ResultOfAction( newObjectAction: shouldMoveToNext ? action.ConditionalNextActionNextAction : ObjectAction.ConditionalNextAction(actionResult.NewObjectAction, action.ConditionalNextActionConditional, action.ConditionalNextActionNextAction), shouldEndLevel: actionResult.ShouldEndLevel, newEnemyObjects: actionResult.NewEnemyObjects, newPowerUps: actionResult.NewPowerUps, newSoundEffectsToPlay: actionResult.NewSoundEffectsToPlay, bossHealthMeterNumber: actionResult.BossHealthMeterNumber, bossHealthMeterMilliPercentage: actionResult.BossHealthMeterMilliPercentage)); case ObjectAction.Type.Union: { bool shouldEndLevel = false; var newUnionActions = new List <ObjectAction>(); var enemyObjects = new List <EnemyObject>(); var newPowerUps = new List <Tuple <long, long> >(); var newSoundEffectsToPlay = new List <string>(); long?bossHealthMeterNumber = null; long?bossHealthMeterMilliPercentage = null; for (var i = 0; i < action.UnionActions.Count; i++) { ResultOfAction r = HandleAction( action: action.UnionActions[i], obj: obj, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, isPlayerDestroyed: isPlayerDestroyed, enemyObjectTemplates: enemyObjectTemplates, rng: rng); newUnionActions.Add(r.NewObjectAction); if (r.ShouldEndLevel) { shouldEndLevel = true; } foreach (EnemyObject newEnemyObj in r.NewEnemyObjects) { enemyObjects.Add(newEnemyObj); } foreach (var newPowerUp in r.NewPowerUps) { newPowerUps.Add(newPowerUp); } foreach (var newSoundEffect in r.NewSoundEffectsToPlay) { newSoundEffectsToPlay.Add(newSoundEffect); } if (r.BossHealthMeterNumber != null) { bossHealthMeterNumber = r.BossHealthMeterNumber; } if (r.BossHealthMeterMilliPercentage != null) { bossHealthMeterMilliPercentage = r.BossHealthMeterMilliPercentage; } } return(new ResultOfAction( newObjectAction: ObjectAction.Union(newUnionActions), shouldEndLevel: shouldEndLevel, newEnemyObjects: enemyObjects, newPowerUps: newPowerUps, newSoundEffectsToPlay: newSoundEffectsToPlay, bossHealthMeterNumber: bossHealthMeterNumber, bossHealthMeterMilliPercentage: bossHealthMeterMilliPercentage)); } default: throw new Exception(); } }
public bool Evaluate( EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable bool?isParentDestroyed, // null if parent doesn't exist bool isPlayerDestroyed, long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, IDTDeterministicRandom rng) { switch (this.BooleanExpressionType) { case Type.True: return(true); case Type.False: return(false); case Type.Variable: if (enemyObjectExpressionInfo == null) { throw new Exception(); } return(enemyObjectExpressionInfo.BooleanVariables[this.VariableName]); case Type.ParentVariable: if (enemyObjectExpressionInfo == null) { throw new Exception(); } if (enemyObjectExpressionInfo.Parent == null) { throw new Exception(); } return(enemyObjectExpressionInfo.Parent.BooleanVariables[this.VariableName]); case Type.IsParentDestroyed: if (isParentDestroyed == null) { throw new Exception(); } return(isParentDestroyed.Value); case Type.IsPlayerDestroyed: return(isPlayerDestroyed); case Type.Equal: case Type.NotEqual: case Type.GreaterThan: case Type.GreaterThanOrEqualTo: case Type.LessThan: case Type.LessThanOrEqualTo: long leftSide = this.MathLeftSide.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); long rightSide = this.MathRightSide.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (this.BooleanExpressionType == Type.Equal) { return(leftSide == rightSide); } else if (this.BooleanExpressionType == Type.NotEqual) { return(leftSide != rightSide); } else if (this.BooleanExpressionType == Type.GreaterThan) { return(leftSide > rightSide); } else if (this.BooleanExpressionType == Type.GreaterThanOrEqualTo) { return(leftSide >= rightSide); } else if (this.BooleanExpressionType == Type.LessThan) { return(leftSide < rightSide); } else if (this.BooleanExpressionType == Type.LessThanOrEqualTo) { return(leftSide <= rightSide); } else { throw new Exception(); } case Type.And: case Type.Or: case Type.Not: bool operand1 = this.BooleanOperand1.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, isParentDestroyed: isParentDestroyed, isPlayerDestroyed: isPlayerDestroyed, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (this.BooleanExpressionType == Type.Not) { return(!operand1); } if (this.BooleanExpressionType == Type.And && operand1 == false) { return(false); } if (this.BooleanExpressionType == Type.Or && operand1 == true) { return(true); } bool operand2 = this.BooleanOperand2.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, isParentDestroyed: isParentDestroyed, isPlayerDestroyed: isPlayerDestroyed, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); if (this.BooleanExpressionType == Type.And) { return(operand1 && operand2); } else if (this.BooleanExpressionType == Type.Or) { return(operand1 || operand2); } else { throw new Exception(); } default: throw new Exception(); } }
public static UpdateResult Update( List <EnemyObject> currentEnemyObjects, long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, bool isPlayerDestroyed, Dictionary <string, EnemyObjectTemplate> enemyObjectTemplates, IDTDeterministicRandom rng) { List <EnemyObjectWrapper> wrapperList = new List <EnemyObjectWrapper>(); foreach (EnemyObject enemyObj in currentEnemyObjects) { wrapperList.Add(new EnemyObjectWrapper(enemyObj, hasHandledAction: false)); } var newPowerUps = new List <Tuple <long, long> >(); var newSoundEffectsToPlay = new List <string>(); long?bossHealthMeterNumber = null; long?bossHealthMeterMilliPercentage = null; bool shouldEndLevel = false; while (true) { bool hasHandledAllActions = true; foreach (EnemyObjectWrapper x in wrapperList) { if (!x.HasHandledAction) { hasHandledAllActions = false; break; } } if (hasHandledAllActions) { break; } var newEnemyObjects = new List <EnemyObject>(); foreach (EnemyObjectWrapper enemyObjectWrapper in wrapperList) { if (enemyObjectWrapper.HasHandledAction) { continue; } enemyObjectWrapper.HasHandledAction = true; EnemyObject enemyObject = enemyObjectWrapper.EnemyObject; if (enemyObject.IsDestroyed) { continue; } ResultOfAction actionResult = HandleAction( action: enemyObject.Action, obj: enemyObject, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, isPlayerDestroyed: isPlayerDestroyed, enemyObjectTemplates: enemyObjectTemplates, rng: rng); enemyObject.Action = actionResult.NewObjectAction; if (actionResult.ShouldEndLevel) { shouldEndLevel = true; } foreach (EnemyObject newEnemy in actionResult.NewEnemyObjects) { newEnemyObjects.Add(newEnemy); } foreach (var newPowerUp in actionResult.NewPowerUps) { newPowerUps.Add(newPowerUp); } foreach (var newSoundEffect in actionResult.NewSoundEffectsToPlay) { newSoundEffectsToPlay.Add(newSoundEffect); } if (actionResult.BossHealthMeterNumber != null) { bossHealthMeterNumber = actionResult.BossHealthMeterNumber; } if (actionResult.BossHealthMeterMilliPercentage != null) { bossHealthMeterMilliPercentage = actionResult.BossHealthMeterMilliPercentage; } if (!enemyObject.IsDestroyed) { var offset = DTDanmakuMath.GetOffset( speedInMillipixelsPerMillisecond: enemyObject.SpeedInMillipixelsPerMillisecond, movementDirectionInMillidegrees: enemyObject.MovementDirectionInMillidegrees, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration); enemyObject.XMillis += offset.DeltaXInMillipixels; enemyObject.YMillis += offset.DeltaYInMillipixels; } } foreach (EnemyObject newEnemyObject in newEnemyObjects) { wrapperList.Add(new EnemyObjectWrapper(newEnemyObject, hasHandledAction: false)); } } var finalEnemyList = new List <EnemyObject>(); foreach (EnemyObjectWrapper enemyObjectWrapper in wrapperList) { if (!enemyObjectWrapper.EnemyObject.IsDestroyed) { finalEnemyList.Add(enemyObjectWrapper.EnemyObject); } } return(new UpdateResult { NewEnemyObjects = finalEnemyList, NewPowerUps = newPowerUps, ShouldEndLevel = shouldEndLevel, NewSoundEffectsToPlay = newSoundEffectsToPlay, BossHealthMeterNumber = bossHealthMeterNumber, BossHealthMeterMilliPercentage = bossHealthMeterMilliPercentage }); }
public EnemyObject( EnemyObjectTemplate template, long initialXMillis, long initialYMillis, long playerXMillis, long playerYMillis, long elapsedMillisecondsPerIteration, bool isPlayerDestroyed, EnemyObject parent /* nullable */, Dictionary <string, IMathExpression> initialNumericVariables, /* MathExpression is with respect to the parent */ /* nullable */ Dictionary <string, BooleanExpression> initialBooleanVariables /* BooleanExpression is with respect to the parent */ /* nullable */, IDTDeterministicRandom rng) { this._objectType = template.ObjectType; this._damageBoxes = template.DamageBoxes; this._collisionBoxes = template.CollisionBoxes; this.SpriteName = template.SpriteName; this.Action = template.Action; if (template.InitialMilliHP != null) { EnemyObjectExpressionInfo enemyObjectExpressionInfo; if (parent != null) { enemyObjectExpressionInfo = parent.GetEnemyObjectExpressionInfo(); } else { enemyObjectExpressionInfo = null; } this.MilliHP = template.InitialMilliHP.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng); } else { this.MilliHP = null; } this.XMillis = initialXMillis; this.YMillis = initialYMillis; this.SpeedInMillipixelsPerMillisecond = 0; this.MovementDirectionInMillidegrees = 180 * 1000; this.FacingDirectionInMillidegrees = 180 * 1000; this.IsDestroyed = false; this._parentObject = parent; this.NumericVariables = new Dictionary <string, long>(); this.BooleanVariables = new Dictionary <string, bool>(); if (initialNumericVariables != null) { foreach (var keyValuePair in initialNumericVariables) { string variableName = keyValuePair.Key; EnemyObjectExpressionInfo enemyObjectExpressionInfo; if (parent != null) { enemyObjectExpressionInfo = parent.GetEnemyObjectExpressionInfo(); } else { enemyObjectExpressionInfo = null; } this.NumericVariables.Add(variableName, keyValuePair.Value.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng)); } } if (initialBooleanVariables != null) { foreach (var keyValuePair in initialBooleanVariables) { string variableName = keyValuePair.Key; EnemyObjectExpressionInfo enemyObjectExpressionInfo; if (parent != null) { enemyObjectExpressionInfo = parent.GetEnemyObjectExpressionInfo(); } else { enemyObjectExpressionInfo = null; } bool?isParentDestroyed; if (parent != null) { isParentDestroyed = parent.IsDestroyed; } else { isParentDestroyed = null; } this.BooleanVariables.Add(variableName, keyValuePair.Value.Evaluate( enemyObjectExpressionInfo: enemyObjectExpressionInfo, isParentDestroyed: isParentDestroyed, isPlayerDestroyed: isPlayerDestroyed, playerXMillis: playerXMillis, playerYMillis: playerYMillis, elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration, rng: rng)); } } }
public static IFrame <IDTDanmakuAssets> GetFirstFrame(int fps, IDTDeterministicRandom rng, GuidGenerator guidGenerator, bool debugMode) { var frame = new InitialLoadingScreenFrame(fps: fps, rng: rng, guidGenerator: guidGenerator, debugMode: debugMode); return(frame); }
public GameLogic( int fps, IDTDeterministicRandom rng, GuidGenerator guidGenerator, int soundVolume, bool debugMode) { this.fps = fps; this.elapsedTimeMillis = 0; long elapsedMillisPerFrame = 1000 / this.fps; this.soundVolume = soundVolume; this.debugMode = debugMode; this.rng = rng; this.rng.Reset(); this.spriteNameToImageDictionary = new Dictionary <string, DTDanmakuImage>(); this.enemyObjectTemplates = new Dictionary <string, EnemyObjectTemplate>(); this.soundNameToSoundDictionary = new Dictionary <string, DTDanmakuSound>(); List <DTDanmakuImage> playerDeadExplosionSprites = new List <DTDanmakuImage>(); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion1); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion2); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion3); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion4); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion5); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion6); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion7); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion8); playerDeadExplosionSprites.Add(DTDanmakuImage.Explosion9); DestructionAnimationGenerator.GenerateDestructionAnimationResult playerDeadDestructionAnimationResult = DestructionAnimationGenerator.GenerateDestructionAnimation( orderedSprites: playerDeadExplosionSprites, millisecondsPerSprite: 200, guidGenerator: guidGenerator); foreach (var entry in playerDeadDestructionAnimationResult.spriteNameToImageDictionary) { this.spriteNameToImageDictionary.Add(entry.Key, entry.Value); } foreach (var entry in playerDeadDestructionAnimationResult.enemyObjectTemplates) { this.enemyObjectTemplates.Add(entry.Key, entry.Value); } this.player = new Player(playerDeadDestructionAnimationResult.objectAction); this.playerBullets = new List <PlayerBullet>(); this.powerUps = new List <PowerUp>(); GenerateEnemiesResult enemies = GenerateEnemiesForLevel.GenerateEnemies( elapsedMillisecondsPerIteration: elapsedMillisPerFrame, rng: rng, guidGenerator: guidGenerator); this.enemyObjects = enemies.enemyObjects; foreach (var entry in enemies.spriteNameToImageDictionary) { this.spriteNameToImageDictionary.Add(entry.Key, entry.Value); } foreach (var entry in enemies.enemyObjectTemplates) { this.enemyObjectTemplates.Add(entry.Key, entry.Value); } foreach (var entry in enemies.soundNameToSoundDictionary) { this.soundNameToSoundDictionary.Add(entry.Key, entry.Value); } this.gameOverCountdownInMillis = null; this.levelFinishedCountdownInMillis = null; this.shouldPlayPlayerShootSound = false; this.playerShootSoundCooldownInMillis = 0; this.soundsThatNeedToBePlayed = new List <DTDanmakuSound>(); this.bossHealthBar = new BossHealthBar(); /* * Note that since these debug things bypass regular game logic, they may break other stuff or crash the program * (Should be used for debugging / development only) */ if (this.debugMode) { this.player.numLivesLeft = 200; } this.debug_renderHitboxes = false; }