Inheritance: MonoBehaviour
        public static void Run()
        {
            // Initialize scene object
            Scene scene = new Scene();

            // Initialize Node class object
            Node cubeNode = new Node("box");

            // ExStart:ConvertBoxPrimitivetoMesh
            // Initialize object by Box class
            IMeshConvertible convertible = new Box();
            // Convert a Box to Mesh
            Mesh mesh = convertible.ToMesh();
            // ExEnd:ConvertBoxPrimitivetoMesh

            // Point node to the Mesh geometry
            cubeNode.Entity = mesh;

            // Add Node to a scene
            scene.RootNode.ChildNodes.Add(cubeNode);

            // The path to the documents directory.
            string MyDir = RunExamples.GetDataDir() + RunExamples.GetOutputFilePath("BoxToMeshScene.fbx");

            // Save 3D scene in the supported file formats
            scene.Save(MyDir, FileFormat.FBX7400ASCII);

            Console.WriteLine("\n Converted the primitive Box to a mesh successfully.\nFile saved at " + MyDir);
        }
		internal DockItemToolbar (DockItem parentItem, PositionType position)
		{
			this.parentItem = parentItem;
			frame = new CustomFrame ();
			switch (position) {
				case PositionType.Top:
					frame.SetMargins (0, 0, 1, 1); 
					frame.SetPadding (0, 2, 2, 0); 
					break;
				case PositionType.Bottom:
					frame.SetMargins (0, 1, 1, 1);
					frame.SetPadding (2, 2, 2, 0); 
					break;
				case PositionType.Left:
					frame.SetMargins (0, 1, 1, 0);
					frame.SetPadding (0, 0, 2, 2); 
					break;
				case PositionType.Right:
					frame.SetMargins (0, 1, 0, 1);
					frame.SetPadding (0, 0, 2, 2); 
					break;
			}
			this.position = position;
			if (position == PositionType.Top || position == PositionType.Bottom)
				box = new HBox (false, 3);
			else
				box = new VBox (false, 3);
			box.Show ();
			frame.Add (box);
			frame.GradientBackround = true;
		}
Example #3
0
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public StackDemo(DemosGame game)
            : base(game)
        {
            kapow.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;
            int height = 50;
            float blockWidth = 3f;
            float blockHeight = 1f;
            float blockLength = 3f;

            for (int i = 0; i < height; i++)
            {
                    var toAdd =
                        new Box(
                            new Vector3(
                                0,
                                blockHeight * .5f + i * (blockHeight),
                                0),
                            blockWidth, blockHeight, blockLength, 10);
                    Space.Add(toAdd);
            }

            Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
            Space.Add(ground);

            game.Camera.Position = new Vector3(0, 6, 15);
        }
Example #4
0
        public void Adding_new_item_to_box_should_have_correct_quantity()
        {
            var box = new Box();
            box.AddItem(3, new Item { Name = "Test Item" });

            Assert.Equal(3, box.Contents.First().Quantity);
        }
Example #5
0
        public void TestConstruction()
        {
            var box1 = new Box(new Point(1, 2), new Point(5, 4));
            Assert.AreEqual(box1.Height, 2);
            Assert.AreEqual(box1.Width, 4);

            var box2 = new Box(new Point(1, 2), 5, 6);
            Assert.AreEqual(box2.Height, 6);
            Assert.AreEqual(box2.Width, 5);

            var box3 = new Box(0, 2, 3, 1);
            Assert.AreEqual(box3.BottomLeft, new Point(0, 1));
            Assert.AreEqual(box3.BottomRight, new Point(3, 1));
            Assert.AreEqual(box3.TopLeft, new Point(0, 2));
            Assert.AreEqual(box3.TopRight, new Point(3, 2));
            Assert.AreEqual(box3.Center, new Point(1.5, 1.5));

            if (!box3.Points.SequenceEqual(new[]
                {
                    box3.TopLeft,
                    box3.TopRight,
                    box3.BottomRight,
                    box3.BottomLeft
                }))
                Assert.Fail();
        }
Example #6
0
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public PlanetDemo(DemosGame game)
            : base(game)
        {
            Space.ForceUpdater.Gravity = Vector3.Zero;

            //By pre-allocating a bunch of box-box pair handlers, the simulation will avoid having to allocate new ones at runtime.
            NarrowPhaseHelper.Factories.BoxBox.EnsureCount(1000);

            var planet = new Sphere(new Vector3(0, 0, 0), 30);
            Space.Add(planet);

            var field = new GravitationalField(new InfiniteForceFieldShape(), planet.Position, 66730 / 2f, 100);
            Space.Add(field);

            //Drop the "meteorites" on the planet.
            Entity toAdd;
            int numColumns = 10;
            int numRows = 10;
            int numHigh = 10;
            float separation = 5;
            for (int i = 0; i < numRows; i++)
                for (int j = 0; j < numColumns; j++)
                    for (int k = 0; k < numHigh; k++)
                    {
                        toAdd = new Box(new Vector3(separation * i - numRows * separation / 2, 40 + k * separation, separation * j - numColumns * separation / 2), 1f, 1f, 1f, 5);
                        toAdd.LinearVelocity = new Vector3(30, 0, 0);
                        toAdd.LinearDamping = 0;
                        toAdd.AngularDamping = 0;
                        Space.Add(toAdd);
                    }
            game.Camera.Position = new Vector3(0, 0, 150);
        }
Example #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="box"></param>
        public void AddBox(Box box)
        {
            if (box.IsLarge)
            {
                using(var ms = new MemoryStream(box.Bytes))
                {
                    var gridFSItem = _context.GridFSUpload(ms);
                    box.GridFSId = gridFSItem.Id;
                    box.Bytes = null;
                }
            }

            var collection = _context.GetCollection(box.UserId);

            //make sure indexes on the searchable fields
            foreach (var item in box.MetaData)
            {
                collection.EnsureIndex(item.Name);
            }

            //make sure unique index on image hash (prevents duplicate images in db)
            collection.EnsureIndex(new IndexKeysBuilder().Ascending(Fields.HASH), IndexOptions.SetUnique(true));

            collection.Insert(box);
        }
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public ParallelSpaceTestDemo(DemosGame game)
            : base(game)
        {
            for (int i = 0; i < 32; i++)
            {
                var space = new Space(null);
                space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
                var box = new Box(new Vector3(20 * i, 0, 0), 100, 1, 100);
                space.Add(box);
                //game.ModelDrawer.Add(box);
                for (int j = 0; j < 30; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        box = new Box(new Vector3(20 * i, 2 + j * 1.1f, 0), 1, 1, 1, 1);
                        entities.Add(box);
                        space.Add(box);
                        //game.ModelDrawer.Add(box);
                    }
                }
                spaces.Add(space);
            }
            game.Camera.Position = new Vector3(20, 10, 70);

        }
Example #9
0
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public IncomingDemo(DemosGame game)
            : base(game)
        {
            Entity toAdd;
            //Build the stack...
            for (int k = 1; k <= 12; k++)
            {
                if (k % 2 == 1)
                {
                    toAdd = new Box(new Vector3(-3, k, 0), 1, 1, 7, 10);
                    Space.Add(toAdd);
                    toAdd = new Box(new Vector3(3, k, 0), 1, 1, 7, 10);
                    Space.Add(toAdd);
                }
                else
                {
                    toAdd = new Box(new Vector3(0, k, -3), 7, 1, 1, 10);
                    Space.Add(toAdd);
                    toAdd = new Box(new Vector3(0, k, 3), 7, 1, 1, 10);
                    Space.Add(toAdd);
                }
            }
            //And then smash it!
            toAdd = new Sphere(new Vector3(0, 150, 0), 3, 100);

            Space.Add(toAdd);
            Space.Add(new Box(new Vector3(0, 0, 0), 10, 1f, 10));
            game.Camera.Position = new Vector3(0, 6, 30);
        }
Example #10
0
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public WallDemo(DemosGame game)
            : base(game)
        {
            int width = 10;
            int height = 10;
            float blockWidth = 2f;
            float blockHeight = 1f;
            float blockLength = 1f;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    var toAdd =
                        new Box(
                            new Vector3(
                                i * blockWidth + .5f * blockWidth * (j % 2) - width * blockWidth * .5f,
                                blockHeight * .5f + j * (blockHeight),
                                0),
                            blockWidth, blockHeight, blockLength, 10);
                    Space.Add(toAdd);
                }
            }

            Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
            Space.Add(ground);
            game.Camera.Position = new Vector3(0, 6, 15);
        }
Example #11
0
    // Use this for initialization
    void Start()
    {
        // get box component
        boxHandler = GetComponent<Box>();

        setInitialRotation();
    }
		public DockItemContainer (DockFrame frame, DockItem item)
		{
			this.item = item;

			mainBox = new VBox ();
			Add (mainBox);

			mainBox.ResizeMode = Gtk.ResizeMode.Queue;
			mainBox.Spacing = 0;
			
			ShowAll ();
			
			mainBox.PackStart (item.GetToolbar (PositionType.Top).Container, false, false, 0);
			
			HBox hbox = new HBox ();
			hbox.Show ();
			hbox.PackStart (item.GetToolbar (PositionType.Left).Container, false, false, 0);
			
			contentBox = new HBox ();
			contentBox.Show ();
			hbox.PackStart (contentBox, true, true, 0);
			
			hbox.PackStart (item.GetToolbar (PositionType.Right).Container, false, false, 0);
			
			mainBox.PackStart (hbox, true, true, 0);
			
			mainBox.PackStart (item.GetToolbar (PositionType.Bottom).Container, false, false, 0);
		}
Example #13
0
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public BridgeDemo(DemosGame game)
            : base(game)
        {
            //Form a long chain of planks connected by revolute joints.
            //The revolute joints control the three linear degrees of freedom and two angular degrees of freedom.
            //The third allowed angular degree of freedom allows the bridge to flex like a rope bridge.
            Vector3 startPosition = new Vector3(0, 0, 0);
            var startPlatform = new Box(startPosition - new Vector3(0, 0, 3.2f), 8, .5f, 8);
            Space.Add(startPlatform);
            Vector3 offset = new Vector3(0, 0, 1.7f);
            Box previousLink = startPlatform;
            Vector3 position = new Vector3();
            for (int i = 1; i <= 200; i++)
            {
                position = startPosition + offset * i;
                Box link = new Box(position, 4.5f, .3f, 1.5f, 50);
                Space.Add(link);
                Space.Add(new RevoluteJoint(previousLink, link, position - offset * .5f, Vector3.Right));

                previousLink = link;
            }
            var endPlatform = new Box(position - new Vector3(0, 0, -4.8f), 8, .5f, 8);
            Space.Add(endPlatform);

            Space.Add(new RevoluteJoint(previousLink, endPlatform, position + offset * .5f, Vector3.Right));

            game.Camera.Position = startPosition + new Vector3(0, 1, offset.Z * 200 + 5);
        }
