public static void Render( List <EnemyObject> enemyObjects, EnemyObjectType enemyObjectType, TranslatedDTDanmakuDisplay display, Dictionary <string, DTDanmakuImage> spriteNameToImageDictionary) { foreach (EnemyObject enemyObj in enemyObjects) { if (enemyObj.IsDestroyed) { continue; } if (enemyObj.ObjectType != enemyObjectType) { continue; } if (enemyObj.SpriteName == null) { continue; } DTDanmakuImage image = spriteNameToImageDictionary[enemyObj.SpriteName]; long width = display.GetWidth(image); long height = display.GetHeight(image); int x = (int)(enemyObj.XMillis / 1000 - width / 2); int y = (int)(700 - enemyObj.YMillis / 1000 - height / 2); display.DrawImageRotatedClockwise(image, x, y, (int)enemyObj.FacingDirectionInMillidegrees); } }
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)); } } }