Beispiel #1
0
        private void decoratorPatternBtn_Click(object sender, RoutedEventArgs e)
        {
            CircleDecorator c = new CircleDecorator();

            Console.WriteLine(c.StrFunc());

            ColoredShape cc = new ColoredShape("red", c);

            Console.WriteLine(cc.StrFunc());

            // Create a decorated Window with horizontal and vertical scrollbars
            DPWindow decoratedWindow = new HorizontalScrollBarDecorator(
                new VerticalScrollBarDecorator(new SimpleWindow()));

            // Print the Window's description
            Console.WriteLine(decoratedWindow.GetDescription());

            Coffee kafica = new SimpleCoffee();

            Utils.printInfo(kafica);

            kafica = new WithMilk(kafica);
            Utils.printInfo(kafica);

            kafica = new WithSprinkles(kafica);
            Utils.printInfo(kafica);
        }
Beispiel #2
0
        public void CheckDescriptionOfCircle()
        {
            CircleShape circle = new CircleShape(50);

            circle.Position = new Vector2f(500, 100);
            ShapeDecorator circleDecorator = new CircleDecorator(circle);

            string expected = "CIRCLE: P=314; S=7850";
            string actual   = circleDecorator.GetDescription();

            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void CheckPerimeterOfCircle()
        {
            CircleShape circle = new CircleShape(50);

            circle.Position = new Vector2f(500, 100);
            ShapeDecorator circleDecorator = new CircleDecorator(circle);

            float expected = 314f;
            float actual   = circleDecorator.GetPerimeter();

            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
        public void CheckAreaOfCircle()
        {
            CircleShape circle = new CircleShape(50);

            circle.Position = new Vector2f(500, 100);
            ShapeDecorator circleDecorator = new CircleDecorator(circle);

            string expected = "7850";
            string actual   = "";

            actual = actual + circleDecorator.GetArea();
            Assert.AreEqual(expected, actual);
        }
        public void PaintWorld(WorldLayer layer)
        {
            var    inRift           = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
            double MRiftProgression = 0;
            int    density          = 0;
            var    monsters         = Hud.Game.AliveMonsters.Where(x => x.IsOnScreen);

            foreach (var monster in monsters)
            {
                double MonsterRiftProgression = 0;
                if (monster.IsOnScreen)
                {
                    int count     = Hud.Game.AliveMonsters.Count(m => (monster.FloorCoordinate.XYZDistanceTo(m.FloorCoordinate) - m.RadiusBottom) <= Distance);
                    var monsters2 = Hud.Game.AliveMonsters.Where(mm => (monster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= MaxRadius && mm.SummonerAcdDynamicId == 0 && mm.IsElite || (monster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= MaxRadius && !mm.IsElite);
                    if (inRift)
                    {
                        foreach (var monster2 in monsters2)
                        {
                            MonsterRiftProgression += monster2.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
                        }
                    }
                    if (count >= density && MonsterRiftProgression >= MRiftProgression)
                    {
                        MCoordinate      = monster.FloorCoordinate;
                        Mcount           = count;
                        density          = count;
                        MRiftProgression = MonsterRiftProgression;
                    }
                }
            }
            foreach (var monster in monsters)
            {
                if (monster.IsOnScreen && Mcount >= DisplayLimit)
                {
                    if (ShowLabel)
                    {
                        if (!inRift)
                        {
                            LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount);
                        }
                        else
                        {
                            if (ShowProgression)
                            {
                                LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount + "(" + MaxRadius + "yards Progression:" + MRiftProgression.ToString("f2") + ")");
                            }
                            else
                            {
                                LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount);
                            }
                        }
                    }
                    if (ShowCircle)
                    {
                        CircleDecorator.Paint(layer, monster, MCoordinate, null);
                    }
                    if (ShowMark)
                    {
                        MarkDecorator.Paint(layer, monster, MCoordinate, null);
                    }
                }
                return;
            }
        }