public static Unit_Serializable Load_Unit_Serializable_Data(string dataPath) { string jsonStr = File.ReadAllText(dataPath); jsonStr = jsonStr.Replace("\n", ""); Unit_Serializable u = JsonUtility.FromJson <Unit_Serializable>(jsonStr); return(u); }
void Perform_Summon(PointerEventData.InputButton input, Vector2Int tileIdx) { if (!Model.Managers.FieldManager.IsInField(tileIdx)) { return; } if (input == PointerEventData.InputButton.Left) { // Debug.Log("vec3" + pos); // Debug.Log("vec2" + tileIdx); if (DungeonEditor.instance.selectedIndex >= 0) { // Debug.Log(DungeonEditor.instance.selectedObject); //유닛 소환 if (DungeonEditor.instance.selectedObject is string) { Unit_Serializable u = Common.Data.Load_Unit_Serializable_Data((string)DungeonEditor.instance.selectedObject); Unit unit = new Unit(u); Common.Command.Summon(unit, tileIdx); } else if (DungeonEditor.instance.selectedObject is Item) { Common.Command.Summon(((Item)DungeonEditor.instance.selectedObject).Clone(), tileIdx); } else if (DungeonEditor.instance.selectedObject is Artifact) { Common.Command.Summon(((Artifact)DungeonEditor.instance.selectedObject).Clone(), tileIdx); } else if (DungeonEditor.instance.selectedObject is Tile) { Vector3Int tilePosition = new Vector3Int(tileIdx.x, tileIdx.y, 0); Tile newtile = ((Tile)DungeonEditor.instance.selectedObject).Clone(); Tile oldtile = Model.Managers.FieldManager.GetTile(tileIdx.x, tileIdx.y); // 이전 타일 연결 관계 유지. newtile.OnTile(oldtile.GetUnit()); newtile.SetObtainable(oldtile.GetObtainable()); Model.Managers.FieldManager.instance.field[tileIdx.y, tileIdx.x] = newtile; Model.Managers.FieldManager.instance.field[tileIdx.y, tileIdx.x].position = tileIdx; Model.Managers.FieldManager.instance.tileMap.SetTile(tilePosition, newtile.TileBase); } //Common.Command.Summon((Unit) DungeonEditor.instance.selectedObject, tileIdx); } } else if (input == PointerEventData.InputButton.Right) { Common.Command.UnSummon(tileIdx); } }