Пример #1
0
        public void DrawGraph()
        {
            for (var i = 0; i < vertices.Length; i++)
            {
                var vertex = vertices[i];
                var x      = vertex.GridPosition / sizeY;
                var y      = vertex.GridPosition % sizeY;

                DebugDrawer.DrawCube(new UnityEngine.Vector2Int(x, y), Vector2Int.one, Color.yellow);
                var edgeEnd = (i + 1 == vertices.Length) ? edges.Length : vertices[i + 1].EdgeOffset;
                if (edgeEnd == -1)
                {
                    continue;
                }

                for (var j = vertex.EdgeOffset; j < edgeEnd; j++)
                {
                    var edge   = edges[j];
                    var target = edge.ToVertex;
                    if (target == -1)
                    {
                        var tx = edge.ToVertexGridPosition / sizeY;
                        var ty = edge.ToVertexGridPosition % sizeY;
                        DebugDrawer.Draw(new Vector2Int(x, y), new Vector2Int(tx, ty), Color.yellow);
                    }
                    else
                    {
                        var tx = vertices[target].GridPosition / sizeY;
                        var ty = vertices[target].GridPosition % sizeY;
                        DebugDrawer.Draw(new Vector2Int(x, y), new Vector2Int(tx, ty), Color.yellow);
                    }
                }
            }
        }
Пример #2
0
        public void PaintDebug(DebugDrawer drawer)
        {
            if (Settings.Data.debugMode)
            {
                Movable locomotion = Locomotion;

                drawer.DrawCircle(drawer.Position, Controller.searchRadius, new Color(1.0f, 0.0f, 0.0f, 0.2f));
                //drawer.DrawLine(drawer.Position, debugHitLocation.RelativeTo(locomotion.GlobalPosition), new Color(0.0f, 1.0f, 0.0f), 2f, true);
                if (target != null)
                {
                    const float size = 24f;
                    drawer.DrawRect(new Rect2(target.Location.RelativeTo(locomotion.GlobalPosition) - new Vector2(size / 2f, size / 2f), size, size), new Color(0.0f, 1.0f, 0.0f), false);
                }

                if (state == ChaseAIState.Wandering)
                {
                    drawer.DrawLine(drawer.Position, target.Location.RelativeTo(locomotion.GlobalPosition), new Color(0.0f, 0.0f, 1.0f), 2f, true);
                    drawer.DrawCircle(target.Location.RelativeTo(locomotion.GlobalPosition), 8f, new Color(0.0f, 0.0f, 1.0f));
                }
                else if (state == ChaseAIState.Chasing)
                {
                    drawer.DrawLine(drawer.Position, target.Location.RelativeTo(locomotion.GlobalPosition), new Color(1.0f, 0.0f, 0.0f), 2f, true);
                    drawer.DrawCircle(target.Location.RelativeTo(locomotion.GlobalPosition), 8f, new Color(1.0f, 0.0f, 0.0f));
                }
            }
        }
Пример #3
0
        public void DrawOverlayGraph(int level)
        {
            for (var i = 0; i < overlayVerticesCellMapping[level].Length; i++)
            {
                for (var j = 0; j < overlayVerticesCellMapping[level][i].Count; j++)
                {
                    var overlayVertex = overlayVertices[overlayVerticesCellMapping[level][i][j]];
                    var vertex        = vertices[overlayVertex.OriginalVertex];
                    var x             = vertex.GridPosition / sizeY;
                    var y             = vertex.GridPosition % sizeY;
                    DebugDrawer.DrawCube(new UnityEngine.Vector2Int(x, y), Vector2Int.one, Color.red);

                    for (var n = 0; n < overlayVertex.OverlayEdges[level - 1].Count; n++)
                    {
                        var target = overlayVertex.OverlayEdges[level - 1][n].NeighborOverlayVertex;
                        if (target == -1)
                        {
                            continue;
                        }

                        var tx = vertices[overlayVertices[target].OriginalVertex].GridPosition / sizeY;
                        var ty = vertices[overlayVertices[target].OriginalVertex].GridPosition % sizeY;
                        DebugDrawer.Draw(new Vector2Int(x, y), new Vector2Int(tx, ty), new Color(1, 1, 1));
                    }
                }
            }
        }
        public override void Update()
        {
            DebugDrawer.AddBoundingBox(AABB, Color.Red, 2000);
            //DebugDrawer.AddBoundingSphere(AABS, Color.Yellow, 2000);

            DebugDrawer.AddLine(ray.Position, ray.Position + (ray.Direction * 10), Color.LawnGreen);
            base.Update();
        }