Example #14
0
        void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
        {

            IAdvanceAxis xaxis = e.Grid["X"] as IAdvanceAxis;
            IAdvanceAxis yaxis = e.Grid["Y"] as IAdvanceAxis;

            if (xaxis == null)
            {
                return;
            }

            int xloc1 = (int)xaxis.MapMinimum;
            int xloc2 = (int)xaxis.MapMaximum;
            int yloc = (int)yaxis.Map(6);

            Box b = new Box(new Point(xloc1, yloc - 2), xloc2 - xloc1, 5, new LineStyle(LineCapStyle.NoAnchor, LineCapStyle.NoAnchor, LineDrawStyle.Solid));
            b.PE.Fill = Color.LightGreen;
            b.Value = 6d; // has to be a double for the value
            b.Caps = PCaps.HitTest | PCaps.Skin | PCaps.Tooltip;
            b.Chart = e.ChartCore.ChartType;
            b.Layer = e.ChartCore.GetChartLayer();
            b.Row = b.Column = -1; // have to set these to -1
            
            e.SceneGraph.Add(b);

        }
Example #15
0
        public void CreateFromTriangleList(List<Triangle> triangles)
        {
            TrianglesIds = new Dictionary<Triangle, int>();
            int i = 0;
            foreach(var t in triangles)
                TrianglesIds.Add(t, i++);

            Vector3 max = new Vector3(0), min = new Vector3(float.PositiveInfinity);
            foreach(var t in triangles)
            {
                foreach(var v in t.Vertices)
                {
                    max.X = Max(max.X, v.Position.X);
                    max.Y = Max(max.Y, v.Position.Y);
                    max.Z = Max(max.Z, v.Position.Z);

                    min.X = Min(min.X, v.Position.X);
                    min.Y = Min(min.Y, v.Position.Y);
                    min.Z = Min(min.Z, v.Position.Z);
                }
            }
            Vector3 center = (max + min) / 2;
            float radius =
                Max(
                    Max(max.X - min.X, max.Y - min.Y)
                    , max.Z - min.Z) / 2;
            BoxTree = new Box(center, radius);
            BoxTree.Triangles = triangles;
            BoxTree.RecursiveDivide();

            Console.WriteLine(TotalNodes);
            Console.WriteLine(TotalLeaves);
        }
Example #16
0
 /// <summary>
 /// Constructs a new demo.
 /// </summary>
 /// <param name="game">Game owning this demo.</param>
 public ColosseumDemo(DemosGame game)
     : base(game)
 {
     double angle;
     int numBoxesPerRing = 12;
     float blockWidth = 2;
     float blockHeight = 2;
     float blockLength = 6f;
     float radius = 15;
     Entity toAdd;
     Space.Add(new Box(new Vector3(0, -blockHeight / 2 - 1, 0), 100, 2f, 100));
     double increment = MathHelper.TwoPi / numBoxesPerRing;
     for (int i = 0; i < 8; i++)
     {
         for (int k = 0; k < numBoxesPerRing; k++)
         {
             if (i % 2 == 0)
             {
                 angle = k * increment;
                 toAdd = new Box(new Vector3(-(float) Math.Cos(angle) * radius, i * blockHeight, (float) Math.Sin(angle) * radius), blockWidth, blockHeight, blockLength, 20);
                 toAdd.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float) angle);
                 Space.Add(toAdd);
             }
             else
             {
                 angle = (k + .5f) * increment;
                 toAdd = new Box(new Vector3(-(float)Math.Cos(angle) * radius, i * blockHeight, (float)Math.Sin(angle) * radius), blockWidth, blockHeight, blockLength, 20);
                 toAdd.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float) angle);
                 Space.Add(toAdd);
             }
         }
     }
     game.Camera.Position = new Vector3(0, 2, 2);
 }
Example #17
0
 public CameraController(ScreenManager screen, Box zoomBox)
     : base(screen)
 {
     this.characters = new List<CharacterController>();
     this.camera = screen.ControllerViewManager.camera;
     this.zoomBox = zoomBox;
 }
Example #18
0
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public BroadPhaseDemo(DemosGame game)
            : base(game)
        {
            //Make a fatter kapow sphere.
            Space.Remove(kapow);
            kapow = new Sphere(new Vector3(11000, 0, 0), 1.5f, 1000);
            Space.Add(kapow);
            Space.Solver.IterationLimit = 1; //Essentially no sustained contacts, so don't need to worry about accuracy.
            Space.ForceUpdater.Gravity = Vector3.Zero;

            int numColumns = 15;
            int numRows = 15;
            int numHigh = 15;
            float separation = 3;

            Entity toAdd;

            for (int i = 0; i < numRows; i++)
                for (int j = 0; j < numColumns; j++)
                    for (int k = 0; k < numHigh; k++)
                    {
                        toAdd = new Box(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1);
                        toAdd.Material.Bounciness = 1; //Superbouncy boxes help propagate shock waves.
                        toAdd.LinearDamping = 0f;
                        toAdd.AngularDamping = 0f;
                        Space.Add(toAdd);
                    }

            game.Camera.Position = new Vector3(0, 3, -10);
            game.Camera.ViewDirection = new Vector3(0, 0, 1);
        }
Example #19
0
        public void BoxConstructor_Test()
        {
            Box target = new Box();

            Assert.IsNotNull(target.Ideas);
            Assert.AreEqual(0, target.Ideas.Count);
        }
Example #20
0
    /**
       * Create a level two box, ie two boxes next to each other
       */
    private void CreateLevel2Box(Box from, Box to, string direction)
    {
        // send rpc to master client to destroy the box
        to.GetComponent<PhotonView>().RPC("Explode", PhotonTargets.MasterClient, null);

        // set the build level to 2
        from.GetComponent<PhotonView>().RPC("BuildLevel", PhotonTargets.All, 2);

        if (direction == "sideways") {
          // ie left to right

          // increase the scale of the box
          from.transform.localScale += new Vector3(1f, 0f, 0f);

          // reposition the box
          from.transform.position += new Vector3(0.5f, 0f, 0f);
        } else {
          // front to back
          // increase the scale of the box
          from.transform.localScale += new Vector3(0f, 0f, 1f);

          // reposition the box
          from.transform.position += new Vector3(0.0f, 0f, 0.5f);
        }
    }
 unsafe public static void Main ()
 {
         Box b = new Box ();
         fixed (Obsolete* p = &b.o)
         {
         }
 }
Example #22
0
        public ScalingWidget(Box targetObject)
            : base(3)
        {
            box = targetObject;

            YArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth)
            {
                Name = "YArrow"
            };
            XArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth) {

                Name = "XArrow"
            };
            ZArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth)
            {
                Name = "ZArrow"
            };

            Objects[0] = YArrow;
            Objects[1] = XArrow;
            Objects[2] = ZArrow;

            scaling = targetObject.ScalingValues;

            Material = new PhongMaterial() { DiffuseColor = Color.Yellow, AmbientCoefficient=1f};
            YArrow.PositionV3 = new Vector3(-scaling.X / 2 - ArrowLineWidth / 2, scaling.Y / 2, -scaling.Z / 2 - ArrowLineWidth / 2);
            XArrow.PositionV3 = new Vector3(scaling.X / 2 + ArrowLineWidth / 2, -scaling.Y / 2 + ArrowLineWidth / 2, -scaling.Z / 2 - ArrowLineWidth / 2);
            ZArrow.PositionV3 = new Vector3(-scaling.X / 2 - ArrowLineWidth / 2, -scaling.Y / 2 + ArrowLineWidth / 2, scaling.Z / 2 + ArrowLineWidth / 2);

            //YArrow.PositionV3 = new Vector3(-box.Scaling / 2 - ArrowLineWidth / 2, box.Height / 2, -box.Depth / 2 - ArrowLineWidth / 2);
            //XArrow.PositionV3 = new Vector3(box.Width / 2 + ArrowLineWidth / 2, -box.Height / 2 + ArrowLineWidth / 2, -box.Depth / 2 - ArrowLineWidth / 2);
            //ZArrow.PositionV3 = new Vector3(-box.Width / 2 - ArrowLineWidth / 2, -box.Height / 2 + ArrowLineWidth / 2, box.Depth / 2 + ArrowLineWidth / 2);
        }
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public FishInABarrelDemo(DemosGame game)
            : base(game)
        {
            game.Camera.Position = new Vector3(0, 7, 30);

            var detector = new Box(new Vector3(0, 0, 0), 1.5f, 1.5f, 1.5f);
            detector.CollisionInformation.CollisionRules.Personal = CollisionRule.NoSolver;
            var acceptedTriggerEntity = new Box(new Vector3(5, 0, 0), 1.6f, .7f, .4f, 1);
            acceptedTrigger = acceptedTriggerEntity.CollisionInformation;

            detector.Tag = "noDisplayObject";
            acceptedTriggerEntity.Tag = "noDisplayObject";
            Space.Add(detector);
            Space.Add(acceptedTriggerEntity);

            var fish = game.Content.Load<Model>("fish");
            game.ModelDrawer.Add(new DisplayEntityModel(acceptedTriggerEntity, fish, game.ModelDrawer));

            var barrelAndPlatform = game.Content.Load<Model>("barrelAndPlatform");
            Vector3[] staticTriangleVertices;
            int[] staticTriangleIndices;
            ModelDataExtractor.GetVerticesAndIndicesFromModel(barrelAndPlatform, out staticTriangleVertices, out staticTriangleIndices);

            //Note that the final 'margin' parameter is optional, but can be used to specify a collision margin on triangles in the static triangle group.
            var fishDepositoryGroup = new StaticMesh(staticTriangleVertices, staticTriangleIndices);
            CollisionRules.AddRule(fishDepositoryGroup, detector, CollisionRule.NoBroadPhase);
            Space.Add(fishDepositoryGroup);
            game.ModelDrawer.Add(fishDepositoryGroup);

            movedBox = new Box(new Vector3(-4, 5, 0), 1, 1, 1, 1);
            detector.Space.Add(movedBox);
            detector.CollisionInformation.Events.InitialCollisionDetected += InitialCollisionDetected;
            detector.CollisionInformation.Events.CollisionEnded += CollisionEnded;
        }
        public void Test_AmoebaConverter_Box()
        {
            var key = new Key(HashAlgorithm.Sha256, new byte[32]);
            var metadata = new Metadata(1, key, CompressionAlgorithm.Xz, CryptoAlgorithm.Aes256, new byte[32 + 32]);
            var seed = new Seed(metadata);
            seed.Name = "aaaa.zip";
            seed.Keywords.AddRange(new KeywordCollection
                {
                    "bbbb",
                    "cccc",
                    "dddd",
                });
            seed.CreationTime = DateTime.Now;
            seed.Length = 10000;

            var box = new Box();
            box.Name = "Box";
            box.Seeds.Add(seed);
            box.Boxes.Add(new Box() { Name = "Box" });

            Box box2;

            using (var streamBox = AmoebaConverter.ToBoxStream(box))
            {
                box2 = AmoebaConverter.FromBoxStream(streamBox);
            }

            Assert.AreEqual(box, box2, "AmoebaConverter #3");
        }
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public ConvexHullTestDemo(DemosGame game)
            : base(game)
        {
            var random = new Random(5);

            for (int i = 0; i < 500000; ++i)
            {
                List<Vector3> points = new List<Vector3>();
                for (int k = 0; k < random.Next(8, 60); k++)
                {
                    points.Add(new Vector3(-100 + 30 * (float)random.NextDouble(), 100 + 500 * (float)random.NextDouble(), 100 + 30 * (float)random.NextDouble()));
                }
                var convexHull = new ConvexHull(new Vector3(0, 7, 0), points, 10);
                Console.WriteLine(convexHull.CollisionInformation.Shape.Vertices.Count);
            }

            var vertices = new[]
            {
                new Vector3(0, -1.750886E-9f, -1.5f),
                new Vector3(1, 1, 0.5f),
                new Vector3(1, -1, 0.5f),
                new Vector3(-1, 1, 0.5f),
                new Vector3(-1, -1, 0.5f),
            };

            var hullVertices = new RawList<Vector3>();
            ConvexHullHelper.GetConvexHull(vertices, hullVertices);

            ConvexHull hull = new ConvexHull(vertices, 5);
            Space.Add(hull);

            Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
            Space.Add(ground);
            game.Camera.Position = new Vector3(0, 6, 15);
        }
