Exemplo n.º 1
0
    public List <NodeDemo> GetNeighbours(NodeDemo node)
    {
        List <NodeDemo> neighbours = new List <NodeDemo>();

        {
            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    if (x == 0 && y == 0)
                    {
                        continue;
                    }
                    int checkX = node.gridX + x;
                    int checkY = node.gridY + y;

                    if (checkX >= 0 && checkX < gridSizeX && checkY >= 0 && checkY < gridSizeY)
                    {
                        neighbours.Add(grid[checkX, checkY]);
                    }
                }
            }
        }
        return(neighbours);
    }
Exemplo n.º 2
0
    void CreateGrid()
    {
        grid = new NodeDemo[gridSizeX, gridSizeY];
        Vector3 worldBottomLeft = transform.position - Vector3.right * gridWorldSize.x / 2 - Vector3.forward * gridWorldSize.y / 2;

        for (int x = 0; x < gridSizeX; x++)
        {
            for (int y = 0; y < gridSizeY; y++)
            {
                Vector3 worldPoint = worldBottomLeft + Vector3.right * (x * nodeDiameter + nodeRadius) + Vector3.forward * (y * nodeDiameter + nodeRadius);
                bool    walkable   = !(Physics.CheckSphere(worldPoint, nodeRadius, unwalkableMask));
                grid[x, y] = new NodeDemo(walkable, worldPoint, x, y);
            }
        }
    }
Exemplo n.º 3
0
 void Start()
 {
     NodeDemo.On("hello", () => Debug.Log("SAY HELLO NODE DEMO FROM NODE 3"));
     NodeDemo.Emit("hello");
 }
Exemplo n.º 4
0
 void Start()
 {
     NodeDemo.On("getData", () => Debug.Log(NodeDemo.instance.secret));
     NodeDemo.Emit("getData");
 }