/// <Summary> /// Move position event process. /// </Summary> /// <param name="eventParts">Event parts data.</param> IEnumerator EventMovePosition(AriadneEventParts eventParts) { // Fade out fadeManager.FadeOut(); var waitTime = new WaitForSeconds(fadeManager.fadeTime); yield return(waitTime); // Set new position if (eventParts.destDungeon == null) { Debug.LogError("Dest dungeon is not assigned to this EventData!"); yield break; } if (eventParts.destMap == null) { Debug.LogError("Dest map is not assigned to this EventData!"); yield break; } // Send dungeon data to DungeonSetting. moveDestDungeon = eventParts.destDungeon; SendDungeonData(gameController); PlayerPosition.currentDungeonId = eventParts.destDungeon.dungeonId; PlayerPosition.currentFloorId = eventParts.destMap.floorId; PlayerPosition.playerPos = eventParts.destPos; PlayerPosition.direction = eventParts.direction; // Get new floor data DungeonSettings ds = gameController.GetComponent <DungeonSettings>(); dungeonData = ds.dungeonData; floorMapData = ds.GetCurrentFloorData(); // Add traverse data TraverseManager.AddDungeonTraverseData(PlayerPosition.currentDungeonId, PlayerPosition.currentFloorId, floorMapData); PlayerPosition.SetTraverseData(); yield return(waitTime); // Remove dungeon walls and redraw dungeon SendRedrawMessage(gameController); // Move camera SetCameraPos(); float targetAngle = CurrentDirAngle(); player.transform.eulerAngles = new Vector3(0, targetAngle, 0); SendSetNewMap(); SendSetDirtyMsg(); yield return(waitTime); // Fade in fadeManager.FadeIn(); yield return(waitTime); OnPostEvent(); }
/// <Summary> /// Generates meshes of traversed position. /// If "isAutoMapping" is false, all hallways in the map are shown on the map. /// </Summary> void DrawMap(VertexHelper vh) { if (mapRt == null) { mapRt = gameObject.GetComponent <RectTransform>(); } Vector3 centerPos = mapRt.transform.localPosition; float cellWidth = mapRt.sizeDelta.x / (1 + showLengthHorizontal * 2); float cellHeight = mapRt.sizeDelta.y / (1 + showLengthVertical * 2); float widthOffset = cellWidth / 2; float heightOffset = cellHeight / 2; if (parentRt == null) { parentRt = GameObject.FindGameObjectWithTag("Map").GetComponent <RectTransform>(); } Vector2 parentPos = parentRt.transform.localPosition; float parentWidth = parentRt.sizeDelta.x; float parentHeight = parentRt.sizeDelta.y; Rect r = mapRt.rect; r.x += parentPos.x + centerPos.x; r.y += parentPos.y + centerPos.y; SetClipRect(r, true); int signX = centerPos.x < 0 ? -1 : 1; int signY = centerPos.y < 0 ? -1 : 1; Vector2 unitSize = new Vector2(cellWidth, cellHeight); float basePosX = parentWidth / 2 - signX * centerPos.x - widthOffset - posLerp.x * unitSize.x; float basePosY = parentHeight / 2 - signY * centerPos.y - heightOffset - posLerp.y * unitSize.y; Vector2 basePos = new Vector2(basePosX, basePosY); for (int yAxis = 0; yAxis < floorMapData.floorSizeVertical; yAxis++) { for (int xAxis = 0; xAxis < floorMapData.floorSizeHorizontal; xAxis++) { int index = xAxis + yAxis * floorMapData.floorSizeHorizontal; Vector3 basePosInLoop = new Vector3(basePos.x + unitSize.x * xAxis, basePos.y + unitSize.y * yAxis); int mapAttrId = MapAttributeDefine.WALL; Vector2Int pos = new Vector2Int(xAxis, yAxis); if (isAutoMapping) { if (!TraverseManager.GetPositionTraverseData(dungeonData.dungeonId, floorMapData.floorId, pos)) { continue; } } mapAttrId = floorMapData.mapInfo[index].mapAttr; PositionSet posSet = GetPositionSet(basePosInLoop, unitSize); DrawMTraversedPos(vh, mapAttrId, posSet); } } }
/// <Summary> /// Set the visible state of the icon according to traverse data. /// </Summary> /// <param name="axisPos">The position on the dungeon.</param> /// <param name="obj">The icon object.</param> void SetIconVisibleState(Vector2Int axisPos, GameObject obj) { bool isTraversed = TraverseManager.GetPositionTraverseData(dungeonData.dungeonId, floorMapData.floorId, axisPos); obj.GetComponent <Image>().enabled = isTraversed; }
/// <Summary> /// Set traverse data of the event position. /// </Summary> /// <param name="eventPos">Position of the event.</param> void SetEventTraverse(Vector2Int eventPos) { // This position is validated in GetEventData method. TraverseManager.SetTraverseData(PlayerPosition.currentDungeonId, PlayerPosition.currentFloorId, eventPos, true); SendSetDirtyMsgImmediately(); }
/// <Summary> /// Set traverse data of the floor. /// </Summary> void SetTraverse() { TraverseManager.InitializeTraverseData(); TraverseManager.AddDungeonTraverseData(dungeonData.dungeonId, floorMapData.floorId, floorMapData); PlayerPosition.SetTraverseData(); }
/// <Summary> /// Set traverse data. /// </Summary> public static void SetTraverseData() { TraverseManager.SetTraverseData(currentDungeonId, currentFloorId, playerPos, true); }