|
每种地图大小的奇观数量
- local worldsizes = {
- [GameInfo.Worlds.WORLDSIZE_DUEL.ID] = 2,
- [GameInfo.Worlds.WORLDSIZE_TINY.ID] = 3,
- [GameInfo.Worlds.WORLDSIZE_SMALL.ID] = 4,
- [GameInfo.Worlds.WORLDSIZE_STANDARD.ID] = 5,
- [GameInfo.Worlds.WORLDSIZE_LARGE.ID] = 6,
- [GameInfo.Worlds.WORLDSIZE_HUGE.ID] = 7
- }
复制代码
- if thisFeature.Type == "FEATURE_GEYSER" then
- wonder_list[1] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_CRATER" then
- wonder_list[2] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_GIBRALTAR" then
- wonder_list[3] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_FUJI" then
- wonder_list[4] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_MESA" then
- wonder_list[5] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_REEF" then
- wonder_list[6] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_VOLCANO" then
- wonder_list[7] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_FOUNTAIN_YOUTH" then
- wonder_list[8] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_POTOSI" then
- wonder_list[9] = thisFeature.ID;
- elseif thisFeature.Type == "FEATURE_EL_DORADO" then
- wonder_list[10] = thisFeature.ID;
- end
复制代码
按照这个顺序
从上到下遍历整个计算各种奇观的符合放置条件的Plot数
然后关键来了
- local iNumPlaced = 0;
- for loop, NW in ipairs(selected_NWs) do
- local bSuccess = self:AttemptToPlaceNaturalWonder(NW)
- if bSuccess then
- iNumPlaced = iNumPlaced + 1;
- end
- end
- if iNumPlaced < iNumNWtoPlace then
- for loop, NW in ipairs(fallback_NWs) do
- if iNumPlaced >= iNumNWtoPlace then
- break
- end
- local bSuccess = self:AttemptToPlaceNaturalWonder(NW)
- if bSuccess then
- iNumPlaced = iNumPlaced + 1;
- end
- end
- end
复制代码
简单的解释一下
就是仍然按之前的列表顺序
检查所有可以放置这个奇观的Plot
检查函数AttemptToPlaceNaturalWonder只有2个条件
1 没有被其他先放置的物体占据(比如玩家起点)
2 距离其他奇观和出生点的距离长度满足条件
只要这2个条件满足 奇观就放置
每放置一个奇观 检查一次数量是否足够 不够则下一个
换句话说 整个过程没有用到随机数
而最后的三个奇观的出现条件其实是
之前的奇观中能满足之前2个条件被放下的数量 不够地图大小所需数量
并且自身还有符合条件的Plot |
|