Exemple #1
0
        public void FixGroupAnimationTime4()
        {
            InitAnimationElements();
            var time     = new TimeSpan(0, 1, 0);
            var group    = timeLine.AnimationElements.OfType <AnimationGroupElement>().LastOrDefault();
            var single   = group.Elements.LastOrDefault();
            var newGroup = group.ConvertToGroup(single);

            newGroup.Route.AnimationStartTime = new TimeSpan(0, 1, 0);
            var newSingleElement = new AnimationSingleElement();

            newSingleElement.Route.AnimationStartTime = new TimeSpan(0, 0, 10);
            newSingleElement.Route.Frames.Add(new AnimationRouteFrame()
            {
                FrameTime = time
            });
            newGroup.Elements.Add(newSingleElement);

            timeLine.FixGroupAnimationTime();

            group = timeLine.AnimationElements.OfType <AnimationGroupElement>().LastOrDefault();
            if (group.Route.AnimationEndTime != new TimeSpan(0, 2, 23))
            {
                throw new NesuException("Time does not match. End time is " + group.Route.AnimationEndTime);
            }
        }
Exemple #2
0
        public void GetCell_GraphicName()
        {
            string name    = "TEST123321";
            var    refElem = new AnimationSingleElement()
            {
                Route = new AnimationRoute()
                {
                    Frames = new List <AnimationRouteFrame>()
                    {
                        new AnimationRouteFrame()
                        {
                            FrameTime = new TimeSpan(0, 0, 0)
                        }
                    }
                }
            };
            var cell = new TLEPanelCell()
            {
                ReferenceElement = refElem, GraphicName = name
            };

            panel.PanelCells = new List <TLEPanelCell>()
            {
                cell
            };
            var receivedCell = panel.GetCell(name);

            if (receivedCell != cell)
            {
                throw new NesuException("Cells differs");
            }
        }
        public void UpdateElement(NameValueCollection values)
        {
            var panel = ParentTLE.PanelHub.SelectedPanel;

            if (panel == null)
            {
                throw new Exception("SelectedPanel is null");
            }

            var selectedCell = panel.SelectedPanelCell;

            if (selectedCell == null)
            {
                throw new Exception("SelectedCell is null");
            }

            ITLEPanelCellElement panelElement = ParentTLE.PanelHub.SelectedPanel.SelectedPanelCell.ReferenceElement;

            if (panelElement is AnimationSingleElement)
            {
                AnimationSingleElement elem = panelElement as AnimationSingleElement;
                elem.UpdateManual(values);
            }
            else if (panelElement is AnimationGroupElement)
            {
                AnimationGroupElement elem = panelElement as AnimationGroupElement;
                elem.UpdateManual(values);
            }

            var lastIndex = ParentTLE.PanelHub.GetLastPanelAnimationElementIndex();

            ParentTLE.PanelHub.InitializePanel(TLEPanelNames.ANIMATION_ELEMENT_PREFIX + lastIndex, ParentTLE.TimeLine.BeatGuider.GetTLECellElements());
        }
Exemple #4
0
        public void ConvertToGroup()
        {
            var    singleElement = new AnimationSingleElement();
            string testName      = "tst1";

            singleElement.Name = testName;

            var returnedGroupElement = element.ConvertToGroup(singleElement);

            if (returnedGroupElement == null)
            {
                throw new NesuException(nameof(returnedGroupElement) + " is null");
            }
            if (returnedGroupElement.Name != testName)
            {
                throw new NesuException("Name is not " + testName);
            }
            if (element.Elements.Contains(singleElement))
            {
                throw new NesuException("Parent element still holds single element");
            }
            if (!element.Elements.Contains(returnedGroupElement))
            {
                throw new NesuException("Parent element does not hold new goup element");
            }
        }