Пример #5
0
 private void OnDrawGizmos()
 {
     if (Application.isPlaying)
     {
         DebugDrawer.DrawBounds(m_ViewBounds, Color.yellow);
         DebugDrawer.DrawBounds(m_ContentBounds, Color.red);
     }
 }
Пример #6
0
 public static void bounds(Bounds bounds, Color color, Color?crossLineColor = null, float duration = 0)
 {
     if (crossLineColor != null)
     {
         Debug.DrawLine(bounds.min, bounds.max, (Color)crossLineColor, duration);
     }
     DebugDrawer.box(bounds.center, bounds.extents, color, duration);
 }
Пример #7
0
        public override void OnPaint(IGraphics graphics)
        {
            DebugDrawer.DebugDrawRect(enemyInfo.GetGuessPositionHistory(10), 10, System.Drawing.Brushes.Blue, graphics);
            DebugDrawer.DebugDrawRect(enemyInfo.GetGuessPositionHeading(10), 10, System.Drawing.Brushes.Green, graphics);
            DebugDrawer.DebugDrawRect(enemyInfo.GetGuessPositionEducated(10), 10, System.Drawing.Brushes.Red, graphics);

            DebugDrawer.DebugDrawLine(this.Position, enemyInfo.Bearings.GetCurrent() + HeadingRadians, 20, System.Drawing.Pens.Red, graphics);
            DebugDrawer.DebugDrawLine(this.Position, MiscHelper.GetAngleBetweenPositions(Position, enemyInfo.GetGuessPositionEducated(10)), 20, System.Drawing.Pens.Green, graphics);
        }
Пример #8
0
 public static void box(Vector3 center, Vector3 size, Color color, float duration = 0)
 {
     DebugDrawer.plane(new Vector3(center.x, center.y + size.y, center.z), size, color, duration);
     DebugDrawer.plane(new Vector3(center.x, center.y - size.y, center.z), size, color, duration);
     Debug.DrawLine(new Vector3(center.x + size.x, center.y - size.y, center.z + size.z), new Vector3(center.x + size.x, center.y + size.y, center.z + size.z), color, duration);
     Debug.DrawLine(new Vector3(center.x - size.x, center.y - size.y, center.z + size.z), new Vector3(center.x - size.x, center.y + size.y, center.z + size.z), color, duration);
     Debug.DrawLine(new Vector3(center.x + size.x, center.y - size.y, center.z - size.z), new Vector3(center.x + size.x, center.y + size.y, center.z - size.z), color, duration);
     Debug.DrawLine(new Vector3(center.x - size.x, center.y - size.y, center.z - size.z), new Vector3(center.x - size.x, center.y + size.y, center.z - size.z), color, duration);
 }
Пример #9
0
        public GameEngine(Game game) : base(game)
        {
            game.Components.Add(this);

            Input   = new InputManager(game);
            camera  = new CameraManager(game);
            debug   = new DebugDrawer();
            counter = new FrameRateCounter(game);
            physics = new PhysicsManager(game);
        }
Пример #10
0
        /// <inheritdoc />
        public Game(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            _environment = System.Environment.Version.ToString();
            Input        = new Input(this);
            Global.Input = Input;

            DebugDrawer        = new DebugDrawer();
            Global.DebugDrawer = DebugDrawer;
        }
