public void SetupWall(FitInTheHole_Template template, float position)
    {
        parent.transform.position = new Vector3(0f, 0.5f, position);
        foreach (var cube in cubes)
        {
            cube.gameObject.SetActive(true);
        }

        var figure = template.GetFigure();

        for (int f = 0; f < figure.Length; f++)
        {
            for (int c = 0; c < cubes.Count; c++)
            {
                if (!figure[f] || !cubes[c]) //тут потенциально может быть баг
                {
                    continue;
                }

                if (Mathf.Abs(figure[f].position.x - cubes[c].position.x) > 0.1f)
                {
                    continue;
                }

                if (Mathf.Abs(figure[f].position.y - cubes[c].position.y) > 0.1f)
                {
                    continue;
                }

                cubes[c].gameObject.SetActive(false);
            }
        }
    }
Example #2
0
    public void SetupWall(FitInTheHole_Template template, float position)
    {
        m_Parent.transform.position = new Vector3(0f, 0.5f, 0f);

        foreach (var cube in m_Cubes)
        {
            cube.gameObject.SetActive(true);
        }

        var figure = template.GetFigure();

        for (int f = 0; f < figure.Length; f++)
        {
            for (int c = 0; c < m_Cubes.Count; c++)
            {
                if (figure[f] == null || m_Cubes[c] == null)
                {
                    //тут потенциально может быть баг
                    continue;
                }

                if (!Mathf.Approximately(figure[f].position.x, m_Cubes[c].position.x))
                {
                    continue;
                }
                if (!Mathf.Approximately(figure[f].position.y, m_Cubes[c].position.y))
                {
                    continue;
                }

                m_Cubes[c].gameObject.SetActive(false);
            }
        }
    }
    public void SetUpWall(FitInTheHole_Template template, float position)
    {
        parent.transform.position = new Vector3(0f, 0f, position);

        foreach (var cube in cubes)
        {
            cube.gameObject.SetActive(true);
        }

        if (template == null)
        {
            return;
        }

        Transform[] figure = template.GetFigure();

        for (int f = 0; f < figure.Length; f++)
        {
            for (int c = 0; c < cubes.Count; c++)
            {
                if (!figure[f] || !cubes[c])
                {
                    continue;
                }

                if (Mathf.Abs(figure[f].position.x - cubes[c].position.x) > 0.1f)
                {
                    continue;
                }

                if (Mathf.Abs(figure[f].position.y - cubes[c].position.y) > 0.1f)
                {
                    continue;
                }

                cubes[c].gameObject.SetActive(false);
            }
        }
    }