Exemple #1
0
        public EngineLvl2Test()
        {
            // seteamos una instancia "falsa" del adapter para usar en los tests.
            OneAdapter.Adapter = new FalseAdapterContain(true);

            // creamos el diccionario de paginas y niveles para los tests.
            Dictionary <string, List <string> > dicc = new Dictionary <string, List <string> >();
            List <string> list = new List <string>();

            list.Add("Page1");
            dicc.Add("Menu", list);
            Creator.UnityPages = dicc;

            // creamos el mundo necesario para testear el motor.
            Singleton <GeneralEngine> .Instance.ActualLevel = "Menu";

            level  = new Level("level", world);
            screen = new Screen("screen", level);

            destination1 = new BlankSpace("destination1", 10, 10, 50, 50, screen, "path");
            source1      = new DragAndDropSource("source1", 50, 50, 50, 50, screen, "path");
            destination2 = new BlankSpace("destination2", 20, 20, 50, 50, screen, "path");
            source2      = new DragAndDropSource("source2", 50, 50, 50, 50, screen, "path");

            word1 = new Word("word1", 10, 10, 50, 50, screen, "path1", source1, destination1);
            word2 = new Word("word2", 10, 10, 50, 50, screen, "path2", source2, destination2);

            screen.Add(word1);
            screen.Add(word2);
            screen.Add(destination1);
            screen.Add(destination2);
        }
Exemple #2
0
        public EngineLvl3Test()
        {
            // seteamos una instancia "falsa" del adapter para usar en los tests.
            OneAdapter.Adapter = new FalseAdapterContain(true);

            // creamos el diccionario de paginas y niveles para los tests.
            Dictionary <string, List <string> > dicc = new Dictionary <string, List <string> >();
            List <string> pagesList = new List <string>();

            pagesList.Add("Page1");
            dicc.Add("Menu", pagesList);
            Creator.UnityPages = dicc;
            Singleton <GeneralEngine> .Instance.ActualLevel = "Menu";

            // creamos el mundo necesario para testear el motor.
            world  = Singleton <World> .Instance;
            level  = new Level("level", world);
            screen = new Screen("screen", level);
            Singleton <EngineLvl3> .Instance.Reset(screen);

            buttonCheck1 = new ButtonCheck("ButtonCheck1", 10, 10, 10, 10, screen, "path", "path2", true);
            buttonCheck2 = new ButtonCheck("ButtonCheck2", 20, 20, 20, 20, screen, "path", "path2", true);
            buttonCheck3 = new ButtonCheck("ButtonCheck3", 30, 30, 30, 30, screen, "path", "path2", true);
            buttonCheck4 = new ButtonCheck("ButtonCheck4", 40, 40, 40, 40, screen, "path", "path2", false);
            buttonCheck5 = new ButtonCheck("ButtonCheck5", 50, 50, 50, 50, screen, "path", "path2", false);

            screen.Add(buttonCheck1);
            screen.Add(buttonCheck2);
            screen.Add(buttonCheck3);
            screen.Add(buttonCheck4);
            screen.Add(buttonCheck5);
        }
Exemple #3
0
        private static void Main()
        {
            var screen = new Screen();
            for (int i = 0; i < 10; i++) {
                screen.Add(new Shape {Location = new Point(i, i), Color = Color.Red});
            }

            using (var tracker = new Tracker().Track(screen)) {
                tracker.Changed += _ => Console.WriteLine("Changed!");
                screen.Add(new Shape()); // "Changed!" x 2 (1 for new element, 1 for Count property change)
                screen[0].Location = new Point(1, 1); // "Changed!"
                screen[1].Color = Color.Blue; // "Changed!"
                screen.RemoveAt(2); // "Changed!" x 2
            }
        }