Пример #11
0
    IEnumerator Render()
    {
        int nx = Screen.width;
        int ny = Screen.height;

        progress   = 0f;
        startTime  = time();
        renderDone = false;

        Vector3 lookFrom      = new Vector3(1f, 2f, 2f);
        Vector3 lookAt        = new Vector3(0f, 0f, -1f);
        float   dist_to_focus = 2f;
        float   aperture      = 0f;
        zCamera zcam          = new zCamera(cam);
        uint    index         = 0;

        if (debugMod)
        {
            Color col = Color.black;
            for (int s = 0; s < 1; s++)
            {
                float u = (float)((int)debugPoint.x + zRandom.Halton5(index++)) / (float)(nx);
                float v = (float)((int)debugPoint.y + zRandom.Halton5(index++)) / (float)(ny);
                zRay  r = zcam.get_ray(u, v);
                DebugDrawer.Init(cam);
                col += color(r, world, 0);
            }
        }
        else
        {
            for (int j = ny - 1; j >= 0; j--)
            {
                Color col = Color.black;
                for (int i = 0; i < nx; i++)
                {
                    for (int s = 0; s < ns; s++)
                    {
                        float u = (float)(i + zRandom.Halton5(index++)) / (float)(nx);
                        float v = (float)(j + zRandom.Halton5(index++)) / (float)(ny);
                        zRay  r = zcam.get_ray(u, v);
                        col += color(r, world, 0);
                    }
                    col /= (float)ns;
                    col  = col.gamma;
                    rtResult.SetPixel(rtResult.width - i, j, col);
                }
                progress += nx;
                yield return(null);
            }
            rtResult.Apply();
            renderDone = true;
            timePassed = time();
        }
        yield return(null);
    }
Пример #12
0
        private bool CalculateShortestPath()
        {
            Node currentNode;

            Position[] neighbors = new Position[8];

            heap.Add(startNode, 0);
            while (heap.Count > 0)
            {
                currentNode = heap.Remove();
                if (currentNode == targetNode)
                {
                    return(true);
                }

                currentNode.setClosed();
                var count = GetNeighbors(currentNode, ref neighbors);
                for (var i = 0; i < count; i++)
                {
                    var neighbor     = neighbors[i];
                    var neighborNode = GetNeighborNode(currentNode, neighbor);
                    if (neighborNode == null || neighborNode.isClosed())
                    {
                        continue;
                    }

                    int newGCost = NewGCost(currentNode, neighborNode);
                    if (newGCost < neighborNode.gCost || !neighborNode.isOpen())
                    {
#if DEBUG_PATHFINDING
                        if (showDebug)
                        {
                            DebugDrawer.Draw(new Vector2Int(currentNode.x, currentNode.y), new Vector2Int(neighborNode.x, neighborNode.y), Color.white);
                            DebugDrawer.DrawCube(new Vector2Int(neighborNode.x, neighborNode.y), Vector2Int.one, Color.white);
                        }
#endif

                        neighborNode.gCost  = newGCost;
                        neighborNode.hCost  = Heuristic(neighborNode, targetNode);
                        neighborNode.parent = currentNode;

                        if (!neighborNode.isOpen())
                        {
                            heap.Add(neighborNode, neighborNode.gCost + neighborNode.hCost);
                            neighborNode.setOpen();
                        }
                        else
                        {
                            heap.Update(neighborNode, neighborNode.gCost + neighborNode.hCost);
                        }
                    }
                }
            }
            return(false);
        }
Пример #13
0
 protected override void DebugDraw(DebugDrawer drawer)
 {
     /*for (int y = 0; y < Nodes.GetLength(1); y++)
      * {
      *  for (int x = 0; x < Nodes.GetLength(0); x++)
      *  {
      *      drawer.DrawCircle(Nodes[x, y].Position, 32, Color.Red, DrawingSpace.Screen);
      *      drawer.DrawText(Nodes[x, y].Position, Nodes[x, y].ToString(), Color.Black, DrawingSpace.Screen);
      *  }
      * }*/
 }
        protected override void Initialize()
        {
            DebugDrawer = new DebugDrawer(this);
            this.Components.Add(DebugDrawer);

            Camera = new Camera(this);
            this.Components.Add(Camera);

            body2.Position = new JVector(4, 2);

            base.Initialize();
        }
        protected override void Initialize()
        {
            DebugDrawer = new DebugDrawer(this);
            this.Components.Add(DebugDrawer);

            Camera = new Camera(this);
            this.Components.Add(Camera);

            body2.Position = new JVector(4, 2);

            base.Initialize();
        }