Example #26
0
 public CompoundBox(Box b1, Box b2, Box b3)
 {
     boxes = new List<Box>();
     boxes.Add(b1);
     boxes.Add(b2);
     boxes.Add(b3);
 }
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public CollisionFilteringDemo(DemosGame game)
            : base(game)
        {
            Entity toAdd;
            toAdd = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
            Space.Add(toAdd);

            //Set up two stacks which go through each other
            var firstStackGroup = new CollisionGroup();
            var secondStackGroup = new CollisionGroup();
            //Adding this rule to the space's collision group rules will prevent entities belong to these two groups from generating collision pairs with each other.
            groupPair = new CollisionGroupPair(firstStackGroup, secondStackGroup);
            CollisionRules.CollisionGroupRules.Add(groupPair, CollisionRule.NoBroadPhase);

            for (int k = 0; k < 10; k++)
            {
                toAdd = new Box(
                    new Vector3(-4 + .12f * k, .5f + k, 0), 1f, 1f, 1f,
                    10);
                toAdd.CollisionInformation.CollisionRules.Group = firstStackGroup;
                Space.Add(toAdd);
                toAdd = new Box(new Vector3(4 - .12f * k, .5f + k, 0),
                                1f, 1f, 1f, 10);
                toAdd.CollisionInformation.CollisionRules.Group = secondStackGroup;
                Space.Add(toAdd);
            }
            //Add another two boxes which ignore each other using the specific entities method; they will still collide with the stacks since they will have the default dynamic collision group.
            toAdd = new Box(new Vector3(1, 3, 0), 1f, 4f, 2f, 10);
            var toAdd2 = new Box(new Vector3(-1, 3, 0), 1f, 4f, 2f, 15);
            CollisionRules.AddRule(toAdd, toAdd2, CollisionRule.NoBroadPhase);
            Space.Add(toAdd);
            Space.Add(toAdd2);
            game.Camera.Position = new Vector3(0, 6, 20);
        }
Example #28
0
        public void Adding_item_with_negative_quanity_throws_error()
        {
            var box = new Box();
            var item = new Item { Name = "Test Item" };

            Assert.Throws<InvalidOperationException>(() => box.AddItem(-3, item));
        }
Example #29
0
			public void TestSaveVisibility()
			{
				var root = new Body
				           	{
				           		Location = new Frame3D(10, 0, 0)
				           	};
				Body box = new Box
				           	{
				           		Location = new Frame3D(10, 20, 30)
				           	};
				root.Add(box);
				var lo = new LoggingObject(box, root);
				lo.SaveVisibilityState(_totalTime);
				Assert.AreEqual(1, lo.VisibilityStates.Count);
				Assert.AreEqual(_totalTime, lo.VisibilityStates[0].StartTime);
				_totalTime ++;
				lo.SaveVisibilityState(_totalTime);
				Assert.AreEqual(1, lo.VisibilityStates.Count);
				Assert.AreEqual(true, lo.VisibilityStates[0].IsVisible);
				root.Remove(box);
				_totalTime++;
				lo.SaveVisibilityState(_totalTime);
				Assert.AreEqual(_totalTime, lo.VisibilityStates.Last().StartTime);
				Assert.AreEqual(2, lo.VisibilityStates.Count);
				Assert.AreEqual(false, lo.VisibilityStates.Last().IsVisible);
			}
        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public MoreConstraintsTestDemo(DemosGame game)
            : base(game)
        {
            Box boxA = new Box(new Vector3(0, 5, 0), 1, 2, 1, 10);
            Box boxB = new Box(new Vector3(0, 8, 0), 1, 2, 1, 10);
            boxA.Orientation = Quaternion.CreateFromYawPitchRoll(0, MathHelper.PiOver4, 0);
            boxB.Orientation = Quaternion.CreateFromYawPitchRoll(MathHelper.PiOver4, 0, 0);

            WeldJoint weld = new WeldJoint(boxA, boxB);

            Space.Add(boxA);
            Space.Add(boxB);
            Space.Add(weld);

            boxA = new Box(new Vector3(3, 5, 0), 1, 2, 1, 10);
            boxB = new Box(new Vector3(3, 8, 0), 1, 2, 1, 10);
            boxA.Orientation = Quaternion.CreateFromYawPitchRoll(0, MathHelper.PiOver4, 0);
            boxB.Orientation = Quaternion.CreateFromYawPitchRoll(MathHelper.PiOver4, 0, 0);

            BallSocketJoint ballSocket = new BallSocketJoint(boxA, boxB, (boxA.Position + boxB.Position) / 2);
            AngularMotor angularMotor = new AngularMotor(boxA, boxB);
            angularMotor.Settings.Mode = MotorMode.Servomechanism;

            Space.Add(boxA);
            Space.Add(boxB);
            Space.Add(ballSocket);
            Space.Add(angularMotor);

            Box ground = new Box(new Vector3(0, 0, 0), 10, 1, 10);

            Space.Add(ground);

            game.Camera.Position = new Vector3(0, 6, 15);
        }
Example #31
0
        /// <summary>
        /// Ends connecting boxes action.
        /// </summary>
        /// <param name="end">The end box.</param>
        public void ConnectingEnd(Box end)
        {
            // Ensure that there was a proper start box
            if (_startBox == null)
            {
                return;
            }

            Box start = _startBox;

            _startBox = null;

            // Check if boxes are diffrent and end box is specified
            if (start == end || end == null)
            {
                return;
            }

            // Check if boxes are connected
            bool areConnected = start.AreConnected(end);

            // Check if boxes are diffrent or (one of them is disabled and both are disconnected)
            if (end.IsOutput == start.IsOutput || !((end.Enabled && start.Enabled) || areConnected))
            {
                // Back
                return;
            }

            // Check if they are already connected
            if (areConnected)
            {
                // Break link
                start.BreakConnection(end);

                // Mark as edited
                MarkAsEdited();

                // Back
                return;
            }

            // Cache Input and Output box (since connection may be made in a diffrent way)
            InputBox  iB;
            OutputBox oB;

            if (start.IsOutput)
            {
                iB = (InputBox)end;
                oB = (OutputBox)start;
            }
            else
            {
                iB = (InputBox)start;
                oB = (OutputBox)end;
            }

            // Validate connection type (also check if any of boxes parent can manage that connections types)
            bool useCaster = false;

            if (!iB.CanUseType(oB.CurrentType))
            {
                if (CanCast(oB.CurrentType, iB.CurrentType))
                {
                    useCaster = true;
                }
                else
                {
                    return;
                }
            }

            // Connect boxes
            if (useCaster)
            {
                // Connect via Caster
                //AddCaster(oB, iB);
                throw new NotImplementedException("AddCaster(..) function");
            }
            else
            {
                // Connect directly
                iB.CreateConnection(oB);
            }

            // Mark as edited
            MarkAsEdited();
        }
Example #32
0
 internal void OnMosueOverBox(Box box)
 {
     _lastBoxUnderMouse = box;
 }
