public void Apply(WallColor wallColor, byte expectedColor)
        {
            var tile = new Tile();

            tile = wallColor.Apply(tile);

            Assert.That(tile.WallColor, Is.EqualTo(expectedColor));
        }
        public void Matches(WallColor wallColor, byte actualColor, bool expected)
        {
            var tile = new Tile
            {
                WallColor = actualColor
            };

            Assert.That(WallColor.Black.Matches(tile), Is.EqualTo(expected));
        }
    public bool WallColorExistsInList(List <WallColor> list, WallColor wc)
    {
        bool ret = false;

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].gameObject == wc.gameObject)
            {
                ret = true;
            }
        }

        return(ret);
    }
    public void ShowRange()
    {
        int layerMask = 1 << 11;

        Collider[] colliders = Physics.OverlapSphere(this.transform.position, startToEndRange, layerMask);

        foreach (Collider hit in colliders)
        {
            WallColor wc = new WallColor(hit.transform.gameObject,
                                         hit.transform.GetComponent <Renderer>().material.color);

            if (!WallColorExistsInList(highlightedWalls, wc))
            {
                highlightedWalls.Add(wc);
                hit.transform.GetComponent <Renderer>().material.color = highlightColor;
            }
        }
    }
Beispiel #5
0
    void identifyWalls()
    {
        HashSet <Vector3Int> tiles_visited = new HashSet <Vector3Int>();


        for (int i = 0; i < (int)WallColor.Count; i++)
        {
            wall_a_filled[i] = false;
        }

        foreach (Vector3Int pos in bounds.allPositionsWithin)
        {
            Vector3Int dir = zero;

            TileBase tile = tilemap.GetTile(pos);
            if (tile == null)
            {
                continue;
            }

            string name = tile.name;

            if (name.Contains("wall") && !tiles_visited.Contains(pos))
            {
                string[] arrow_name      = tilemap.GetTile(pos).name.Split('_');
                string   arrow_direction = arrow_name[arrow_name.Length - 1];

                if (arrow_direction == "up")
                {
                    dir = dy;
                }
                if (arrow_direction == "down")
                {
                    dir = -dy;
                }
                if (arrow_direction == "left")
                {
                    dir = -dx;
                }
                if (arrow_direction == "right")
                {
                    dir = dx;
                }

                WallColor color = getWallColor(pos);
                bool      is_a  = !wall_a_filled[(int)color];

                Wall wall = identifyWall(pos, dir, is_a, ref tiles_visited);

                if (is_a)
                {
                    wall_a[(int)color]        = wall;
                    wall_a_filled[(int)color] = true;
                }
                else
                {
                    wall_b[(int)color]        = wall;
                    wall_b_filled[(int)color] = true;
                }
            }
        }
    }