Exemple #4
0
        /// <summary>
        /// Setup UI events
        /// </summary>
        public void Init()
        {
            /** Textures **/
            AvatarButton.Texture = Screen.SimCreateButtonImage;
            CityButton.Texture   = Screen.CityButtonTemplateImage;
            HouseButton.Texture  = Screen.HouseButtonTemplateImage;

            /** Send tab stuff to the bottom **/
            Screen.SendToBack(TabBackground, TabEnterBackground, TabDescBackground);

            /** Events **/
            EnterTabButton.OnButtonClick += new ButtonClickDelegate(EnterTabButton_OnButtonClick);
            DescTabButton.OnButtonClick  += new ButtonClickDelegate(DescTabButton_OnButtonClick);

            NewAvatarButton.OnButtonClick += new ButtonClickDelegate(NewAvatarButton_OnButtonClick);

            PersonDescriptionSlider.AttachButtons(PersonDescriptionScrollUpButton, PersonDescriptionScrollDownButton, 1);
            PersonDescriptionText.AttachSlider(PersonDescriptionSlider);


            CityThumb = new UIImage {
                X = CityButton.X + 6,
                Y = CityButton.Y + 6
            };
            CityThumb.SetSize(78, 58);
            Screen.Add(CityThumb);



            SetTab(PersonSlotTab.EnterTab);
        }
        public PlayerSpaceShip(
            Game i_Game,
            GameScreen i_Screen,
            string i_GameAsset,
            ShootsManager i_ShootsManager,
            bool i_IsFirstPlayer)
            : base(i_Game, i_Screen, i_GameAsset, i_ShootsManager)
        {
            m_NumOFSouls    = k_StartingNumOfSouls;
            DrawOrder       = k_DrawOrder;
            m_IsFirstPlayer = i_IsFirstPlayer;
            m_Animator      = new CompositeAnimator(this);
            CompositeAnimator lostSoulAnimation = new CompositeAnimator("lostSoul", TimeSpan.FromSeconds(1.6), this,
                                                                        new BlinkAnimator("lostSoulBlink", TimeSpan.FromSeconds(1 / 14), TimeSpan.FromSeconds(2.4)));
            CompositeAnimator dieAnimation = new CompositeAnimator("dying", TimeSpan.FromSeconds(1.6), this,
                                                                   new RotateAnimator("dyingRotate", TimeSpan.FromSeconds(2.4), 4),
                                                                   new FadeOutAnimator("dyingFade", TimeSpan.FromSeconds(2.4)));

            m_Animator.Add(dieAnimation);
            m_Animator.Add(lostSoulAnimation);
            dieAnimation.Enabled      = false;
            lostSoulAnimation.Enabled = false;
            m_SoulsSprites            = new Soul[3];
            m_SoulsSprites[0]         = new Soul(i_Game, i_Screen, i_GameAsset);
            m_SoulsSprites[1]         = new Soul(i_Game, i_Screen, i_GameAsset);
            m_SoulsSprites[2]         = new Soul(i_Game, i_Screen, i_GameAsset);
            foreach (Soul soul in m_SoulsSprites)
            {
                Screen.Add(soul);
            }
        }
Exemple #6
0
        public void Should_throw_when_changing_position_of_non_existent_element()
        {
            var screen = new Screen();

            screen.Add(new Circle());
            m.ElementIndexChange(screen.Shapes, new Circle());
        }
