Exemplo n.º 1
0
 void _AddComponent(ElementTag tagEntity, IGraphicComponent com)
 {
     com.EntityTag = tagEntity;
     components[tagEntity].Add(com.Tag, com);
     entityHas[tagEntity].Add(com.GetType());
     notify.NotifyChange(com);
 }
Exemplo n.º 2
0
 public IGraphicComponent AddComponent(ElementTag tagEntity, IGraphicComponent com)
 {
     comSynchronizer.Add((owner, inp) => {
         owner._AddComponent(tagEntity, inp);
     }, com);
     return(com);
 }
Exemplo n.º 3
0
 public void AddComponent(IGraphicComponent comp)
 {
     comp.CheckNull("comp");
     RegisterEventHandler(comp);
     components.Add(comp);
     Invalidate();
 }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        public VisualComponentItem(IGraphicComponent com, IRenderUpdater updater)
        {
            this.com     = com;
            this.updater = updater;

            OpenPropertiesEditor = new Windows.VisualTreeviewerViewModel.OpenPropertiesEditorComponentItemCommand(updater);
        }
Exemplo n.º 6
0
        public void SetStartSize(IGraphicComponent component)
        {
            component.CheckNull("component");

            StartWidth = component.Width;
            StartHeight = component.Height;
        }
Exemplo n.º 7
0
 public MultiLayeredComponent(IGraphicComponent mainComponent)
 {
     nullObject = new NullGraphicObject();
     this.mainComponent = mainComponent;
     foreground = nullObject;
     background = nullObject;
 }
Exemplo n.º 8
0
        void _RemoveComponent(ElementTag tagEntity, IGraphicComponent com)
        {
            var removed = components[tagEntity].Remove(com.Tag);

            removed = entityHas[tagEntity].Remove(com.GetType());
            com.Dispose();
            notify.NotifyChange(com);
        }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 public bool TryRefresh(IGraphicComponent com)
 {
     if (!hash.ContainsKey(com.Tag))
     {
         return(false);
     }
     hash[com.Tag].Refresh(com);
     return(true);
 }
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
        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);

        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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;
            }
        }
Exemplo n.º 15
0
        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;
        }
Exemplo n.º 16
0
        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;
        }
Exemplo n.º 17
0
        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;
            }
        }
Exemplo n.º 18
0
        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;
        }
Exemplo n.º 19
0
 private static void SetComponentPosition(IGraphicComponent component, float xPosition, float yPosition)
 {
     component.XPosition = xPosition;
     component.YPosition = yPosition;
 }
Exemplo n.º 20
0
 private void RegisterEventHandler(IGraphicComponent comp)
 {
     comp.PreferredSizeChanged += PreferredSizeChangedHandler;
     comp.SizeChanged += SizeChangedHandler;
 }
Exemplo n.º 21
0
 public void TurnToDirection(Direction direction)
 {
     currentDirection = directionDictionary[direction];
 }
Exemplo n.º 22
0
 public void RemoveComponent(IGraphicComponent component)
 {
     if (!components.Remove(component))
         return;
     
     RemoveEventHandler(component);
     Invalidate();
 }
Exemplo n.º 23
0
 private static bool ComponentResizePolicyIsPreferred(IGraphicComponent e)
 {
     return e.VerticalPolicy == ResizePolicy.Preferred ||
         e.HorizontalPolicy == ResizePolicy.Preferred;
 }
Exemplo n.º 24
0
 public static void IsInConstraints(this IGraphicComponent component, IGraphicComponent other)
 {
     component.IsInConstraints(other.XPosition, other.YPosition, other.Width, other.Height);
 }
Exemplo n.º 25
0
 public void RemoveComponent(IGraphicComponent component)
 {
     manager.RemoveComponent(Tag, component);
 }
Exemplo n.º 26
0
 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);
 }
Exemplo n.º 27
0
        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;
        }
Exemplo n.º 28
0
 public void Handle(IGraphicComponent com)
 {
     others.Add(com);
 }
Exemplo n.º 29
0
 private void RemoveEventHandler(IGraphicComponent c)
 {
     c.PreferredSizeChanged -= PreferredSizeChangedHandler;
     c.SizeChanged -= SizeChangedHandler;
 }
Exemplo n.º 30
0
 private bool ComponentResizePolicyIsFixed(IGraphicComponent component)
 {
     return component.VerticalPolicy == ResizePolicy.Fixed
         || component.HorizontalPolicy == ResizePolicy.Fixed;
 }
Exemplo n.º 31
0
        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;
        }
Exemplo n.º 32
0
        public VisualComponentItem(IGraphicComponent com, IPropertyTabManager propertyTabManager)
        {
            this.com = com;

            OpenPropertiesTab = new OpenPropertiesTabCommand(this, propertyTabManager);
        }
Exemplo n.º 33
0
 public void Draw(IGraphicComponent component, ISpriteBatch batch, GameTime gameTime)
 {
     component.Draw(gameTime, batch);
 }
Exemplo n.º 34
0
 public void Refresh(IGraphicComponent component)
 {
     com = component;
     SetPropertyChanged(nameof(Name));
 }
Exemplo n.º 35
0
 public void RemoveComponent(ElementTag tagEntity, IGraphicComponent com)
 {
 }
Exemplo n.º 36
0
 public static void SetCoordinates(this IGraphicComponent component, IGraphicComponent constraints)
 {
     component.SetCoordinates(constraints.XPosition, constraints.YPosition, constraints.Width, constraints.Height);
 }
Exemplo n.º 37
0
 public IGraphicComponent AddComponent(ElementTag tagEntity, IGraphicComponent com) => EmptyGraphicComponent.Create();
Exemplo n.º 38
0
 public void RemoveComponent(ElementTag tagEntity, IGraphicComponent com)
 {
     comSynchronizer.Add((owner, inp) => {
         owner._RemoveComponent(tagEntity, inp);
     }, com);
 }
Exemplo n.º 39
0
 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;
 }