Пример #16
0
        public void DrawSubGoals()
        {
            foreach (var subgoal in subGoals.Values)
            {
                DebugDrawer.DrawCube(new UnityEngine.Vector2Int(subgoal.x, subgoal.y), Vector2Int.one, Color.yellow);

                foreach (var edge in subgoal.edges)
                {
                    DebugDrawer.Draw(new Vector2Int(subgoal.x, subgoal.y), new Vector2Int(edge.toX, edge.toY), Color.yellow);
                }
            }
        }
Пример #17
0
        private void Update()
        {
            if (!this.isReadOnly && this.isDirty)
            {
                this.renderChunk();
            }

            if (Main.isDeveloperMode)
            {
                DebugDrawer.bounds(this.chunkBounds, this.isReadOnly ? new Color(1, 0, 0, 0.25f) : this.hasDoneGen2 ? Color.blue : new Color(0, 1, 0, 0.25f));
            }
        }
Пример #18
0
        private void drawEdgesVertex(int vertexID, int chunkID)
        {
            var targetNeighborChunk = graph.GetChunk(chunkID);
            var targetVertex        = targetNeighborChunk.vertices[vertexID];

            var(tx, ty) = fromGridPosition(targetVertex.GridPosition);
            for (var k = targetVertex.EdgeOffset; k < targetNeighborChunk.vertices[vertexID + 1].EdgeOffset; k++)
            {
                var edge       = targetNeighborChunk.edges[k];
                var edgeTarget = edge.ToVertex;
                var(hx, hy) = fromGridPosition(edgeTarget == -1 ? edge.ToVertexGridPosition : targetNeighborChunk.vertices[edgeTarget].GridPosition);
                DebugDrawer.Draw(new Vector2Int(tx, ty), new Vector2Int(hx, hy), Color.white);
            }
        }
Пример #19
0
        private void Awake()
        {
            World = new World(new Vector2(0, -10));

            // Define the gravity vector.
            DebugDrawer = DebugDrawer.GetDrawer();

            WorldDrawer = new BoxDrawer {
                Drawer = DebugDrawer
            };

            World.SetDebugDrawer(WorldDrawer);
            Logger.SetLogger(new UnityLogger());
        }
Пример #20
0
        public void DrawCellBorders()
        {
            var chunkSizeX = grid.GetSize().x / chunkSize;
            var chunkSizeY = grid.GetSize().y / chunkSize;

            for (var x = 0; x < chunkSizeX; x++)
            {
                for (var y = 0; y < chunkSizeY; y++)
                {
                    DebugDrawer.DrawNoOffset(new Vector2Int(x * chunkSize, y * chunkSize + chunkSize), new Vector2Int(x * chunkSize + chunkSize, y * chunkSize + chunkSize), Color.magenta);
                    DebugDrawer.DrawNoOffset(new Vector2Int(x * chunkSize + chunkSize, y * chunkSize + chunkSize), new Vector2Int(x * chunkSize + chunkSize, y * chunkSize), Color.magenta);
                }
            }
        }
Пример #21
0
    private void Update()
    {
        Debug.Log($"INFO: There are currently {electricNetworks.Count} electric networks. ");


        if (Input.GetKeyUp(KeyCode.U))
        {
            if (debugDrawer == null)
            {
                debugDrawer = new DebugDrawer(electricNetworks, debugConnectionLinePrefab);
            }

            debugDrawer.CreateDebugLinesForNetworks();
        }
    }
        public static void DrawFaceWithOutline(int faceIndex, RigidTransform t, NativeHull hull, Color fillColor, Color outlineColor)
        {
            var verts  = hull.GetVertices(faceIndex).Select(cp => (Vector3)cp).ToArray();
            var tVerts = new List <Vector3>();

            for (int i = 0; i < verts.Length; i++)
            {
                var v = math.transform(t, verts[i]);
                tVerts.Add(v);
                var nextIndex = i + 1 < verts.Length ? i + 1 : 0;
                var next      = math.transform(t, verts[nextIndex]);
                Debug.DrawLine(v, next, outlineColor);
            }
            DebugDrawer.DrawAAConvexPolygon(tVerts.ToArray(), fillColor);
        }