Exemple #5
0
        public static AnimationSingleElement GetAnimationElement2()
        {
            var values = new System.Collections.Specialized.NameValueCollection();

            values.Add("Prediction", "False");
            values.Add("ShapeTypeName", "IdkYet32");
            var aElem = new AnimationSingleElement();

            aElem.UpdateManual(values);
            return(aElem);
        }
        public void SetSerializedObjectTest()
        {
            var values = new System.Collections.Specialized.NameValueCollection();

            values.Add("Prediction", "False");
            values.Add("ShapeName", "IdkYet");
            var aElem = new AnimationSingleElement();

            aElem.UpdateManual(values);
            manager.SaveSerializedObject(aElem, "TestSerialization", "TestSerialization");
        }
Exemple #7
0
        public void GetCellElementBasedOnGraphicName()
        {
            panel.PanelCells = new List <TLEPanelCell>();
            var firstCell = new AnimationSingleElement()
            {
                Route = new AnimationRoute()
                {
                    Frames = new List <AnimationRouteFrame>()
                    {
                        new AnimationRouteFrame()
                        {
                            FrameTime = new TimeSpan(0, 0, 0)
                        }
                    }
                }
            };
            var secondCell = new AnimationSingleElement()
            {
                Route = new AnimationRoute()
                {
                    Frames = new List <AnimationRouteFrame>()
                    {
                        new AnimationRouteFrame()
                        {
                            FrameTime = new TimeSpan(0, 0, 0)
                        }
                    }
                }
            };

            panel.PanelCells.Add(new TLEPanelCell()
            {
                ReferenceElement = firstCell, GraphicName = "Test1"
            });
            panel.PanelCells.Add(new TLEPanelCell()
            {
                ReferenceElement = secondCell, GraphicName = "Test2"
            });

            var receivedFirstCell = panel.GetCellElementBasedOnGraphicName("Test1");

            if (receivedFirstCell != firstCell)
            {
                throw new NesuException("First cell does not match");
            }
            var receivedSecondCell = panel.GetCellElementBasedOnGraphicName("Test2");

            if (receivedSecondCell != secondCell)
            {
                throw new NesuException("Second cell does not match");
            }
        }
Exemple #8
0
        public static string CreateGraphicElement(AnimationSingleElement element)
        {
            string shapeName = element.GetType().Name;

            byte[] resourceBytes  = StaticHub.ResourceManager.GetResource(element.Shape.GetType().Name, shapeName);
            string gameObjectName = GenerateGraphicName(element);

            GameObject gameObject = PrepareGameObject(gameObjectName);

            ShapesOnScreen.Add(gameObjectName, gameObject);

            return(gameObjectName);
        }
Exemple #9
0
        internal static string GenerateGraphicName(AnimationSingleElement animationElement)
        {
            string name = animationElement.Shape.GetType().Name.ToString() + "_" + (GraphicElementNameIndex++);

            if (animationElement.Prediction)
            {
                return("Prediction_EAE_" + name);
            }
            else
            {
                return("EAE_" + name);
            }
        }
        public void AddNewElement()
        {
            AnimationSingleElement element = new AnimationSingleElement();

            element.SetStartTime(ParentTLE.PanelHub.TimeIdentyficator.SelectedTime);

            var panel = ParentTLE.PanelHub.SelectedPanel;

            if (panel == null)
            {
                throw new Exception("SelectedPanel is null");
            }

            var selectedCell = panel.SelectedPanelCell;

            if (selectedCell == null)
            {
                throw new Exception("SelectedCell is null");
            }

            ITLEPanelCellElement selectedPanelElement = ParentTLE.PanelHub.SelectedPanel.SelectedPanelCell.ReferenceElement;

            IAnimationElement animElem = selectedPanelElement as IAnimationElement;

            if (animElem == null)
            {
                throw new Exception("AddNewElement: Reference element is not an AnimationElement");
            }

            var parent = ParentTLE.TimeLine.SearchParentAnimationElement(animElem);

            if (parent != null)
            {
                var group = parent as AnimationGroupElement;
                if (group == null)
                {
                    throw new Exception("AddNewElement: Parent is not an GroupElement");
                }
                group.Elements.Add(element);
                ParentTLE.TimeLine.Refresh();
                ParentTLE.PanelHub.InitializePanel(ParentTLE.PanelHub.SelectedPanel.PanelName, group.Elements);
            }
            else
            {
                ParentTLE.TimeLine.AnimationElements.Add(element);
                ParentTLE.TimeLine.Refresh();
                ParentTLE.PanelHub.InitializePanel(ParentTLE.PanelHub.SelectedPanel.PanelName, ParentTLE.TimeLine.AnimationElements);
            }
        }
