/// <Summary> /// Copy constructor of base parts. /// </Summary> /// <param name="baseParts">Base parts data for copying.</param> public AriadneEventParts(AriadneEventParts baseParts) { eventCategory = baseParts.eventCategory; eventTrigger = baseParts.eventTrigger; eventPos = baseParts.eventPos; startCondition = baseParts.startCondition; startFlagName = baseParts.startFlagName; startItemId = baseParts.startItemId; startNum = baseParts.startNum; comparisonOperator = baseParts.comparisonOperator; hasExecutedFlag = baseParts.hasExecutedFlag; executedFlagName = baseParts.executedFlagName; doorKeyType = baseParts.doorKeyType; destDungeon = baseParts.destDungeon; destMap = baseParts.destMap; destPos = baseParts.destPos; direction = baseParts.direction; treasureType = baseParts.treasureType; itemId = baseParts.itemId; itemNum = baseParts.itemNum; msgList = new List <string>(); foreach (string msg in baseParts.msgList) { msgList.Add(msg); } }
/// <Summary> /// Returns the map attribute of the position that is specified direction of target position. /// </Summary> /// <param name="mapData">Target position to check.</param> /// <param name="pos">Target position to check.</param> /// <param name="dir">Direction to check.</param> public static int GetMapInfoByDirection(FloorMapMasterData mapData, Vector2Int pos, DungeonDir dir) { int wallInfo = 0; Vector2Int targetPos = pos; switch (dir) { case DungeonDir.North: targetPos.y += 1; break; case DungeonDir.East: targetPos.x += 1; break; case DungeonDir.South: targetPos.y -= 1; break; case DungeonDir.West: targetPos.x -= 1; break; } if (CheckPositionIsValid(targetPos, mapData.floorSizeHorizontal, mapData.floorSizeVertical)) { int index = targetPos.x + targetPos.y * mapData.floorSizeHorizontal; wallInfo = mapData.mapInfo[index].mapAttr; } else { wallInfo = 1; } return(wallInfo); }
/// <Summary> /// Returns a floor data which corresponds to the floor ID stored in PlayerPosition. /// </Summary> public FloorMapMasterData GetCurrentFloorData() { if (dungeonData.floorList == null) { ShowAssignErrorMessage(dungeonData.name); return(null); } FloorMapMasterData floorData = null; if (dungeonData.floorList.Count > 0) { floorData = dungeonData.floorList[0]; foreach (FloorMapMasterData floor in dungeonData.floorList) { if (floor == null) { continue; } if (floor.floorId == PlayerPosition.currentFloorId) { floorData = floor; break; } } } if (floorData == null) { ShowAssignErrorMessage(dungeonData.name); } return(floorData); }
/// <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> /// Show setting GUI about move position event. /// </Summary> void ShowMovePositionEventParts() { // Dest dungeon oldDungeon = editingEventParts.destDungeon; Undo.RecordObject(this, undoName); editingEventParts.destDungeon = (DungeonMasterData)EditorGUILayout.ObjectField("Dest dungeon", editingEventParts.destDungeon, typeof(DungeonMasterData), false); if (editingEventParts.destDungeon == null) { return; } DungeonFloorStruct dfs = new DungeonFloorStruct(editingEventParts.destDungeon); floorIds = dfs.floorIds; floorNames = dfs.floorNames; if (oldDungeon != editingEventParts.destDungeon) { selectedFloor = 0; editingEventParts.destMap = null; isPosSelected = false; selectedGridPos = Vector2Int.zero; editingEventParts.destPos = Vector2Int.zero; } // Dest map oldMap = editingEventParts.destMap; Undo.RecordObject(this, undoName); selectedFloor = EditorGUILayout.IntPopup("Dest map", selectedFloor, floorNames, floorIds); editingEventParts.destMap = editingEventParts.destDungeon.floorList.Find((floor) => floor.floorId == selectedFloor); if (editingEventParts.destMap != null) { isShowMap = true; } else { isShowMap = false; } if (oldMap != editingEventParts.destMap) { isPosSelected = false; selectedGridPos = Vector2Int.zero; editingEventParts.destPos = Vector2Int.zero; } // Dest position Undo.RecordObject(this, undoName); editingEventParts.destPos = EditorGUILayout.Vector2IntField("Dest position", editingEventParts.destPos); if (isPosSelected) { editingEventParts.destPos = selectedGridPos; } Undo.RecordObject(this, undoName); editingEventParts.direction = (DungeonDir)EditorGUILayout.EnumPopup("Direction of after move", editingEventParts.direction); }
/// <Summary> /// Get floor data from the DungeonSettings component. /// </Summary> void GetFloorData() { if (gameController == null) { gameController = GameObject.FindGameObjectWithTag("GameController"); } if (dungeonSettings == null) { dungeonSettings = gameController.GetComponent <DungeonSettings>(); } floorMapData = dungeonSettings.GetCurrentFloorData(); }
void GetSettings() { gameController = GameObject.FindGameObjectWithTag("GameController"); DungeonSettings ds = gameController.GetComponent <DungeonSettings>(); dungeonData = ds.dungeonData; floorMapData = ds.GetCurrentFloorData(); dungeonParts = floorMapData.dungeonParts; if (dungeonParts == null) { DungeonPartsManager.GetDefaultDungeonParts(); } player = GameObject.FindGameObjectWithTag("Player"); }
/// <Summary> /// Get settings such as dungeon data from DungeonSettings class. /// </Summary> protected void GetSettings() { gameController = GameObject.FindGameObjectWithTag("GameController"); DungeonSettings ds = gameController.GetComponent <DungeonSettings>(); dungeonData = ds.dungeonData; currentFloorMapData = ds.GetCurrentFloorData(); dungeonParts = currentFloorMapData.dungeonParts; if (dungeonParts == null) { DungeonPartsManager.GetDefaultDungeonParts(); } isDrawOutsideWall = ds.isDrawOutsideWall; outsideWallSize = ds.outsideWallSize; }
/// <Summary> /// Search floor map data in the project and set it to the list. /// </Summary> void SetFloorMapDataList() { floorMapDataList = new List <FloorMapMasterData>(); string dataType = "FloorMapMasterData"; string[] guidArray = MapEditorUtil.GetGuidArray(dataType); foreach (string guid in guidArray) { string path = AssetDatabase.GUIDToAssetPath(guid); FloorMapMasterData floorData = AssetDatabase.LoadAssetAtPath <FloorMapMasterData>(path); if (floorData == null) { continue; } if (floorData.name != MapEditorUtil.tempFileName) { floorMapDataList.Add(floorData); } } }
/// <Summary> /// Add traverse data set of the new floor. /// </Summary> /// <param name="dungeonId">Sepcify the dungeon ID.</param> /// <param name="floorId">Floor ID in the dungeon.</param> /// <param name="floorData">FloorMapData for adding traverse data.</param> public static void AddDungeonTraverseData(int dungeonId, int floorId, FloorMapMasterData floorData) { TraverseData td = GetDungeonTraverseData(dungeonId); if (td == null) { td = new TraverseData(dungeonId); traverseList.Add(td); } for (int y = 0; y < floorData.floorSizeVertical; y++) { for (int x = 0; x < floorData.floorSizeHorizontal; x++) { Vector2Int pos = new Vector2Int(x, y); string key = GetTraverseKeyString(floorId, pos); if (!td.traverseDict.ContainsKey(key)) { td.traverseDict.Add(key, false); } } } }