private void DrawSelectedElement(DrawableComponent drawable, int iconX, int iconY) { if (Utils.Random(0, 2) == 0) { DrawElement(drawable, iconX, iconY); } }
/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="spriteBatch"></param> public void draw(GameTime gameTime, SpriteBatch spriteBatch) { List <int> dra = ComponentManager.Instance.GetAllEntitiesWithComponentType <DrawableComponent>(); if (dra != null) { foreach (var a in dra) { PositionComponent p = ComponentManager.Instance.GetEntityComponent <PositionComponent>(a); DrawableComponent d = ComponentManager.Instance.GetEntityComponent <DrawableComponent>(a); AnimationComponent anim = ComponentManager.Instance.GetEntityComponent <AnimationComponent>(a); if (p != null && d != null && d.visible == true) { if (anim != null) { d.drawRectangle = new Rectangle((int)p.position.X, (int)p.position.Y, anim.sourceRectangle.Width, anim.sourceRectangle.Height); spriteBatch.Draw(d.texture, p.position, anim.sourceRectangle, d.colour, 0, Vector2.Zero, 1, d.flip, 1); } else { spriteBatch.Draw(d.texture, p.position, null, d.colour, 0, Vector2.Zero, 1, d.flip, 1); } } } } }
public IEnumerable <DrawableComponent> GetDrawableComponents() { var comp = new DrawableComponent() { TextureName = this.SurfaceName, RenderSize = new Vector2f(70, 104), Position = new Vector2f(this.X - 35, this.Y - 100), Rect = new IntRect(513 * (int)girlDirection, 800 * animStep, 513, 800) }; if (this.flagForHitCounter > 0) { if (this.flagForHitCounter < 5) { comp.Color = Color.Red; } else { if (this.flagForHitCounter % 10 < 5) { comp.Color = new Color(50, 255, 255); } } this.flagForHitCounter += 1; this.flagForHitCounter %= 75; } yield return(comp); }
public void AddOrUpdate(GameWorld world, Entity e, bool recursion = false) { RoadComponent road = e.Get <RoadComponent>(); string value = "dirt-road-" + GetRoadValue(world.Map, road.BuiltAt); // set the value of built into the roadPlanner if (!Built.ContainsKey(road.BuiltAt)) { Built.Add(road.BuiltAt, value); } else { Built[road.BuiltAt] = value; } if (road.Updateable) { DrawableComponent drawable = e.Get <DrawableComponent>(); foreach (GameDrawable sprite in drawable.Drawables["Foundation"].ToList()) { if (sprite.PrototypeID.Contains("road")) { // remove old road drawables drawable.Drawables["Foundation"].Remove(sprite); } } road.RoadType = Built[road.BuiltAt]; drawable.Add("Foundation", (GameDrawable)world.Prototypes[road.RoadType]); } if (recursion) { UpdateNeighbors(world, e); } }
/// <summary> /// The TextInput constructor /// </summary> /// <param name="name">name of the component</param> /// <param name="drawInfo">Drawing info about the text component</param> /// <param name="inputActionCallBack">The function to be called whence enter is pressed.</param> public TextInputComponent(string name, DrawableComponent drawInfo, stringCallBack inputActionCallBack) : base(name, drawInfo) { _sCurrentInput = ""; _inputActionCallBack = inputActionCallBack; }
public void AddSelectedComponent(DrawableComponent dc) { if (!SelectedComponents.Contains(dc)) { SelectedComponents.Add(dc); } }
public void ControllPoweruppLife(GameTime timer) { List <int> balls = ComponentManager.Instance.GetAllEntitiesWithComponentType <BallOfSpikesPowerUpComponent>(); if (balls != null) { foreach (var ball in balls) { BallOfSpikesPowerUpComponent b = ComponentManager.Instance.GetEntityComponent <BallOfSpikesPowerUpComponent>(ball); double test = b.lifeTime - timer.ElapsedGameTime.TotalSeconds; if (test <= 0) { DrawableComponent newDraw = ComponentManager.Instance.GetEntityComponent <DrawableComponent>(ball); BallOfSpikesPowerUpComponent pow = ComponentManager.Instance.GetEntityComponent <BallOfSpikesPowerUpComponent>(ball); newDraw.texture = b.prevTexture; if (b.anime != null) { ComponentManager.Instance.AddComponentToEntity(ball, b.anime); } ComponentManager.Instance.RemoveComponentFromEntity(ball, b); } b.lifeTime = test; } } }
/// <summary> /// onSceneUpdate this function handles the logic for the state which should be run durring the update partion of the game. /// For example this could be to check for conditions to continue to the next state of the gameplay. /// </summary> public void onSceneUpdate() { if (fc.alphaValue <= 0) { List <IComponent> complist; //This is used for changin the currentState //SetUpPlayerScene stateTwo = new SetUpPlayerScene(); //SceneSystem.Instance.setCurrentScene(stateTwo); string[] menuItems = { "Start Game", "Options", "About", "End Game" }; MenuScene menu = new MenuScene(menuItems); SceneSystem.Instance.setCurrentScene(menu); foreach (int comp in entitiesInState) { complist = ComponentManager.Instance.GetAllEntityComponents(comp); foreach (IComponent a in complist) { if (a.GetType() == typeof(DrawableComponent)) { DrawableComponent hej = (DrawableComponent)a; hej.visible = false; } if (a.GetType() == typeof(DrawableTextComponent)) { DrawableTextComponent hej = (DrawableTextComponent)a; SceneSystem.Instance.clearScene(entitiesInState); } } } } }
/// <summary> /// Creates Power Upp component and adds it to an entity /// </summary> /// <param name="id"></param> public void OnPowerUpPicup(int id) { BallOfSpikesPowerUpComponent temp = ComponentManager.Instance.GetEntityComponent <BallOfSpikesPowerUpComponent>(id); if (temp == null) { ComponentManager test = ComponentManager.Instance; BallOfSpikesPowerUpComponent ball = new BallOfSpikesPowerUpComponent(5); DrawableComponent newDraw = test.GetEntityComponent <DrawableComponent>(id); AnimationComponent anima = test.GetEntityComponent <AnimationComponent>(id); ball.prevTexture = newDraw.texture; newDraw.texture = ball.SpikeTexture; if (anima != null) { ball.anime = anima; ComponentManager.Instance.RemoveComponentFromEntity(id, anima); } test.AddComponentToEntity(id, ball); CollisionRectangleComponent rec = ComponentManager.Instance.GetEntityComponent <CollisionRectangleComponent>(id); PositionComponent pos = ComponentManager.Instance.GetEntityComponent <PositionComponent>(id); rec.CollisionRec = new Rectangle((int)pos.position.X, (int)pos.position.Y, newDraw.texture.Width, newDraw.texture.Height); rec.CollisionRec.X = (int)pos.position.X; rec.CollisionRec.Y = (int)pos.position.Y; rec.CollisionRec.Width = newDraw.texture.Width; rec.CollisionRec.Height = newDraw.texture.Height; } else { temp.lifeTime += 10; } }
public override void Shutdown() { DrawableComponent drawable = dataTracker.Get <DrawableComponent>(); foreach (List <GameDrawable> d in drawable.Drawables.Values) { foreach (GameDrawable gd in d) { gd.Alpha = 1.0f; gd.Visible = true; } } drawable.Drawables.Clear(); ClearButtons(); World.Input.LeftClick -= Instance_LeftClick; World.Input.BuildBack.Event -= BuildBack_Event; World.Input.BuildHotKey1.Event -= BuildHotKey1_Event; World.Input.BuildHotKey2.Event -= BuildHotKey2_Event; World.Input.BuildHotKey3.Event -= BuildHotKey3_Event; World.Input.BuildHotKey4.Event -= BuildHotKey4_Event; World.Input.BuildHotKey5.Event -= BuildHotKey5_Event; World.Input.BuildHotKey6.Event -= BuildHotKey6_Event; World.Input.BuildHotKey7.Event -= BuildHotKey7_Event; World.Input.BuildHotKey8.Event -= BuildHotKey8_Event; World.Input.BuildHotKey9.Event -= BuildHotKey9_Event; World.Input.BuildHotKey0.Event -= BuildHotKey0_Event; ClearDragState(); }
private void CloneMembers(DrawableComponent original) { IconName = original.IconName; DisplayName = original.DisplayName; DisplayCost = original.DisplayCost; displayQuantity = original.DisplayQuantity; }
public override void Update(double dt) { foreach (Entity e in brains) { DrawableComponent drawable = e.Get <DrawableComponent>(); CitizenComponent citizen = e.Get <CitizenComponent>(); foreach (GameDrawable d in drawable.Get("Text")) { d.Visible = true; if (d is DrawableText) { string text = ""; Behavior brain = citizen.Brain; while (brain != null) { text += brain.GetType().Name + System.Environment.NewLine; brain = brain.Child; } ((DrawableText)d).Text = text; } } } }
public override void Init(GameWorld world, Entity self) { base.Init(world, self); DrawableComponent drawable = self.Get <DrawableComponent>(); if (FadeIn) { foreach (GameDrawable d in drawable.Get("Foreground")) { if (d is DrawableSprite) { if (d.Alpha >= 1.0f) { Skip = true; } } d.Visible = true; } } foreach (GameDrawable d in drawable.Get("Foreground")) { if (FadeIn) { FadeCounter = FadeTime - (int)(d.Alpha * FadeTime); } else { FadeCounter = (int)(d.Alpha * FadeTime); } break; } }
/// <summary> /// Updates the collision rectangles of all collision components /// </summary> private void updatecolRec() { List <int> CollisionComp = ComponentManager.Instance.GetAllEntitiesWithComponentType <CollisionComponent>(); if (CollisionComp != null) { foreach (var item in CollisionComp) { CollisionRectangleComponent rec = ComponentManager.Instance.GetEntityComponent <CollisionRectangleComponent>(item); PositionComponent pos = ComponentManager.Instance.GetEntityComponent <PositionComponent>(item); DrawableComponent draw = ComponentManager.Instance.GetEntityComponent <DrawableComponent>(item); AnimationComponent ani = ComponentManager.Instance.GetEntityComponent <AnimationComponent>(item); if (ani != null && draw != null) { rec.CollisionRec = new Rectangle((int)pos.position.X, (int)pos.position.Y, ani.sourceRectangle.Width, ani.sourceRectangle.Height); } if (draw != null && ani == null) { rec.CollisionRec.X = (int)pos.position.X; rec.CollisionRec.Y = (int)pos.position.Y; rec.CollisionRec.Width = draw.texture.Width; rec.CollisionRec.Height = draw.texture.Height; } else { rec.CollisionRec.X = (int)pos.position.X; rec.CollisionRec.Y = (int)pos.position.Y; } } } }
/// <summary> /// Creates an new Player with Controlls /// </summary> /// <param name="pixlePer"> True if pixelPerfect shall be used </param> /// <param name="GamePade"> True if GamePad the player uses a gamepad </param> /// <param name="PadJump"> Key binding to gamePad </param> /// <param name="Jump"> key binding to keybord </param> /// <param name="position"> Player start Position </param> /// <param name="name"> The name off the player</param> /// <param name="dir"> The players starting direction</param> /// <param name="index"> Playerindex For GamePad </param> /// <returns></returns> public int CreatePlayer(bool pixlePer, bool GamePade, Buttons PadJump, Keys Jump, Vector2 position, string name, Direction dir, PlayerIndex index, Color colour) { SpriteEffects flip; GamePadComponent gam; KeyBoardComponent kcb; int id = ComponentManager.Instance.CreateID(); if (dir == Direction.Left) { flip = SpriteEffects.FlipHorizontally; } else { flip = SpriteEffects.None; } if (GamePade == true) { gam = new GamePadComponent(index); gam.gamepadActions.Add(ActionsEnum.Jump, PadJump); ComponentManager.Instance.AddComponentToEntity(id, gam); } else { kcb = new KeyBoardComponent(); kcb.keyBoardActions.Add(ActionsEnum.Jump, Jump); ComponentManager.Instance.AddComponentToEntity(id, kcb); } DirectionComponent dc = new DirectionComponent(dir); DrawableComponent comp = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Pic/kanin1"), flip); PositionComponent pos = new PositionComponent(position); VelocityComponent vel = new VelocityComponent(new Vector2(200F, 0), 50F); JumpComponent jump = new JumpComponent(300F, 200F); CollisionRectangleComponent CRC = new CollisionRectangleComponent(new Rectangle((int)pos.position.X, (int)pos.position.Y, comp.texture.Width, comp.texture.Height)); CollisionComponent CC = new CollisionComponent(pixlePer); PlayerComponent pc = new PlayerComponent(name); DrawableTextComponent dtc = new DrawableTextComponent(name, Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/TestFont")); HUDComponent hudc = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), new Vector2(pos.position.X, pos.position.Y)); HUDComponent hudc2 = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), Vector2.One); HealthComponent hc = new HealthComponent(3, false); //AnimationComponent ani = new AnimationComponent(100, 114, comp.texture.Width, comp.texture.Height, 0.2); comp.colour = colour; ComponentManager.Instance.AddComponentToEntity(id, vel); ComponentManager.Instance.AddComponentToEntity(id, comp); ComponentManager.Instance.AddComponentToEntity(id, pos); ComponentManager.Instance.AddComponentToEntity(id, CRC); ComponentManager.Instance.AddComponentToEntity(id, CC); ComponentManager.Instance.AddComponentToEntity(id, pc); ComponentManager.Instance.AddComponentToEntity(id, dtc); ComponentManager.Instance.AddComponentToEntity(id, hudc); ComponentManager.Instance.AddComponentToEntity(id, hc); //ComponentManager.Instance.AddComponentToEntity(id, ani); ComponentManager.Instance.AddComponentToEntity(id, dc); ComponentManager.Instance.AddComponentToEntity(id, jump); return(id); }
public void SetNewComponent(DrawableComponent dc) { newComponent = dc; currentProject.Simulation.ClearSelectedComponents(); currentProject.Simulation.AddComponent(dc); currentProject.Simulation.AddSelectedComponent(dc); state = EditorState.MovingSelection; }
private void DrawElement(DrawableComponent drawable, int iconX, int iconY) { Texture2D iconTexture = TextureCache.GetCachedTexture(drawable.IconName); graphics.DrawImage(iconTexture.bitmap, iconX, iconY); graphics.DrawString(drawable.DisplayName, SystemFonts.CaptionFont, Brushes.Black, iconX + 8, iconY + 8); graphics.DrawString($"Buy: {drawable.DisplayCost.ToString()}", SystemFonts.CaptionFont, Brushes.Black, iconX + 8, iconY + 24); graphics.DrawString($"{drawable.DisplayQuantity.ToString()}x", SystemFonts.CaptionFont, Brushes.SlateGray, iconX + 8, iconY + 64); }
public override void ComponentLoaded(Entity e, Component c, JObject o) { // Do custom handling of the component switch (c.GetType().Name) { case "DrawableComponent": DrawableComponent drawable = (DrawableComponent)c; drawable.Drawables.Clear(); if (o["Sources"] != null) { IEnumerable <string> sources = o["Sources"].Values <string>(); foreach (string str in sources) { GameDrawable d = (GameDrawable)Library[str]; drawable.Add(d.Layer, d); } } if (o["Drawables"] != null) { DrawableComponent dd = JsonConvert.DeserializeObject <DrawableComponent>(o.ToString(), new DrawableConverter()); foreach (KeyValuePair <string, List <GameDrawable> > kvp in dd.Drawables) { foreach (GameDrawable d in kvp.Value) { drawable.Add(kvp.Key, d); } } } break; case "FoundationComponent": FoundationComponent floor = (FoundationComponent)c; switch (floor.PlanType) { case "Fill": Point start = floor.Plan[0].Offset; Point end = floor.Plan[1].Offset; floor.Plan.Clear(); // clear the plan, the for loops will fill it for (int xx = start.X; xx <= end.X; xx++) { for (int yy = start.Y; yy <= end.Y; yy++) { floor.Plan.Add(new LocationValue() { Offset = new Point(xx, yy) }); } } break; } break; } }
public Ball(DrawableComponent drawable, Entity entity, Platform platform) { Active = false; Drawable = drawable; Entity = entity; Platform = platform; HitPoints = 1; }
public static void ModifyAll(DrawableComponent Component, IDrawableUnit Modification) { for (int x = 0; x < Component.SizeX; x++) { for (int y = 0; y < Component.SizeY; y++) { Component.Contents[x, y] = Modification; } } }
public static void Clear(DrawableComponent Component) { for (int x = 0; x < Component.SizeX; x++) { for (int y = 0; y < Component.SizeY; y++) { Component.Contents[x, y] = new Pixel(Component.Background); } } }//Do not use every tick
public override void Update(double dt) { if (delayCountdown > 0) { delayCountdown -= dt; } if (string.IsNullOrWhiteSpace(selectedCategory) || selectedEntityIndex == -1) { return; } if (isDragging) { UpdateDraggables(); } else { DrawableComponent drawable = dataTracker.Get <DrawableComponent>(); PositionComponent drawablePosition = dataTracker.Get <PositionComponent>(); Entity selectedEntity = indexedBuildables[selectedCategory][selectedEntityIndex]; BuildableComponent selectedBuildable = selectedEntity.Get <BuildableComponent>(); FoundationComponent foundation = selectedEntity.Get <FoundationComponent>(); // pick out the tile index that the screen coords intersect Point index = GetMouseIndex(); // translate the index into a screen position and up the position component Vector2 dPositiion = World.Map.GetPositionFromIndex(index.X, index.Y); drawablePosition.X = dPositiion.X; drawablePosition.Y = dPositiion.Y; bool spaceTaken = false; foreach (LocationValue lv in foundation.Plan) { if (World.Foundations.SpaceTaken.ContainsKey(new Point(index.X + lv.Offset.X, index.Y + lv.Offset.Y))) { spaceTaken = true; break; } } bool visible = World.Map.IsValidIndex(index.X, index.Y); foreach (List <GameDrawable> d in drawable.Drawables.Values) { foreach (GameDrawable gd in d) { gd.Visible = visible; gd.Alpha = (spaceTaken) ? 0.5f : 0.85f; } } } }
public List <WorkspaceComponent> GenerateComponents(List <DrawableComponent> components) { List <WorkspaceComponent> comps = new List <WorkspaceComponent>(); for (int i = 0; i < components.Count; i++) { DrawableComponent dc = components[i]; string type = ""; if (dc is DrawableLogicGate) { type = ((DrawableLogicGate)dc).GetLogicName(); } else if (dc is DrawableCircuitLamp) { type = "Lamp"; } else if (dc is DrawableCircuitSwitch) { type = "Switch"; } else if (dc is DrawableIC) { type = ((DrawableIC)dc).Description.Name; } List <WorkspaceComponentConnection> connections = new List <WorkspaceComponentConnection>(); foreach (CircuitOutput co in dc.Outputs) { foreach (DrawableWire dw in co.Signals) { WorkspaceComponentConnection wcc = new WorkspaceComponentConnection(components.IndexOf(dw.To), dw.FromIndex, dw.ToIndex); connections.Add(wcc); } } WorkspaceComponent wc = new WorkspaceComponent(type, dc.Position, connections); if (dc is DrawableCircuitLamp) { wc.SetID(((DrawableCircuitLamp)dc).ID); } if (dc is DrawableCircuitSwitch) { wc.SetID(((DrawableCircuitSwitch)dc).ID); } comps.Add(wc); } return(comps); }
public int CreateBackground(Vector2 position, string texture, int width, int height) { int id = ComponentManager.Instance.CreateID(); PositionComponent pos = new PositionComponent(position); DrawableComponent draw = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Background/" + texture), SpriteEffects.None); ComponentManager.Instance.AddComponentToEntity(id, pos); ComponentManager.Instance.AddComponentToEntity(id, draw); return(id); }
public override void Initialize() { // Load model for platform drawable Model platformModel = Game.Content.Load <Model>(@"Models\platform"); // Create platform itself platformDrawable = new DrawableComponent(platformModel, camera, Game); platformDrawable.LocalTransform *= Matrix.CreateScale(2.5f); platformDrawable.LocalTransform *= Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f)); platformDrawable.LocalTransform *= Matrix.CreateRotationY(MathHelper.ToRadians(45.0f)); platformDrawable.LocalTransform *= Matrix.CreateRotationY(MathHelper.ToRadians(OrientationAngle)); platformDrawable.WorldTransform *= Matrix.CreateTranslation(Position); platformDrawable.LightingEnable = true; // Obtain physics space instance ISpace space = (ISpace)Game.Services.GetService(typeof(ISpace)); // Load model for the balls Model ballModel = Game.Content.Load <Model>(@"Models\sphere"); // Create balls for (int n = 0; n < 4; n++) { // Create entity for the ball Entity ballEntity = new Sphere(Position + new Vector3(0.0f, 0.5f, 0.0f), 0.5f); ballEntity.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous; ballEntity.CollisionInformation.CollisionRules.Group = ballsGroup; ballEntity.Material.Bounciness = STANDARD_BALL_BOUNCINESS; // Create drawable for the ball DrawableComponent ballDrawable = new DrawableComponent(ballModel, camera, Game); ballDrawable.DiffuseColor = BallColor; ballDrawable.LocalTransform = Matrix.CreateScale(0.5f); ballDrawable.LightingEnable = true; ballDrawable.FogEnable = true; // Create ball instance Ball ball = new Ball(ballDrawable, ballEntity, this); balls.Add(ball); } // Set one ball to be active currentBall = balls[0]; currentBall.Active = true; scoreScale = 1.0f; }
public void DontDrawWhenComponentIsInvisible() { DrawableComponent disabledComponent = A.Fake <DrawableComponent>(); disabledComponent.Visible = false; // it is a fake, but it cannot fake visible because its sealed collection.Add(disabledComponent); collection.LoadContent(null); collection.Draw(null, null); A.CallTo(() => disabledComponent.Draw(null, null)).MustNotHaveHappened(); }
/// <summary> /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime. /// </summary> public void onSceneCreated() { ChangeCubesSystem ccs = (ChangeCubesSystem)SystemManager.Instance.RetrieveSystem <IUpdate>("ChangeCubesSystem"); ccs.Respawn(3); SpawnPowerUpSystem sps = (SpawnPowerUpSystem)SystemManager.Instance.RetrieveSystem <IUpdate>("SpawnPowerUpSystem"); sps.Initialize(); List <int> maps = ComponentManager.Instance.GetAllEntitiesWithComponentType <DrawableTextComponent>(); if (maps.Count == 1) { int temp = maps.First(); DrawableTextComponent draw = ComponentManager.Instance.GetEntityComponent <DrawableTextComponent>(temp); switch (draw.text) { case "Whiteboard": WhiteboardMap(); break; case "Temp": tempMap(); break; case "Random": randomMap(); break; } } SceneSystem.Instance.clearScene(maps); List <int> Players = ComponentManager.Instance.GetAllEntitiesWithComponentType <PlayerComponent>(); int i = 1; Random rand = new Random(); foreach (var play in Players) { DrawableComponent tempDraw = ComponentManager.Instance.GetEntityComponent <DrawableComponent>(play); KeyBoardComponent tempkey = ComponentManager.Instance.GetEntityComponent <KeyBoardComponent>(play); PositionComponent temppos = ComponentManager.Instance.GetEntityComponent <PositionComponent>(play); Keys key; tempkey.keyBoardActions.TryGetValue(ActionsEnum.Up, out key); entitiesInState.Add(GameEntityFactory.Instance.CreatePlayer(true, false, Buttons.A, key, new Vector2(rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Width)), rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Height * 0.6))), "Player " + i, Direction.Right, PlayerIndex.One, tempDraw.colour)); i++; ComponentManager.Instance.RemoveEntity(play); //ComponentManager.Instance.RecycleID(play); } entitiesInState.Add(GameEntityFactory.Instance.CreateAIPlayer(Direction.Right, new Vector2(rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Width)), rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Height * 0.8))), true, "AI one", Color.Red)); }
public static Entity AddComponent(this Entity entity, DrawableComponent drawableComponent, BodyComponent bodyComponent) { if (drawableComponent == null || bodyComponent == null) { throw new ArgumentNullException($"Argument {nameof(drawableComponent)} or {nameof(bodyComponent)} can't be null!"); } // This is necessary because Aether.Physics2D works better with negative Y gravity. // See samples: https://github.com/tainicom/Aether.Physics2D/tree/master/Samples drawableComponent.DrawInUICamera = false; entity.AddComponent(drawableComponent).AddComponent(bodyComponent); return(entity); }
}//Do not use every tick public static void ModifyBoarders(DrawableComponent Component) { for (int x = 0; x < Component.SizeX; x++) { for (int y = 0; y < Component.SizeY; y++) { if (x == 0 || x == Component.SizeX - 1 || y == 0 || y == Component.SizeY - 1) //If it's on the boarders { Component.Contents[x, y] = new Pixel(Component.Foreground); } } } }
public BlockHitAnimation(Block block, Vector3 hitPos, Platform platform) { this.block = block; GameLevel level = block.BlockType.Owner; light = new DrawableComponent(block.BlockType.Model, level.Camera, level.Game); light.LocalTransform = Matrix.CreateScale(block.Scale) * Matrix.CreateScale(1.1f); light.DiffuseColor = block.BlockType.Color; this.platform = platform; this.platformPos = platform.Position; }
public ButtonComponent(string Name, DrawableComponent drawInfo, IDrawableUnit SelectedColors, IDrawableUnit PressedColors, IDrawableUnit UnselectedColors, PressAction calledWhenPressed) : base(Name,drawInfo) { this.SelectedColors = SelectedColors; this.UnselectedColors = UnselectedColors; this.PressedColors = PressedColors; Pressed = false; Selected = false; SetColors(UnselectedColors); this.calledWhenPressed = calledWhenPressed; }
public ConsoleComponent(string Name, DrawableComponent drawInfo) : base(Name, drawInfo) { //Set up scrolling AutoScroll = true; //Set up input _CurrentInput = ""; Reading = false; //Set up the contents of the console ConsoleText = new StringBuilder(Text); //Set up read/write streams Out = new StringWriter(ConsoleText); In = new StringReader(_CurrentInput); }