Example #33
0
        private void load(OsuColour colours, GameHost host, OsuConfigManager config)
        {
            if (Beatmap.Value is DummyWorkingBeatmap)
            {
                isNewBeatmap  = true;
                Beatmap.Value = beatmapManager.CreateNew(Ruleset.Value, api.LocalUser.Value);
            }

            beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
            beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);

            // Todo: should probably be done at a DrawableRuleset level to share logic with Player.
            clock = new EditorClock(Beatmap.Value, beatDivisor)
            {
                IsCoupled = false
            };

            UpdateClockSource();

            dependencies.CacheAs(clock);
            AddInternal(clock);

            clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());

            // todo: remove caching of this and consume via editorBeatmap?
            dependencies.Cache(beatDivisor);

            try
            {
                playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Could not load beatmap successfully!");
                // couldn't load, hard abort!
                this.Exit();
                return;
            }

            AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, Beatmap.Value.Skin));
            dependencies.CacheAs(editorBeatmap);
            changeHandler = new EditorChangeHandler(editorBeatmap);
            dependencies.CacheAs <IEditorChangeHandler>(changeHandler);

            updateLastSavedHash();

            OsuMenuItem undoMenuItem;
            OsuMenuItem redoMenuItem;

            EditorMenuItem cutMenuItem;
            EditorMenuItem copyMenuItem;
            EditorMenuItem pasteMenuItem;

            var fileMenuItems = new List <MenuItem>
            {
                new EditorMenuItem("Save", MenuItemType.Standard, Save)
            };

            if (RuntimeInfo.IsDesktop)
            {
                fileMenuItems.Add(new EditorMenuItem("Export package", MenuItemType.Standard, exportBeatmap));
            }

            fileMenuItems.Add(new EditorMenuItemSpacer());
            fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));

            AddInternal(new OsuContextMenuContainer
            {
                RelativeSizeAxes = Axes.Both,
                Children         = new[]
                {
                    new Container
                    {
                        Name             = "Screen container",
                        RelativeSizeAxes = Axes.Both,
                        Padding          = new MarginPadding {
                            Top = 40, Bottom = 60
                        },
                        Child = screenContainer = new Container <EditorScreen>
                        {
                            RelativeSizeAxes = Axes.Both,
                            Masking          = true
                        }
                    },
                    new Container
                    {
                        Name             = "Top bar",
                        RelativeSizeAxes = Axes.X,
                        Height           = 40,
                        Child            = menuBar = new EditorMenuBar
                        {
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            RelativeSizeAxes = Axes.Both,
                            Mode             = { Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose },
                            Items            = new[]
                            {
                                new MenuItem("File")
                                {
                                    Items = fileMenuItems
                                },
                                new MenuItem("Edit")
                                {
                                    Items = new[]
                                    {
                                        undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
                                        redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, Redo),
                                        new EditorMenuItemSpacer(),
                                        cutMenuItem   = new EditorMenuItem("Cut", MenuItemType.Standard, Cut),
                                        copyMenuItem  = new EditorMenuItem("Copy", MenuItemType.Standard, Copy),
                                        pasteMenuItem = new EditorMenuItem("Paste", MenuItemType.Standard, Paste),
                                    }
                                },
                                new MenuItem("View")
                                {
                                    Items = new[]
                                    {
                                        new WaveformOpacityMenu(config)
                                    }
                                }
                            }
                        }
                    },
                    new Container
                    {
                        Name             = "Bottom bar",
                        Anchor           = Anchor.BottomLeft,
                        Origin           = Anchor.BottomLeft,
                        RelativeSizeAxes = Axes.X,
                        Height           = 60,
                        Children         = new Drawable[]
                        {
                            bottomBackground = new Box {
                                RelativeSizeAxes = Axes.Both
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Vertical = 5, Horizontal = 10
                                },
                                Child = new GridContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    ColumnDimensions = new[]
                                    {
                                        new Dimension(GridSizeMode.Absolute, 220),
                                        new Dimension(),
                                        new Dimension(GridSizeMode.Absolute, 220)
                                    },
                                    Content = new[]
                                    {
                                        new Drawable[]
                                        {
                                            new Container
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                                Padding          = new MarginPadding {
                                                    Right = 10
                                                },
                                                Child = new TimeInfoContainer {
                                                    RelativeSizeAxes = Axes.Both
                                                },
                                            },
                                            new SummaryTimeline
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                            },
                                            new Container
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                                Padding          = new MarginPadding {
                                                    Left = 10
                                                },
                                                Child = new PlaybackControl {
                                                    RelativeSizeAxes = Axes.Both
                                                },
                                            }
                                        },
                                    }
                                },
                            }
                        }
                    },
                }
            });

            changeHandler.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
            changeHandler.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);

            editorBeatmap.SelectedHitObjects.BindCollectionChanged((_, __) =>
            {
                var hasObjects = editorBeatmap.SelectedHitObjects.Count > 0;

                cutMenuItem.Action.Disabled  = !hasObjects;
                copyMenuItem.Action.Disabled = !hasObjects;
            }, true);

            clipboard.BindValueChanged(content => pasteMenuItem.Action.Disabled = string.IsNullOrEmpty(content.NewValue));

            menuBar.Mode.ValueChanged += onModeChanged;

            bottomBackground.Colour = colours.Gray2;
        }
Example #34
0
        public void UpdateTab()
        {
            if (Child != null)
            {
                Widget w = Child;
                Remove(w);
                w.Destroy();
            }

            mainBox = new Alignment(0, 0, 1, 1);
            if (bar.Orientation == Gtk.Orientation.Horizontal)
            {
                box = new HBox();
                if (bar.AlignToEnd)
                {
                    mainBox.SetPadding(3, 3, 11, 9);
                }
                else
                {
                    mainBox.SetPadding(3, 3, 9, 11);
                }
            }
            else
            {
                box = new VBox();
                if (bar.AlignToEnd)
                {
                    mainBox.SetPadding(11, 9, 3, 3);
                }
                else
                {
                    mainBox.SetPadding(9, 11, 3, 3);
                }
            }

            Gtk.Widget customLabel = null;
            if (it.DockLabelProvider != null)
            {
                customLabel = it.DockLabelProvider.CreateLabel(bar.Orientation);
            }

            if (customLabel != null)
            {
                customLabel.ShowAll();
                box.PackStart(customLabel, true, true, 0);
            }
            else
            {
                if (it.Icon != null)
                {
                    var desat = it.Icon.WithAlpha(0.5);
                    crossfade = new CrossfadeIcon(desat, it.Icon);
                    box.PackStart(crossfade, false, false, 0);
                    desat.Dispose();
                }

                if (!string.IsNullOrEmpty(it.Label))
                {
                    label           = new Gtk.Label(it.Label);
                    label.UseMarkup = true;
                    if (bar.Orientation == Gtk.Orientation.Vertical)
                    {
                        label.Angle = 270;
                    }
                    box.PackStart(label, true, true, 0);
                }
                else
                {
                    label = null;
                }
            }

            box.Spacing = 2;
            mainBox.Add(box);
            mainBox.ShowAll();
            Add(mainBox);
            QueueDraw();
        }
Example #35
0
 public override void UpdateBoundingBox(bool cascadeToParent = true)
 {
     BoundingBox = new Box(Faces.Select(x => x.BoundingBox));
     base.UpdateBoundingBox(cascadeToParent);
 }
Example #36
0
 public TaikoPlayfield(ControlPointInfo controlPoints)
 {
     InternalChild = new PlayfieldAdjustmentContainer
     {
         Anchor           = Anchor.CentreLeft,
         Origin           = Anchor.CentreLeft,
         RelativeSizeAxes = Axes.Both,
         Children         = new Drawable[]
         {
             backgroundContainer = new Container
             {
                 Name             = "Transparent playfield background",
                 RelativeSizeAxes = Axes.Both,
                 Masking          = true,
                 EdgeEffect       = new EdgeEffectParameters
                 {
                     Type   = EdgeEffectType.Shadow,
                     Colour = Color4.Black.Opacity(0.2f),
                     Radius = 5,
                 },
                 Children = new Drawable[]
                 {
                     background = new Box
                     {
                         RelativeSizeAxes = Axes.Both,
                         Alpha            = 0.6f
                     },
                 }
             },
             new Container
             {
                 Name             = "Right area",
                 RelativeSizeAxes = Axes.Both,
                 Padding          = new MarginPadding {
                     Left = left_area_size
                 },
                 Children = new Drawable[]
                 {
                     new Container
                     {
                         Name             = "Masked elements before hit objects",
                         RelativeSizeAxes = Axes.Both,
                         Padding          = new MarginPadding {
                             Left = HIT_TARGET_OFFSET
                         },
                         Masking  = true,
                         Children = new Drawable[]
                         {
                             hitExplosionContainer = new Container <HitExplosion>
                             {
                                 RelativeSizeAxes = Axes.Both,
                                 FillMode         = FillMode.Fit,
                                 Blending         = BlendingMode.Additive,
                             },
                             HitTarget = new HitTarget
                             {
                                 Anchor           = Anchor.CentreLeft,
                                 Origin           = Anchor.Centre,
                                 RelativeSizeAxes = Axes.Both,
                                 FillMode         = FillMode.Fit
                             }
                         }
                     },
                     barlineContainer = new Container
                     {
                         RelativeSizeAxes = Axes.Both,
                         Padding          = new MarginPadding {
                             Left = HIT_TARGET_OFFSET
                         }
                     },
                     new Container
                     {
                         Name             = "Hit objects",
                         RelativeSizeAxes = Axes.Both,
                         Padding          = new MarginPadding {
                             Left = HIT_TARGET_OFFSET
                         },
                         Masking = true,
                         Child   = HitObjectContainer
                     },
                     kiaiExplosionContainer = new Container <KiaiHitExplosion>
                     {
                         Name             = "Kiai hit explosions",
                         RelativeSizeAxes = Axes.Both,
                         FillMode         = FillMode.Fit,
                         Margin           = new MarginPadding {
                             Left = HIT_TARGET_OFFSET
                         },
                         Blending = BlendingMode.Additive
                     },
                     judgementContainer = new JudgementContainer <DrawableTaikoJudgement>
                     {
                         Name             = "Judgements",
                         RelativeSizeAxes = Axes.Y,
                         Margin           = new MarginPadding {
                             Left = HIT_TARGET_OFFSET
                         },
                         Blending = BlendingMode.Additive
                     },
                 }
             },
             overlayBackgroundContainer = new Container
             {
                 Name             = "Left overlay",
                 RelativeSizeAxes = Axes.Y,
                 Size             = new Vector2(left_area_size, 1),
                 Children         = new Drawable[]
                 {
                     overlayBackground = new Box
                     {
                         RelativeSizeAxes = Axes.Both,
                     },
                     new InputDrum(controlPoints)
                     {
                         Anchor = Anchor.CentreRight,
                         Origin = Anchor.CentreRight,
                         Scale  = new Vector2(0.9f),
                         Margin = new MarginPadding {
                             Right = 20
                         }
                     },
                     new Box
                     {
                         Anchor           = Anchor.TopRight,
                         RelativeSizeAxes = Axes.Y,
                         Width            = 10,
                         Colour           = Framework.Graphics.Colour.ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.6f), Color4.Black.Opacity(0)),
                     },
                 }
             },
             new Container
             {
                 Name              = "Border",
                 RelativeSizeAxes  = Axes.Both,
                 Masking           = true,
                 MaskingSmoothness = 0,
                 BorderThickness   = 2,
                 AlwaysPresent     = true,
                 Children          = new[]
                 {
                     new Box
                     {
                         RelativeSizeAxes = Axes.Both,
                         Alpha            = 0,
                         AlwaysPresent    = true
                     }
                 }
             },
             topLevelHitContainer = new Container
             {
                 Name             = "Top level hit objects",
                 RelativeSizeAxes = Axes.Both,
             }
         }
     };
 }
Example #37
0
 public void SetCamWithBox(Box value)
 {
     SetCamWithBox(value.Min, value.Max);
 }
Example #38
0
 public void Unselect()
 {
     selectedSide = BarType.none;
     selectedBox  = null;
 }