Exemple #7
0
        public InteractionController(WorldView Map, Economy Economy, Screen Screen)
        {
            _Map = Map;
            _Map.ChangeView(R => R.ChangeViewByPoint(M => M.Biome.Color, true, true));
            _Economy                  = Economy;
            _CurrentItem              = _Economy.All;
            _Map.OnClick             += new EventHandler <MouseEventArgs>(ClickedMap);
            _Map.OnRightClick        += new EventHandler <MouseEventArgs>(RightClickedMap);
            _RegionViewWindow.Visible = false;

            //Buttons
            string[] Classes = new string[]
            {
                "button-biome",
                "button-temperature",
                "button-moisture",
                "button-elevation",
                "button-population",
                "button-wealth",
                "button-culture",
                "button-nation",
                "button-good"
            };
            Action <object, MouseEventArgs>[] Actions = new Action <object, MouseEventArgs>[]
            {
                delegate(object S, MouseEventArgs E) { _Map.ChangeView(R => R.ChangeViewByPoint(M => M.Biome.Color, true, true)); },
                delegate(object S, MouseEventArgs E) { _Map.ChangeView(R => R.ChangeViewByPoint(M => M.Temperature, Color.Blue, Color.Red)); },
                delegate(object S, MouseEventArgs E) { _Map.ChangeView(R => R.ChangeViewByPoint(M => M.Moisture, Color.Yellow, Color.Blue)); },
                delegate(object S, MouseEventArgs E) { _Map.ChangeView(R => R.ChangeViewByPoint(M => M.Height, Color.Green, Color.White)); },
                delegate(object S, MouseEventArgs E) { _Map.ChangeView(R => R.Region.PopulationDensity, Color.White, Color.Red); },
                delegate(object S, MouseEventArgs E) { _Map.ChangeView(R => (float)R.Region.FlowPerCapita(), Color.White, Color.Red); },
                delegate(object S, MouseEventArgs E) { },
                delegate(object S, MouseEventArgs E) { },
                delegate(object S, MouseEventArgs E) { }
            };

            for (int i = 0; i < Classes.Length; ++i)
            {
                Button Button = new Button(Classes[i]);
                Button.Position = new SFML.Window.Vector2f(34 * i + 10, 0);
                Button.OnClick += new EventHandler <MouseEventArgs>(Actions[i]);
                Screen.Add(Button);
            }

            Screen.Add(_RegionViewWindow);
        }
Exemple #8
0
        public void Should_undo_redo_collection_changes_in_batch()
        {
            var screen = new Screen();

            m.Batch(() => {
                var circle = new Circle();
                screen.Add(new Circle {
                    Radius = 10
                });
                screen.Add(circle);
                screen.MoveToFront(1);
                screen.Remove(circle);
            });
            Assert.AreEqual(1, screen.Shapes.Count);
            UndoCount(1);

            m.Undo();
            Assert.AreEqual(0, screen.Shapes.Count);
        }
Exemple #9
0
        public void Should_fire_collection_element_position_change_event()
        {
            var screen = new Screen();
            var circle = new Circle();

            screen.Add(new Circle());
            screen.Add(circle);

            int count = 0;

            m.Changed += (_, args) => {
                Assert.AreEqual(typeof(ElementIndexChangeEvent <Circle>), args.Event.GetType());
                Assert.AreSame(screen.Shapes, ((ElementIndexChangeEvent <Circle>)args.Event).Collection);
                Assert.AreSame(circle, ((ElementIndexChangeEvent <Circle>)args.Event).Element);
                Assert.AreEqual(1, ((ElementIndexChangeEvent <Circle>)args.Event).Index);
                count++;
            };
            screen.MoveToFront(1);
            m.Undo();
            Assert.AreEqual(2, count);
        }
Exemple #10
0
        public void Should_undo_redo_collection_position_change()
        {
            var    screen = new Screen();
            Circle circle1, circle2;

            screen.Add(circle1 = new Circle());
            screen.Add(circle2 = new Circle());
            m.Reset();

            screen.MoveToFront(1);
            Assert.AreSame(circle2, screen.Shapes[0]);
            Assert.AreSame(circle1, screen.Shapes[1]);

            m.Undo();
            Assert.AreSame(circle1, screen.Shapes[0]);
            Assert.AreSame(circle2, screen.Shapes[1]);

            m.Redo();
            Assert.AreSame(circle2, screen.Shapes[0]);
            Assert.AreSame(circle1, screen.Shapes[1]);
        }
