Пример #1
0
        public void DrawRectangle()
        {
            var Instructions = new Dictionary <ConsoleCommand, string> {
                { ConsoleCommand.ObjectType, "R" },
                { ConsoleCommand.X1, "14" },
                { ConsoleCommand.Y1, "1" },
                { ConsoleCommand.X2, "18" },
                { ConsoleCommand.Y2, "3" }
            };
            List <DataLine> Actual = new RectangleBuilder().BuildGeometry(Canvas, Instructions);

            List <DataLine> Expected = new List <DataLine> {
                new DataLine {
                    Line = new StringBuilder().Insert(0, "----------------------")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|             xxxxx  |")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|             x   x  |")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|             xxxxx  |")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|                    |")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "----------------------")
                }
            };

            Expected.ForEach(x => Assert.AreEqual(x.Line.ToString(), Actual[Expected.IndexOf(x)].Line.ToString()));
        }
Пример #2
0
 private int result = 0; //0: nothing, 1: loading, 2: failure, 3: succeed.
 private void StartLoadingBar()
 {
     result           = 1;
     rbBlackScreen    = ScreenElement.BuildRectangle("BlackScreen0", Parent).SetSize(32, 32);
     sbLoading        = ScreenElement.BuildSprite("Loading", Parent).SetSprite(gm.spriteDB.loading).PlaceOutside(Direction.Up);
     loadingCoroutine = StartCoroutine(AnimateLoadingBar());
 }
Пример #3
0
        private void OpenAreaSelection()
        {
            currentScreen = 1;
            //If the player is entering the map he already is in, start hovering in his current area, rather than the 'area 0' of that map.
            displayArea = (displayMap == originalMap) ? OriginalAreaIndexInCurrentMap : 0;

            if (currentAreaMarker != null)
            {
                currentAreaMarker.SetActive(false);
            }

            //The marker that indicates the area that is being chosen.
            hoveredMarker = ScreenElement.BuildRectangle("OptionMarker", screenDisplay.transform).SetSize(2, 2).SetFlickPeriod(0.25f)
                            .SetPosition(thisWorldData.areas[SelectedArea].coords);
            hoveredAreaName = ScreenElement.BuildTextBox("AreaName", screenDisplay.transform, DFont.Small).SetText("area").SetPosition(28, 5);

            if (displayMap == 0 || displayMap == 3)
            {
                hoveredAreaName.SetPosition(2, 1);
            }
            else
            {
                hoveredAreaName.SetPosition(2, 26);
            }

            hoveredAreaName.Text = string.Format("area{0:00}", SelectedArea + 1); //+1 because, in game, areas start at #1, not 0.
        }
Пример #4
0
        private void DrawAreaMarkers(bool displayOriginalArea)
        {
            ClearMarkers(); //Destroy all current markers.

            int[] shownAreas = thisWorldData.GetAreasInMap(displayMap);

            foreach (int i in shownAreas)
            {
                if (gm.WorldMgr.GetAreaCompleted(originalWorld, i))
                {
                    RectangleBuilder marker = ScreenElement.BuildRectangle($"Area {i} Marker", Parent)
                                              .SetSize(2, 2).SetPosition(thisWorldData.areas[i].coords);
                    completedMarkers.Add(marker);
                }
                if (displayOriginalArea)
                {
                    if (originalArea == i)
                    {
                        currentAreaMarker = ScreenElement.BuildRectangle($"Current Area Marker", Parent)
                                            .SetSize(2, 2).SetPosition(thisWorldData.areas[i].coords).SetFlickPeriod(0.25f);
                        completedMarkers.Add(currentAreaMarker);
                    }
                }
            }
        }