Example #39
0
 public void Select(Box _selectedBox)
 {
     selectedBox = _selectedBox;
     UpdateGraphics();
 }
Example #40
0
        private void createEntity(EntityItem entity)
        {
            Line        line;
            float       w, h;
            Collectable collectable;
            Box         box;

            EntityItem next = null;

            if (!GroupedEntities.ContainsKey(entity.Group))
            {
                GroupedEntities.Add(entity.Group, new List <EntityItem>());
            }
            GroupedEntities[entity.Group].Add(entity);

            Vector4 color   = new Vector4(1.0f, 1.0f, 0.0f, 0.2f);
            float   boxSize = 0;

            collectable = null;

            if (entity.NextID != 0 && Data.Entities.ContainsKey(entity.NextID))
            {
                next = Data.Entities.GetValue(entity.NextID);
            }

            switch (entity.GameType)
            {
            case EntityItem.EntityType.WaypointAmmo:
            case EntityItem.EntityType.WaypointFuel:
            case EntityItem.EntityType.WaypointShield:
            case EntityItem.EntityType.WaypointShortcut:
            case EntityItem.EntityType.WaypointSpecial1:
            case EntityItem.EntityType.WaypointSpecial2:
            case EntityItem.EntityType.WaypointSpecial3:
            case EntityItem.EntityType.WaypointFast:
            case EntityItem.EntityType.WaypointSlow:
                color = new Vector4(0.1f, 0.1f, 1.0f, 1.0f);
                //boxSize = 0.04f;
                if (next != null)
                {
                    line      = new Line(entity.Center, next.Center, color);
                    line.Name = "Waypoint line " + entity.ID + " to " + next.ID;
                    WaypointLines.AddNode(line);
                }
                break;

            case EntityItem.EntityType.WallSegment:
                color = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
                if (next != null)
                {
                    line      = new Line(entity.Center + Vector3.UnitY, next.Center + Vector3.UnitY, color);
                    line.Name = "Wall segment line " + entity.ID + " to " + next.ID;
                    WallLines.AddNode(line);
                }
                break;

            case EntityItem.EntityType.TriggerCraft:
            case EntityItem.EntityType.TriggerRocket:
                w            = entity.OffsetX + 1f;
                h            = entity.OffsetY + 1f;
                box          = new Box(0, 0, 0, w, 2, h, new Vector4(0.9f, 0.3f, 0.6f, 0.5f));
                box.Position = entity.Pos + Vector3.UnitY * 0.01f;
                Entities.AddNode(box);
                break;

            case EntityItem.EntityType.TriggerTimed:
                Billboard timer = new Billboard("images/stopwatch.png", 0.4f, 0.4f);
                timer.Position = entity.Center;
                Entities.AddNode(timer);
                break;


            case EntityItem.EntityType.MorphOnce:
            case EntityItem.EntityType.MorphPermanent:
                w = entity.OffsetX + 1f;
                h = entity.OffsetY + 1f;
                //box = new Box(0, 0, 0, w, 1, h, new Vector4(0.1f, 0.3f, 0.9f, 0.5f));
                //box.Position = entity.Pos + Vector3.UnitY * 0.01f;
                //AddNode(box);

                EntityItem source = Data.Entities.GetValue(entity.NextID);

                // morph for this entity and its linked source
                List <Column> targetColumns = ColumnsInRange((int)entity.Pos.X, (int)entity.Pos.Z, w, h);
                List <Column> sourceColumns = ColumnsInRange((int)source.Pos.X, (int)source.Pos.Z, w, h);

                // regular morph
                if (targetColumns.Count == sourceColumns.Count)
                {
                    for (int i = 0; i < targetColumns.Count; i++)
                    {
                        targetColumns[i].MorphSource = sourceColumns[i];
                        sourceColumns[i].MorphSource = targetColumns[i];
                    }
                }
                else
                {
                    // permanent morphs dont destroy buildings, instead they morph the column based on terrain height
                    if (entity.GameType == EntityItem.EntityType.MorphPermanent)
                    {
                        // we need to update surrounding columns too because they could be affected (one side of them)
                        // (problem comes from not using terrain height for all columns in realtime)
                        targetColumns = ColumnsInRange((int)entity.Pos.X - 1, (int)entity.Pos.Z - 1, w + 1, h + 1);

                        // create dummy morph source columns at source position
                        foreach (Column column in targetColumns)
                        {
                            Vector3 colPos = new Vector3(source.Pos.X + (column.Position.X - entity.Pos.X), 0, source.Pos.Z + (column.Position.Z - entity.Pos.Z));
                            column.MorphSource = new Column(column.Definition, colPos, Data, Atlas);
                        }

                        sourceColumns.Clear();
                    }
                    else
                    {
                        // in this case (MorphOnce) there are no target columns and
                        // (target and source areas are swapped from game perspective)
                        // and buildings have to be destroyed as soon as the morph starts
                        foreach (Column column in sourceColumns)
                        {
                            column.DestroyOnMorph = true;
                        }
                        foreach (Column column in targetColumns)
                        {
                            column.DestroyOnMorph = true;
                        }
                    }
                }

                // create and collect morph instances
                Morph morph = new Morph(source, entity, (int)w, (int)h, entity.GameType == EntityItem.EntityType.MorphPermanent);
                morph.Columns.AddRange(targetColumns);
                Morphs.Add(morph);

                // source
                morph = new Morph(entity, source, (int)w, (int)h, entity.GameType == EntityItem.EntityType.MorphPermanent);
                morph.Columns.AddRange(sourceColumns);
                Morphs.Add(morph);
                break;

            case EntityItem.EntityType.MorphSource1:
            case EntityItem.EntityType.MorphSource2:
                // no need to display morph sources since they are handled above by their targets
                break;

            case EntityItem.EntityType.RecoveryTruck:
                Craft recov = new Craft("RECOV0-0", entity.Center + Vector3.UnitY * 6f);
                Entities.AddNode(recov);
                break;

            case EntityItem.EntityType.Cone:
                Cone cone = new Cone(entity.X + 0.5f, entity.Y + 0.104f, entity.Z + 0.5f);
                Entities.AddNode(cone);
                break;

            case EntityItem.EntityType.Checkpoint:
                color     = new Vector4(1.0f, 0.0f, 1.0f, 1.0f);
                line      = new Line(entity.Center, entity.Center + new Vector3(entity.OffsetX, 0, entity.OffsetY), color);
                line.Name = "Checkpoint line " + entity.ID;
                Entities.AddNode(line);
                break;

            case EntityItem.EntityType.Explosion:
                BillboardAnimation explosion = new BillboardAnimation("images/tmaps/explosion.png", 1f, 1f, 88, 74, 10);

                explosion.Position = entity.Center;
                Entities.AddNode(explosion);
                break;

            case EntityItem.EntityType.ExtraFuel:
                collectable = new Collectable(29);
                break;

            case EntityItem.EntityType.FuelFull:
                collectable = new Collectable(30);
                break;

            case EntityItem.EntityType.DoubleFuel:
                collectable = new Collectable(31);
                break;

            case EntityItem.EntityType.ExtraAmmo:
                collectable = new Collectable(32);
                break;

            case EntityItem.EntityType.AmmoFull:
                collectable = new Collectable(33);
                break;

            case EntityItem.EntityType.DoubleAmmo:
                collectable = new Collectable(34);
                break;

            case EntityItem.EntityType.ExtraShield:
                collectable = new Collectable(35);
                break;

            case EntityItem.EntityType.ShieldFull:
                collectable = new Collectable(36);
                break;

            case EntityItem.EntityType.DoubleShield:
                collectable = new Collectable(37);
                break;

            case EntityItem.EntityType.BoosterUpgrade:
                collectable = new Collectable(40);
                break;

            case EntityItem.EntityType.MissileUpgrade:
                collectable = new Collectable(39);
                break;

            case EntityItem.EntityType.MinigunUpgrade:
                collectable = new Collectable(38);
                break;

            case EntityItem.EntityType.UnknownShieldItem:
                collectable = new Collectable(41);
                break;

            case EntityItem.EntityType.UnknownItem:
            case EntityItem.EntityType.Unknown:
                collectable = new Collectable(50);
                break;

            default:
                boxSize = 0.98f;
                break;
            }

            if (collectable != null)
            {
                collectable.Position = entity.Center;
                Entities.AddNode(collectable);
            }

            if (boxSize > 0f)
            {
                box = new Box(boxSize, entity.Center - 0.5f * boxSize * Vector3.One, color);
                Entities.AddNode(box);
            }
        }
Example #41
0
        public FilterControl()
        {
            Children = new Drawable[]
            {
                Background = new Box
                {
                    Colour           = Color4.Black,
                    Alpha            = 0.8f,
                    RelativeSizeAxes = Axes.Both,
                },
                new Container
                {
                    Padding          = new MarginPadding(20),
                    RelativeSizeAxes = Axes.Both,
                    Width            = 0.5f,
                    Anchor           = Anchor.TopRight,
                    Origin           = Anchor.TopRight,
                    Children         = new Drawable[]
                    {
                        searchTextBox = new SearchTextBox
                        {
                            RelativeSizeAxes = Axes.X,
                            Exit             = () => Exit?.Invoke(),
                        },
                        new Box
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 1,
                            Colour           = OsuColour.Gray(80),
                            Origin           = Anchor.BottomLeft,
                            Anchor           = Anchor.BottomLeft,
                        },
                        new FillFlowContainer
                        {
                            Anchor           = Anchor.BottomRight,
                            Origin           = Anchor.BottomRight,
                            Direction        = FillDirection.Horizontal,
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Children         = new Drawable[]
                            {
                                groupTabs = new OsuTabControl <GroupMode>
                                {
                                    RelativeSizeAxes = Axes.X,
                                    Height           = 24,
                                    Width            = 0.5f,
                                    AutoSort         = true
                                },
                                //spriteText = new OsuSpriteText
                                //{
                                //    Font = @"Exo2.0-Bold",
                                //    Text = "Sort results by",
                                //    Size = 14,
                                //    Margin = new MarginPadding
                                //    {
                                //        Top = 5,
                                //        Bottom = 5
                                //    },
                                //},
                                sortTabs = new OsuTabControl <SortMode>
                                {
                                    RelativeSizeAxes = Axes.X,
                                    Width            = 0.5f,
                                    Height           = 24,
                                    AutoSort         = true,
                                }
                            }
                        },
                    }
                }
            };

            searchTextBox.Current.ValueChanged += t => FilterChanged?.Invoke(CreateCriteria());

            groupTabs.PinItem(GroupMode.All);
            groupTabs.PinItem(GroupMode.RecentlyPlayed);
            groupTabs.Current.ValueChanged += val => Group = val;
            sortTabs.Current.ValueChanged  += val => Sort = val;
        }