Exemple #11
0
        /// <summary>
        /// Setup UI events
        /// </summary>
        public void Init()
        {
            /** Textures **/
            AvatarButton.Texture = Screen.SimCreateButtonImage;
            CityButton.Texture   = Screen.CityButtonTemplateImage;
            HouseButton.Texture  = Screen.HouseButtonTemplateImage;

            /** Send tab stuff to the bottom **/
            Screen.SendToBack(TabBackground, TabEnterBackground, TabDescBackground);

            /** Events **/
            EnterTabButton.OnButtonClick += new ButtonClickDelegate(EnterTabButton_OnButtonClick);
            DescTabButton.OnButtonClick  += new ButtonClickDelegate(DescTabButton_OnButtonClick);

            NewAvatarButton.OnButtonClick    += new ButtonClickDelegate(OnSelect);
            DeleteAvatarButton.OnButtonClick += new ButtonClickDelegate(DeleteAvatarButton_OnButtonClick);

            PersonDescriptionSlider.AttachButtons(PersonDescriptionScrollUpButton, PersonDescriptionScrollDownButton, 1);
            PersonDescriptionText.AttachSlider(PersonDescriptionSlider);

            CityThumb = new UIImage
            {
                X = CityButton.X + 6,
                Y = CityButton.Y + 6
            };
            CityThumb.SetSize(78, 58);
            Screen.Add(CityThumb);


            HouseThumb = new UIImage
            {
                X = HouseButton.X + 6,
                Y = HouseButton.Y + 6
            };
            HouseThumb.SetSize(78, 58);
            Screen.Add(HouseThumb);

            Sim = new UISim
            {
                Visible  = false,
                Position = AvatarButton.Position + new Vector2(1, 10),
                Size     = new Vector2(140, 200)
            };

            Screen.Add(Sim);
            SetTab(PersonSlotTab.EnterTab);

            AvatarButton.OnButtonClick += new ButtonClickDelegate(OnSelect);
            CityButton.OnButtonClick   += new ButtonClickDelegate(OnSelect);
            HouseButton.OnButtonClick  += new ButtonClickDelegate(OnSelect);
        }
Exemple #12
0
        public void Should_undo_redo_collection_addition()
        {
            var screen = new Screen();
            var circle = new Circle();

            screen.Add(circle);
            UndoCount(1);

            m.Undo();
            Assert.AreEqual(0, screen.Shapes.Count);

            m.Redo();
            Assert.AreSame(circle, screen.Shapes[0]);
        }
Exemple #13
0
        public void PositiveTest()
        {
            // string Name, int PositionY, int PositionX, int Length, int Width,Screen Screen, string ImagePath, bool Right
            Letter letter = new Letter("letter", 10, 10, 10, 10, screen, "path", true);

            screen.Add(letter);

            Singleton <EngineLvl1> .Instance.Check(letter);

            bool actualState   = letter.Screen.State;
            bool expectedState = true;

            Assert.Equal(actualState, expectedState);

            Singleton <EngineLvl1> .Instance.Reset(screen);
        }
Exemple #14
0
        public void Should_fire_collection_removal_event()
        {
            var screen = new Screen();
            var circle = new Circle();

            screen.Add(circle);

            int count = 0;

            m.Changed += (_, args) => {
                Assert.AreEqual(typeof(ElementRemovalEvent <Circle>), args.Event.GetType());
                Assert.AreSame(screen.Shapes, ((ElementRemovalEvent <Circle>)args.Event).Collection);
                Assert.AreSame(circle, ((ElementRemovalEvent <Circle>)args.Event).Element);
                Assert.AreEqual(0, ((ElementRemovalEvent <Circle>)args.Event).Index);
                count++;
            };
            screen.Remove(circle);
            m.Undo();
            Assert.AreEqual(2, count);
        }
Exemple #15
0
        public void TestShow()
        {
            var box = new Box(2, 3, 4, 5);

            StreamWriter standardOut = new StreamWriter(Console.OpenStandardOutput());

            standardOut.AutoFlush = true;

            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                var screen = new Screen(10, 10);
                screen.Add(box);
                screen.Show();

                var expected = string.Format("          {0}          {0}          {0}  ┌───┐   {0}  │   │   {0}  │   │   {0}  │   │   {0}  │   │   {0}  └───┘   {0}          {0}", Environment.NewLine);

                Assert.AreEqual(expected, sw.ToString());
            }

            Console.SetOut(standardOut);
        }
