예제 #1
0
    public void Collapse()
    {
        float total = 0;

        for (int i = 0; i < superPosition.Count; i++)
        {
            total += superPosition[i].testP;
        }
        superPosition.Shuffle();
        float random = Random.value * total;

        for (int i = 0; i < superPosition.Count; i++)
        {
            float v = superPosition[i].testP;
            if (random < v)
            {
                WFCTileType toKeep = superPosition[i];
                superPosition.Clear();
                superPosition.Add(toKeep);
                Refresh();
                return;
            }
            random -= v;
        }

        print("Somthing went horribly wrong");
    }
예제 #2
0
    public bool Propagete(WFCTile neighbourTile)
    {
        bool changed = false;

        for (int i = superPosition.Count - 1; i >= 0; i--)
        {
            if (!CanCollapse())
            {
                break;
            }
            WFCTileType tileType   = superPosition[i];
            bool        compatible = false;
            for (int j = 0; j < neighbourTile.superPosition.Count; j++)
            {
                WFCTileType neighbourTileType = neighbourTile.superPosition[j];
                if (tileType.IsCompatible(neighbourTileType.tileType))
                {
                    compatible = true;
                    break;
                }
            }
            if (!compatible)
            {
                superPosition.RemoveAt(i);
                changed = true;
            }
        }
        Refresh();
        return(changed);
    }