public static GameObject BuildCharacterEntity( Game1 game, int playerNumber, Color playerColor, Vector2 position, float rotation, Vector2 scale, float maxGroundSpeed, float maxAirSpeed, SpriteType spriteType, List<Shape> boundingBoxes, Dictionary<ActionDefinition, ActionInfo> actionsInformationList) { GameObject entity = DynamicEntityFactory.BuildDynamicEntity(game, position, rotation, scale, maxGroundSpeed, maxAirSpeed, spriteType, boundingBoxes); PlayerComponent playerComponent = new PlayerComponent(entity, playerNumber); HealthComponent healthComponent = new HealthComponent(entity); ColorComponent colorComponent = new ColorComponent(entity, playerColor); CurrentActionComponent curActionComponent = (CurrentActionComponent)entity.GetComponent(ComponentType.Action); curActionComponent.SetActionInfoList(actionsInformationList); entity.AddComponent(playerComponent); entity.AddComponent(healthComponent); entity.AddComponent(colorComponent); return entity; }
public GameObject BuildStaticRectangularObstacle( Vector2 translation, Rectangle rect, float friction, Color color) { GameObject obstacle = new GameObject(this._game); List<Vector2> vertices = new List<Vector2>(); vertices.Add(new Vector2(rect.Left, rect.Top)); vertices.Add(new Vector2(rect.Right, rect.Top)); vertices.Add(new Vector2(rect.Right, rect.Bottom)); vertices.Add(new Vector2(rect.Left, rect.Bottom)); Transform2DComponent transformComponent = new Transform2DComponent( obstacle, translation, 0.0f, new Vector2(1.0f, 1.0f)); MeshComponent meshComponent = new MeshComponent(obstacle, vertices); ColorComponent colorComponent = new ColorComponent(obstacle, color); BoundingBoxComponent boundingBoxComponent = new BoundingBoxComponent( obstacle, new List<Shape>{ new Shape(vertices) }, false); PhysicalPropertiesComponent physicsPropertiesComponent = new PhysicalPropertiesComponent(obstacle, friction); IsPhysicalComponent isPhysicalComponent = new IsPhysicalComponent(obstacle, false); obstacle.AddComponent(transformComponent); obstacle.AddComponent(meshComponent); obstacle.AddComponent(colorComponent); obstacle.AddComponent(boundingBoxComponent); obstacle.AddComponent(physicsPropertiesComponent); obstacle.AddComponent(isPhysicalComponent); return obstacle; }