Пример #23
0
        public void DrawCellBorders()
        {
            for (var i = 0; i < OverlayGraph.LevelDimensions.Length; i++)
            {
                var chunkSizeX = grid.GetSize().x / OverlayGraph.LevelDimensions[i];
                var chunkSizeY = grid.GetSize().y / OverlayGraph.LevelDimensions[i];

                for (var x = 0; x < chunkSizeX; x++)
                {
                    for (var y = 0; y < chunkSizeY; y++)
                    {
                        DebugDrawer.DrawNoOffset(new Vector2Int(x * OverlayGraph.LevelDimensions[i], y * OverlayGraph.LevelDimensions[i] + OverlayGraph.LevelDimensions[i]), new Vector2Int(x * OverlayGraph.LevelDimensions[i] + OverlayGraph.LevelDimensions[i], y * OverlayGraph.LevelDimensions[i] + OverlayGraph.LevelDimensions[i]), Color.magenta);
                        DebugDrawer.DrawNoOffset(new Vector2Int(x * OverlayGraph.LevelDimensions[i] + OverlayGraph.LevelDimensions[i], y * OverlayGraph.LevelDimensions[i] + OverlayGraph.LevelDimensions[i]), new Vector2Int(x * OverlayGraph.LevelDimensions[i] + OverlayGraph.LevelDimensions[i], y * OverlayGraph.LevelDimensions[i]), Color.magenta);
                    }
                }
            }
        }
        public void DebugGroundHit()
        {
            if (_originHit != null)
            {
                DebugDrawer.DrawVector(_originHit.point, _originHit.normal, 4f, 1, Color.yellow, 0);
            }

            if (_primaryGround != null)
            {
                DebugDrawer.DrawVector(_primaryGround.point, _primaryGround.normal, 3.5f, 1, Color.magenta, 0);
            }

            if (_flushGround != null)
            {
                DebugDrawer.DrawVector(_flushGround.point, _flushGround.normal, 3, 1, Color.blue, 0);
            }
        }
Пример #25
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Debug draw
            _debugEffect.LightingEnabled    = false;
            _debugEffect.VertexColorEnabled = true;
            _debugEffect.CurrentTechnique.Passes[0].Apply();
            DebugDrawer.DrawDebugWorld(World);

            // Draw shapes
            foreach (RigidBody body in World.CollisionObjectArray)
            {
                DrawModel(body.CollisionShape, body.WorldTransform);
            }
        }
Пример #26
0
        private void updateForwardFrontier(Node node, float nodeScore)
        {
#if DEBUG_PATHFINDING
            if (showDebug)
            {
                DebugDrawer.Draw(new Vector2Int(node.parentA.x, node.parentA.y), new Vector2Int(node.x, node.y), Color.white);
                DebugDrawer.DrawCube(new Vector2Int(node.x, node.y), Vector2Int.one, Color.white);
            }
#endif

            if (node.isClosedB())
            {
                var pathLength = node.costB + nodeScore;
                if (bestPathLength > pathLength)
                {
                    bestPathLength = pathLength;
                    middleNode     = node;
                }
            }
        }
Пример #27
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && debugMod)
        {
            DebugDrawer.Clear();
            debugPoint   = Input.mousePosition;
            debugPoint.x = Screen.width - debugPoint.x;
            StartCoroutine(Render());
        }

        if (Input.GetKeyDown(KeyCode.S) && !debugMod)
        {
            StartCoroutine(Render());
        }

        if (DebugDrawer.isDebug != debugMod)
        {
            DebugDrawer.isDebug = debugMod;
        }
    }
Пример #28
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Draw background physics map.
            ServerConsole.PhysicsWorld.DrawDebugOverlay(Camera);


            // Draw overlayed map components.
            DebugTools.BeginCustomDraw(DebugViewProjection, DebugViewTranslation);
            {
                foreach (var player in Player.AllPlayers)
                {
                    DebugDrawer.DrawDebugPlayer(DebugTools, player);
                }
            }
            DebugTools.EndCustomDraw();


            // Draw Text to debug pannel.
            DebugDrawer.BeginPanelText();
            {
                DebugDrawer.DrawPanelText("--------- Players ---------");
                foreach (var player in Player.AllPlayers)
                {
                    DebugDrawer.DrawPanelText(" ");
                    DebugDrawer.DrawPanelText(string.Format("Name:{0}", player.Name));
                    DebugDrawer.DrawPanelText(string.Format("Id:{0}", player.UniqueID));
                    DebugDrawer.DrawPanelText(string.Format("Position:{0}", player.Position));
                }
            }
            DebugDrawer.EndPanelText(DebugTools);



            // Outputs map text.
            DebugTools.RenderDebugData(DebugViewProjection, DebugViewTranslation);

            // Draw Xna base game.
            base.Draw(gameTime);
        }
