Esempio n. 1
0
    /// <summary> ランダムウォークの目的地設定 </summary>
    private Vector2Int RandomDestination()
    {
        List <Vector2Int> lotteryCoords = new List <Vector2Int>();

        _influenceMap.MatrixOperate((x, y) =>
        {
            if (Mathf.Abs(x - _initialPosition.x) <= moveRangeRadius.x && Mathf.Abs(y - _initialPosition.y) <= moveRangeRadius.y)
            {
                if (_passableMap[x, y])
                {
                    lotteryCoords.Add(new Vector2Int(x, y));
                }
            }
        });
        return(lotteryCoords[Random.Range(0, lotteryCoords.Count)]);
    }
Esempio n. 2
0
    //最終影響マップ生成
    private void Mapping()
    {
        MapMatrix enemyMap = new MapMatrix {
            map = EnemyMapping(), coefficient = enemyCoefficient
        };
        MapMatrix itemMap = new MapMatrix {
            map = ItemMapping(), coefficient = itemCoefficient
        };

        switch (fusionSwitch)
        {
        case 0:
            map = influenceMap.WeightedAverage(new List <MapMatrix> {
                enemyMap, itemMap
            });
            break;

        case 1:
            map = influenceMap.Ceiling(new List <MapMatrix> {
                enemyMap, itemMap
            });
            break;

        case 2:
            map = influenceMap.Floor(new List <MapMatrix> {
                enemyMap, itemMap
            });
            break;

        default:
            map = new float[mapRange.x, mapRange.y];
            break;
        }
        influenceMap.MatrixOperate((xcount, ycount) =>
        {
            if (terrains[xcount, ycount].GetComponent <Renderer>().material.color != Color.gray)
            {
                terrains[xcount, ycount].GetComponent <Renderer>().material.color = new Color(map[xcount, ycount], 0, 0);
                terrains[xcount, ycount].transform.GetChild(0).GetChild(0).GetComponent <Text>().text = map[xcount, ycount].ToString("f3");
            }
        });
    }