Example #42
0
        public ChatOverlay()
        {
            RelativeSizeAxes     = Axes.Both;
            RelativePositionAxes = Axes.Both;
            Anchor = Anchor.BottomLeft;
            Origin = Anchor.BottomLeft;

            const float padding = 5;

            Children = new Drawable[]
            {
                channelSelectionContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Height           = 1f - DEFAULT_HEIGHT,
                    Masking          = true,
                    Children         = new[]
                    {
                        channelSelection = new ChannelSelectionOverlay
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    },
                },
                chatContainer = new Container
                {
                    Name             = @"chat container",
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.Both,
                    Height           = DEFAULT_HEIGHT,
                    Children         = new[]
                    {
                        new Container
                        {
                            Name             = @"chat area",
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = TAB_AREA_HEIGHT
                            },
                            Children = new Drawable[]
                            {
                                chatBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                },
                                currentChannelContainer = new Container <DrawableChannel>
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Padding          = new MarginPadding
                                    {
                                        Bottom = textbox_height
                                    },
                                },
                                new Container
                                {
                                    Anchor           = Anchor.BottomLeft,
                                    Origin           = Anchor.BottomLeft,
                                    RelativeSizeAxes = Axes.X,
                                    Height           = textbox_height,
                                    Padding          = new MarginPadding
                                    {
                                        Top    = padding * 2,
                                        Bottom = padding * 2,
                                        Left   = ChatLine.LEFT_PADDING + padding * 2,
                                        Right  = padding * 2,
                                    },
                                    Children = new Drawable[]
                                    {
                                        textbox = new FocusedTextBox
                                        {
                                            RelativeSizeAxes     = Axes.Both,
                                            Height               = 1,
                                            PlaceholderText      = "type your message",
                                            Exit                 = () => State = Visibility.Hidden,
                                            OnCommit             = postMessage,
                                            ReleaseFocusOnCommit = false,
                                            HoldFocus            = true,
                                        }
                                    }
                                },
                                loading = new LoadingAnimation(),
                            }
                        },
                        tabsArea = new Container
                        {
                            Name             = @"tabs area",
                            RelativeSizeAxes = Axes.X,
                            Height           = TAB_AREA_HEIGHT,
                            Children         = new Drawable[]
                            {
                                tabBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                },
                                channelTabs = new ChatTabControl
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    OnRequestLeave   = removeChannel,
                                },
                            }
                        },
                    },
                },
            };

            channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel;
            channelTabs.ChannelSelectorActive.ValueChanged += value => channelSelection.State = value ? Visibility.Visible : Visibility.Hidden;
            channelSelection.StateChanged += state =>
            {
                channelTabs.ChannelSelectorActive.Value = state == Visibility.Visible;

                if (state == Visibility.Visible)
                {
                    textbox.HoldFocus = false;
                    if (1f - ChatHeight.Value < channel_selection_min_height)
                    {
                        transformChatHeightTo(1f - channel_selection_min_height, 800, Easing.OutQuint);
                    }
                }
                else
                {
                    textbox.HoldFocus = true;
                }
            };
        }
Example #43
0
            public WedgeButton()
            {
                Child = new Container
                {
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomCentre,
                    RelativeSizeAxes = Axes.Y,
                    Width            = 100,
                    Shear            = new Vector2(-0.1f, 0),
                    Masking          = true,
                    Child            = clickCon = new ClickableContainer
                    {
                        Shear      = new Vector2(0.1f, 0),
                        Anchor     = Anchor.BottomRight,
                        Origin     = Anchor.BottomRight,
                        Size       = new Vector2(wedge_width * 1.1f),
                        Action     = () => Action?.Invoke(),
                        Masking    = true,
                        EdgeEffect = new EdgeEffectParameters
                        {
                            Colour = Color4.Black.Opacity(0.05f),
                            Type   = EdgeEffectType.Shadow,
                            Radius = 10
                        },
                        Children = new Drawable[]
                        {
                            background = new Box
                            {
                                Anchor           = Anchor.BottomRight,
                                Origin           = Anchor.BottomRight,
                                RelativeSizeAxes = Axes.Both,
                                Shear            = new Vector2(-0.05f, 0.05f),
                                Width            = 0.95f,
                                Colour           = ActiveColour,
                                EdgeSmoothness   = Vector2.One
                            },
                            new Box
                            {
                                Anchor           = Anchor.BottomRight,
                                Origin           = Anchor.BottomRight,
                                RelativeSizeAxes = Axes.Both,
                                Shear            = new Vector2(-0.05f, 0.05f),
                                Width            = 0.95f,
                                Colour           = Color4.White.Opacity(0.1f),
                                Alpha            = 0
                            },
                            ButtonIcon = new SpriteIcon
                            {
                                RelativeSizeAxes = Axes.Both,
                                Y        = -10,
                                Anchor   = Anchor.Centre,
                                Origin   = Anchor.Centre,
                                FillMode = FillMode.Fit,
                                Colour   = Color4.White
                            },
                            buttonText = new SpriteText
                            {
                                Y              = 25,
                                Shadow         = true,
                                AllowMultiline = false,
                                Anchor         = Anchor.Centre,
                                Origin         = Anchor.Centre,
                                TextSize       = 20
                            }
                        }
                    }
                };

                buttonText.Hide();
            }
Example #44
0
        public override void Run(Box parent)
        {
            var scroller = new Scroller(parent)
            {
                WeightX     = 1,
                WeightY     = 1,
                AlignmentX  = -1,
                AlignmentY  = -1,
                ScrollBlock = ScrollBlock.Horizontal,
            };

            scroller.Show();

            var box = new Box(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            box.Show();

            scroller.SetContent(box);

            var images = new string[] { "image.png", "image2.jpg" };

            int numRows = 80;

            box.MinimumHeight = 200 * numRows;
            for (int i = 0; i < numRows; i++)
            {
                var innerScroller = new Scroller(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 200,
                    MinimumWidth  = 720,
                    ScrollBlock   = ScrollBlock.Vertical,
                };

                innerScroller.Show();
                box.PackEnd(innerScroller);

                var innerBox = new Box(parent)
                {
                    AlignmentX   = -1,
                    AlignmentY   = -1,
                    WeightX      = 1,
                    WeightY      = 1,
                    IsHorizontal = true,
                };
                innerBox.Show();

                int numCols = 10;
                innerBox.MinimumHeight = 200;
                innerBox.MinimumWidth  = 200 * numCols;

                for (int j = 0; j < numCols; j++)
                {
                    var img = new Image(parent)
                    {
                        AlignmentX    = -1,
                        AlignmentY    = -1,
                        WeightX       = 1,
                        WeightY       = 1,
                        MinimumHeight = 200,
                        MinimumWidth  = 200,
                    };
                    img.Load(Application.Current.DirectoryInfo.Resource + images[(i + j) % 2]);
                    img.Show();

                    img.Show();
                    innerBox.PackEnd(img);
                }
                innerScroller.SetContent(innerBox);
            }

            parent.PackEnd(scroller);
        }
Example #45
0
 public override void OnExpired(Box b)
 {
     throw new System.NotImplementedException();
 }
Example #46
0
 ///////////////???
 public override bool ShouldTakeEffect(Box b)
 {
     throw new System.NotImplementedException();
 }
Example #47
0
            public ChannelTabItem(Channel value) : base(value)
            {
                Width = 150;

                RelativeSizeAxes = Axes.Y;

                Anchor = Anchor.BottomLeft;
                Origin = Anchor.BottomLeft;

                Shear = new Vector2(shear_width / ChatOverlay.TAB_AREA_HEIGHT, 0);

                Masking    = true;
                EdgeEffect = new EdgeEffectParameters
                {
                    Type   = EdgeEffectType.Shadow,
                    Radius = 10,
                    Colour = Color4.Black.Opacity(0.2f),
                };

                Children = new Drawable[]
                {
                    box = new Box
                    {
                        EdgeSmoothness   = new Vector2(1, 0),
                        RelativeSizeAxes = Axes.Both,
                    },
                    highlightBox = new Box
                    {
                        Width            = 5,
                        Alpha            = 0,
                        Anchor           = Anchor.BottomRight,
                        Origin           = Anchor.BottomRight,
                        EdgeSmoothness   = new Vector2(1, 0),
                        RelativeSizeAxes = Axes.Y,
                    },
                    new Container
                    {
                        Shear            = new Vector2(-shear_width / ChatOverlay.TAB_AREA_HEIGHT, 0),
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            icon = new TextAwesome
                            {
                                Icon     = FontAwesome.fa_hashtag,
                                Anchor   = Anchor.CentreLeft,
                                Origin   = Anchor.CentreLeft,
                                Colour   = Color4.Black,
                                X        = -10,
                                Alpha    = 0.2f,
                                TextSize = ChatOverlay.TAB_AREA_HEIGHT,
                            },
                            text = new OsuSpriteText
                            {
                                Margin   = new MarginPadding(5),
                                Origin   = Anchor.CentreLeft,
                                Anchor   = Anchor.CentreLeft,
                                Text     = value.ToString(),
                                TextSize = 18,
                            },
                            textBold = new OsuSpriteText
                            {
                                Alpha    = 0,
                                Margin   = new MarginPadding(5),
                                Origin   = Anchor.CentreLeft,
                                Anchor   = Anchor.CentreLeft,
                                Text     = value.ToString(),
                                Font     = @"Exo2.0-Bold",
                                TextSize = 18,
                            },
                        }
                    }
                };
            }
Example #48
0
 public override void Effect(Box b)
 {
     throw new System.NotImplementedException();
 }