Пример #29
0
 void Awake()
 {
     Debug.unityLogger.logEnabled = Config.LOGGING;
     GM.instance            = this;
     this.OnUpdateGameState = null;
     this.filePicker        = this.canvasGameObject.transform.Find("FilePicker").GetComponent <GUIFilePicker>();
     this.playPanel         = this.canvasGameObject.transform.Find("PlayPanel").gameObject;
     this.editorPanel       = this.canvasGameObject.transform.Find("EditorPanel").gameObject;
     this.pausePanel        = this.canvasGameObject.transform.Find("PausePanel").gameObject;
     GM.inputManager        = this.coreGameObject.GetComponent <InputManager>();
     GM.boardManager        = this.coreGameObject.GetComponent <BoardManager>();
     GM.editManager         = this.coreGameObject.GetComponent <EditManager>();
     GM.playManager         = this.coreGameObject.GetComponent <PlayManager>();
     GM.debugDrawer         = this.coreGameObject.GetComponent <DebugDrawer>();
     GM.cursor = this.coreGameObject.GetComponentInChildren <Cursor>();
     this.OnUpdateGameState += GM.boardManager.OnUpdateGameState;
     this.OnUpdateGameState += GM.inputManager.OnUpdateGameState;
     this.OnUpdateGameState += GM.editManager.OnUpdateGameState;
     this.OnUpdateGameState += GM.playManager.OnUpdateGameState;
     this.OnUpdateGameState += GM.cursor.OnUpdateGameState;
 }
Пример #30
0
    public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var position    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            var positionInt = new Vector3Int((int)position.x, (int)position.y, 0);

            Debug.Log("Clicked at: " + positionInt.x + " - " + positionInt.y);

            /*var tile = Ground.GetTile(positionInt);
             *
             * if (tile == walkable)
             * {
             *  Ground.SetTile(positionInt, blocked);
             * }
             * else if (tile == blocked)
             * {
             *  Ground.SetTile(positionInt, road);
             * }
             * else if (tile == road)
             * {
             *  Ground.SetTile(positionInt, walkable);
             * }*/
        }
        else if (Input.GetMouseButtonDown(1))
        {
            var position    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            var positionInt = new Vector3Int((int)position.x, (int)position.y, 0);
            if (has(end) == false && has(start))
            {
                Path.SetTile(positionInt, end);
            }
            else
            {
                DebugDrawer.Clear();
                Path.ClearAllTiles();
                Path.SetTile(positionInt, start);
            }
        }
    }
Пример #31
0
        private void Awake()
        {
            if (!Dropdown)
            {
                throw new NullReferenceException("Test dropdown not found");
            }

            if (!RestartButton)
            {
                throw new NullReferenceException("Restart button not found");
            }

            _testTypes = typeof(TestBase).Assembly.GetTypes().Where(e => e.BaseType == typeof(TestBase)).ToArray();

            Settings             = gameObject.GetComponent <TestSettings>() ?? gameObject.AddComponent <TestSettings>();
            Settings.DebugDrawer = DebugDrawer.GetDrawer();
            Settings.WorldDrawer = new BoxDrawer {
                Drawer = Settings.DebugDrawer
            };

            Dropdown.ClearOptions();
            Dropdown.AddOptions(_testTypes.Select(e => e.Name).ToList());
            Dropdown.onValueChanged.AddListener(OnTestSelect);

            RestartButton.onClick.AddListener(Restart);

            foreach (var toggleField in typeof(TestSettings)
                     .GetFields()
                     .Where(f => f.GetCustomAttribute <ToggleAttribute>() != null))
            {
                var toggleName   = $"Canvas/{toggleField.Name}";
                var toggleObject = GameObject.Find(toggleName)
                                   ?? throw new NullReferenceException($"{toggleName} not found");
                var toggle = toggleObject.GetComponent <Toggle>();
                toggle.isOn = (bool)toggleField.GetValue(Settings);
                toggle.onValueChanged.AddListener(
                    value => { toggleField.SetValue(Settings, value); });
            }
        }
