public FadeEffect(DrawableEntity entityToApply, float fadeAmount) : base(entityToApply) { this.fadeAmount = fadeAmount; this.fadeMin = 0.0f; this.fadeMax = 1.0f; }
public RumbleHarmedEffect(DrawableEntity entityToApply) : base(entityToApply) { EventManager.Instance.addListener(EventType.HARMED_EVENT, this.entityToApply, this); EventManager.Instance.addListener(EventType.TRANCE_BEGIN_EVENT, this); EventManager.Instance.addListener(EventType.TRANCE_END_EVENT, this); }
public FadeEffect(DrawableEntity entityToApply, float fadeAmount, float fadeMin, float fadeMax) : base(entityToApply) { this.fadeAmount = fadeAmount; this.fadeMin = fadeMin; this.fadeMax = fadeMax; }
private void AddVerticesFromLine(DrawableEntity entity) { var color = entity.Get<Color>(); var points = entity.GetInterpolatedList<Vector3D>(); foreach (Vector3D point in points) vertices.Add(new VertexPosition3DColor(point, color)); }
public BasicRenderer(DrawableEntity owner, string asset, Rectangle sourceRectangle) { this.owner = owner; this.asset = asset; this.sourceRectangle = sourceRectangle; initialize(); }
public void TogglingVisibilityOnShownDrawableEntityHidesIt() { var drawable = new DrawableEntity(); drawable.ToggleVisibility(); Assert.IsFalse(drawable.IsVisible); }
public AnimationRenderer(DrawableEntity owner, string asset, AnimationManagerComponent animationManager) { this.owner = owner; this.asset = asset; this.animationManager = animationManager; initialize(); }
public void Add(DrawBehavior behavior, DrawableEntity entity) { if (behaviors.ContainsKey(behavior)) behaviors[behavior].Add(entity); else behaviors.Add(behavior, new List<DrawableEntity> { entity }); }
private void AddVerticesFromLine(DrawableEntity entity) { var color = entity.Get<Color>(); var points = entity.GetInterpolatedList<Vector2D>(); foreach (Vector2D point in points) vertices.Add(new VertexPosition2DColor(ScreenSpace.Current.ToPixelSpaceRounded(point), color)); }
private static void ThrowExceptionsWhenInterpolationElementsAreNotFound( DrawableEntity drawableEntity) { Assert.Throws <DrawableEntity.ListWithLerpElementsForInterpolationWasNotFound>( () => { drawableEntity.GetInterpolatedList <MockLerp>(); }); Assert.Throws <DrawableEntity.ArrayWithLerpElementsForInterpolationWasNotFound>( () => { drawableEntity.GetInterpolatedArray <MockLerp>(); }); }
public void TogglingVisibilityOnHiddenDrawableEntityShowsIt() { var drawable = new DrawableEntity { IsVisible = false }; drawable.ToggleVisibility(); Assert.IsTrue(drawable.IsVisible); }
private void AddVerticesFromLine(DrawableEntity entity) { var color = entity.Get <Color>(); var points = entity.GetInterpolatedList <Vector3D>(); foreach (Vector3D point in points) { vertices.Add(new VertexPosition3DColor(point, color)); } }
public void CreateFromComponents() { var drawable = new DrawableEntity(); drawable.SetComponents(new List <object> { 5, false }); Assert.AreEqual(5, drawable.Get <int>()); Assert.IsFalse(drawable.IsVisible); }
private static void LoadDrawableEntityDrawBehaviors(BinaryReader reader, DrawableEntity drawable) { var drawBehaviors = LoadArray(null, typeof(List <string>), reader) as List <string>; foreach (string behavior in drawBehaviors) { drawable.OnDraw(BinaryDataExtensions.GetTypeFromShortNameOrFullNameIfNotFound(behavior)); } }
public void AddVisibleDrawableEntity() { var drawable = new DrawableEntity { IsVisible = false }; drawable.OnDraw <DrawTest>(); drawable.ToggleVisibility(); Assert.IsTrue(drawable.IsVisible); }
private void FormEllipsePoints(DrawableEntity entity) { ellipsePoints = entity.Get <List <Vector2D> >(); ellipsePoints.Clear(); ellipsePoints.Add(center); for (int i = pointsCount - 1; i >= 0; i--) { FormRotatedEllipsePoint(i); } entity.SetWithoutInterpolation(ellipsePoints); }
private void AddVerticesFromLine(DrawableEntity entity) { var color = entity.Get <Color>(); var points = entity.GetInterpolatedList <Vector2D>(); foreach (Vector2D point in points) { vertices.Add(new VertexPosition2DColor(ScreenSpace.Current.ToPixelSpaceRounded(point), color)); } }
private void AddVerticesFromEllipse(DrawableEntity entity) { var color = entity.Get<Color>(); var center = entity.Get<Vector3D>(); var radius = entity.Get<float>(); var point = Vector3D.UnitX * radius; for (int i = 0; i < 360; i += 5) { var rotatedPoint = point.RotateAround(Vector3D.UnitZ, i); vertices.Add(new VertexPosition3DColor(rotatedPoint + center, color)); } }
private static void SaveDrawableEntityDrawBehaviors(DrawableEntity drawable, BinaryWriter writer) { List <DrawBehavior> drawBehaviorTypes = drawable.GetDrawBehaviors(); var drawBehaviorNames = new List <string>(); foreach (DrawBehavior behaviorType in drawBehaviorTypes) { drawBehaviorNames.Add(behaviorType.GetShortNameOrFullNameIfNotFound()); } SaveArray(drawBehaviorNames, writer); }
private void AddVerticesFromEllipse(DrawableEntity entity) { var color = entity.Get <Color>(); var center = entity.Get <Vector3D>(); var radius = entity.Get <float>(); var point = Vector3D.UnitX * radius; for (int i = 0; i < 360; i += 5) { var rotatedPoint = point.RotateAround(Vector3D.UnitZ, i); vertices.Add(new VertexPosition3DColor(rotatedPoint + center, color)); } }
public BasicRenderer(DrawableEntity owner, string asset, Rectangle sourceRectangle, int fadeFramesNumber, int intervalFadeFrames) { this.owner = owner; this.asset = asset; this.sourceRectangle = sourceRectangle; if (fadeFramesNumber > 0 && intervalFadeFrames > 0) { this.pastFrames = new DrawParameters[fadeFramesNumber]; this.fadeFramesNumber = fadeFramesNumber; this.intervalFadeFrames = intervalFadeFrames; this.currentFadeFrame = intervalFadeFrames; } initialize(); }
public AnimationRenderer(DrawableEntity owner, string asset, AnimationManagerComponent animationManager, int fadeFramesNumber, int intervalFadeFrames) { this.owner = owner; this.asset = asset; this.animationManager = animationManager; if (fadeFramesNumber > 0 && intervalFadeFrames > 0) { this.pastFrames = new DrawParameters[fadeFramesNumber]; this.fadeFramesNumber = fadeFramesNumber; this.intervalFadeFrames = intervalFadeFrames; this.currentFadeFrame = intervalFadeFrames; } initialize(); }
private DrawableEntity CreateVerticesAndIndices() { imagesVertices = new List<VertexPosition2DColorUV>(); imagesIndices = new List<short>(); for (int y = 0; y < 100; y++) for (int x = 0; x < 100; x++) { CreateVertices(x, y); CreateIndicesForTwoPolygonsPerQuad(x, y); } var entity = new DrawableEntity(); entity.Add(imagesVertices.ToArray()); entity.Add(imagesIndices.ToArray()); return entity; }
private DrawableEntity CreateVerticesAndIndices() { imagesVertices = new List <VertexPosition2DColorUV>(); imagesIndices = new List <short>(); for (int y = 0; y < 100; y++) { for (int x = 0; x < 100; x++) { CreateVertices(x, y); CreateIndicesForTwoPolygonsPerQuad(x, y); } } var entity = new DrawableEntity(); entity.Add(imagesVertices.ToArray()); entity.Add(imagesIndices.ToArray()); return(entity); }
void CustomInitialize() { if (!Layer2D.Texts.Contains(EntireScene.Texts[0])) { throw new Exception("Texts in entire Scenes which come from files in Screens are not properly added to Layers"); } // The Layer defined by the Entity should be under the Layer defined by the screen. int indexOfEntityLayer = SpriteManager.Layers.IndexOf(this.LayerOwnerInstance.InternalLayer); int indexOfScreenLayer = SpriteManager.Layers.IndexOf(this.Layer2D); if (indexOfScreenLayer < indexOfEntityLayer) { throw new Exception("Unlayered Entity instances are placing their layers above the Layers defined by Screens"); } if (Layer3DIndependentOfCamera.LayerCameraSettings == null) { throw new Exception("The 3D Layer needs its own LayerCameraSettings to be independent from the Camera"); } if(Layer3DIndependentOfCamera.LayerCameraSettings.Orthogonal) { throw new Exception("The 3D Layer should not be orthogonal - it should be 3D 3D"); } int right = FlatRedBall.Math.MathFunctions.RoundToInt(Layer2DPercentage.LayerCameraSettings.RightDestination); if (right != FlatRedBall.Math.MathFunctions.RoundToInt(SpriteManager.Camera.DestinationRectangle.Right * .4f)) { throw new Exception("Percentage LayerCoordinateUnit is not working properly"); } int left = FlatRedBall.Math.MathFunctions.RoundToInt(Layer2DPercentage.LayerCameraSettings.LeftDestination); if (left != FlatRedBall.Math.MathFunctions.RoundToInt(SpriteManager.Camera.DestinationRectangle.Right * .1f)) { throw new Exception("Percentage LayerCoordinateUnit is not working properly - Left is wrong"); } float orthoWidth = Layer2DPercentage.LayerCameraSettings.OrthogonalWidth; if ((orthoWidth - .3f * SpriteManager.Camera.OrthogonalWidth) > .1f) { throw new Exception("Percentage-based ortho widths are not working properly"); } Sprite spriteThatShouldntBeOnMultipleLayers = this.LayerOwnerInstanceOnLayer.BearFromLayeredScene; int numberFound = 0; for (int i = 0; i < SpriteManager.Layers.Count; i++) { if (SpriteManager.Layers[i].Sprites.Contains(spriteThatShouldntBeOnMultipleLayers)) { numberFound++; } } if (numberFound > 1) { throw new Exception("Sprites which are on Layers in Entities which themselves are put on Layers are being rendered twice"); } spriteThatShouldntBeOnMultipleLayers = this.LayerOwnerInstanceOnLayer.LayeredBear; numberFound = 0; for (int i = 0; i < SpriteManager.Layers.Count; i++) { if (SpriteManager.Layers[i].Sprites.Contains(spriteThatShouldntBeOnMultipleLayers)) { numberFound++; } } if (numberFound > 1) { throw new Exception("Sprites which are on Layers in Entities, which come from Scenes which are not on Layers, and have their Entity put on a Layer are being rendered twice."); } MoveToLayerEntityInstance.MoveToLayer(Layer2D); if (Layer2D.Circles.Contains(MoveToLayerEntityInstance.CircleInstance) == false) { throw new Exception("Circles on entities are not moved to a layer when calling MoveToLayer"); } // set a 3D camera to make sure layers with null LayerCameraSettings are also 3d: Camera.Main.Orthogonal = false; layer2D = Camera.Main.AddLayer(); layer2D.Name = "layer2D created in code"; layer2D.UsePixelCoordinates(); layer3D = Camera.Main.AddLayer(); layer3D.Name = "layer3D created in code"; on3DInstance = new DrawableEntity(this.ContentManagerName, false); on3DInstance.AddToManagers(layer3D); }
private static void LoadDrawableEntityDrawBehaviors(BinaryReader reader, DrawableEntity drawable) { var drawBehaviors = LoadArray(null, typeof(List<string>), reader) as List<string>; foreach (string behavior in drawBehaviors) drawable.OnDraw(BinaryDataExtensions.GetTypeFromShortNameOrFullNameIfNotFound(behavior)); }
public HaloEffect(DrawableEntity entityToApply) : base(entityToApply) { }
public AbstractDrawEffect(DrawableEntity entityToApply) { this.entityToApply = entityToApply; }
private static void SaveDrawableEntityDrawBehaviors(DrawableEntity drawable, BinaryWriter writer) { List<DrawBehavior> drawBehaviorTypes = drawable.GetDrawBehaviors(); var drawBehaviorNames = new List<string>(); foreach (DrawBehavior behaviorType in drawBehaviorTypes) drawBehaviorNames.Add(behaviorType.GetShortNameOrFullNameIfNotFound()); SaveArray(drawBehaviorNames, writer); }
public DyingFadeEffect(DrawableEntity entityToApply, float fadeAmount) : base(entityToApply, fadeAmount) { EventManager.Instance.addListener(EventType.DEAD_EVENT, entityToApply, this); }
public void CreateFromComponents() { var drawable = new DrawableEntity(); drawable.SetComponents(new List<object> { 5, false }); Assert.AreEqual(5, drawable.Get<int>()); Assert.IsFalse(drawable.IsVisible); }
public LevelObjectHandler(int levelSize) { LevelSize = levelSize; ObjectList = new DrawableEntity[levelSize]; }
public void AddVisibleDrawableEntity() { var drawable = new DrawableEntity { IsVisible = false }; drawable.OnDraw<DrawTest>(); drawable.ToggleVisibility(); Assert.IsTrue(drawable.IsVisible); }
public override void LoadContent() { base.LoadContent(); List<CollisionBody> bodyList = new List<CollisionBody>(); int i = 0; // poligonos de arriba List<Vector2> polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 2, blockSize * 7), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 4, blockSize * 2), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 7, blockSize * 2), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 3, GameConstants.CAMERA_INNER_BORDER + blockSize * 3)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 3, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 9, blockSize * 3), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 12, blockSize * 5), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 15, blockSize * 5), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize * 4)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 4, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 21, blockSize * 2), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 26, blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 29, blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 33, blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 38, blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 48, blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 3, GameConstants.CAMERA_INNER_BORDER + blockSize * 3)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 3, GameConstants.CAMERA_INNER_BORDER + 0)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 59, blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); // poligonos de abajo polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 4, blockSize * 12), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize * 2)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 2, GameConstants.CAMERA_INNER_BORDER + blockSize * 2)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 6, blockSize * 13), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 10, blockSize * 14), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 22, blockSize * 14), false, GameLayers.MIDDLE_PLAY_AREA)); polyPoints = new List<Vector2>(); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + 0)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize, GameConstants.CAMERA_INNER_BORDER + blockSize)); polyPoints.Add(new Vector2(GameConstants.CAMERA_INNER_BORDER + 0, GameConstants.CAMERA_INNER_BORDER + blockSize)); bodyList.Add(ShapeFactory.CreatePolygon("Polygon" + ++i, this, true, false, polyPoints, new Vector2(blockSize * 58, blockSize * 12), false, GameLayers.MIDDLE_PLAY_AREA)); i = 0; // bloques de arriba bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 2, blockSize * 8, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 0, GameConstants.CAMERA_INNER_BORDER + blockSize * 0), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 2, blockSize * 3, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 2, GameConstants.CAMERA_INNER_BORDER + blockSize * 0), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 1, blockSize * 4, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 2, GameConstants.CAMERA_INNER_BORDER + blockSize * 3), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 8, blockSize * 2, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 4, GameConstants.CAMERA_INNER_BORDER + blockSize * 0), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 4, blockSize, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 8, GameConstants.CAMERA_INNER_BORDER + blockSize * 2), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 5, blockSize, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 16, GameConstants.CAMERA_INNER_BORDER + blockSize * 5), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 5, blockSize * 2, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 21, GameConstants.CAMERA_INNER_BORDER + blockSize * 0), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 38, blockSize * 1, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 26, GameConstants.CAMERA_INNER_BORDER + blockSize * 0), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 3, blockSize * 1, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 30, GameConstants.CAMERA_INNER_BORDER + blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 9, blockSize * 1, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 39, GameConstants.CAMERA_INNER_BORDER + blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); bodyList.Add(ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 2, blockSize * 3, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 62, GameConstants.CAMERA_INNER_BORDER + blockSize * 1), false, GameLayers.MIDDLE_PLAY_AREA)); // bloques de abajo List<AreaCollisionBodyWrapper> bodyWrapperList = new List<AreaCollisionBodyWrapper>(); AreaCollisionBodyWrapper wrapper = null; wrapper = new AreaCollisionBodyWrapper(this, ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 4, blockSize * 4, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 0, GameConstants.CAMERA_INNER_BORDER + blockSize * 12), false, GameLayers.MIDDLE_PLAY_AREA)); wrapper.addBoolProperty(EntityProperty.Earth, true); bodyWrapperList.Add(wrapper); wrapper = new AreaCollisionBodyWrapper(this, ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 2, blockSize * 3, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 4, GameConstants.CAMERA_INNER_BORDER + blockSize * 13), false, GameLayers.MIDDLE_PLAY_AREA)); wrapper.addBoolProperty(EntityProperty.Earth, true); bodyWrapperList.Add(wrapper); wrapper = new AreaCollisionBodyWrapper(this, ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 5, blockSize, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 6, GameConstants.CAMERA_INNER_BORDER + blockSize * 15), false, GameLayers.MIDDLE_PLAY_AREA)); wrapper.addBoolProperty(EntityProperty.Earth, true); bodyWrapperList.Add(wrapper); wrapper = new AreaCollisionBodyWrapper(this, ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 11, blockSize * 2, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 11, GameConstants.CAMERA_INNER_BORDER + blockSize * 14), false, GameLayers.MIDDLE_PLAY_AREA)); wrapper.addBoolProperty(EntityProperty.Earth, true); bodyWrapperList.Add(wrapper); wrapper = new AreaCollisionBodyWrapper(this, ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 36, blockSize, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 22, GameConstants.CAMERA_INNER_BORDER + blockSize * 15), false, GameLayers.MIDDLE_PLAY_AREA)); wrapper.addBoolProperty(EntityProperty.Earth, true); bodyWrapperList.Add(wrapper); wrapper = new AreaCollisionBodyWrapper(this, ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize, blockSize * 3, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 58, GameConstants.CAMERA_INNER_BORDER + blockSize * 13), false, GameLayers.MIDDLE_PLAY_AREA)); wrapper.addBoolProperty(EntityProperty.Earth, true); bodyWrapperList.Add(wrapper); wrapper = new AreaCollisionBodyWrapper(this, ShapeFactory.CreateRectangle("Block" + ++i, this, true, false, blockSize * 5, blockSize * 4, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 59, GameConstants.CAMERA_INNER_BORDER + blockSize * 12), false, GameLayers.MIDDLE_PLAY_AREA)); wrapper.addBoolProperty(EntityProperty.Earth, true); bodyWrapperList.Add(wrapper); CollisionComponent.addBodies(bodyList); CollisionComponent.addWrappers(bodyWrapperList); EventManager.Instance.addCollisionListener(this, new SurfaceCollisionResponse(this)); PhysicsData boxPhysics = new PhysicsData(); boxPhysics.MinimumVelocity = new Vector2(-500, -5000); boxPhysics.MaximumVelocity = new Vector2(500, 2000); boxPhysics.Weight = 15; boxPhysics.RunningImpulse = 30000; boxPhysics.AirImpulse = 15000; boxPhysics.JumpImpulse = 1200000; Dictionary<ElementType, float> boxElementMultipliers = UtilMethods.getDamageMultipliers(DamageMultipliers.NORMAL_DAMAGE, DamageMultipliers.HIGH_DAMAGE, DamageMultipliers.NORMAL_DAMAGE, DamageMultipliers.NORMAL_DAMAGE, DamageMultipliers.NORMAL_DAMAGE); // Conjunto de bloques que desaparecen visualmente cuando // se activa un trigger DrawableEntity fadeWall = new DrawableEntity(); fadeWall.addDrawEffect(new FadeEffect(fadeWall, 0.02f, 0.4f, 1.0f)); // Trigger utilizado para desaparecer // visualmente una entidad cuando se entra // en el rango del trigger BaseTrigger baseTrigger = new BaseTrigger(); Box cameraTriggerBody = ShapeFactory.CreateRectangle("trigger", baseTrigger, false, false, blockSize * 9, blockSize * 5, new Vector2(GameConstants.CAMERA_INNER_BORDER + blockSize * 12, GameConstants.CAMERA_INNER_BORDER + blockSize * 0), false); baseTrigger.Zone = cameraTriggerBody; FadeInTrigger ct = new FadeInTrigger(baseTrigger, fadeWall); this.areaItems.Add(baseTrigger); }
/// <summary> /// Carga inicial despues de haber construido el objeto, solo debe hacerse una vez /// </summary> public void LoadContent() { if (hasLoaded == false) { // Aquí inicializo todo lo referente a la entidad principal ya que aún no se donde ponerlo DrawableEntity goemon = new DrawableEntity(GlobalIDs.MAIN_CHARACTER_ID); this.mainEntity = goemon; goemon.Position = new Vector2(175 + 100, 200 + 200); //HERE DEADEVENT SE DEBERÏA MOVER PERO SI NO PRODUCE BUG //el orden de creación de los componentes influye en el orden en que se envían los eventos goemon.addComponent(new DeadComponent(goemon)); /************** Inicialización animación Goemon **********/ Animation runningAnimation = new Animation(ActionsList.Running, 30, 38, 8, 40, 9, new Vector2(3.84f, 5f), 0, 0); runningAnimation.addAllDefaultFrames(6); Animation attackAnimation = new Animation(ActionsList.Attack, 55, 52, 5, 4, 185, new Vector2(3.84f, 5f), 10, 10); attackAnimation.addAllDefaultFrames(2); attackAnimation.addFrame(new AnimationFrame(new Rectangle(110, 185, 48, 52), 5, null, new Vector2(3.84f, 5f), 10, 10)); attackAnimation.addFrame(new AnimationFrame(new Rectangle(162, 185, 55, 52), 5, null, new Vector2(3.84f, 5f), -10, 10)); attackAnimation.addFrame(new AnimationFrame(new Rectangle(220, 185, 55, 52), 5, "Rectangle TestBody False 180 70 0 -20 False;FeInwork.collision.responses.SingleHitCollisionResponse!TestBody;10", new Vector2(3.84f, 5f), -10, 10)); Animation deadAnimation = new Animation(ActionsList.Dead, 76, 78, 6, 192, 577, new Vector2(1.7f, 1.7f)); deadAnimation.addAllDefaultFrames(4); Animation stillAnimation = new Animation(ActionsList.Default, 28, 34, 60, 315, 10, new Vector2(3.84f, 5f), 0, 0); stillAnimation.addAllDefaultFrames(4); //Todas las animiaciones se deben agregar al animation manager que necesita una por defecto AnimationManagerComponent animationManager = new AnimationManagerComponent(goemon, new AliveAttackerActionChooser(goemon), stillAnimation); animationManager.addAction(attackAnimation); animationManager.addAction(runningAnimation); animationManager.addAction(deadAnimation); /************** FIN de Inicialización animación Goemon **********/ // Efectos de dibujo a aplicarle al personaje principal goemon.addDrawEffect(new HaloEffect(goemon)); goemon.addDrawEffect(new FadeEffect(goemon, 0.02f, 0.4f, 1.0f)); goemon.addComponent(new AnimationRenderer(goemon, AssetNames.GOEMON_ASSET, animationManager, 5, 5)); goemon.addComponent(new ControlComponent(goemon)); goemon.addComponent(new PhysicalAttackComponent(goemon, 10)); goemon.addComponent(new SpecialActionManagerComponent(goemon)); HealthComponent hp = new HealthComponent(goemon, null, 100, 70, 120); goemon.addComponent(hp); //goemon.addComponent(new HealthRenderer(goemon, hp, 10, 10)); PhysicsData goemonPhysics = new PhysicsData(); goemonPhysics.MinimumVelocity = new Vector2(-500, -5000); goemonPhysics.MaximumVelocity = new Vector2(500, 2000); goemonPhysics.Weight = 20; goemonPhysics.RunningImpulse = 30000; goemonPhysics.AirImpulse = 15000; goemonPhysics.JumpImpulse = 1200000; goemon.addComponent(new BasicPhysicsComponent(goemon, goemonPhysics)); Box goemonMainBody = ShapeFactory.CreateRectangle("goemonMainBody", goemon, true, false, 90, 160, goemon.Position, true, GameLayers.MIDDLE_PLAY_AREA, GameConstants.TANGIBLE_BODY_TAG); Box goemonPortalBody = ShapeFactory.CreateRectangle("goemonPortalBody", goemon, true, false, 20, 20, goemon.Position, true, GameLayers.MIDDLE_PLAY_AREA, GameConstants.OPEN_DOOR_TAG); Box goemonInteractBody = ShapeFactory.CreateRectangle("goemonInteractBody", goemon, false, false, 95, 140, new Vector2(135 + 100, 130 + 200), false, GameLayers.MIDDLE_PLAY_AREA, Color.Blue); Box goemonTriggerBody = ShapeFactory.CreateRectangle("goemonTriggerBody", goemon, false, false, 95, 140, new Vector2(135 + 100, 130 + 200), false, GameLayers.MIDDLE_PLAY_AREA, Color.AliceBlue); Box goemonTriggerBody2 = ShapeFactory.CreateRectangle("goemonTriggerBody2", goemon, false, false, 200, 140, new Vector2(135 + 100, 130 + 200), false, GameLayers.MIDDLE_PLAY_AREA, Color.AliceBlue); List<CollisionBody> goemonBodies = new List<CollisionBody>(); goemonBodies.Add(goemonMainBody); goemonBodies.Add(goemonPortalBody); goemonBodies.Add(goemonInteractBody); goemonBodies.Add(goemonTriggerBody); //goemonBodies.Add(goemonTriggerBody2); //goemonBodies.Add(earthCastingArea); goemon.addComponent(new AnimatedCollisionComponent(goemon, goemonBodies)); // listener general de colisiones para mario EventManager.Instance.addCollisionListener(goemon, new SoftBodyCollisionResponse(goemon)); Camera2D camera = new Camera2D(Program.GAME, goemon); Program.GAME.Camera = camera; // mover camara a un target random lejos camera.MoveSpeed = 2f; // debería ir código para cargar la lista de rooms y doors de los xml AreaEntity roomTestM = new AreaTestMetroid(); this.hasLoaded = true; } else { throw new InvalidOperationException("El WorldManager ya ha sido cargado anteriormente."); } }
private void FormEllipsePoints(DrawableEntity entity) { ellipsePoints = entity.Get<List<Vector2D>>(); ellipsePoints.Clear(); ellipsePoints.Add(center); for (int i = pointsCount - 1; i >= 0; i--) FormRotatedEllipsePoint(i); entity.SetWithoutInterpolation(ellipsePoints); }
void CustomInitialize() { if (!Layer2D.Texts.Contains(EntireScene.Texts[0])) { throw new Exception("Texts in entire Scenes which come from files in Screens are not properly added to Layers"); } // The Layer defined by the Entity should be under the Layer defined by the screen. int indexOfEntityLayer = SpriteManager.Layers.IndexOf(this.LayerOwnerInstance.InternalLayer); int indexOfScreenLayer = SpriteManager.Layers.IndexOf(this.Layer2D); if (indexOfScreenLayer < indexOfEntityLayer) { throw new Exception("Unlayered Entity instances are placing their layers above the Layers defined by Screens"); } if (Layer3DIndependentOfCamera.LayerCameraSettings == null) { throw new Exception("The 3D Layer needs its own LayerCameraSettings to be independent from the Camera"); } if (Layer3DIndependentOfCamera.LayerCameraSettings.Orthogonal) { throw new Exception("The 3D Layer should not be orthogonal - it should be 3D 3D"); } int right = FlatRedBall.Math.MathFunctions.RoundToInt(Layer2DPercentage.LayerCameraSettings.RightDestination); if (right != FlatRedBall.Math.MathFunctions.RoundToInt(SpriteManager.Camera.DestinationRectangle.Right * .4f)) { throw new Exception("Percentage LayerCoordinateUnit is not working properly"); } int left = FlatRedBall.Math.MathFunctions.RoundToInt(Layer2DPercentage.LayerCameraSettings.LeftDestination); if (left != FlatRedBall.Math.MathFunctions.RoundToInt(SpriteManager.Camera.DestinationRectangle.Right * .1f)) { throw new Exception("Percentage LayerCoordinateUnit is not working properly - Left is wrong"); } float orthoWidth = Layer2DPercentage.LayerCameraSettings.OrthogonalWidth; if ((orthoWidth - .3f * SpriteManager.Camera.OrthogonalWidth) > .1f) { throw new Exception("Percentage-based ortho widths are not working properly"); } Sprite spriteThatShouldntBeOnMultipleLayers = this.LayerOwnerInstanceOnLayer.BearFromLayeredScene; int numberFound = 0; for (int i = 0; i < SpriteManager.Layers.Count; i++) { if (SpriteManager.Layers[i].Sprites.Contains(spriteThatShouldntBeOnMultipleLayers)) { numberFound++; } } if (numberFound > 1) { throw new Exception("Sprites which are on Layers in Entities which themselves are put on Layers are being rendered twice"); } spriteThatShouldntBeOnMultipleLayers = this.LayerOwnerInstanceOnLayer.LayeredBear; numberFound = 0; for (int i = 0; i < SpriteManager.Layers.Count; i++) { if (SpriteManager.Layers[i].Sprites.Contains(spriteThatShouldntBeOnMultipleLayers)) { numberFound++; } } if (numberFound > 1) { throw new Exception("Sprites which are on Layers in Entities, which come from Scenes which are not on Layers, and have their Entity put on a Layer are being rendered twice."); } TestMovingEntitiesAlsoMovesShapes(); if (SpriteManager.TopLayer.Sprites.Contains(TopLayerSprite) == false) { throw new Exception($"The {nameof(TopLayerSprite)} should be on the SpriteManager's TopLayer, but it's not!"); } // set a 3D camera to make sure layers with null LayerCameraSettings are also 3d: Camera.Main.Orthogonal = false; layer2D = Camera.Main.AddLayer(); layer2D.Name = "layer2D created in code"; layer2D.UsePixelCoordinates(); layer3D = Camera.Main.AddLayer(); layer3D.Name = "layer3D created in code"; on3DInstance = new DrawableEntity(this.ContentManagerName, false); on3DInstance.AddToManagers(layer3D); TestMoveToLayerDerived(); TestAddedToLayerInvisibleShapesStayInvisible(); }
public BasicRenderer(DrawableEntity owner, string asset) { this.owner = owner; this.asset = asset; initialize(); }
public FadeInTrigger(BaseTrigger trigger, DrawableEntity entityToFade) { this.trigger = trigger; this.entityToFade = entityToFade; initialize(); }
public StaticObjectsRenderer(DrawableEntity owner, List<DrawParameters> renderList) { this.owner = owner; this.renderList = renderList; initialize(); }