Пример #5
0
        public void Fill()
        {
            var Instructions = new Dictionary <ConsoleCommand, string> {
                { ConsoleCommand.ObjectType, "L" },
                { ConsoleCommand.X1, "1" },
                { ConsoleCommand.Y1, "2" },
                { ConsoleCommand.X2, "6" },
                { ConsoleCommand.Y2, "2" }
            };
            List <DataLine> Actual = new LineBuilder().BuildGeometry(Canvas, Instructions);

            Instructions = new Dictionary <ConsoleCommand, string> {
                { ConsoleCommand.ObjectType, "L" },
                { ConsoleCommand.X1, "6" },
                { ConsoleCommand.Y1, "3" },
                { ConsoleCommand.X2, "6" },
                { ConsoleCommand.Y2, "4" }
            };
            Actual       = new LineBuilder().BuildGeometry(Canvas, Instructions);
            Instructions = new Dictionary <ConsoleCommand, string> {
                { ConsoleCommand.ObjectType, "R" },
                { ConsoleCommand.X1, "14" },
                { ConsoleCommand.Y1, "1" },
                { ConsoleCommand.X2, "18" },
                { ConsoleCommand.Y2, "3" }
            };
            Actual = new RectangleBuilder().BuildGeometry(Canvas, Instructions);

            Instructions = new Dictionary <ConsoleCommand, string> {
                { ConsoleCommand.ObjectType, "B" },
                { ConsoleCommand.X1, "10" },
                { ConsoleCommand.Y1, "3" },
                { ConsoleCommand.Colour, "o" }
            };
            Actual = new FillUtility().Fill(Canvas, Instructions);

            List <DataLine> Expected = new List <DataLine> {
                new DataLine {
                    Line = new StringBuilder().Insert(0, "----------------------")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|oooooooooooooxxxxxoo|")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|xxxxxxooooooox   xoo|")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|     xoooooooxxxxxoo|")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "|     xoooooooooooooo|")
                },
                new DataLine {
                    Line = new StringBuilder().Insert(0, "----------------------")
                }
            };

            Expected.ForEach(x => Assert.AreEqual(x.Line.ToString(), Actual[Expected.IndexOf(x)].Line.ToString()));
        }
Пример #6
0
        public static void TestTopic()
        {
            RectangleBuilder rectangleBuilder = BuildBaseSquare;

            Rectangle rectangle = rectangleBuilder();

            Debug.WriteLine($"CovarianceDelegate: Rectangle has been created with sides top-right-bottom-left - {rectangle.TopSideSize}-{rectangle.RightSideSize}-{rectangle.BottomSideSize}-{rectangle.LeftSideSize}.");
        }
        public void GetAreaTest()
        {
            // Arange
            FigureBuilder rectangleBuilder = new RectangleBuilder("RectangleFigure");
            Figures       rectangleFigure1 = rectangleBuilder.Create(5, 4);
            double        expected         = 20;
            //Act
            var result = rectangleFigure1.GetArea();

            // Assert
            Assert.AreEqual(result, expected, 0.01);
        }