Пример #32
0
            * Matrix.CreateTranslation(-3, 0, -15); // POSITION

        #endregion Fields

        #region Constructors

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Construct our particle system components.
            explosionParticles = new ExplosionParticleSystem(this, Content);
            explosionSmokeParticles = new ExplosionSmokeParticleSystem(this, Content);
            projectileTrailParticles = new ProjectileTrailParticleSystem(this, Content);
            smokePlumeParticles = new SmokePlumeParticleSystem(this, Content);
            fireParticles = new FireParticleSystem(this, Content);

            // Set the draw order so the explosions and fire
            // will appear over the top of the smoke.
            smokePlumeParticles.DrawOrder = 100;
            explosionSmokeParticles.DrawOrder = 200;
            projectileTrailParticles.DrawOrder = 300;
            explosionParticles.DrawOrder = 400;
            fireParticles.DrawOrder = 500;

            // Register the particle system components.
            Components.Add(explosionParticles);
            Components.Add(explosionSmokeParticles);
            Components.Add(projectileTrailParticles);
            Components.Add(smokePlumeParticles);
            Components.Add(fireParticles);

            GAME_WINDOW =
            (System.Windows.Forms.Form)
            System.Windows.Forms.Form.FromHandle(
            this.Window.Handle);

            InitializePhysics();

            debugDrawer = new DebugDrawer(this);
            debugDrawer.Enabled = true;
            Components.Add(debugDrawer);
        }
Пример #33
0
        /// <summary>
        /// Gets the 3D data from map centered in pos.
        /// </summary>
        /// <param name="pos">The center of square</param>
        /// <param name="size">The size of the square</param>
        /// <returns></returns>
        public Frame getPosition(Vector2 pos, uint size = 10)
        {
            Contract.Requires(map.ValidPosition(new Vector3(pos, 2)));

            //ToDo: work the case when some blocks don't exist because they are outside the map. In that case the frontier blocks should be repeated.
            List<VertexPositionNormalTexture> VertexPosList = new List<VertexPositionNormalTexture>();
            List<int> IndexBufferList = new List<int>();

            for (uint i = (uint)pos.X - size; i < pos.X + size; i++)
            {
                for (uint j = (uint)(pos.Y) - size; j < pos.Y + size; j++)
                {
                    for (uint k = 0; k < map.Height; k++)
                    {
                        Block block = map.GetBlock(new Vector3(i, j, k));
                        int idx = 0;
                        foreach (VertexPositionNormalTexture vx in block.Coors)
                        {
                            VertexPosList.Add(vx);
                            idx++;
                        }
                        int c = VertexPosList.Count - idx;
                        foreach (int ib in block.IndexBufferCollection)
                        {
                            IndexBufferList.Add(c + ib);
                        }
                    }
                }
            }

            List<VertexPositionNormalTexture> objectsVertexPosList = new List<VertexPositionNormalTexture>();
            List<int> objectsIndexBufferList = new List<int>();

            foreach (Pedestrian ped in pedList)
            {
                Frame md = ped.Draw();
                int idx = 0;
                foreach (VertexPositionNormalTexture vx in md.ObjectVertexList)
                {
                    objectsVertexPosList.Add(vx);
                    idx++;
                }
                int c = objectsVertexPosList.Count - idx;
                foreach (int ib in md.ObjectIndexList)
                {
                    objectsIndexBufferList.Add(c + ib);
                }

            }

            Frame frame = new Frame(VertexPosList, IndexBufferList, objectsVertexPosList, objectsIndexBufferList, pos);
            if(debugDraw)
            {
                drawer = new DebugDrawer();
                foreach (RigidBody body in _physics.RigidBodiesList)
                {
                    body.DebugDraw(drawer);
                    body.AllowDeactivation = false;
                    body.EnableDebugDraw = true;
                }

                frame.TriangleDebug = drawer.DrawInfo.TriangleDebug;
                frame.LineDebug = drawer.DrawInfo.LineDebug;
            }

            return frame;
        }