Example #49
0
    static void Main(string[] args)
    {
        // <Snippet2>
        List <Box> Boxes = new List <Box>();

        Boxes.Add(new Box(4, 20, 14));
        Boxes.Add(new Box(12, 12, 12));
        Boxes.Add(new Box(8, 20, 10));
        Boxes.Add(new Box(6, 10, 2));
        Boxes.Add(new Box(2, 8, 4));
        Boxes.Add(new Box(2, 6, 8));
        Boxes.Add(new Box(4, 12, 20));
        Boxes.Add(new Box(18, 10, 4));
        Boxes.Add(new Box(24, 4, 18));
        Boxes.Add(new Box(10, 4, 16));
        Boxes.Add(new Box(10, 2, 10));
        Boxes.Add(new Box(6, 18, 2));
        Boxes.Add(new Box(8, 12, 4));
        Boxes.Add(new Box(12, 10, 8));
        Boxes.Add(new Box(14, 6, 6));
        Boxes.Add(new Box(16, 6, 16));
        Boxes.Add(new Box(2, 8, 12));
        Boxes.Add(new Box(4, 24, 8));
        Boxes.Add(new Box(8, 6, 20));
        Boxes.Add(new Box(18, 18, 12));

        // Sort by an Comparer<T> implementation that sorts
        // first by the length.
        Boxes.Sort(new BoxLengthFirst());

        Console.WriteLine("H - L - W");
        Console.WriteLine("==========");
        foreach (Box bx in Boxes)
        {
            Console.WriteLine("{0}\t{1}\t{2}",
                              bx.Height.ToString(), bx.Length.ToString(),
                              bx.Width.ToString());
        }
        // </Snippet2>

        Console.WriteLine();
        Console.WriteLine("H - L - W");
        Console.WriteLine("==========");

        // <Snippet3>
        // Get the default comparer that
        // sorts first by the height.
        Comparer <Box> defComp = Comparer <Box> .Default;

        // Calling Boxes.Sort() with no parameter
        // is the same as calling Boxs.Sort(defComp)
        // because they are both using the default comparer.
        Boxes.Sort();

        foreach (Box bx in Boxes)
        {
            Console.WriteLine("{0}\t{1}\t{2}",
                              bx.Height.ToString(), bx.Length.ToString(),
                              bx.Width.ToString());
        }
        // </Snippet3>

        // <Snippet4>

        // This explicit interface implementation
        // compares first by the length.
        // Returns -1 because the length of BoxA
        // is less than the length of BoxB.
        BoxLengthFirst LengthFirst = new BoxLengthFirst();

        Comparer <Box> bc = (Comparer <Box>)LengthFirst;

        Box BoxA = new Box(2, 6, 8);
        Box BoxB = new Box(10, 12, 14);
        int x    = LengthFirst.Compare(BoxA, BoxB);

        Console.WriteLine();
        Console.WriteLine(x.ToString());
        // </Snippet4>
    }
Example #50
0
            public PropertyItem(MemberInfo info, IDrawable d)
            {
                Type type;

                switch (info.MemberType)
                {
                case MemberTypes.Property:
                    PropertyInfo propertyInfo = (PropertyInfo)info;
                    type     = propertyInfo.PropertyType;
                    getValue = () => propertyInfo.GetValue(d);
                    break;

                case MemberTypes.Field:
                    FieldInfo fieldInfo = (FieldInfo)info;
                    type     = fieldInfo.FieldType;
                    getValue = () => fieldInfo.GetValue(d);
                    break;

                default:
                    throw new NotImplementedException(@"Not a value member.");
                }

                RelativeSizeAxes = Axes.X;
                AutoSizeAxes     = Axes.Y;

                AddRangeInternal(new Drawable[]
                {
                    new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Padding          = new MarginPadding
                        {
                            Right = 6
                        },
                        Child = new FillFlowContainer <SpriteText>
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Direction        = FillDirection.Horizontal,
                            Spacing          = new Vector2(10f),
                            Children         = new[]
                            {
                                new SpriteText
                                {
                                    Text   = info.Name,
                                    Colour = Color4.LightBlue,
                                },
                                new SpriteText
                                {
                                    Text   = $@"[{type.Name}]:",
                                    Colour = Color4.MediumPurple,
                                },
                                valueText = new SpriteText
                                {
                                    Colour = Color4.White,
                                },
                            }
                        }
                    },
                    changeMarker = new Box
                    {
                        Size   = new Vector2(4, 18),
                        Anchor = Anchor.CentreRight,
                        Origin = Anchor.CentreRight,
                        Colour = Color4.Red
                    }
                });

                // Update the value once
                updateValue();
            }
Example #51
0
    // Use this for initialization
    void Start()
    {
        battleComponent   = GetComponent <UIPanel>().ui;
        boxButton         = battleComponent.GetChild("boxButton").asButton;
        boxButton.visible = false;

        boxButton.onClick.Add(() => {
            boxWindow = new BoxWindow(box);
            boxWindow.Show();
        });

        // 坦克将碰撞到的盒子传递过来,通过判断盒子是否为空表示远离或接近
        Box.boxDelegate += (Box box) => {
            boxButton.visible = box == null ? false : true;
            // 远离盒子时关闭窗口
            if (!boxButton.visible && boxWindow != null)
            {
                boxWindow.Hide();
                boxWindow.Dispose();
                boxWindow          = null;
                boxButton.selected = false;
            }
            this.box = box;
        };

        Tank.goodsDelegate += (List <Goods> goodsList) => {
            // 清除旧窗口
            if (goodsWindow != null)
            {
                goodsWindow.Hide();
                goodsWindow.Dispose();
                goodsWindow = null;
            }
            // 新建新窗口
            createGoodsWindow(goodsList);
        };

        // 注册拖拽事件
        GGroup footer = battleComponent.GetChild("footer").asGroup;

        mulGoodsList = battleComponent.GetChildInGroup(footer, "buttleList").asList;
        sinGoodsList = battleComponent.GetChildInGroup(footer, "goodsList").asList;
        GObject[] mulGoodsButtons = mulGoodsList.GetChildren();
        GObject[] sinGoodsButtons = sinGoodsList.GetChildren();
        getGoodsDelegate += getGoods;

        dragIcon = battleComponent.GetChild("dragIcon").asLoader;
        touchID  = -1;

        bulletEmptyList   = new List <GButton>();
        medecineEmptyList = new List <GButton>();

        for (int i = 0; i < mulGoodsButtons.Length; i++)
        {
            GButton btn = (GButton)mulGoodsButtons[i];
            btn.visible = false;
            addDragAndDrop(btn);

            bulletEmptyList.Add(btn);
        }
        for (int i = 0; i < sinGoodsButtons.Length; i++)
        {
            GButton btn = (GButton)sinGoodsButtons[i];
            btn.visible = false;
            addDragAndDrop(btn);

            // 包含药品、道具
            medecineEmptyList.Add(btn);
        }

        coldDownTable        = new Hashtable();
        bulletColdDownTime   = 0;
        medecineColdDownTime = 0;
    }
Example #52
0
 public static string AsString(this Box box)
 {
     return($"{box.Left} {box.Bottom} {box.Width} {box.Height}");
 }
Example #53
0
        private void BtnCancelar(object sender, EventArgs e)
        {
            Box.AbortAnimation("ColorTo");

            //ViewExtensions.CancelAnimation(Box);
        }
Example #54
0
        /// <inheritdoc />
        public Task <Box> CreateAsync(Box box)
        {
            this.Boxes.Add(box);

            return(Task.FromResult(this.Boxes.Find(b => b.Equals(box))));
        }
Example #55
0
 public Error(int error)
 {
     Box.Show(ec[error], "Caution", 951);
 }
Example #56
0
 private async void BtnColor(object sender, EventArgs e)
 {
     var colorTo = Color.FromHex(TxtColor.Text);
     await Box.ColorTo(Box.BackgroundColor, colorTo, p => Box.BackgroundColor = p, 5000, Easing.Linear);
 }
Example #57
0
        public override void PropChanged(object sender, EventArgs args)
        {
            var builder = ContainingBox.Builder;

            builder.CurrentHookup = this;
            var newItems = Fetcher().ToArray();
            // See how much we can keep at the start of the sequence;
            int firstChildToReplace = 0;
            int firstItemToReplace  = 0;

            while (firstChildToReplace < Children.Count)
            {
                var group = ((IItemsHookup)Children[firstChildToReplace]).ItemGroup;
                if (!DoesGroupMatch(group, newItems, firstItemToReplace))
                {
                    break;
                }
                firstChildToReplace++;
                firstItemToReplace += group.Length;
            }
            // See how much we can keep at the end of the sequence;
            int limChildToReplace = Children.Count;
            int limItemToReplace  = newItems.Length;

            while (limChildToReplace > firstChildToReplace)
            {
                var group = ((IItemsHookup)Children[limChildToReplace - 1]).ItemGroup;
                if (!DoesGroupMatch(group, newItems, limItemToReplace - group.Length))
                {
                    break;
                }
                limChildToReplace--;
                limItemToReplace -= group.Length;
            }
            Box firstBoxToRemove = null;

            for (int i = firstChildToReplace; i < limChildToReplace && firstBoxToRemove == null; i++)
            {
                firstBoxToRemove = ((IItemsHookup)Children[i]).FirstBox;
            }
            Box lastBoxToRemove = GetLastBoxInRange(firstChildToReplace, limChildToReplace);

            Children.RemoveRange(firstChildToReplace, limChildToReplace - firstChildToReplace);
            if (firstBoxToRemove != null)
            {
                ContainingBox.RemoveBoxes(firstBoxToRemove, lastBoxToRemove);
            }
            if (limItemToReplace > firstItemToReplace)
            {
                var lazyBox = new LazyBox <T>(builder.NestedBoxStyles, this,
                                              newItems.Skip(firstItemToReplace).Take(limItemToReplace - firstItemToReplace));
                ContainingBox.InsertBox(lazyBox, GetLastBoxInRange(0, firstChildToReplace));
                Children.Insert(firstChildToReplace, lazyBox);
                using (var gh = ContainingBox.Root.Site.DrawingInfo)
                {
                    lazyBox.RelayoutWithParents(gh);
                }
            }
            else if (limChildToReplace > firstChildToReplace)
            {
                // pure deletion.
                using (var gh = ContainingBox.Root.Site.DrawingInfo)
                {
                    ContainingBox.RelayoutWithParents(gh);
                }
            }
        }
Example #58
0
        protected SearchableListFilterControl()
        {
            if (!typeof(T).IsEnum)
            {
                throw new InvalidOperationException("SearchableListFilterControl's sort tabs only support enums as the generic type argument");
            }

            RelativeSizeAxes = Axes.X;

            var       controls = CreateSupplementaryControls();
            Container controlsContainer;

            Children = new Drawable[]
            {
                filterContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = BackgroundColour,
                            Alpha            = 0.9f,
                        },
                        tabStrip = new Box
                        {
                            Anchor           = Anchor.BottomLeft,
                            Origin           = Anchor.BottomLeft,
                            RelativeSizeAxes = Axes.X,
                            Height           = 1,
                        },
                        new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Padding          = new MarginPadding {
                                Top = padding, Horizontal = SearchableListOverlay.WIDTH_PADDING
                            },
                            Children = new Drawable[]
                            {
                                Search = new FilterSearchTextBox
                                {
                                    RelativeSizeAxes = Axes.X,
                                },
                                controlsContainer = new Container
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Margin           = new MarginPadding {
                                        Top = controls != null ? padding : 0
                                    },
                                },
                                Tabs = new PageTabControl <T>
                                {
                                    RelativeSizeAxes = Axes.X,
                                },
                                new Box //keep the tab strip part of autosize, but don't put it in the flow container
                                {
                                    RelativeSizeAxes = Axes.X,
                                    Height           = 1,
                                    Colour           = Color4.White.Opacity(0),
                                },
                            },
                        },
                    },
                },
                DisplayStyleControl = new DisplayStyleControl <U>
                {
                    Anchor = Anchor.TopRight,
                    Origin = Anchor.TopRight,
                },
            };

            if (controls != null)
            {
                controlsContainer.Children = new[] { controls }
            }
            ;

            Tabs.Current.Value = DefaultTab;
            Tabs.Current.TriggerChange();
        }