Пример #8
0
        private IEnumerator PADisplayPattern()
        {
            gm.LockInput();

            keypad  = ScreenElement.BuildSprite("Keypad", Parent).SetSize(24, 24).Center().SetSprite(gm.spriteDB.jackpot_pad);
            keys[0] = ScreenElement.BuildSprite("Key Left", Parent).SetSize(8, 12).SetPosition(4, 10)
                      .SetSprite(gm.spriteDB.jackpot_keys[0]).SetTransparent(true).SetActive(false);
            keys[1] = ScreenElement.BuildSprite("Key Right", Parent).SetSize(8, 12).SetPosition(20, 10)
                      .SetSprite(gm.spriteDB.jackpot_keys[1]).SetTransparent(true).SetActive(false);
            keys[2] = ScreenElement.BuildSprite("Key Up", Parent).SetSize(12, 8).SetPosition(10, 4)
                      .SetSprite(gm.spriteDB.jackpot_keys[2]).SetTransparent(true).SetActive(false);
            keys[3] = ScreenElement.BuildSprite("Key Down", Parent).SetSize(12, 8).SetPosition(10, 20)
                      .SetSprite(gm.spriteDB.jackpot_keys[3]).SetTransparent(true).SetActive(false);

            SpriteBuilder hourglass = ScreenElement.BuildSprite("Hourglass", Parent).SetSprite(gm.spriteDB.hourglass);

            yield return(new WaitForSeconds(0.75f));

            hourglass.Dispose();

            for (int i = 0; i < pattern.Length; i++)
            {
                audioMgr.PlaySound(audioMgr.beepLow);
                keys[pattern[i]].SetActive(true);
                yield return(new WaitForSeconds(delay));

                keys[pattern[i]].SetActive(false);
            }

            //Black screen:
            RectangleBuilder rbBlackScreen = ScreenElement.BuildRectangle("BlackScreen0", Parent).SetSize(32, 32);
            SpriteBuilder    sbLoading     = ScreenElement.BuildSprite("Loading", Parent).SetSprite(gm.spriteDB.loading).PlaceOutside(Direction.Up);

            for (int i = 0; i < 64; i++)
            {
                sbLoading.Move(Direction.Down);
                yield return(new WaitForSeconds((delay * 2f) / 64));
            }
            rbBlackScreen.Dispose();
            sbLoading.Dispose();

            //Ready the player:
            keypad.Move(Direction.Down, 4);
            keys.Move(Direction.Down, 4);
            tbTime = ScreenElement.BuildTextBox("Time", screenDisplay.transform, DFont.Small)
                     .SetText("TIME").SetSize(18, 5).SetPosition(1, 1);
            tbTimeCount = ScreenElement.BuildTextBox("TimeCount", screenDisplay.transform, DFont.Small)
                          .SetText(timeRemaining.ToString()).SetSize(10, 5).SetPosition(22, 1);
            StartCoroutine(TimeCount());

            gm.UnlockInput();
        }
        public void GetPerimeterTest()
        {
            // Arange
            double[]        v = { 5, 4 };
            RectangleFigure rectangleFigure2 = new RectangleFigure(v);
            FigureBuilder   rectangleBuilder = new RectangleBuilder("RectangleFigure");
            Figures         rectangleFigure1 = rectangleBuilder.Create(5, 4);
            double          expected         = 18;
            //Act
            var result = rectangleFigure2.GetPerimeter();

            // Assert
            Assert.AreEqual(result, expected);
        }
        public void Equals1_RectangleFigure_True()
        {
            // Arange
            double[]        v = { 3, 6 };
            RectangleFigure rectangleFigure2 = new RectangleFigure(v);

            FigureBuilder rectangleBuilder1 = new RectangleBuilder("RectangleFigure");
            Figures       rectangleFigure1  = rectangleBuilder1.Create(3, 6);
            //Act
            var result = RectangleFigure.Equals1(rectangleFigure1, rectangleFigure2);

            // Assert
            Assert.IsTrue(result);
        }
        public void RectangleFigureTest()
        {
            // Arange
            double[] v = { 5, 4 };
            //  RectangleFigure rectangleFigure = new RectangleFigure(v);

            FigureBuilder rectangleBuilder = new RectangleBuilder("RectangleFigure");
            Figures       rectangleFigure1 = rectangleBuilder.Create(5, 4);
            var           expected         = Convert.ToString(rectangleFigure1);
            //Act
            var result  = new RectangleFigure(v);
            var result1 = Convert.ToString(result);

            // Assert
            Assert.AreEqual(expected, result1);
            // Assert.Fail();
        }
Пример #12
0
        public override void ReflowScreen(Screen screen, List <Window> windows)
        {
            if (windows.Count == 0)
            {
                return;
            }

            int mainPanelCount      = Math.Min(windows.Count, base.MainPaneCount);
            int secondaryPanelCount = windows.Count - mainPanelCount;

            bool hasSecondaryPane = secondaryPanelCount > 0;

            double mainPaneWindowHeight      = Math.Round((double)screen.WorkingArea.Height / mainPanelCount);
            double secondaryPaneWindowHeight = hasSecondaryPane
                ? Math.Round((double)screen.WorkingArea.Height / secondaryPanelCount)
                : 0.0;

            double mainPaneWindowWidth =
                Math.Round((double)screen.WorkingArea.Width * (hasSecondaryPane ? base.MainPaneSize : 1));
            double secondaryPaneWindowWidth = screen.WorkingArea.Width - mainPaneWindowWidth;

            for (int i = 0; i < windows.Count; ++i)
            {
                Window           window = windows[i];
                RectangleBuilder frame  = new RectangleBuilder();

                if (i < mainPanelCount)
                {
                    frame.X      = screen.WorkingArea.X;
                    frame.Y      = (int)(screen.WorkingArea.Y + (mainPaneWindowHeight * i));
                    frame.Width  = (int)mainPaneWindowWidth;
                    frame.Height = (int)mainPaneWindowHeight;
                }
                else
                {
                    frame.X      = (int)(screen.WorkingArea.X + mainPaneWindowWidth);
                    frame.Y      = (int)(screen.WorkingArea.Y + (secondaryPaneWindowHeight * (i - mainPanelCount)));
                    frame.Width  = (int)secondaryPaneWindowWidth;
                    frame.Height = (int)secondaryPaneWindowHeight;
                }
                base.SetWindowPosition(window, frame);
            }
        }