Пример #1
0
    public void addBlock(Vector3 position, Block blockPrefab)
    {
        var block = Instantiate(blockPrefab);

        block.gameObject.SetActive(true);
        block.transform.parent   = transform;
        block.transform.position = transform.position + position;

        activeSites.Remove(position);
        blocks[position] = block;

        foreach (Direction dir in DirectionHelper.GetDirections())
        {
            var     aspect     = block.getAspect(dir);
            Vector3 targetSite = DirectionHelper.dirToVector(dir) + position;
            if (blocks.ContainsKey(targetSite))
            {
                continue;
            }

            switch (aspect)
            {
            case Aspect.ACCESS:
            case Aspect.OPEN:
                activeSites.Add(targetSite);
                break;
            }
        }

        minExtent = new Vector3(Mathf.Min(position.x - 0.5f, minExtent.x), Mathf.Min(position.y - 0.5f, minExtent.y), Mathf.Min(position.z - 0.5f, minExtent.z));
        maxExtent = new Vector3(Mathf.Max(position.x + 0.5f, maxExtent.x), Mathf.Max(position.y + 0.5f, maxExtent.y), Mathf.Max(position.z + 0.5f, maxExtent.z));
    }
Пример #2
0
    public bool testBlock(Vector3 position, Block block)
    {
        if (!activeSites.Contains(position))
        {
            return(false);
        }

        foreach (Direction dir in DirectionHelper.GetDirections())
        {
            Block other = null;
            blocks.TryGetValue(DirectionHelper.dirToVector(dir) + position, out other);
            if (other != null)
            {
                bool aspectsAreCompatible = getMatchingAspects(block, other, dir);
                if (!aspectsAreCompatible)
                {
                    return(false);
                }
            }
        }

        return(true);
    }