Exemple #16
0
        static void Main(string[] args)
        {
            //RunTest();

            var mainFrame = new Frame("main", 22, 22)
            {
                Row = 1,
                Col = 27
            };


            var messageFrame = new Frame("messages", 3, 17)
            {
                Row = 1,
                Col = 1
            };

            var message = new Sprite(1, 15)
            {
                Row = 1,
                Col = 1
            };

            messageFrame.Sprites.Add(message);

            IBlock block = new Pillar();

            mainFrame.Add(block);

            var screen = new Screen();

            screen.Add(mainFrame);
            screen.Add(messageFrame);

            var loop = true;

            while (loop)
            {
                var projectionSucceeded = screen.Project((c, cols) =>
                {
                    message.PrintH(0, 0, "Collision!", ConsoleColor.Red);
                    block.Undo();
                    return(false);
                });

                if (!projectionSucceeded)
                {
                    screen.Project();
                }

                var keyInfo = Console.ReadKey(true);
                switch (keyInfo.KeyChar)
                {
                case 'w': block.Rotate(); break;

                case 's': block.MoveDown(); break;

                case 'a': block.MoveLeft(); break;

                case 'd': block.MoveRight(); break;

                case 'r': screen.Refresh(); break;

                case 'q': loop = false; break;
                }
                message.Clear();
            }
        }
Exemple #17
0
        private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!Mouse_Down)
            {
                return;
            }
            Mouse_Down = false;
            //---------------------------------Add the last point to the canvas and screen---------------------------------
            Point P = e.GetPosition(this);

            Draw_Point(P);
            Temp.Add_Point(P);
            //---------------------------------Do the finished work--------------------------------------------------------
            Temp.Finish_Collecting();
            if (!Temp.Finished_Collecting)
            {
                return;
            }
            //--------------------------check if the current gesture should be unioned with the last gesture-----------------------
            if (Screen.Count != 0)
            {
                Mouse_Data REF = Screen[Screen.Count - 1];
                if ((Screen[Screen.Count - 1].Intersect(Temp) || (Screen[Screen.Count - 1].Boundary.Contains(Temp.Center)) && Recognizer.Recognize(ref REF) != "square root"))
                {
                    Mouse_Data T = Screen[Screen.Count - 1];
                    T.Union(Temp);
                    Screen[Screen.Count - 1] = T;
                }
                else
                {
                    RecLast();
                    if (Screen.Last().Label == "horizontal line")
                    {
                        Mouse_Data D = new Mouse_Data(Screen.Last());
                        D.Union(Temp);
                        if (Recognizer.Recognize(ref Temp) == "horizontal line" && Recognizer.Recognize(ref D, false) == "equals")
                        {
                            Screen[Screen.Count - 1] = D;
                            double R = Calculate_Value();
                            Debug.Print(R.ToString());
                            #region Output_Answer
                            Label AnswerBox = new Label();
                            AnswerBox.Content = R.ToString();
                            double L, T;
                            AnswerBox.Margin   = new Thickness(L = Temp.Boundary.X + Temp.Boundary.Width + 10, T = ((Temp.Boundary.Y + Temp.Boundary.Height + D.Boundary.Y + D.Boundary.Height) / 2 - 50), 0, MainCanvas.Height - T - 20);
                            AnswerBox.FontSize = 50;
                            MainCanvas.Children.Add(AnswerBox);
                            #endregion
                        }
                        else
                        {
                            Screen.Add(Temp);
                        }
                    }
                    else
                    {
                        Screen.Add(Temp);
                    }
                }
            }
            else
            {
                Screen.Add(Temp);
            }
        }