示例#1
0
        private static void GenerateSceneRandomInfo(int id, int questCellCount, List <ScenePosData> cachedMapData, Dictionary <int, DbSceneSpecialPosData> cachedSpecialData)
        {
            List <int> randQuestList = new List <int>();

            Scene.Instance.Rule.Generate(randQuestList, questCellCount);

            var posList = new List <DbSceneSpecialPosData>();
            int index   = 0;

            foreach (var scenePosData in cachedMapData)
            {
                DbSceneSpecialPosData specialData;
                cachedSpecialData.TryGetValue(scenePosData.Id, out specialData);

                if (specialData == null)//表示不是预设的格子
                {
                    specialData    = new DbSceneSpecialPosData();
                    specialData.Id = scenePosData.Id;
                    if (randQuestList.Count > index)
                    {
                        specialData.Type = "Quest";
                        specialData.Info = randQuestList[index++];    //随机一个出来
                    }
                    else
                    {
                        specialData.Type = "Tile";
                    }
                }
                cachedSpecialData[specialData.Id] = specialData;

                posList.Add(specialData);
            }

            UserProfile.Profile.InfoWorld.PosInfos = posList;
        }
示例#2
0
        private static void ReadBody(StreamReader sr, int mapWidth, int mapHeight, Random r,
                                     List <SceneManager.ScenePosData> cachedMapData, List <DbSceneSpecialPosData> cachedSpecialData,
                                     int wid, int height, int xoff, int yoff)
        {
            int cellWidth  = GameConstants.SceneTileStandardWidth * mapWidth / 1422;
            int cellHeight = GameConstants.SceneTileStandardHeight * mapHeight / 855;
            Dictionary <int, List <SceneManager.ScenePosData> > randomGroup = new Dictionary <int, List <SceneManager.ScenePosData> >();

            for (int i = 0; i < height; i++)
            {
                string[] data = sr.ReadLine().Split('\t');
                for (int j = 0; j < wid; j++)
                {
                    int val = Int32.Parse(data[j]);
                    if (val == 0)
                    {
                        continue;
                    }

                    int lineOff = (int)(cellWidth * (height - i - 1) * GameConstants.SceneTileGradient);
                    SceneManager.ScenePosData so = new SceneManager.ScenePosData
                    {
                        Id     = val,
                        X      = xoff + j * cellWidth + lineOff,
                        Y      = yoff + i * cellHeight,
                        Width  = cellWidth,
                        Height = cellHeight
                    };
                    if (val < 1000) //随机组
                    {
                        so.Id = (height - i) * 1000 + j + 1;
                        if (!randomGroup.ContainsKey(val))
                        {
                            randomGroup[val] = new List <SceneManager.ScenePosData>();
                        }
                        randomGroup[val].Add(so);
                    }
                    else
                    {
                        cachedMapData.Add(so);
                    }
                }
            }

            RandomSequence rs = new RandomSequence(randomGroup.Count, r);

            for (int i = 0; i < Math.Ceiling(randomGroup.Keys.Count * 0.5f); i++)
            {
                foreach (var randPos in randomGroup[rs.NextNumber() + 1])
                {
                    cachedMapData.Add(randPos);
                }
            }

            string line;

            while ((line = sr.ReadLine()) != null)
            {
                string[] data = line.Split('\t');
                if (data.Length < 2)
                {
                    continue;
                }

                var posData = new DbSceneSpecialPosData();
                posData.Id         = Int32.Parse(data[0]);
                posData.Type       = data[1];
                posData.MapSetting = true;
                if (data.Length > 2)
                {
                    posData.Info = Int32.Parse(data[2]);
                }
                cachedSpecialData.Add(posData);
            }
        }