void _AddComponent(ElementTag tagEntity, IGraphicComponent com) { com.EntityTag = tagEntity; components[tagEntity].Add(com.Tag, com); entityHas[tagEntity].Add(com.GetType()); notify.NotifyChange(com); }
public IGraphicComponent AddComponent(ElementTag tagEntity, IGraphicComponent com) { comSynchronizer.Add((owner, inp) => { owner._AddComponent(tagEntity, inp); }, com); return(com); }
public void AddComponent(IGraphicComponent comp) { comp.CheckNull("comp"); RegisterEventHandler(comp); components.Add(comp); Invalidate(); }
public void DrawComponentReflection(IGraphicComponent component, float[] drawingTranslation, float[] drawingRotation, float[] lightPosition) { GL.glPushMatrix(); if (component is IShadowingGraphicComponent) { drawReflectedShadow(component as IShadowingGraphicComponent, drawingTranslation, drawingRotation, lightPosition); } beginStencil(eStencils.Reflection); GL.glScalef(1, 1, -1); GL.glTranslatef(drawingTranslation[0], drawingTranslation[1], drawingTranslation[2]); GL.glRotatef(drawingRotation[0], 1, 0, 0); GL.glRotatef(drawingRotation[1], 0, 1, 0); GL.glRotatef(drawingRotation[2], 0, 0, 1); GL.glColor3f(1, 1, 1); component.Draw(); stopStencil(); GL.glPopMatrix(); }
public VisualComponentItem(IGraphicComponent com, IRenderUpdater updater) { this.com = com; this.updater = updater; OpenPropertiesEditor = new Windows.VisualTreeviewerViewModel.OpenPropertiesEditorComponentItemCommand(updater); }
public void SetStartSize(IGraphicComponent component) { component.CheckNull("component"); StartWidth = component.Width; StartHeight = component.Height; }
public MultiLayeredComponent(IGraphicComponent mainComponent) { nullObject = new NullGraphicObject(); this.mainComponent = mainComponent; foreground = nullObject; background = nullObject; }
void _RemoveComponent(ElementTag tagEntity, IGraphicComponent com) { var removed = components[tagEntity].Remove(com.Tag); removed = entityHas[tagEntity].Remove(com.GetType()); com.Dispose(); notify.NotifyChange(com); }
internal HPLine(IGraphicComponent outerLine, IGraphicComponent innerLine, IGraphicComponent hpLine, Color backgroundColor) { this.outerLine = outerLine; this.innerLine = innerLine; this.hpLine = hpLine; outerLine.Color = Color.Black; innerLine.Color = backgroundColor; }
public bool TryRefresh(IGraphicComponent com) { if (!hash.ContainsKey(com.Tag)) { return(false); } hash[com.Tag].Refresh(com); return(true); }
private HPLine CreateLine(IGraphicComponent hpLine) { var outerLine = new Mock<IGraphicComponent>().Object; var innerLine = new Mock<IGraphicComponent>().Object; var line = new HPLine(outerLine, innerLine, hpLine, Color.White); line.MaxHP = 100; line.Setup(); return line; }
private ItemBox CreateItemBox(IGraphicComponent arrow = null, ITextGraphicComponent text = null) { if (arrow == null) arrow = new GraphicComponentMock(); if (text == null) text = new TextGraphicComponentMock(); return new ItemBox(arrow, text); }
public void Update(GameTime time, IGraphicComponent component) { if (!IsTimeIntervalOver(time, lastTime)) return; lastTime = time; component.IsVisible = !component.IsVisible; currentNumberOfBlinks++; if (AnimationDone()) AnimationFinished(this, EventArgs.Empty); }
public void Change(IGraphicComponent com) { switch (com) { case HittableGeometryComponent geo: // TODO remove this IF, remake additing to Manager base on Generic type if (geo.IsDisposed) { synchronizer.Add((_, cc) => { _.Remove(cc.EntityTag); _.isActualStateDrawed = false; }, geo); } else { geo.BuildTreeAsync() .ContinueWith(x => { synchronizer.Add((_, cc) => { var g = (HittableGeometryComponent)cc; var tr = context .GetComponentManager() .GetComponents <TransformComponent>(cc.EntityTag); var b = g.Box; if (tr.Any()) { b = b.Transform(tr.Single().MatrixWorld); } _.Add(b, g.EntityTag); _.isActualStateDrawed = false; }, x.Result); }); } break; case TransformComponent tr when TryGet(tr.EntityTag, out var found): var entity = tr.EntityTag; var box = context .GetComponentManager() .GetComponent <HittableGeometryComponent>(entity).Box; synchronizer.Add((_, cc) => { var t = (TransformComponent)cc; _.Remove(entity); var worldBox = box.Transform(t.MatrixWorld); _.Add(worldBox, entity); _.isActualStateDrawed = false; }, tr); break; } }
public CharacterSprite(IGraphicComponent lookingLeft, IGraphicComponent lookingRight, IGraphicComponent lookingUp, IGraphicComponent lookingDown) { if (lookingLeft == null) throw new ArgumentNullException("lookingLeft"); if (lookingRight == null) throw new ArgumentNullException("lookingRight"); if (lookingUp == null) throw new ArgumentNullException("lookingUp"); if (lookingDown == null) throw new ArgumentNullException("lookingDown"); directionDictionary[Direction.Down] = lookingDown; directionDictionary[Direction.Left] = lookingLeft; directionDictionary[Direction.Right] = lookingRight; directionDictionary[Direction.Up] = lookingUp; currentDirection = lookingDown; }
public void Update(GameTime time, IGraphicComponent component) { if (targetHP == currentHP) { if (AnimationFinished != null) AnimationFinished(this, null); currentHP = 0; return; } if (!time.ElapsedGameTime.TotalMilliseconds.AlmostEqual(0)) return; if (lower) currentHP = Math.Max(currentHP - 1, targetHP); else currentHP = Math.Min(currentHP + 1, targetHP); line.Current = currentHP; }
private static void SetComponentSize(IGraphicComponent c, float cellWidth, float cellHeight) { switch (c.HorizontalPolicy) { case ResizePolicy.Preferred: c.Width = Math.Min(cellWidth, c.PreferredWidth); break; case ResizePolicy.Extending: c.Width = cellWidth; break; } switch (c.VerticalPolicy) { case ResizePolicy.Preferred: c.Height = Math.Min(cellHeight, c.PreferredHeight); break; case ResizePolicy.Extending: c.Height = cellHeight; break; } }
public void Update(GameTime time, IGraphicComponent component) { component.CheckNull("component"); if (!IsInitialized) Init(); if (currentWidth.CompareTo(EndWidth) == 0 && currentHeight.CompareTo(EndHeight) == 0) Finished(); if (time.ElapsedGameTime.TotalMilliseconds.AlmostEqual(0)) return; if (shrinkX) currentWidth = Math.Max(currentWidth - SpeedX, EndWidth); else currentWidth = Math.Min(currentWidth + SpeedX, EndWidth); if (shrinkY) currentHeight = Math.Max(currentHeight - SpeedY, EndHeight); else currentHeight = Math.Max(currentWidth + SpeedY, EndHeight); component.Width = currentWidth; component.Height = currentHeight; }
private static void SetComponentPosition(IGraphicComponent component, float xPosition, float yPosition) { component.XPosition = xPosition; component.YPosition = yPosition; }
private void RegisterEventHandler(IGraphicComponent comp) { comp.PreferredSizeChanged += PreferredSizeChangedHandler; comp.SizeChanged += SizeChangedHandler; }
public void TurnToDirection(Direction direction) { currentDirection = directionDictionary[direction]; }
public void RemoveComponent(IGraphicComponent component) { if (!components.Remove(component)) return; RemoveEventHandler(component); Invalidate(); }
private static bool ComponentResizePolicyIsPreferred(IGraphicComponent e) { return e.VerticalPolicy == ResizePolicy.Preferred || e.HorizontalPolicy == ResizePolicy.Preferred; }
public static void IsInConstraints(this IGraphicComponent component, IGraphicComponent other) { component.IsInConstraints(other.XPosition, other.YPosition, other.Width, other.Height); }
public void RemoveComponent(IGraphicComponent component) { manager.RemoveComponent(Tag, component); }
private void AssertCoordinatesEqual(IGraphicComponent firstComponent, IGraphicComponent secondComponent) { Assert.AreEqual(firstComponent.XPosition, secondComponent.XPosition); Assert.AreEqual(firstComponent.YPosition, secondComponent.YPosition); Assert.AreEqual(firstComponent.Width, secondComponent.Width); Assert.AreEqual(firstComponent.Height, secondComponent.Height); }
private MultiLayeredComponent CreateComponent(IGraphicComponent mainComponent = null, IGraphicComponent background = null, IGraphicComponent foreground = null) { if (mainComponent == null) mainComponent = new GraphicComponentMock(); var testComponent = new MultiLayeredComponent(mainComponent); testComponent.Background = background; testComponent.Foreground = foreground; return testComponent; }
public void Handle(IGraphicComponent com) { others.Add(com); }
private void RemoveEventHandler(IGraphicComponent c) { c.PreferredSizeChanged -= PreferredSizeChangedHandler; c.SizeChanged -= SizeChangedHandler; }
private bool ComponentResizePolicyIsFixed(IGraphicComponent component) { return component.VerticalPolicy == ResizePolicy.Fixed || component.HorizontalPolicy == ResizePolicy.Fixed; }
private static void SetSizeWithLimits(IGraphicComponent component, float height, float width, float heightLimit, float widthLimit) { if (component.VerticalPolicy == ResizePolicy.Preferred) component.Height = Math.Min(component.PreferredHeight, heightLimit); else if(component.VerticalPolicy == ResizePolicy.Extending) component.Height = height; if (component.HorizontalPolicy == ResizePolicy.Preferred) component.Width = Math.Min(component.PreferredWidth, widthLimit); else if (component.HorizontalPolicy == ResizePolicy.Extending) component.Width = width; }
public VisualComponentItem(IGraphicComponent com, IPropertyTabManager propertyTabManager) { this.com = com; OpenPropertiesTab = new OpenPropertiesTabCommand(this, propertyTabManager); }
public void Draw(IGraphicComponent component, ISpriteBatch batch, GameTime gameTime) { component.Draw(gameTime, batch); }
public void Refresh(IGraphicComponent component) { com = component; SetPropertyChanged(nameof(Name)); }
public void RemoveComponent(ElementTag tagEntity, IGraphicComponent com) { }
public static void SetCoordinates(this IGraphicComponent component, IGraphicComponent constraints) { component.SetCoordinates(constraints.XPosition, constraints.YPosition, constraints.Width, constraints.Height); }
public IGraphicComponent AddComponent(ElementTag tagEntity, IGraphicComponent com) => EmptyGraphicComponent.Create();
public void RemoveComponent(ElementTag tagEntity, IGraphicComponent com) { comSynchronizer.Add((owner, inp) => { owner._RemoveComponent(tagEntity, inp); }, com); }
public void IsInConstraints(IGraphicComponent component) { IsInConstraints(component.XPosition, component.YPosition, component.Width, component.Height); }
public GraphicComponentSizeChangedEventArgs(IGraphicComponent component, float width, float height) { Component = component; Width = width; Height = height; }