Example #59
0
        private void load(OsuColour colours, GameHost host)
        {
            this.host = host;

            // TODO: should probably be done at a RulesetContainer level to share logic with Player.
            var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();

            clock = new EditorClock(Beatmap.Value, beatDivisor)
            {
                IsCoupled = false
            };
            clock.ChangeSource(sourceClock);

            dependencies.CacheAs <IFrameBasedClock>(clock);
            dependencies.CacheAs <IAdjustableClock>(clock);
            dependencies.Cache(beatDivisor);

            EditorMenuBar     menuBar;
            TimeInfoContainer timeInfo;
            SummaryTimeline   timeline;
            PlaybackControl   playback;

            Children = new[]
            {
                new Container
                {
                    Name             = "Screen container",
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Top = 40, Bottom = 60
                    },
                    Child = screenContainer = new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        Masking          = true
                    }
                },
                new Container
                {
                    Name             = "Top bar",
                    RelativeSizeAxes = Axes.X,
                    Height           = 40,
                    Child            = menuBar = new EditorMenuBar
                    {
                        Anchor           = Anchor.CentreLeft,
                        Origin           = Anchor.CentreLeft,
                        RelativeSizeAxes = Axes.Both,
                        Items            = new[]
                        {
                            new MenuItem("File")
                            {
                                Items = new[]
                                {
                                    new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap),
                                    new EditorMenuItemSpacer(),
                                    new EditorMenuItem("Exit", MenuItemType.Standard, Exit)
                                }
                            }
                        }
                    }
                },
                new Container
                {
                    Name             = "Bottom bar",
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.X,
                    Height           = 60,
                    Children         = new Drawable[]
                    {
                        bottomBackground = new Box {
                            RelativeSizeAxes = Axes.Both
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Vertical = 5, Horizontal = 10
                            },
                            Child = new GridContainer
                            {
                                RelativeSizeAxes = Axes.Both,
                                ColumnDimensions = new[]
                                {
                                    new Dimension(GridSizeMode.Absolute, 220),
                                    new Dimension(),
                                    new Dimension(GridSizeMode.Absolute, 220)
                                },
                                Content = new[]
                                {
                                    new Drawable[]
                                    {
                                        new Container
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Padding          = new MarginPadding {
                                                Right = 10
                                            },
                                            Child = new TimeInfoContainer {
                                                RelativeSizeAxes = Axes.Both
                                            },
                                        },
                                        new SummaryTimeline
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                        },
                                        new Container
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Padding          = new MarginPadding {
                                                Left = 10
                                            },
                                            Child = new PlaybackControl {
                                                RelativeSizeAxes = Axes.Both
                                            },
                                        }
                                    },
                                }
                            },
                        }
                    }
                },
            };

            menuBar.Mode.ValueChanged += onModeChanged;

            bottomBackground.Colour = colours.Gray2;
        }
Example #60
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;

            // Create box for base atom.
            var baseBox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);

            if (this.SubscriptAtom == null && this.SuperscriptAtom == null)
            {
                if (baseBox is CharBox)
                {
                    // This situation should only happen when CreateBox called on a temporary ScriptsAtom created from
                    // BigOperatorAtom.CreateBox. The CharBox's Shift should then be fixed up.
                    baseBox.Shift = -(baseBox.Height + baseBox.Depth) / 2
                                    - environment.MathFont.GetAxisHeight(environment.Style);
                }

                return(baseBox);
            }

            // Create result box.
            var resultBox = new HorizontalBox(baseBox);

            // Get last font used or default Mu font.
            int lastFontId = baseBox.GetLastFontId();

            if (lastFontId == TexFontUtilities.NoFontId)
            {
                lastFontId = texFont.GetMuFontId();
            }

            var subscriptStyle   = environment.GetSubscriptStyle();
            var superscriptStyle = environment.GetSuperscriptStyle();

            // Set delta value and preliminary shift-up and shift-down amounts depending on type of base atom.
            var    delta = 0d;
            double shiftUp, shiftDown;

            if (this.BaseAtom is AccentedAtom)
            {
                var accentedBox = ((AccentedAtom)this.BaseAtom).BaseAtom.CreateBox(environment.GetCrampedStyle());
                shiftUp   = accentedBox.Height - texFont.GetSupDrop(superscriptStyle.Style);
                shiftDown = accentedBox.Depth + texFont.GetSubDrop(subscriptStyle.Style);
            }
            else if (this.BaseAtom is SymbolAtom && this.BaseAtom.Type == TexAtomType.BigOperator)
            {
                var charInfo = texFont.GetCharInfo(((SymbolAtom)this.BaseAtom).Name, style).Value;
                if (style < TexStyle.Text && texFont.HasNextLarger(charInfo))
                {
                    charInfo = texFont.GetNextLargerCharInfo(charInfo, style);
                }
                var charBox = new CharBox(environment, charInfo);

                charBox.Shift = -(charBox.Height + charBox.Depth) / 2 - environment.MathFont.GetAxisHeight(
                    environment.Style);
                resultBox = new HorizontalBox(charBox);

                delta = charInfo.Metrics.Italic;
                if (delta > TexUtilities.FloatPrecision && this.SubscriptAtom == null)
                {
                    resultBox.Add(new StrutBox(delta, 0, 0, 0));
                }

                shiftUp   = resultBox.Height - texFont.GetSupDrop(superscriptStyle.Style);
                shiftDown = resultBox.Depth + texFont.GetSubDrop(subscriptStyle.Style);
            }
            else if (this.BaseAtom is CharSymbol charSymbol)
            {
                var charFont = charSymbol.GetCharFont(texFont).Value;
                if (!charSymbol.IsTextSymbol || !texFont.HasSpace(charFont.FontId))
                {
                    delta = texFont.GetCharInfo(charFont, style).Value.Metrics.Italic;
                }
                if (delta > TexUtilities.FloatPrecision && this.SubscriptAtom == null)
                {
                    resultBox.Add(new StrutBox(delta, 0, 0, 0));
                    delta = 0;
                }

                shiftUp   = 0;
                shiftDown = 0;
            }
            else
            {
                shiftUp   = baseBox.Height - texFont.GetSupDrop(superscriptStyle.Style);
                shiftDown = baseBox.Depth + texFont.GetSubDrop(subscriptStyle.Style);
            }

            Box superscriptBox          = null;
            Box superscriptContainerBox = null;
            Box subscriptBox            = null;
            Box subscriptContainerBox   = null;

            if (this.SuperscriptAtom != null)
            {
                // Create box for superscript atom.
                superscriptBox          = this.SuperscriptAtom.CreateBox(superscriptStyle);
                superscriptContainerBox = new HorizontalBox(superscriptBox);

                // Add box for script space.
                superscriptContainerBox.Add(scriptSpaceAtom.CreateBox(environment));

                // Adjust shift-up amount.
                double p;
                if (style == TexStyle.Display)
                {
                    p = texFont.GetSup1(style);
                }
                else if (environment.GetCrampedStyle().Style == style)
                {
                    p = texFont.GetSup3(style);
                }
                else
                {
                    p = texFont.GetSup2(style);
                }
                shiftUp = Math.Max(Math.Max(shiftUp, p), superscriptBox.Depth + Math.Abs(texFont.GetXHeight(
                                                                                             style, lastFontId)) / 4);
            }

            if (this.SubscriptAtom != null)
            {
                // Create box for subscript atom.
                subscriptBox          = this.SubscriptAtom.CreateBox(subscriptStyle);
                subscriptContainerBox = new HorizontalBox(subscriptBox);

                // Add box for script space.
                subscriptContainerBox.Add(scriptSpaceAtom.CreateBox(environment));
            }

            // Check if only superscript is set.
            if (subscriptBox == null)
            {
                superscriptContainerBox.Shift = -shiftUp;
                resultBox.Add(superscriptContainerBox);
                return(resultBox);
            }

            // Check if only subscript is set.
            if (superscriptBox == null)
            {
                subscriptContainerBox.Shift = Math.Max(Math.Max(shiftDown, texFont.GetSub1(style)), subscriptBox.Height - 4 *
                                                       Math.Abs(texFont.GetXHeight(style, lastFontId)) / 5);
                resultBox.Add(subscriptContainerBox);
                return(resultBox);
            }

            // Adjust shift-down amount.
            shiftDown = Math.Max(shiftDown, texFont.GetSub2(style));

            // Reposition both subscript and superscript.
            double defaultLineThickness = texFont.GetDefaultLineThickness(style);
            // Space between subscript and superscript.
            double scriptsInterSpace = shiftUp - superscriptBox.Depth + shiftDown - subscriptBox.Height;

            if (scriptsInterSpace < 4 * defaultLineThickness)
            {
                shiftUp += 4 * defaultLineThickness - scriptsInterSpace;

                // Position bottom of superscript at least 4/5 of X-height above baseline.
                double psi = 0.8 * Math.Abs(texFont.GetXHeight(style, lastFontId)) - (shiftUp - superscriptBox.Depth);
                if (psi > 0)
                {
                    shiftUp   += psi;
                    shiftDown -= psi;
                }
            }
            scriptsInterSpace = shiftUp - superscriptBox.Depth + shiftDown - subscriptBox.Height;

            // Create box containing both superscript and subscript.
            var scriptsBox = new VerticalBox();

            superscriptContainerBox.Shift = delta;
            scriptsBox.Add(superscriptContainerBox);
            scriptsBox.Add(new StrutBox(0, scriptsInterSpace, 0, 0));
            scriptsBox.Add(subscriptContainerBox);
            scriptsBox.Height = shiftUp + superscriptBox.Height;
            scriptsBox.Depth  = shiftDown + subscriptBox.Depth;
            resultBox.Add(scriptsBox);

            return(resultBox);
        }