Exemple #11
0
        public void SearchParentAnimationElement_IAnimationElement()//IAnimationElemnt
        {
            var childElem = new AnimationSingleElement();

            childElem.Route.Frames = new List <AnimationRouteFrame>();

            element.Elements.Add(childElem);

            var resultEelemtn = element.SearchParentAnimationElement(childElem);

            if (resultEelemtn != element)
            {
                throw new NesuException("REf differs");
            }
        }
Exemple #12
0
        public void SearchParentAnimationElement_RouteChild()
        {
            var testFrame = new AnimationRouteFrame();

            testFrame.Amplitude = 123;

            element.Route.Frames = new List <AnimationRouteFrame>();
            element.Route.Frames.Add(new AnimationRouteFrame());

            var childElem = new AnimationSingleElement();

            childElem.Route.Frames = new List <AnimationRouteFrame>();
            childElem.Route.Frames.Add(testFrame);

            element.Elements.Add(childElem);

            var resultEelemtn = element.SearchParentAnimationElement(testFrame);

            if (resultEelemtn != childElem)
            {
                throw new NesuException("REf differs");
            }
        }
        public void AddNewChildElement()
        {
            AnimationSingleElement element = new AnimationSingleElement();

            element.SetStartTime(ParentTLE.PanelHub.TimeIdentyficator.SelectedTime);

            var panel = ParentTLE.PanelHub.SelectedPanel;

            if (panel == null)
            {
                throw new Exception("SelectedPanel is null");
            }

            var selectedCell = panel.SelectedPanelCell;

            if (selectedCell == null)
            {
                throw new Exception("SelectedCell is null");
            }

            ITLEPanelCellElement panelElement = ParentTLE.PanelHub.SelectedPanel.SelectedPanelCell.ReferenceElement;

            if (panelElement as AnimationGroupElement != null)
            {
                AnimationGroupElement group = panelElement as AnimationGroupElement;
                group.Elements.Add(element);
                ParentTLE.PanelHub.InitializeNewAnimationPanel(group.Elements.ToList());
            }
            else if (panelElement as AnimationSingleElement != null)
            {
                AnimationSingleElement singleAnimationElement = panelElement as AnimationSingleElement;
                IAnimationElement      parentParentElement    = ParentTLE.TimeLine.SearchParentAnimationElement(singleAnimationElement);

                if (parentParentElement is AnimationGroupElement)
                {
                    var par = parentParentElement as AnimationGroupElement;
                    if (par != null)
                    {
                        var convertedGroup = par.ConvertToGroup(singleAnimationElement);
                        convertedGroup.Elements.Add(element);

                        ParentTLE.PanelHub.InitializeNewAnimationPanel(convertedGroup.Elements.ToList());
                    }
                }
                else if (parentParentElement == null)// no parent, timeline
                {
                    var group = ParentTLE.TimeLine.ConvertToGroup(singleAnimationElement);
                    group.Elements.Add(element);

                    ParentTLE.PanelHub.InitializeNewAnimationPanel(group.Elements.ToList());
                }
            }
            else //null no group, directly attached to TimeLine. This shouldn't be used, although just in case.
            {
                ParentTLE.TimeLine.AnimationElements.Add(element);
                ParentTLE.PanelHub.InitializeNewAnimationPanel(ParentTLE.TimeLine.GetAnimationSingleElementFirstLayer());
                //throw new Exception("Nesu: TimeLineEditor - Parent animation element is null");
            }

            ParentTLE.TimeLine.Refresh();
        }
Exemple #14
0
 public AnimationSingleElementTests()
 {
     element = new AnimationSingleElement();
 }