Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
tuseGameColor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shujianhe
tuseGameColor
Commits
2dac4321
Commit
2dac4321
authored
Aug 20, 2023
by
Ever
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新代码
parent
f6d1bad2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
24 deletions
+90
-24
jpg.jpg.meta
Assets/Resources/cc2D9Z2w9k0evqUiCQ/jpg.jpg.meta
+1
-1
mainGameOneImageView.cs
Assets/scripts/common/mainGameOneImageView.cs
+1
-1
mainGameView.cs
Assets/scripts/common/mainGameView.cs
+58
-8
SaveManager.cs
Assets/scripts/utils/SaveManager.cs
+30
-14
No files found.
Assets/Resources/cc2D9Z2w9k0evqUiCQ/jpg.jpg.meta
View file @
2dac4321
...
...
@@ -21,7 +21,7 @@ TextureImporter:
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable:
0
isReadable:
1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
...
...
Assets/scripts/common/mainGameOneImageView.cs
View file @
2dac4321
...
...
@@ -419,7 +419,7 @@ public class mainGameOneImageView : mainGameView //回放上面,回放用的
height
=
gameidJsondata
.
height
;
return
true
;
}
public
override
void
loadFileInfo
(
string
url
,
string
localpath
,
int
typeId
)
public
override
void
loadFileInfo
(
string
url
,
string
localpath
,
int
typeId
,
string
key
=
""
)
{
if
(
typeId
==
1
||
typeId
==
2
)
...
...
Assets/scripts/common/mainGameView.cs
View file @
2dac4321
...
...
@@ -585,11 +585,34 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
}
}
public
virtual
void
loadFileInfo
(
string
url
,
string
localpath
,
int
typeId
)
public
virtual
void
loadFileInfo
(
string
url
,
string
localpath
,
int
typeId
,
string
key
=
""
)
{
if
(
typeId
==
1
||
typeId
==
2
)
{
//if (typeId == 1)
//{
// string pngpath = Application.persistentDataPath + $"/MyPic/{key}/{key}.png";
// if (!File.Exists(pngpath))
// {
// File.Move(localpath, pngpath);
// }
//}
//else
//{
// string jpgpath = Application.persistentDataPath + $"/MyPic/{key}/{key}.jpg";
// if (!File.Exists(jpgpath))
// {
// File.Move(localpath, jpgpath);
// }
//}
DownLoadFileinfos
.
Add
(
url
);
EventDispatcher
.
Dispatch
(
EventName
.
Event
.
Event_LoadingChange
);
//加载完成
if
(
DownLoadFileinfos
.
Count
>=
3
)
{
StartGame
();
}
return
;
utilsTools
.
httpDOWNIMG
(
this
,
url
,
localpath
,
(
string
id
,
string
url1
,
bool
isSuccess
,
System
.
Object
data
)
=>
{
if
(
isSuccess
==
false
)
...
...
@@ -644,6 +667,21 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
}
else
if
(
typeId
==
3
)
{
//string path = Application.persistentDataPath + $"/MyPic/{key}/{key}.json"; //这个以后改为、bin文件
//if (!File.Exists(path))
//{
// File.Move(localpath,path);
//}
EventDispatcher
.
Dispatch
(
EventName
.
Event
.
Event_LoadingChange
);
//加载完成
DownLoadFileinfos
.
Add
(
url
);
if
(
DownLoadFileinfos
.
Count
>=
3
)
{
StartGame
();
}
return
;
utilsTools
.
httpDownText
(
this
,
url
,
localpath
,
(
string
id
,
string
url1
,
bool
isSuccess
,
System
.
Object
data
)
=>
{
if
(
isSuccess
==
false
)
...
...
@@ -775,13 +813,19 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
//utilsTools.setGDataByKey("loadBinEnd", utilsTools.getTotalMillisecond());
//utilsTools.setGDataByKey("downJson", utilsTools.getTotalMillisecond());
EventDispatcher
.
Dispatch
(
EventName
.
Event
.
Event_LoadingChange
);
//开始加载文件
EventDispatcher
.
Dispatch
(
EventName
.
Event
.
Event_LoadingChange
);
//开始加载本地文件
string
dicpath
=
Application
.
persistentDataPath
+
$"/MyPic/
{
gameUserInfo
.
id
}
"
;
if
(!
Directory
.
Exists
(
dicpath
))
{
Directory
.
CreateDirectory
(
dicpath
);
}
loadFileInfo
(
gameUserInfo
.
json
,
jsonPath
,
3
);
loadFileInfo
(
gameUserInfo
.
json
,
jsonPath
,
3
,
gameUserInfo
.
id
);
//utilsTools.setGDataByKey("loadGaoQing", utilsTools.getTotalMillisecond());
loadFileInfo
(
gameUserInfo
.
img
,
linePath
,
1
);
loadFileInfo
(
gameUserInfo
.
img
,
linePath
,
1
,
gameUserInfo
.
id
);
//utilsTools.setGDataByKey("loadJpg", utilsTools.getTotalMillisecond());
loadFileInfo
(
gameUserInfo
.
finishImg
,
colorPath
,
2
);
loadFileInfo
(
gameUserInfo
.
finishImg
,
colorPath
,
2
,
gameUserInfo
.
id
);
return
true
;
}
public
bool
loadGameImgId
()
...
...
@@ -1741,12 +1785,15 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
var
jsondata
=
getdata
(
"cc2D9Z2w9k0evqUiCQ"
);
item
.
GetComponent
<
GameMgr
>().
Init
(
"cc2D9Z2w9k0evqUiCQ"
,
png
,
jpg
,
jsondata
);
SaveManager
.
Instance
.
SaveRes
(
"cc2D9Z2w9k0evqUiCQ"
,
jsondata
,
png
);
//SaveManager.Instance.SaveJPG("cc2D9Z2w9k0evqUiCQ", jpg_texture);
}
IEnumerator
LoadPic
(
string
dirpath
,
string
name
,
Transform
item
)
{
Texture2D
png
=
null
;
Sprite
jpg
=
null
;
Texture2D
jpg_texture
=
null
;
string
pngpath
=
dirpath
+
$"
{
name
}
.png"
;
UnityWebRequest
request
;
if
(
File
.
Exists
(
pngpath
))
...
...
@@ -1769,13 +1816,13 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
yield
return
request
.
SendWebRequest
();
if
(
request
.
isDone
)
{
var
jpg_texture
=
DownloadHandlerTexture
.
GetContent
(
request
);
jpg_texture
=
DownloadHandlerTexture
.
GetContent
(
request
);
jpg
=
Sprite
.
Create
(
jpg_texture
,
new
Rect
(
0
,
0
,
jpg_texture
.
width
,
jpg_texture
.
height
),
new
Vector2
(
0.5f
,
0.5f
));
}
}
else
{
var
jpg_texture
=
Resources
.
Load
<
Texture2D
>(
"cc2D9Z2w9k0evqUiCQ/jpg"
);
jpg_texture
=
Resources
.
Load
<
Texture2D
>(
"cc2D9Z2w9k0evqUiCQ/jpg"
);
jpg
=
Sprite
.
Create
(
jpg_texture
,
new
Rect
(
0
,
0
,
jpg_texture
.
width
,
jpg_texture
.
height
),
new
Vector2
(
0.5f
,
0.5f
));
}
...
...
@@ -1783,7 +1830,9 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
var
jsondata
=
getdata
(
"cc2D9Z2w9k0evqUiCQ"
);
item
.
GetComponent
<
GameMgr
>().
Init
(
"cc2D9Z2w9k0evqUiCQ"
,
png
,
jpg
,
jsondata
);
SaveManager
.
Instance
.
SaveRes
(
"cc2D9Z2w9k0evqUiCQ"
,
jsondata
,
png
);
yield
return
new
WaitForSeconds
(
0.5f
);
SaveManager
.
Instance
.
SaveJPG
(
"cc2D9Z2w9k0evqUiCQ"
,
item
.
GetComponent
<
GameMgr
>().
md
.
jpg
.
texture
);
}
private
ResJsonData
getdata
(
string
name
)
...
...
@@ -1797,6 +1846,7 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
FileStream
readFs
=
new
FileStream
(
path
,
FileMode
.
Open
);
BinaryFormatter
readBf
=
new
BinaryFormatter
();
ResJsonData
rjd
=
(
ResJsonData
)
readBf
.
Deserialize
(
readFs
);
readFs
.
Close
();
return
rjd
;
...
...
Assets/scripts/utils/SaveManager.cs
View file @
2dac4321
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
UnityEngine
;
using
System.IO
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Net.NetworkInformation
;
public
class
SaveManager
:
MonoBehaviour
{
...
...
@@ -40,23 +41,27 @@ public class SaveManager : MonoBehaviour
public
void
SaveBin
(
string
key
,
ResJsonData
data
)
{
string
json
=
JsonUtility
.
ToJson
(
data
);
SaveBin
(
key
,
json
);
StartCoroutine
(
SaveBing
(
key
,
data
));
}
IEnumerator
SaveBing
(
string
key
,
ResJsonData
data
)
{
yield
return
null
;
SaveBin_Ie
(
key
,
data
);
}
/// <summary>
/// 保存bin文件
/// </summary>
/// <param name="path"></param>
/// <param name="json"></param>
public
void
SaveBin
(
string
key
,
string
json
)
public
void
SaveBin
_Ie
(
string
key
,
ResJsonData
data
)
{
CreateDirectory
(
SavePath
+
$"
{
key
}
"
);
string
path
=
SavePath
+
$"
{
key
}
/
{
key
}
.bin"
;
FileStream
fs
=
new
FileStream
(
path
,
FileMode
.
Create
,
FileAccess
.
Write
);
FileStream
fs
=
new
FileStream
(
path
,
FileMode
.
OpenOr
Create
,
FileAccess
.
Write
);
BinaryFormatter
saveBf
=
new
BinaryFormatter
();
saveBf
.
Serialize
(
fs
,
json
);
saveBf
.
Serialize
(
fs
,
data
);
fs
.
Close
();
}
...
...
@@ -69,26 +74,37 @@ public class SaveManager : MonoBehaviour
{
CreateDirectory
(
SavePath
+
$"
{
key
}
"
);
string
path
=
SavePath
+
$"
{
key
}
/
{
key
}
.png"
;
byte
[]
dataBytes
=
png
.
EncodeToPNG
();
FileStream
fs
=
File
.
Open
(
path
,
FileMode
.
OpenOrCreate
);
fs
.
Write
(
dataBytes
,
0
,
dataBytes
.
Length
);
fs
.
Flush
();
fs
.
Close
();
StartCoroutine
(
SavePic
(
path
,
png
));
//byte[] dataBytes = png.EncodeToPNG();
//FileStream fs = File.Open(path, FileMode.OpenOrCreate);
//fs.Write(dataBytes, 0, dataBytes.Length);
//fs.Flush();
//fs.Close();
}
public
void
SaveJPG
(
string
key
,
Texture2D
pn
g
)
public
void
SaveJPG
(
string
key
,
Texture2D
jp
g
)
{
string
path
=
SavePath
+
$"
{
key
}
/
{
key
}
.jpg"
;
CreateDirectory
(
SavePath
+
$"
{
key
}
"
);
byte
[]
dataBytes
=
png
.
EncodeToPNG
();
StartCoroutine
(
SavePic
(
path
,
jpg
));
//byte[] dataBytes = png.EncodeToPNG();
//FileStream fs = File.Open(path, FileMode.OpenOrCreate);
//fs.Write(dataBytes, 0, dataBytes.Length);
//fs.Flush();
//fs.Close();
}
IEnumerator
SavePic
(
string
path
,
Texture2D
pic
)
{
yield
return
null
;
byte
[]
dataBytes
=
pic
.
EncodeToPNG
();
FileStream
fs
=
File
.
Open
(
path
,
FileMode
.
OpenOrCreate
);
fs
.
Write
(
dataBytes
,
0
,
dataBytes
.
Length
);
fs
.
Flush
();
fs
.
Close
();
}
private
void
CreateDirectory
(
string
dirpath
)
{
if
(!
Directory
.
Exists
(
dirpath
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment