void CreateCollider(GameObject mapContainer, List<ColliderDataInfo> aColliderDataInfo, MapInfo aMapInfo, List<string> aActivatedColliderLayers) { GameObject container = new GameObject (); container.name = "ColliderContainer"; container.transform.SetParent (mapContainer.transform, false); for (int i = 0; i < aColliderDataInfo.Count; i++) { ColliderDataInfo colliderDataInfo = aColliderDataInfo[i]; GameObject colliderGo = new GameObject (); colliderGo.name = CAMERA_LIMIT_NAME+i; colliderGo.transform.SetParent (container.transform, false); colliderGo.AddComponent<BoxCollider2D>(); colliderGo.layer = colliderDataInfo.m_Layer; colliderGo.transform.localPosition = colliderDataInfo.m_Position; colliderGo.transform.localScale = colliderDataInfo.m_Scale; colliderGo.transform.localRotation = colliderDataInfo.m_Rotation; MapColliderLayer mapColliderLayer = colliderGo.AddComponent<MapColliderLayer>(); mapColliderLayer.m_ColliderLayer = colliderDataInfo.m_ColliderMapLayer; aMapInfo.m_ListMapColliderLayer.Add(mapColliderLayer); if(!string.IsNullOrEmpty(colliderDataInfo.m_ColliderMapLayer) && !aActivatedColliderLayers.Contains(colliderDataInfo.m_ColliderMapLayer)){ colliderGo.SetActive(false); } } }
public void PlaceObjects(MapInfo.MapObject[] mapObjects, int gridWidth, int gridHeight, bool loadPlayer) { int positionCorrection = this.TileRenderSize / this.TileTextureSize; for (int i = 0; i < mapObjects.Length; ++i) { MapInfo.MapObject mapObject = mapObjects[i]; GameObject spawner = null; if (mapObject.name == PLAYER) { if (loadPlayer) spawner = Instantiate<GameObject>(this.PlayerSpawnerPrefab); } else if (mapObject.name.Contains(ENEMY)) { spawner = Instantiate<GameObject>(this.EnemySpawnerPrefab); } else if (mapObject.name.Contains(HEART)) { spawner = Instantiate<GameObject>(this.HeartSpawnerPrefab); } if (spawner != null) { spawner.transform.parent = this.transform; int x = (mapObject.x + mapObject.width / 2) * positionCorrection; int y = !this.FlipVertical ? (mapObject.y + mapObject.height) * positionCorrection : gridHeight * this.TileRenderSize - ((mapObject.y) * positionCorrection) + (1 * positionCorrection); spawner.transform.localPosition = new Vector3(x, y); } } }
public void CopyFromRemote(WorldMap remoteMap, MapInfo mapInfo) { if (remoteMap == null) { Debug.Log("Didn't get world map!"); return; } width = remoteMap.world_width; height = remoteMap.world_height; worldNameEnglish = remoteMap.name_english; offset = new Vector3( (-mapInfo.block_pos_x + (remoteMap.map_x * 16)) * 48 * GameMap.tileWidth, -mapInfo.block_pos_z * GameMap.tileHeight, (mapInfo.block_pos_y - (remoteMap.map_y * 16)) * 48 * GameMap.tileWidth); worldPosition = new Vector3(mapInfo.block_pos_x, mapInfo.block_pos_y, mapInfo.block_pos_z); meshRenderer.material.SetFloat("_Scale", scale); meshRenderer.material.SetFloat("_SeaLevel", (99 * GameMap.tileHeight) + offset.y); InitArrays(); for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) { int index = y * width + x; elevation[x, y] = remoteMap.elevation[index]; rainfall[x, y] = remoteMap.rainfall[index]; vegetation[x, y] = remoteMap.vegetation[index]; temperature[x, y] = remoteMap.temperature[index]; evilness[x, y] = remoteMap.evilness[index]; drainage[x, y] = remoteMap.drainage[index]; volcanism[x, y] = remoteMap.volcanism[index]; savagery[x, y] = remoteMap.savagery[index]; salinity[x, y] = remoteMap.salinity[index]; } GenerateMesh(); }
public static int[,] CreateVerticalPath(int[] startPoint, int[] endPoint, int openLength, int[,] map, MapInfo mapInfo) { PseudoRandom pRnd = mapInfo.GetSeededPsuedoRnd (); int initalLength = openLength; bool justChanged = true; for (int y = startPoint[1]; y <= endPoint[1]; y++) { if (y == startPoint [1] || y == endPoint[1]) { initalLength = openLength; } for (int x = 0; x < initalLength; x++) { map [y, startPoint [0] + x] = 0; } if (!justChanged) { justChanged = true; double num = pRnd.Next (); if (num < (mapInfo.windiness / 2) && initalLength <= mapInfo.maxEntrySize) { initalLength += 1; } else if (num >= (mapInfo.windiness / 2) && num < mapInfo.windiness && initalLength > 2) { initalLength -= 1; } } else { justChanged = false; } } return map; }
public static int[,] CreateSurrounding(int[,] map, MapInfo mapInfo) { int[,] newMap = CreateFullSurrounding(map); // This is have access to the man made macro map that generates the tiles // These will be stored in a 2D array and they will simply get them // from there instead of generating them here. //MapInfo topInfo = new MapInfo (mapInfo, 0,1); //MapInfo rightInfo = new MapInfo(seedX, seedY, seedZ, 3, 1, 2, 1); //MapInfo leftInfo = new MapInfo (seedX-1, seedY, seedZ, 3, 1, 2, 1); //MapInfo downInfo = new MapInfo (seedX, seedY-1, seedZ, 3, 1, 2, 1); if (mapInfo.openUp) { newMap = CreateTopSide (newMap, mapInfo); } if (mapInfo.openRight) { newMap = CreateRightSide(newMap, mapInfo); } if (mapInfo.openDown) { newMap = CreateDownSide (newMap, mapInfo); } if (mapInfo.openLeft) { newMap = CreateLeftSide (newMap, mapInfo); } return newMap; }
public static WDT ReadWDT(MapInfo entry) { var dir = entry.InternalName; var wdtDir = Path.Combine(baseDir, dir); var wdtName = dir; var wdtFilePath = Path.Combine(wdtDir, wdtName + Extension); var finder = WCellTerrainSettings.GetDefaultMPQFinder(); if (!finder.FileExists(wdtFilePath)) return null; var wdt = new WDT(entry.Id) { Entry = entry, Name = wdtName, Filename = wdtDir }; using (var fileReader = new BinaryReader(finder.OpenFile(wdtFilePath))) { ReadMVER(fileReader, wdt); ReadMPHD(fileReader, wdt); ReadMAIN(fileReader, wdt); if (wdt.Header.IsWMOMap) { // No terrain, the map is a "global" wmo // MWMO and MODF chunks follow ReadMWMO(fileReader, wdt); ReadMODF(fileReader, wdt); } } return wdt; }
public static void WriteMapWMOs(MapInfo entry) { var path = Path.Combine(TerrainDisplayConfig.M2Dir, entry.Id.ToString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (var wmoPair in LoadedWMORoots) { var filePath = Path.Combine(path, wmoPair.Key); var dirPath = Path.GetDirectoryName(filePath); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } var fullFilePath = Path.ChangeExtension(filePath, TerrainConstants.WMOFileExtension); var file = File.Create(fullFilePath); var writer = new BinaryWriter(file); WriteWMO(writer, wmoPair.Value); file.Close(); } }
static int[,] CreateRightSide(int[,] newMap, MapInfo mapInfo) { PseudoRandom rightPRnd = mapInfo.GetSeededPsuedoRnd (); int[] rightDirection = new int[2]{-1,0}; int numOfEntries = 0; for (int i = 0; i < mapInfo.maxNumOfEntries; i++) { int startPoint = rightPRnd.Next(1, newMap.GetLength(0)-1-mapInfo.maxEntrySize); int entrySize = rightPRnd.Next(2, mapInfo.maxEntrySize+1); int[] startCoord = new int[2]{newMap.GetLength(1)-1, startPoint}; int[] connect = PathGenerator.FindEndPoint (startCoord, entrySize, rightDirection, newMap); //Debug.Log ("Connection: " + i + " (" + connect[0] + "," + connect[1] + ")"); newMap = PathGenerator.CreateHorizontalPath(connect, startCoord, entrySize, newMap); /*for (int y = startPoint; y <= (startPoint + entrySize); y++) { for (int x = newMap.GetLength (1) - 1; x >= connect [0]; x--) { newMap [y, x] = 0; } }*/ } return newMap; }
public void SetActiveForButtons(MapInfo mapInfo) { if (mapInfo.openUp) { this.transform.FindChild ("UpButton").gameObject.SetActive (true); } else { this.transform.FindChild ("UpButton").gameObject.SetActive (false); } if (mapInfo.openRight) { this.transform.FindChild ("RightButton").gameObject.SetActive (true); } else { this.transform.FindChild ("RightButton").gameObject.SetActive (false); } if (mapInfo.openDown) { this.transform.FindChild ("DownButton").gameObject.SetActive (true); } else { this.transform.FindChild ("DownButton").gameObject.SetActive (false); } if (mapInfo.openLeft) { this.transform.FindChild ("LeftButton").gameObject.SetActive (true); } else { this.transform.FindChild ("LeftButton").gameObject.SetActive (false); } }
public static WDT Process(MapInfo entry) { var dir = entry.InternalName; var wdtDir = Path.Combine(baseDir, dir); var wdtName = dir; var wdtFilePath = Path.Combine(wdtDir, wdtName + Extension); if (!MpqManager.FileExists(wdtFilePath)) return null; var wdt = new WDT { Manager = MpqManager, Entry = entry, Name = wdtName, Path = wdtDir }; using (var fileReader = new BinaryReader(MpqManager.OpenFile(wdtFilePath))) { ReadMVER(fileReader, wdt); ReadMPHD(fileReader, wdt); ReadMAIN(fileReader, wdt); if (wdt.Header.IsWMOMap) { // No terrain, the map is a "global" wmo // MWMO and MODF chunks follow wdt.IsWMOOnly = true; ReadMWMO(fileReader, wdt); ReadMODF(fileReader, wdt); } } return wdt; }
void Awake() { cheat = 0; uiCanvas = GameObject.FindObjectOfType<Canvas> (); CreateMapInfo (100, 100, 100); currentMapInfo = mapInfoArray [0, 0]; CreateSceneFromInfo (currentMapInfo); }
public static int[,] CreateCAMap(int mapSize, MapInfo mapInfo) { PseudoRandom rnd = mapInfo.GetSeededPsuedoRnd (); CellularAutomata ca = new CellularAutomata(); int[,] start = ca.InitialiseMap (0.4f, mapSize, rnd); int[,] map = ca.CreateCellularAutomataFromMap (start, rnd); map = MapEdges.CreateSurrounding (map, mapInfo); return map; }
public static BitmapSource GetMapImage(MapInfo map) { var swf = map.ToSwf(); return swf?.Tags .SkipWhile(x => x.TagType != TagType.ShowFrame) //1フレーム飛ばす .OfType<DefineBitsTag>() .FirstOrDefault(x => x.TagType == TagType.DefineBitsJPEG3) .ToBitmapFrame(); }
internal BattleEvent(MapInfo rpMap, RawMapExploration rpData, string rpNodeWikiID) : base(rpData) { Battle = new BattleInfo(rpData); int rNodeID; if (rpNodeWikiID.IsNullOrEmpty()) rNodeID = rpData.Node << 16; else rNodeID = rpNodeWikiID[0] - 'A'; EnemyEncounters = EnemyEncounterService.Instance.GetEncounters(rpMap.ID, rNodeID, rpMap.Difficulty); }
public int QueryFinalHP(MapInfo map) { try { int[] r; if (!finalhptable.TryGetValue(map.Id, out r)) return 1; if (r.Length == 1) return r[0]; return (r[(int)map.Difficulty]); } catch { return 1; } }
public Layout(Grid grid, MapInfo mapInfo) { width = grid.width; height = grid.height; layout = new int[height,width]; InstantiateLayout (); if (mapInfo.type == 2) { layout = Generate.CreateABMap (width - 2, mapInfo); }else if(mapInfo.type == 1){ layout = Generate.CreateCAMap (width - 2, mapInfo); } }
public MapForm1(MapInfo.Mapping.Map map) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // mapControl1.Map = map; }
public MapUtil() { for (int i = 0; i < MaxNumMaps; i++) { Maps[i] = new MapInfo(); Maps[i].bmp = null; Maps[i].fname = ""; } //hourglass = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("GpsSample.Graphics.hourglass.png")); hourglass = Form1.LoadBitmap("hourglass.png"); clearNav(false); }
public static MapInfo GetMapInfoCached(string mapName) { var cached = HttpContext.Current.Application["mi_" + mapName]; if (cached != null) return (MapInfo)cached; MapInfo mi; try { mi = MapInfo.FromFile(HttpContext.Current.Server.MapPath(string.Format("mapinfo/{0}.xml", mapName))); } catch { mi = new MapInfo(); } HttpContext.Current.Application["mi_" + mapName] = mi; return mi; }
IEnumerator LoadNewMap(string aMapToLoad, string aSpawnPoint) { m_IsLoading = true; m_CurrentMapInfo.OnTriggerTeleport -= OnTriggerTeleport; m_MapImporter.UnloadCurrentMap (m_CurrentMapInfo); m_CurrentMapInfo = null; SetupMap (aMapToLoad); PlaceCharacter (aSpawnPoint); yield return 0; m_IsLoading = false; }
private void buttonCombine_Click(object sender, EventArgs e) { MapInfo mapInf0 = new MapInfo(this, 0); MapInfo mapInf1 = new MapInfo(this, 1); MapInfo mapInf2 = new MapInfo(this, 2); MapInfo mapInf3 = new MapInfo(this, 3); MapInfo mapInf4 = new MapInfo(this, 4); mapInf0.Create(); mapInf1.Open(); mapInf2.Open(); mapInf3.Open(); mapInf4.Open(); MapInfo.Data[] data1 = new MapInfo.Data[mapInf1.Width >> 3]; MapInfo.Data[] data2 = new MapInfo.Data[mapInf2.Width >> 3]; MapInfo.Data[] data3 = new MapInfo.Data[mapInf3.Width >> 3]; MapInfo.Data[] data4 = new MapInfo.Data[mapInf4.Width >> 3]; for(int f = 0; f < data1.Length; ++f) data1[f].m_Bloak = mapInf1.ReadLine(); for (int f = 0; f < data2.Length; ++f) data2[f].m_Bloak = mapInf2.ReadLine(); for (int f = 0; f < data3.Length; ++f) data3[f].m_Bloak = mapInf3.ReadLine(); for (int f = 0; f < data4.Length; ++f) data4[f].m_Bloak = mapInf4.ReadLine(); for (int f = 0; f < data1.Length; ++f) { mapInf0.Write(data1[f].m_Bloak); mapInf0.Write(data3[f].m_Bloak); } for (int f = 0; f < data1.Length; ++f) { mapInf0.Write(data2[f].m_Bloak); mapInf0.Write(data4[f].m_Bloak); } mapInf0.Close(); mapInf1.Close(); mapInf2.Close(); mapInf3.Close(); mapInf4.Close(); }
public static int[,] CreateAgentBasedMap(int _mapSize, MapInfo mapInfo) { int mapSize = _mapSize; PseudoRandom rnd = mapInfo.GetSeededPsuedoRnd (); int[,] map = InitialiseMap(mapSize); int[] startPoint = ChooseRandomPoint( (int)Math.Round(mapSize/3f), (int)Math.Round(2f*mapSize/3f), rnd); AgentBased agent = new AgentBased(0.05, 0.05, startPoint, rnd.Next(0,4)); while(agent.CanContinue(map, rnd) && (!CheckFilled(map, 0.5f)) ) { map = agent.PlaceRoom(map, rnd); map = agent.MoveInDirection(map, rnd); } return map; }
internal WorldPart(MapItem data, MapInfo mapDataList, SencePart sencePart, int collusionLayer, MapManager.MapLoadingData loadingData) { m_data = loadingData; int count = data.List.Count; m_manager = WorldManager.GetInstance(); m_mapData = sencePart; m_collusionLayer = collusionLayer; //m_filepath = new string[count]; m_layers = new MapDrawer[count +1]; string path = "Maps/" + mapDataList.Name + "/"; m_locate = new Vector2(data.X * ImageSize, data.Y * ImageSize); foreach( var textureInfo in data.List) { DataReader.LoadAsync<Texture2D>( path + textureInfo.Texture, LoadingItemCallback, textureInfo.Layer ); m_data.LoadingLeft++; } }
public static IDictionary<int, Point> GetMapCellPoints(MapInfo map) { var swf = map.ToSwf(); if (swf == null) return new Dictionary<int, Point>(); var places = swf.Tags .OfType<DefineSpriteTag>() .SelectMany(sprite => sprite.ControlTags) .OfType<PlaceObject2Tag>() .Where(place => place.Name != null) .Where(place => place.Name.StartsWith("line")) .ToArray(); var cellNumbers = Master.Current.MapInfos[map.Id] //.Where(c => new[] { 0, 1, 2, 3, 8 }.All(x => x != c.Value.ColorNo)) //敵じゃないセルは除外(これでは気のせいは見分け付かない) .Select(c => c.IdInEachMapInfo) .ToArray(); return cellNumbers .OrderBy(n => n) .ToDictionary(n => n, n => places.FindPoint(n)); }
public static int[,] CreateSurrounding(int[,] map, int seedX, int seedY, int seedZ) { int[,] newMap = CreateFullSurrounding(map); // This is have access to the man made macro map that generates the tiles // These will be stored in a 2D array and they will simply get them // from there instead of generating them here. MapInfo topInfo = new MapInfo (seedX, seedY, seedZ, 3, 1, 2, 1); MapInfo rightInfo = new MapInfo(seedX, seedY, seedZ+1, 3, 1, 2, 1); MapInfo leftInfo = new MapInfo (seedX-1, seedY, seedZ+1, 3, 1, 2, 1); MapInfo downInfo = new MapInfo (seedX, seedY-1, seedZ, 3, 1, 2, 1); newMap = CreateTopSide (newMap, topInfo); newMap = CreateRightSide(newMap, rightInfo); newMap = CreateDownSide (newMap, downInfo); newMap = CreateLeftSide (newMap, leftInfo); return newMap; }
static int[,] CreateTopSide(int[,] newMap, MapInfo mapInfo) { PseudoRandom topPRnd = mapInfo.GetSeededPsuedoRnd (); int[] topDirection = new int[2]{0,-1}; int numOfEntries = 0; for (int i = 0; i < mapInfo.maxNumOfEntries; i++) { int startPoint = topPRnd.Next(1, newMap.GetLength(1)-1-mapInfo.maxEntrySize); int entrySize = topPRnd.Next(2, mapInfo.maxEntrySize+1); int[] startCoord = new int[2]{startPoint, newMap.GetLength(0)-1}; int[] connect = PathGenerator.FindEndPoint(startCoord, entrySize, topDirection, newMap); newMap = PathGenerator.CreateVerticalPath(connect, startCoord, entrySize, newMap, mapInfo); } return newMap; }
public MapInfo(MapInfo mapInfo, int indexX, int indexY) { seedX = mapInfo.seedX+indexX; seedY = mapInfo.seedY+indexY; seedZ = mapInfo.seedZ; coords = new int[2]; coords [0] = indexX; coords [1] = indexY; partyList = new List<Player> (); enemyList = new List<Enemy> (); maxEntrySize = mapInfo.maxEntrySize; minEntrySize = mapInfo.minEntrySize; windiness = mapInfo.windiness; maxNumOfEntries = mapInfo.maxNumOfEntries; type = Random.Range(1,3);; miRangeX = mapInfo.miRangeX; miRangeY = mapInfo.miRangeY; CalculateEdges (); }
void CreateCameraLimit(GameObject mapContainer, List<CameraLimitDataInfo> aCameraLimitDataInfo, MapInfo aMapInfo) { GameObject container = new GameObject (); container.name = "CameraLimitContainer"; container.transform.SetParent (mapContainer.transform, false); for (int i = 0; i < aCameraLimitDataInfo.Count; i++) { CameraLimitDataInfo cameraLimitDataInfo = aCameraLimitDataInfo[i]; GameObject cameraLimit = new GameObject (); cameraLimit.name = CAMERA_LIMIT_NAME+i; cameraLimit.transform.SetParent (container.transform, false); cameraLimit.transform.localPosition = cameraLimitDataInfo.m_Position; if(cameraLimitDataInfo.m_Type == CameraLimitType.TOP_LEFT) { aMapInfo.m_CameraTopLeft = cameraLimit.transform; }else if(cameraLimitDataInfo.m_Type == CameraLimitType.BOTTOM_RIGHT){ aMapInfo.m_CameraBottomRight = cameraLimit.transform; } } }
public void CreateSceneFromInfo(MapInfo mapInfo) { if (SceneObjects.CheckListSize () > 0) { SceneObjects.ClearScene (); } uiCanvas.GetComponent<CanvasController> ().SetActiveForButtons (mapInfo); int seedX = mapInfo.seedX; int seedY = mapInfo.seedY; int seedZ = mapInfo.seedZ; gridWidth = 40; gridHeight = 40; warningList = new List<Vector2> (); grid = new Grid (gridWidth,gridHeight, 0.5f, 0.5f); layout = new Layout (grid, mapInfo); //ForestSetup.CreateForestMeshFromMap (layout, grid, seedX, seedY, seedZ); //CreateMeshFromMap (); if (mapInfo.type == 2) { DungeonSetup.CreateMineMeshFromMap(layout, grid, mapInfo); }else{ ForestSetup.CreateForestMeshFromMap (layout, grid, seedX, seedY, seedZ); } grid.ExpandGrid (); layout.ExpandLayout (); gridWidth = grid.width; gridHeight = grid.height; CreateBlocksOnEdges (); this.GetComponent<PartyController> ().SetCurrentPlayers (GetParty ()); this.GetComponent<EnemyController> ().CreateEnemiesForTile(); }
public MapInfo LoadMap() { Debug.Log("LoadMap Start"); MapInfo mapinfo = new MapInfo(); XmlDocument xmlFile = new XmlDocument(); xmlFile.Load("test.xml"); XmlNode mapSize = xmlFile.SelectSingleNode("MapInfo/MapSize"); string mapSizeString = mapSize.InnerText; string[] sizes = mapSizeString.Split( ' ' ); int mapSizeX = mapinfo.MapSizeX = int.Parse(sizes[0]); int mapSizeY = mapinfo.MapSizeY = int.Parse(sizes[1]); int mapSizeZ = mapinfo.MapSizeZ = int.Parse(sizes[2]); XmlNodeList hexes = xmlFile.SelectNodes("MapInfo/Hex"); foreach(XmlNode hex in hexes) { string mapposStr = hex["MapPos"].InnerText; string[] mapposes = mapposStr.Split( ' ' ); int MapPosX = int.Parse(mapposes[0]); int MapPosY = int.Parse(mapposes[1]); int MapPosZ = int.Parse(mapposes[2]); string passableStr = hex["Passable"].InnerText; bool passable = passableStr == "True"; HexInfo info = new HexInfo(); info.MapPosX = MapPosX; info.MapPosY = MapPosY; info.MapPosZ = MapPosZ; info.Passable = passable; mapinfo.HexInfos.Add(info); } return mapinfo; }
protected virtual void UpdateView() { nameText.text = LanguageUtil.GetTxt(11106) + ": " + BattleModel.Instance.crtConfig.name; resultText.text = LanguageUtil.GetTxt(11807); closeButton.GetComponentInChildren <Text>().text = LanguageUtil.GetTxt(11804); againButton.GetComponentInChildren <Text>().text = LanguageUtil.GetTxt(11803); nextButton.GetComponentInChildren <Text>().text = LanguageUtil.GetTxt(11802); scoreLabel.text = LanguageUtil.GetTxt(11801); EventTriggerListener.Get(closeButton.gameObject).onClick = reportModule.OnCloseClick; EventTriggerListener.Get(againButton.gameObject).onClick = reportModule.OnAgainClick; EventTriggerListener.Get(nextButton.gameObject).onClick = reportModule.OnNextClick; float rollOffTime = 0; scoreText.RollNumber(FightModel.Instance.fightInfo.score, "", rollOffTime); rollOffTime += scoreText.maxRollTime; List <config_sort_item> scoreItems = ResModel.Instance.config_sort.GetItemsByType(3); for (int c = 0; c < scoreItems.Count; c++) { config_sort_item scoreItem = scoreItems[c]; if (scoreItem.refer <= FightModel.Instance.fightInfo.score) { SocialModel.Instance.ReportProgress(scoreItem.gid, 1); } } int star = FightModel.Instance.fightInfo.GetStarCount(); star1Image.gameObject.SetActive(false); star2Image.gameObject.SetActive(false); star3Image.gameObject.SetActive(false); if (star >= 1) { star1BGImage.color = ColorUtil.GetColor(ColorUtil.COLOR_WIGHT, 0.01f); star1Image.gameObject.SetActive(true); GameObject effectPrefab = ResModel.Instance.GetPrefab("effect/" + "effect_fireworks_n"); GameObject itemEffect = GameObject.Instantiate(effectPrefab); itemEffect.transform.SetParent(star1Image.transform, false); itemEffect.transform.SetParent(transform, true); } if (star >= 2) { star2BGImage.color = ColorUtil.GetColor(ColorUtil.COLOR_WIGHT, 0.01f); star2Image.gameObject.SetActive(true); GameObject effectPrefab = ResModel.Instance.GetPrefab("effect/" + "effect_fireworks_n"); GameObject itemEffect = GameObject.Instantiate(effectPrefab); itemEffect.transform.SetParent(star2Image.transform, false); itemEffect.transform.SetParent(transform, true); } if (star >= 3) { star3BGImage.color = ColorUtil.GetColor(ColorUtil.COLOR_WIGHT, 0.01f); star3Image.gameObject.SetActive(true); GameObject effectPrefab = ResModel.Instance.GetPrefab("effect/" + "effect_fireworks_n"); GameObject itemEffect = GameObject.Instantiate(effectPrefab); itemEffect.transform.SetParent(star3Image.transform, false); itemEffect.transform.SetParent(transform, true); } int winCoin = (int)FightModel.Instance.fightInfo.score / (int)GameModel.Instance.GetGameConfig(1009); WealthInfo coinInfo = PlayerModel.Instance.GetWealth((int)WealthTypeEnum.Coin); int winGem = 0; WealthInfo gemInfo = PlayerModel.Instance.GetWealth((int)WealthTypeEnum.Gem); bool isPassed = MapModel.Instance.IsPassed(BattleModel.Instance.crtConfig.id); if (isPassed) { int coinAdd = (int)GameModel.Instance.GetGameConfig(1008); winCoin += coinAdd; coinInfo.count += winCoin; coinText.RollNumber(winCoin, "+", rollOffTime); rollOffTime += coinText.maxRollTime; gemText.RollNumber(winGem, "+", rollOffTime); rollOffTime += gemText.maxRollTime; } else { int coinAdd = (int)GameModel.Instance.GetGameConfig(1005);; winCoin += coinAdd; coinInfo.count += winCoin; coinText.RollNumber(winCoin, "+", rollOffTime); rollOffTime += coinText.maxRollTime; int gemAdd = (int)GameModel.Instance.GetGameConfig(1006);; winGem += gemAdd; gemInfo.count += winGem; gemText.RollNumber(winGem, "+", rollOffTime); rollOffTime += gemText.maxRollTime; } GameObject bottlePrefab = ResModel.Instance.GetPrefab("prefab/reportmodule/" + "ReportBottle"); bottleList.itemPrefab = bottlePrefab; bool findSkillLv = false; for (int i = 0; i < SkillTempletModel.Instance.skillGroups.Count; i++) { SkillGroupInfo skillTempletGroupInfo = SkillTempletModel.Instance.skillGroups[i]; int groupId = skillTempletGroupInfo.GetGroupId(); int groupCount = CollectModel.Instance.profileCollect.GetCount(groupId); if (groupCount > 0) { Transform bottleTrans = bottleList.NewItem().GetComponent <Transform>(); bottleTrans.name = "" + i; Image mask = bottleTrans.FindChild("mask").GetComponent <Image>(); mask.color = ColorUtil.GetColor(ColorUtil.GetCellColorValue(groupId)); Image icon = bottleTrans.FindChild("icon").GetComponent <Image>(); icon.overrideSprite = ResModel.Instance.GetSprite("icon/cell/cell_" + groupId); NumberText numText = bottleTrans.FindChild("Text").GetComponent <NumberText>(); numText.RollNumber(groupCount, "+", rollOffTime); rollOffTime += numText.maxRollTime; WealthInfo bottleInfo = PlayerModel.Instance.GetWealth(groupId); bottleInfo.count += groupCount; EventTriggerListener.Get(bottleTrans.gameObject).onClick = OnOpenSkill; string prefStr = PlayerPrefsUtil.BOTTLE_COLLECT + groupId; PlayerPrefsUtil.SetInt(prefStr, PlayerPrefsUtil.GetInt(prefStr) + groupCount); config_sort_item config_sort_item = ResModel.Instance.config_sort.GetItemByTypeAndSpecial(2, "" + groupId); float bottleProgress = PlayerPrefsUtil.GetInt(prefStr) / (config_sort_item.refer + 0.00f); SocialModel.Instance.ReportProgress(config_sort_item.gid, bottleProgress); } SkillTempletInfo skillTempletInfo = skillTempletGroupInfo.skillTemplets[1]; if (skillTempletInfo.IsUnlock() && skillTempletInfo.config.type == 1 && findSkillLv == false && skillButton != null) { if (skillTempletInfo.lv < SkillTempletModel.MAX_LEVEL) { int leftStar = MapModel.Instance.starInfo.GetSkillCanUseStar(); if (leftStar >= skillTempletInfo.LevelUpCostStar()) { int levelUpNeedBottle = skillTempletInfo.LevelUpCostBottle(); WealthInfo bottleInfo = PlayerModel.Instance.GetWealth(groupId); if (bottleInfo.count >= levelUpNeedBottle) { findSkillLv = true; skillButton.gameObject.SetActive(true); SkillTempletModel.Instance.selectGroupIndex = i; Image skillIcon = skillButton.transform.FindChild("icon").GetComponent <Image>(); skillIcon.overrideSprite = ResModel.Instance.GetSprite("icon/cell/cell_" + groupId); EventTriggerListener.Get(skillButton.gameObject).onClick = OnClickSkill; } } } } } if (findSkillLv == false && skillButton != null) { skillButton.gameObject.SetActive(false); } PlayerModel.Instance.SaveWealths(); MapInfo mapInfo = new MapInfo(); mapInfo.configId = BattleModel.Instance.crtConfig.id; mapInfo.score = FightModel.Instance.fightInfo.score; mapInfo.star = star; MapModel.Instance.PassLevel(mapInfo); nextButton.gameObject.SetActive(FightModel.Instance.fightInfo.isWin); config_sort_item star_item = ResModel.Instance.config_sort.GetItemByTypeAndSpecial(1, "11104"); SocialModel.Instance.ReportScore(star_item.gid, MapModel.Instance.starInfo.crtStar); config_sort_item level_item = ResModel.Instance.config_sort.GetItemByTypeAndSpecial(1, "1"); SocialModel.Instance.ReportScore(level_item.gid, MapModel.Instance.starInfo.openMapFullStar / 3); config_sort_item diamond_item = ResModel.Instance.config_sort.GetItemByTypeAndSpecial(1, "11101"); SocialModel.Instance.ReportScore(diamond_item.gid, gemInfo.count); }
/// <summary> /// Play a new file by file path. /// </summary> private async Task PlayNewFile(string path, bool play) { var sw = Stopwatch.StartNew(); var playerInst = InstanceManage.GetInstance <PlayersInst>(); ComponentPlayer audioPlayer = null; var dbInst = InstanceManage.GetInstance <OsuDbInst>(); if (path == null) { return; } if (File.Exists(path)) { try { var osuFile = await OsuFile.ReadFromFileAsync(path); //50 ms var fi = new FileInfo(path); if (!fi.Exists) { throw new FileNotFoundException("Cannot locate.", fi.FullName); } var dir = fi.Directory.FullName; /* Clear */ ClearHitsoundPlayer(); /* Set new hitsound player*/ playerInst.SetAudioPlayer(path, osuFile); //todo: 700 ms audioPlayer = playerInst.AudioPlayer; await audioPlayer.InitializeAsync(); audioPlayer.ProgressRefreshInterval = 500; SignUpPlayerEvent(audioPlayer); /* Set Meta */ var nowIdentity = new MapIdentity(fi.Directory.Name, osuFile.Metadata.Version); MapInfo mapInfo = DbOperate.GetMapFromDb(nowIdentity); //BeatmapEntry entry = App.PlayerList.Entries.GetBeatmapByIdentity(nowIdentity); BeatmapEntry entry = dbInst.Beatmaps.FilterByIdentity(nowIdentity); LblTitle.Content = osuFile.Metadata.TitleMeta.ToUnicodeString(); LblArtist.Content = osuFile.Metadata.ArtistMeta.ToUnicodeString(); ((ToolTip)NotifyIcon.TrayToolTip).Content = (string)LblArtist.Content + " - " + (string)LblTitle.Content; bool isFaved = SetFaved(nowIdentity); //50 ms audioPlayer.HitsoundOffset = mapInfo.Offset; Offset.Value = audioPlayer.HitsoundOffset; InstanceManage.GetInstance <PlayerList>().CurrentInfo = new CurrentInfo(osuFile.Metadata.Artist, osuFile.Metadata.ArtistUnicode, osuFile.Metadata.Title, osuFile.Metadata.TitleUnicode, osuFile.Metadata.Creator, osuFile.Metadata.Source, osuFile.Metadata.TagList, osuFile.Metadata.BeatmapId, osuFile.Metadata.BeatmapSetId, entry != null ? (entry.DiffStarRatingStandard.ContainsKey(Mods.None) ? entry.DiffStarRatingStandard[Mods.None] : 0) : 0, osuFile.Difficulty.HpDrainRate, osuFile.Difficulty.CircleSize, osuFile.Difficulty.ApproachRate, osuFile.Difficulty.OverallDifficulty, audioPlayer?.Duration ?? 0, nowIdentity, mapInfo, entry, isFaved); // 20 ms /* Set Lyric */ SetLyricSynchronously(); //todo: 900ms /* Set Progress */ //PlayProgress.Value = App.HitsoundPlayer.SingleOffset; PlayProgress.Maximum = audioPlayer.Duration; PlayProgress.Value = 0; PlayerViewModel.Current.Duration = InstanceManage.GetInstance <PlayersInst>().AudioPlayer.Duration; //LblTotal.Content = new TimeSpan(0, 0, 0, 0, audioPlayer.Duration).ToString(@"mm\:ss"); //LblNow.Content = new TimeSpan(0, 0, 0, 0, audioPlayer.PlayTime).ToString(@"mm\:ss"); /* Set Storyboard */ if (true) { // Todo: Set Storyboard } /* Set Video */ bool showVideo = PlayerViewModel.Current.EnableVideo && !ViewModel.IsMiniMode; if (VideoElement != null) { await ClearVideoElement(showVideo); if (showVideo) { var videoName = osuFile.Events.VideoInfo?.Filename; if (videoName == null) { VideoElement.Source = null; VideoElementBorder.Visibility = System.Windows.Visibility.Hidden; } else { var vPath = Path.Combine(dir, videoName); if (File.Exists(vPath)) { VideoElement.Source = new Uri(vPath); _videoOffset = -(osuFile.Events.VideoInfo.Offset); if (_videoOffset >= 0) { _waitAction = () => { }; _position = TimeSpan.FromMilliseconds(_videoOffset); } else { _waitAction = () => { Thread.Sleep(TimeSpan.FromMilliseconds(-_videoOffset)); }; } } else { VideoElement.Source = null; VideoElementBorder.Visibility = System.Windows.Visibility.Hidden; } } } } /* Set Background */ if (osuFile.Events.BackgroundInfo != null) { var bgPath = Path.Combine(dir, osuFile.Events.BackgroundInfo.Filename); BlurScene.Source = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null; Thumb.Source = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null; } else { BlurScene.Source = null; } /* Start Play */ switch (MainFrame.Content) { case RecentPlayPage recentPlayPage: var item = recentPlayPage.DataModels.FirstOrDefault(k => k.GetIdentity().Equals(nowIdentity)); recentPlayPage.RecentList.SelectedItem = item; break; case CollectionPage collectionPage: collectionPage.MapList.SelectedItem = collectionPage.ViewModel.Beatmaps.FirstOrDefault(k => k.GetIdentity().Equals(nowIdentity)); break; } _videoPlay = play; if (play) { if (showVideo && VideoElement?.Source != null) { // use event to control here. //VideoPlay(); //App.HitsoundPlayer.Play(); } else { audioPlayer.Play(); } } //if (!App.PlayerList.Entries.Any(k => k.GetIdentity().Equals(nowIdentity))) // App.PlayerList.Entries.Add(entry); PlayerConfig.Current.CurrentPath = path; PlayerConfig.SaveCurrent(); //RunSurfaceUpdate(); DbOperate.UpdateMap(nowIdentity); } catch (RepeatTimingSectionException ex) { var result = MsgBox.Show(this, @"铺面读取时发生问题:" + ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { if (audioPlayer == null) { return; } if (audioPlayer.PlayerStatus != PlayerStatus.Playing) { PlayNextAsync(false, true); } } } catch (BadOsuFormatException ex) { var result = MsgBox.Show(this, @"铺面读取时发生问题:" + ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { if (audioPlayer == null) { return; } if (audioPlayer.PlayerStatus != PlayerStatus.Playing) { PlayNextAsync(false, true); } } } catch (VersionNotSupportedException ex) { var result = MsgBox.Show(this, @"铺面读取时发生问题:" + ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { if (audioPlayer == null) { return; } if (audioPlayer.PlayerStatus != PlayerStatus.Playing) { PlayNextAsync(false, true); } } } catch (Exception ex) { var result = MsgBox.Show(this, @"发生未处理的异常问题:" + (ex.InnerException ?? ex), Title, MessageBoxButton.OK, MessageBoxImage.Error); if (result == MessageBoxResult.OK) { if (audioPlayer == null) { return; } if (audioPlayer.PlayerStatus != PlayerStatus.Playing) { PlayNextAsync(false, true); } } Console.WriteLine(ex); } } else { MsgBox.Show(this, string.Format(@"所选文件不存在{0}。", InstanceManage.GetInstance <OsuDbInst>().Beatmaps == null ? "" : " ,可能是db没有及时更新。请关闭此播放器或osu后重试"), Title, MessageBoxButton.OK, MessageBoxImage.Warning); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); }
private static Point FindVertexTouched(MapInfo mapInfo, IEnumerable <Point> vertices, double screenDistance) { return(vertices.OrderBy(v => v.Distance(mapInfo.WorldPosition)).FirstOrDefault(v => v.Distance(mapInfo.WorldPosition) < mapInfo.Resolution * screenDistance)); }
// interactive stuffs private void MapMouseDrag(object sender, MouseEventArgs e) { if (MapInfo.DoDrag && MapInfo.CanDrag) { bool doupdate = false; Vec deltamouse = MapInfo.OldMousePos - new Vec() { e.GetPosition(map).X, e.GetPosition(map).Y }; Areas.TotalDistance += deltamouse.Mag; Time.delta = (deltamouse.Mag * MapInfo.MoveRate); Time.time += (uint)Time.delta; MapInfo.position = MapInfo.position + deltamouse; if (MapInfo.position[0] < -100) { MapInfo.position[0] += 200; MapInfo.chunkpos[0] -= 1; doupdate = true; } if (MapInfo.position[0] > 100) { MapInfo.position[0] -= 200; MapInfo.chunkpos[0] += 1; doupdate = true; } if (MapInfo.position[1] < -100) { MapInfo.position[1] += 200; MapInfo.chunkpos[1] -= 1; doupdate = true; } if (MapInfo.position[1] > 100) { MapInfo.position[1] -= 200; MapInfo.chunkpos[1] += 1; doupdate = true; } if (doupdate) { MapInfo.DoDrag = false; MapInfo.Update(); } MapInfo.MoveUpdate(); Areas.Load(MapInfo.CurrBiome); TransformGroup group = new TransformGroup(); group.Children.Add(new TranslateTransform(-MapInfo.position[0], -MapInfo.position[1])); map.RenderTransform = group; Characters.Update(); Sun.Draw(); double shortest_dist = double.MaxValue; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { try { foreach (Bases.Base checking in Bases.BaseList[(int)MapInfo.chunkpos[0] + i, (int)MapInfo.chunkpos[1] + j]) { Vec temp = MapInfo.position + new Vec() { 100, 100 } -(checking.pos + new Vec() { 200 * i, 200 * j }); double dist = temp * temp; if (dist <= shortest_dist) { shortest_dist = dist; Bases.NearestBase = checking; } } } catch { } } } Bases.Base temp_base = Bases.SelectedBase; if (Bases.NearestBase.distance_to <= 50) { Bases.SelectedBase = Bases.NearestBase; } else { Bases.SelectedBase = null; } if (temp_base != Bases.SelectedBase) { MapInfo.Update(); } } }
public int SaveMapObjects(string name) { print("save map objects"); MapInfo mapInfo = new MapInfo(); mapInfo.name = name; mapInfo.author = player.name; mapInfo.dateTime = DateTime.Now.ToString(); if (isOfficial) { mapInfoJson.officialMaps.Add(mapInfo); } else { mapInfoJson.customMaps.Add(mapInfo); } string json = JsonUtility.ToJson(mapInfoJson, true); File.WriteAllText(Application.persistentDataPath + "/General/MapsInfo.json", json); MapObjInfo mapObjInfo = new MapObjInfo(); Transform t; t = ball.transform; mapObjInfo.ballInfo = new TransformProperty(t.position, t.localEulerAngles, t.localScale); t = destination.transform; mapObjInfo.destInfo = new TransformProperty(t.position, t.localEulerAngles, t.localScale); mapObjInfo.mapInfo = mapInfo; mapObjInfo.wallInfo = new List <TransformProperty>(); for (int i = 0; i < walls.transform.childCount; i++) { t = walls.transform.GetChild(i); mapObjInfo.wallInfo.Add(new TransformProperty(t.position, t.localEulerAngles, t.localScale)); } mapObjInfo.fieldNumList = new List <int>(); mapObjInfo.fieldTypeList = new List <string>(); foreach (KeyValuePair <string, int> kv in _fieldMaxDic) { mapObjInfo.fieldTypeList.Add(kv.Key); mapObjInfo.fieldNumList.Add(myUI.FieldNumLimitGet(kv.Key)); } BinaryFormatter bf = new BinaryFormatter(); string dir = GetMapDir() + "/Levels/" + name + "_" + player.name; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } FileStream file = File.Open(dir + "/general", FileMode.OpenOrCreate); bf.Serialize(file, mapObjInfo); file.Close(); //Transform[] fieldsTrans = mapFields.transform.GetComponentsInChildren<Transform>(); dir = dir + "/fields"; MyUtils.EmptyOrCreateDir(dir); foreach (var kv in mapFieldDic) { for (int i = 0; i < kv.Value.Count; i++) { file = File.Open(dir + '/' + kv.Key + i, FileMode.OpenOrCreate); FieldInfo info = kv.Value[i].GetComponent <Field>().Save(); bf.Serialize(file, info); file.Close(); } } return(-1); }
public void LoadMap(MapInfo map_info) { }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { var selectedStep = 0; if (PhStep1.Visible) { selectedStep = 1; } else if (PhStep2.Visible) { selectedStep = 2; } PhStep1.Visible = PhStep2.Visible = false; if (selectedStep == 1) { var isConflict = false; var conflictKeywords = string.Empty; if (!string.IsNullOrEmpty(TbKeywords.Text)) { if (_mapId > 0) { var mapInfo = DataProviderWx.MapDao.GetMapInfo(_mapId); isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemId, mapInfo.KeywordId, PageUtils.FilterXss(TbKeywords.Text), out conflictKeywords); } else { isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemId, PageUtils.FilterXss(TbKeywords.Text), out conflictKeywords); } } if (isConflict) { FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词"); PhStep1.Visible = true; } else { PhStep2.Visible = true; BtnSubmit.Text = "确 认"; } } else if (selectedStep == 2) { var mapInfo = new MapInfo(); if (_mapId > 0) { mapInfo = DataProviderWx.MapDao.GetMapInfo(_mapId); } mapInfo.PublishmentSystemId = PublishmentSystemId; mapInfo.KeywordId = DataProviderWx.KeywordDao.GetKeywordId(PublishmentSystemId, _mapId > 0, TbKeywords.Text, EKeywordType.Map, mapInfo.KeywordId); mapInfo.IsDisabled = !CbIsEnabled.Checked; mapInfo.Title = PageUtils.FilterXss(TbTitle.Text); mapInfo.ImageUrl = ImageUrl.Value;; mapInfo.Summary = TbSummary.Text; mapInfo.MapWd = TbMapWd.Text; try { if (_mapId > 0) { DataProviderWx.MapDao.Update(mapInfo); LogUtils.AddAdminLog(Body.AdministratorName, "修改微导航", $"微导航:{TbTitle.Text}"); SuccessMessage("修改微导航成功!"); } else { _mapId = DataProviderWx.MapDao.Insert(mapInfo); LogUtils.AddAdminLog(Body.AdministratorName, "添加微导航", $"微导航:{TbTitle.Text}"); SuccessMessage("添加微导航成功!"); } var redirectUrl = PageMap.GetRedirectUrl(PublishmentSystemId); AddWaitAndRedirectScript(redirectUrl); } catch (Exception ex) { FailMessage(ex, "微导航设置失败!"); } BtnSubmit.Visible = false; BtnReturn.Visible = false; } } }
public void SetMapInfo(MapInfo mapInfo) { _currentGame.MapInfo = mapInfo; }
public MapInfoTest() { mapInfo = new MapInfo(); mapInfoExtraA = new MapInfoExtraA(); mapInfoExtraB = new MapInfoExtraB(); }