public IEnumerator GenerateRandomPoints(
        int width,
        int height,
        int pointNum,
        RandomPointParameter para)
    {
        _width  = width;
        _height = height;
        _para   = para;

        yield return(_GetRandomLoosePoints(pointNum));
    }
    public IEnumerator GenerateRandomLocalAreaMap(
        int width,
        int height,
        RandomPointParameter para,
        IReturn <float[]> ret)
    {
        _width  = width;
        _height = height;
        _para   = para;

        _localAreaMap = new float[_width * _height];

        yield return(_GetRandomLoosePoints(_para.NUM));

        yield return(_GenerateRandomLocalAreaMap());

        ret.Accept(_localAreaMap);
    }
Example #3
0
    public IEnumerator GenerateManaMap(
        int width,
        int height,
        ManaParameter para,
        IReturn <float[]> ret)
    {
        _width       = width;
        _height      = height;
        _para        = para;
        _randomParam = para.RANDOM_POINT_GEN_PARA;

        _manaMap      = new float[_width * _height];
        _localAreaMap = new float[_width * _height];

        var totalPoints =
            _para.POSITIVE_HIGH_POINTS_NUM +
            _para.POSITIVE_MID_POINTS_NUM +
            _para.POSITIVE_LOW_POINTS_NUM +
            _para.NEGATIVE_HIGH_POINTS_NUM +
            _para.NEGATIVE_MID_POINTS_NUM +
            _para.NEGATIVE_LOW_POINTS_NUM;

        yield return(_randPointGen.GenerateRandomPoints(
                         width,
                         height,
                         totalPoints,
                         _randomParam));

        var points = _randPointGen.Points.OrderBy(i => Random.value).ToList();

        _highPosPoints = points.Take(_para.POSITIVE_HIGH_POINTS_NUM).ToList();
        points         = points.Skip(_para.POSITIVE_HIGH_POINTS_NUM).ToList();
        _midPosPoints  = points.Take(_para.POSITIVE_HIGH_POINTS_NUM).ToList();
        points         = points.Skip(_para.POSITIVE_HIGH_POINTS_NUM).ToList();
        _lowPosPoints  = points.Take(_para.POSITIVE_LOW_POINTS_NUM).ToList();
        points         = points.Skip(_para.POSITIVE_LOW_POINTS_NUM).ToList();
        _highNegPoints = points.Take(_para.NEGATIVE_HIGH_POINTS_NUM).ToList();
        points         = points.Skip(_para.NEGATIVE_HIGH_POINTS_NUM).ToList();
        _midNegPoints  = points.Take(_para.NEGATIVE_MID_POINTS_NUM).ToList();
        points         = points.Skip(_para.NEGATIVE_MID_POINTS_NUM).ToList();
        _lowNegPoints  = points.Take(_para.NEGATIVE_LOW_POINTS_NUM).ToList();

        yield return(_GenerateRandomLocalAreaMap(_highPosPoints, _para.POSITIVE_HIGH_RADIUS, _para.POSITIVE_HIGH_FACTOR));

        yield return(_GenerateRandomLocalAreaMap(_midPosPoints, _para.POSITIVE_MID_RADIUS, _para.POSITIVE_MID_FACTOR));

        yield return(_GenerateRandomLocalAreaMap(_lowPosPoints, _para.POSITIVE_LOW_RADIUS, _para.POSITIVE_LOW_FACTOR));

        yield return(_GenerateRandomLocalAreaMap(_highNegPoints, _para.NEGATIVE_HIGH_RADIUS, _para.NEGATIVE_HIGH_FACTOR));

        yield return(_GenerateRandomLocalAreaMap(_midNegPoints, _para.NEGATIVE_MID_RADIUS, _para.NEGATIVE_MID_FACTOR));

        yield return(_GenerateRandomLocalAreaMap(_lowNegPoints, _para.NEGATIVE_LOW_RADIUS, _para.NEGATIVE_LOW_FACTOR));

        for (int x = 0; x < _width; x++)
        {
            for (int y = 0; y < _height; y++)
            {
                var idx = y * _width + x;
                _manaMap[idx] = _localAreaMap[idx] + 0.5f;
            }
        }

        ret.Accept(_manaMap);
    }