Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mercury233
ygopro2
Commits
68b5410a
Commit
68b5410a
authored
Mar 13, 2019
by
Unicorn369
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update
parent
a3791faa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
376 additions
and
335 deletions
+376
-335
Assets/SibylSystem/Menu/Menu.cs
Assets/SibylSystem/Menu/Menu.cs
+7
-5
Assets/SibylSystem/Program.cs
Assets/SibylSystem/Program.cs
+1
-0
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
+319
-316
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
+49
-14
No files found.
Assets/SibylSystem/Menu/Menu.cs
View file @
68b5410a
...
...
@@ -141,14 +141,16 @@ public class Menu : WindowServantSP
void
onClickDownload
()
{
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
Application
.
OpenURL
(
"https://github.com/Unicorn369/pro2_android_closeup/releases/
download/1.0/closeup_version1.0.zip
"
);
Application
.
OpenURL
(
"https://github.com/Unicorn369/pro2_android_closeup/releases/
tag/1.0
"
);
#elif UNITY_ANDROID //Android
AndroidJavaObject
jo
=
new
AndroidJavaObject
(
"cn.unicorn369.library.API"
);
if
(!
File
.
Exists
(
"updates/closeup_version1.0.txt"
))
{
//用于检查更新
if
(
File
.
Exists
(
"closeup_version1.0.zip"
))
{
//如果有则直接解压
jo
.
Call
(
"doExtractZipFile"
,
"closeup_version1.0.zip"
,
Program
.
ANDROID_GAME_PATH
);
if
(!
File
.
Exists
(
"updates/closeup_version1.1.txt"
))
{
//用于检查更新
if
(
File
.
Exists
(
"closeup_version1.1.zip"
))
{
//如果有则直接解压
jo
.
Call
(
"doExtractZipFile"
,
"closeup_version1.1.zip"
,
Program
.
ANDROID_GAME_PATH
);
}
else
if
(
File
.
Exists
(
"updates/closeup_version1.0.txt"
)){
//如果有则下载更新包
jo
.
Call
(
"doDownloadZipFile"
,
"https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/up_closeup_version1.1.zip"
);
}
else
{
//否则下载并解压,锁定目录:/ygocore
jo
.
Call
(
"doDownloadZipFile"
,
"https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.
0
.zip"
);
jo
.
Call
(
"doDownloadZipFile"
,
"https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.
1
.zip"
);
}
}
else
{
jo
.
Call
(
"showToast"
,
"已下载,无需再次下载!"
);
...
...
Assets/SibylSystem/Program.cs
View file @
68b5410a
...
...
@@ -379,6 +379,7 @@ public class Program : MonoBehaviour
File
.
Create
(
"updates/image_version1.1.txt"
);
}
else
{
jo
.
Call
(
"showToast"
,
"没有发现卡图包,是否未安装YGOMobile"
);
Application
.
OpenURL
(
"https://www.taptap.com/app/37972"
);
}
}
#endif
...
...
Assets/SibylSystem/ResourceManagers/GameTextureManager.cs
View file @
68b5410a
...
...
@@ -25,6 +25,7 @@ public class GameTextureManager
static
HttpDldFile
df
=
new
HttpDldFile
();
private
static
readonly
Semaphore
_sem
=
new
Semaphore
(
30
,
30
);
public
class
BitmapHelper
{
public
System
.
Drawing
.
Color
[,]
colors
=
null
;
...
...
@@ -144,7 +145,7 @@ public class GameTextureManager
public
static
Texture2D
opBack
=
null
;
public
static
Texture2D
unknown
=
null
;
public
static
Texture2D
unknown
=
null
;
public
static
Texture2D
attack
=
null
;
...
...
@@ -152,7 +153,7 @@ public class GameTextureManager
public
static
Texture2D
bar
=
null
;
public
static
Texture2D
exBar
=
null
;
public
static
Texture2D
exBar
=
null
;
public
static
Texture2D
lp
=
null
;
...
...
@@ -207,12 +208,12 @@ public class GameTextureManager
while
(
waitLoadStack
.
Count
>
0
)
{
thu
++;
if
(
thu
==
10
)
if
(
thu
==
10
)
{
Thread
.
Sleep
(
50
);
thu
=
0
;
}
if
(
bLock
==
false
)
if
(
bLock
==
false
)
{
PictureResource
pic
;
...
...
@@ -227,41 +228,23 @@ public class GameTextureManager
}
if
(
pic
.
type
==
GameTextureType
.
card_feature
)
{
try
{
ProcessingCardFeature
(
pic
);
}
catch
(
Exception
e
)
{
Debug
.
Log
(
"e 1"
+
e
.
ToString
());
}
_sem
.
WaitOne
();
new
Thread
(()
=>
ProcessingCardFeature
(
pic
)).
Start
();
}
if
(
pic
.
type
==
GameTextureType
.
card_picture
)
{
try
{
ProcessingCardPicture
(
pic
);
}
catch
(
Exception
e
)
{
Debug
.
Log
(
"e 2"
+
e
.
ToString
());
}
_sem
.
WaitOne
();
new
Thread
(()
=>
ProcessingCardPicture
(
pic
)).
Start
();
}
if
(
pic
.
type
==
GameTextureType
.
card_verticle_drawing
)
{
try
{
ProcessingVerticleDrawing
(
pic
);
}
catch
(
Exception
e
)
{
Debug
.
Log
(
"e 3"
+
e
.
ToString
());
}
_sem
.
WaitOne
();
new
Thread
(()
=>
ProcessingVerticleDrawing
(
pic
)).
Start
();
}
}
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
Debug
.
Log
(
"erroe 1"
+
e
.
ToString
());
}
...
...
@@ -270,96 +253,57 @@ public class GameTextureManager
private
static
void
ProcessingCardFeature
(
PictureResource
pic
)
{
if
(
File
.
Exists
(
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
))
{
string
path
=
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
;
#
if
UNITY_EDITOR
||
UNITY_STANDALONE_WIN
//编译器、Windows
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
int
left
;
int
right
;
int
up
;
int
down
;
CutTop
(
bitmap
,
out
left
,
out
right
,
out
up
,
out
down
);
up
=
CutLeft
(
bitmap
,
up
);
down
=
CutRight
(
bitmap
,
down
);
right
=
CutButton
(
bitmap
,
right
);
int
width
=
right
-
left
;
int
height
=
down
-
up
;
pic
.
hashed_data
=
new
float
[
width
,
height
,
4
];
for
(
int
w
=
0
;
w
<
width
;
w
++)
{
for
(
int
h
=
0
;
h
<
height
;
h
++)
{
System
.
Drawing
.
Color
color
=
bitmap
.
GetPixel
(
left
+
w
,
up
+
h
);
float
a
=
(
float
)
color
.
A
/
255f
;
if
(
w
<
40
)
if
(
a
>
(
float
)
w
/
(
float
)
40
)
a
=
(
float
)
w
/
(
float
)
40
;
if
(
w
>
(
width
-
40
))
if
(
a
>
1f
-
(
float
)(
w
-
(
width
-
40
))
/
(
float
)
40
)
a
=
1f
-
(
float
)(
w
-
(
width
-
40
))
/
(
float
)
40
;
if
(
h
<
40
)
if
(
a
>
(
float
)
h
/
(
float
)
40
)
a
=
(
float
)
h
/
(
float
)
40
;
if
(
h
>
(
height
-
40
))
if
(
a
>
1f
-
(
float
)(
h
-
(
height
-
40
))
/
(
float
)
40
)
a
=
1f
-
(
float
)(
h
-
(
height
-
40
))
/
(
float
)
40
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
0
]
=
(
float
)
color
.
R
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
1
]
=
(
float
)
color
.
G
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
2
]
=
(
float
)
color
.
B
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
3
]
=
a
;
}
}
caculateK
(
pic
);
/*
* 以上处理其他平台无法正常使用
* 暂时只能直接贴图,以后再处理
*/
#
elif
UNITY_ANDROID
||
UNITY_IPHONE
//Android、iPhone
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
}
pic
.
data
=
data
;
#
endif
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
}
else
try
{
string
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
bool
Iam8
=
false
;
if
(!
File
.
Exists
(
path
))
if
(
File
.
Exists
(
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
))
{
Iam8
=
true
;
path
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
pic
.
hashed_data
=
new
float
[
10
,
10
,
4
];
for
(
int
w
=
0
;
w
<
10
;
w
++)
string
path
=
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
;
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
int
left
;
int
right
;
int
up
;
int
down
;
CutTop
(
bitmap
,
out
left
,
out
right
,
out
up
,
out
down
);
up
=
CutLeft
(
bitmap
,
up
);
down
=
CutRight
(
bitmap
,
down
);
right
=
CutButton
(
bitmap
,
right
);
int
width
=
right
-
left
;
int
height
=
down
-
up
;
pic
.
hashed_data
=
new
float
[
width
,
height
,
4
];
for
(
int
w
=
0
;
w
<
width
;
w
++)
{
for
(
int
h
=
0
;
h
<
10
;
h
++)
for
(
int
h
=
0
;
h
<
height
;
h
++)
{
pic
.
hashed_data
[
w
,
h
,
0
]
=
0
;
pic
.
hashed_data
[
w
,
h
,
1
]
=
0
;
pic
.
hashed_data
[
w
,
h
,
2
]
=
0
;
pic
.
hashed_data
[
w
,
h
,
3
]
=
0
;
System
.
Drawing
.
Color
color
=
bitmap
.
GetPixel
(
left
+
w
,
up
+
h
);
float
a
=
(
float
)
color
.
A
/
255f
;
if
(
w
<
40
)
if
(
a
>
(
float
)
w
/
(
float
)
40
)
a
=
(
float
)
w
/
(
float
)
40
;
if
(
w
>
(
width
-
40
))
if
(
a
>
1f
-
(
float
)(
w
-
(
width
-
40
))
/
(
float
)
40
)
a
=
1f
-
(
float
)(
w
-
(
width
-
40
))
/
(
float
)
40
;
if
(
h
<
40
)
if
(
a
>
(
float
)
h
/
(
float
)
40
)
a
=
(
float
)
h
/
(
float
)
40
;
if
(
h
>
(
height
-
40
))
if
(
a
>
1f
-
(
float
)(
h
-
(
height
-
40
))
/
(
float
)
40
)
a
=
1f
-
(
float
)(
h
-
(
height
-
40
))
/
(
float
)
40
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
0
]
=
(
float
)
color
.
R
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
1
]
=
(
float
)
color
.
G
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
2
]
=
(
float
)
color
.
B
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
3
]
=
a
;
}
}
caculateK
(
pic
);
/*
* 以上处理其他平台无法正常使用
* 暂时只能直接贴图,以后再处理
*/
#elif UNITY_ANDROID || UNITY_IPHONE //Android、iPhone
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
}
pic
.
data
=
data
;
#endif
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
...
...
@@ -367,40 +311,90 @@ public class GameTextureManager
}
else
{
pic
.
hashed_data
=
getCuttedPic
(
path
,
pic
.
pCard
,
Iam8
);
int
width
=
pic
.
hashed_data
.
GetLength
(
0
);
int
height
=
pic
.
hashed_data
.
GetLength
(
1
);
int
size
=
(
int
)(
height
*
0.8
);
int
empWidth
=
(
width
-
size
)
/
2
;
int
empHeight
=
(
height
-
size
)
/
2
;
int
right
=
width
-
empWidth
;
int
buttom
=
height
-
empHeight
;
for
(
int
w
=
0
;
w
<
width
;
w
++)
string
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
for
(
int
h
=
0
;
h
<
height
;
h
++)
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
bool
Iam8
=
false
;
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
pic
.
hashed_data
=
new
float
[
10
,
10
,
4
];
for
(
int
w
=
0
;
w
<
10
;
w
++)
{
float
a
=
pic
.
hashed_data
[
w
,
h
,
3
];
if
(
w
<
empWidth
)
if
(
a
>
((
float
)
w
)
/
(
float
)
empWidth
)
a
=
((
float
)
w
)
/
(
float
)
empWidth
;
if
(
h
<
empHeight
)
if
(
a
>
((
float
)
h
)
/
(
float
)
empHeight
)
a
=
((
float
)
h
)
/
(
float
)
empHeight
;
if
(
w
>
right
)
if
(
a
>
1f
-
((
float
)(
w
-
right
))
/
(
float
)
empWidth
)
a
=
1f
-
((
float
)(
w
-
right
))
/
(
float
)
empWidth
;
if
(
h
>
buttom
)
if
(
a
>
1f
-
((
float
)(
h
-
buttom
))
/
(
float
)
empHeight
)
a
=
1f
-
((
float
)(
h
-
buttom
))
/
(
float
)
empHeight
;
pic
.
hashed_data
[
w
,
h
,
3
]
=
a
*
0.7f
;
for
(
int
h
=
0
;
h
<
10
;
h
++)
{
pic
.
hashed_data
[
w
,
h
,
0
]
=
0
;
pic
.
hashed_data
[
w
,
h
,
1
]
=
0
;
pic
.
hashed_data
[
w
,
h
,
2
]
=
0
;
pic
.
hashed_data
[
w
,
h
,
3
]
=
0
;
}
}
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
}
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
else
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
pic
.
hashed_data
=
getCuttedPic
(
path
,
pic
.
pCard
,
Iam8
);
int
width
=
pic
.
hashed_data
.
GetLength
(
0
);
int
height
=
pic
.
hashed_data
.
GetLength
(
1
);
int
size
=
(
int
)(
height
*
0.8
);
int
empWidth
=
(
width
-
size
)
/
2
;
int
empHeight
=
(
height
-
size
)
/
2
;
int
right
=
width
-
empWidth
;
int
buttom
=
height
-
empHeight
;
for
(
int
w
=
0
;
w
<
width
;
w
++)
{
for
(
int
h
=
0
;
h
<
height
;
h
++)
{
float
a
=
pic
.
hashed_data
[
w
,
h
,
3
];
if
(
w
<
empWidth
)
if
(
a
>
((
float
)
w
)
/
(
float
)
empWidth
)
a
=
((
float
)
w
)
/
(
float
)
empWidth
;
if
(
h
<
empHeight
)
if
(
a
>
((
float
)
h
)
/
(
float
)
empHeight
)
a
=
((
float
)
h
)
/
(
float
)
empHeight
;
if
(
w
>
right
)
if
(
a
>
1f
-
((
float
)(
w
-
right
))
/
(
float
)
empWidth
)
a
=
1f
-
((
float
)(
w
-
right
))
/
(
float
)
empWidth
;
if
(
h
>
buttom
)
if
(
a
>
1f
-
((
float
)(
h
-
buttom
))
/
(
float
)
empHeight
)
a
=
1f
-
((
float
)(
h
-
buttom
))
/
(
float
)
empHeight
;
pic
.
hashed_data
[
w
,
h
,
3
]
=
a
*
0.7f
;
}
}
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
}
}
}
catch
(
Exception
e
)
{
Debug
.
Log
(
"e 1"
+
e
.
ToString
());
}
finally
{
_sem
.
Release
();
}
}
private
static
void
caculateK
(
PictureResource
pic
)
...
...
@@ -439,7 +433,7 @@ public class GameTextureManager
int
width
=
pic
.
hashed_data
.
GetLength
(
0
);
int
height
=
pic
.
hashed_data
.
GetLength
(
1
);
int
h
=
0
;
for
(
h
=
height
-
1
;
h
>
0
;
h
--)
for
(
h
=
height
-
1
;
h
>
0
;
h
--)
{
int
all
=
0
;
for
(
int
w
=
0
;
w
<
width
;
w
++)
...
...
@@ -454,7 +448,7 @@ public class GameTextureManager
break
;
}
}
pic
.
k
=((
float
)
h
)
/
((
float
)
height
);
pic
.
k
=
((
float
)
h
)
/
((
float
)
height
);
if
(
pic
.
k
>
1
)
{
pic
.
k
=
1f
;
...
...
@@ -465,12 +459,12 @@ public class GameTextureManager
}
}
private
static
float
[,,]
getCuttedPic
(
string
path
,
bool
pCard
,
bool
EightEdition
)
private
static
float
[,,]
getCuttedPic
(
string
path
,
bool
pCard
,
bool
EightEdition
)
{
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
int
left
=
0
,
top
=
0
,
right
=
bitmap
.
colors
.
GetLength
(
0
),
buttom
=
bitmap
.
colors
.
GetLength
(
1
);
//right is width and buttom is height now
if
(
EightEdition
)
if
(
EightEdition
)
{
if
(
pCard
)
{
...
...
@@ -594,148 +588,146 @@ public class GameTextureManager
private
static
void
ProcessingVerticleDrawing
(
PictureResource
pic
)
{
string
path
=
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
try
{
#
if
UNITY_EDITOR
||
UNITY_STANDALONE_WIN
//编译器、Windows
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
bool
Iam8
=
false
;
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
path
=
"textures/unknown.jpg"
;
//YGOMobile Paths
}
string
path
=
"picture/closeup/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
return
;
}
pic
.
hashed_data
=
getCuttedPic
(
path
,
pic
.
pCard
,
Iam8
);
softVtype
(
pic
,
0.5f
);
pic
.
k
=
1
;
//pic.autoMade = true;
/*
* 以上处理其他平台无法正常使用
* 暂时只能直接贴图,以后再处理
*/
#
elif
UNITY_ANDROID
||
UNITY_IPHONE
//Android、iPhone
path
=
"picture/null.png"
;
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
}
pic
.
data
=
data
;
//#elif UNITY_IPHONE //iPhone Test (Android not support)
//path = Application.streamingAssetsPath + "/closeup/" + pic.code.ToString() + ".png";
//if (File.Exists(path))
//{
// www = new WWW(path);
// byte[] data = www.bytes;
// pic.data = data;
//} else {
// path = Application.streamingAssetsPath + "/null.png"
// www = new WWW(path);
// byte[] data = www.bytes;
// pic.data = data;
//}
#
endif
}
else
{
#
if
UNITY_EDITOR
||
UNITY_STANDALONE_WIN
//编译器、Windows
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
int
left
;
int
right
;
int
up
;
int
down
;
CutTop
(
bitmap
,
out
left
,
out
right
,
out
up
,
out
down
);
up
=
CutLeft
(
bitmap
,
up
);
down
=
CutRight
(
bitmap
,
down
);
right
=
CutButton
(
bitmap
,
right
);
int
width
=
right
-
left
;
int
height
=
down
-
up
;
pic
.
hashed_data
=
new
float
[
width
,
height
,
4
];
for
(
int
w
=
0
;
w
<
width
;
w
++)
{
for
(
int
h
=
0
;
h
<
height
;
h
++)
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
System
.
Drawing
.
Color
color
=
bitmap
.
GetPixel
(
left
+
w
,
up
+
h
);
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
0
]
=
(
float
)
color
.
R
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
1
]
=
(
float
)
color
.
G
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
2
]
=
(
float
)
color
.
B
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
3
]
=
(
float
)
color
.
A
/
255f
;
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
}
float
wholeUNalpha
=
0
;
for
(
int
w
=
0
;
w
<
width
;
w
++)
{
if
(
pic
.
hashed_data
[
w
,
0
,
3
]
>
0.1f
)
bool
Iam8
=
false
;
if
(!
File
.
Exists
(
path
))
{
wholeUNalpha
+=
((
float
)
Math
.
Abs
(
w
-
width
/
2
))
/
((
float
)(
width
/
2
));
Iam8
=
true
;
path
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(
pic
.
hashed_data
[
w
,
height
-
1
,
3
]
>
0.1f
)
if
(
!
File
.
Exists
(
path
)
)
{
wholeUNalpha
+=
1
;
Iam8
=
true
;
path
=
"pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
}
for
(
int
h
=
0
;
h
<
height
;
h
++)
{
if
(
pic
.
hashed_data
[
0
,
h
,
3
]
>
0.1f
)
if
(!
File
.
Exists
(
path
))
{
Iam8
=
true
;
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
wholeUNalpha
+=
1
;
path
=
"textures/unknown.jpg"
;
//YGOMobile Paths
}
if
(
pic
.
hashed_data
[
width
-
1
,
h
,
3
]
>
0.1f
)
if
(
!
File
.
Exists
(
path
)
)
{
wholeUNalpha
+=
1
;
path
=
"picture/null.png"
;
}
pic
.
hashed_data
=
getCuttedPic
(
path
,
pic
.
pCard
,
Iam8
);
softVtype
(
pic
,
0.5f
);
pic
.
k
=
1
;
//pic.autoMade = true;
/*
* 以上处理其他平台无法正常使用
* 暂时只能直接贴图,以后再处理
*/
#elif UNITY_ANDROID || UNITY_IPHONE //Android、iPhone
path
=
"picture/null.png"
;
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
}
pic
.
data
=
data
;
#endif
}
if
(
wholeUNalpha
>=
((
width
+
height
)
*
0.5f
*
0.12f
))
else
{
softVtype
(
pic
,
0.7f
);
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
BitmapHelper
bitmap
=
new
BitmapHelper
(
path
);
int
left
;
int
right
;
int
up
;
int
down
;
CutTop
(
bitmap
,
out
left
,
out
right
,
out
up
,
out
down
);
up
=
CutLeft
(
bitmap
,
up
);
down
=
CutRight
(
bitmap
,
down
);
right
=
CutButton
(
bitmap
,
right
);
int
width
=
right
-
left
;
int
height
=
down
-
up
;
pic
.
hashed_data
=
new
float
[
width
,
height
,
4
];
for
(
int
w
=
0
;
w
<
width
;
w
++)
{
for
(
int
h
=
0
;
h
<
height
;
h
++)
{
System
.
Drawing
.
Color
color
=
bitmap
.
GetPixel
(
left
+
w
,
up
+
h
);
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
0
]
=
(
float
)
color
.
R
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
1
]
=
(
float
)
color
.
G
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
2
]
=
(
float
)
color
.
B
/
255f
;
pic
.
hashed_data
[
w
,
height
-
h
-
1
,
3
]
=
(
float
)
color
.
A
/
255f
;
}
}
float
wholeUNalpha
=
0
;
for
(
int
w
=
0
;
w
<
width
;
w
++)
{
if
(
pic
.
hashed_data
[
w
,
0
,
3
]
>
0.1f
)
{
wholeUNalpha
+=
((
float
)
Math
.
Abs
(
w
-
width
/
2
))
/
((
float
)(
width
/
2
));
}
if
(
pic
.
hashed_data
[
w
,
height
-
1
,
3
]
>
0.1f
)
{
wholeUNalpha
+=
1
;
}
}
for
(
int
h
=
0
;
h
<
height
;
h
++)
{
if
(
pic
.
hashed_data
[
0
,
h
,
3
]
>
0.1f
)
{
wholeUNalpha
+=
1
;
}
if
(
pic
.
hashed_data
[
width
-
1
,
h
,
3
]
>
0.1f
)
{
wholeUNalpha
+=
1
;
}
}
if
(
wholeUNalpha
>=
((
width
+
height
)
*
0.5f
*
0.12f
))
{
softVtype
(
pic
,
0.7f
);
}
caculateK
(
pic
);
/*
* 以上处理其他平台无法正常使用
* 暂时只能直接贴图,以后再处理
*/
#elif UNITY_ANDROID || UNITY_IPHONE //Android、iPhone
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
}
pic
.
data
=
data
;
#endif
}
caculateK
(
pic
);
/*
* 以上处理其他平台无法正常使用
* 暂时只能直接贴图,以后再处理
*/
#
elif
UNITY_ANDROID
||
UNITY_IPHONE
//Android、iPhone
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
pic
.
data
=
data
;
#
endif
}
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
catch
(
Exception
e
)
{
Debug
.
Log
(
"e 3"
+
e
.
ToString
());
}
finally
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
_sem
.
Release
(
);
}
}
...
...
@@ -791,64 +783,75 @@ public class GameTextureManager
private
static
void
ProcessingCardPicture
(
PictureResource
pic
)
{
string
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
path
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
path
=
"pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
)
&&
pic
.
code
!=
0
&&
Program
.
DownloadImage
)
{
//YGOMobile (177x254)
df
.
Download
(
"http://download.ygo2019.xyz/ygopro/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
,
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
);
path
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
)
&&
pic
.
code
!=
0
&&
Program
.
DownloadImage
)
{
//先行卡 (177x254)
df
.
Download
(
"http://download.ygo2019.xyz/ygopro2-data/expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
,
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
);
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
try
{
if
(
pic
.
code
>
0
)
string
path
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".png"
;
if
(!
File
.
Exists
(
path
))
{
p
ic
.
u_data
=
unknown
;
p
ath
=
"picture/card/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
else
if
(!
File
.
Exists
(
path
))
{
p
ic
.
u_data
=
myBack
;
p
ath
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)
))
if
(!
File
.
Exists
(
path
))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
)
;
path
=
"pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
}
else
{
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
)
)
if
(!
File
.
Exists
(
path
))
{
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
)
&&
pic
.
code
!=
0
&&
Program
.
DownloadImage
)
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
d
ata
=
new
byte
[
file
.
Length
]
;
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
)
;
//YGOMobile (177x254)
d
f
.
Download
(
"http://api.ygo2019.xyz/ygopro/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
,
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
)
;
path
=
"expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
pic
.
data
=
data
;
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
if
(!
File
.
Exists
(
path
)
&&
pic
.
code
!=
0
&&
Program
.
DownloadImage
)
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
//先行卡 (177x254)
df
.
Download
(
"http://download.ygo2019.xyz/ygopro2-data/expansions/pics/"
+
pic
.
code
.
ToString
()
+
".jpg"
,
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
);
path
=
"picture/cardIn8thEdition/"
+
pic
.
code
.
ToString
()
+
".jpg"
;
}
if
(!
File
.
Exists
(
path
))
{
if
(
pic
.
code
>
0
)
{
pic
.
u_data
=
unknown
;
}
else
{
pic
.
u_data
=
myBack
;
}
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
}
else
{
byte
[]
data
;
using
(
FileStream
file
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
file
.
Seek
(
0
,
SeekOrigin
.
Begin
);
data
=
new
byte
[
file
.
Length
];
file
.
Read
(
data
,
0
,
(
int
)
file
.
Length
);
}
pic
.
data
=
data
;
if
(!
loadedList
.
ContainsKey
(
hashPic
(
pic
.
code
,
pic
.
type
)))
{
loadedList
.
Add
(
hashPic
(
pic
.
code
,
pic
.
type
),
pic
);
}
}
}
catch
(
Exception
e
)
{
Debug
.
Log
(
"e 2"
+
e
.
ToString
());
}
finally
{
_sem
.
Release
();
}
}
...
...
@@ -932,7 +935,7 @@ public class GameTextureManager
return
ret
;
}
public
static
bool
uiLoaded
=
false
;
public
static
bool
uiLoaded
=
false
;
public
static
Texture2D
get
(
string
name
)
{
...
...
@@ -1004,9 +1007,9 @@ public class GameTextureManager
ts
=
UIHelper
.
getTexture2D
(
"textures/duel/phase/ts.png"
);
//YGOMobile Paths
N
=
new
Texture2D
(
10
,
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
a
=
0
;
a
<
10
;
a
++)
for
(
int
a
=
0
;
a
<
10
;
a
++)
{
N
.
SetPixel
(
i
,
a
,
new
UnityEngine
.
Color
(
0
,
0
,
0
,
0
));
}
...
...
@@ -1016,7 +1019,7 @@ public class GameTextureManager
{
ColorUtility
.
TryParseHtmlString
(
File
.
ReadAllText
(
"textures/duel/chainColor.txt"
),
out
chainColor
);
//YGOMobile Paths
}
catch
(
Exception
)
catch
(
Exception
)
{
}
...
...
Assets/SibylSystem/ResourceManagers/HttpDldFile.cs
View file @
68b5410a
...
...
@@ -10,25 +10,36 @@ using UnityEngine;
public
class
HttpDldFile
{
private
readonly
System
.
Threading
.
Semaphore
semaphore
=
new
System
.
Threading
.
Semaphore
(
6
,
6
);
public
bool
Download
(
string
url
,
string
filename
)
{
bool
flag
=
false
;
try
{
if
(!
Directory
.
Exists
(
Path
.
GetDirectoryName
(
filename
))){
Directory
.
CreateDirectory
(
Path
.
GetDirectoryName
(
filename
));
}
using
(
var
client
=
new
WebClient
())
{
ServicePointManager
.
ServerCertificateValidationCallback
=
MyRemoteCertificateValidationCallback
;
//client.Headers.Add(HttpRequestHeader.Authorization, string.Concat("token ", RepoData.GetToken()));
client
.
Headers
.
Add
(
HttpRequestHeader
.
ContentType
,
"application/x-www-form-urlencoded; charset=UTF-8"
);
client
.
Headers
.
Add
(
HttpRequestHeader
.
UserAgent
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063"
);
client
.
DownloadFile
(
new
Uri
(
url
),
filename
+
".tmp"
);
}
flag
=
true
;
if
(
File
.
Exists
(
filename
))
if
(!
Directory
.
Exists
(
Path
.
GetDirectoryName
(
filename
)))
{
Directory
.
CreateDirectory
(
Path
.
GetDirectoryName
(
filename
));
}
using
(
var
client
=
new
TimeoutWebClient
())
{
ServicePointManager
.
ServerCertificateValidationCallback
=
MyRemoteCertificateValidationCallback
;
//authorization needed to acces github
if
(
Path
.
GetExtension
(
filename
).
Contains
(
"png"
))
{
//client.Headers.Add(HttpRequestHeader.Authorization, string.Concat("token ", RepoData.GetToken()));
client
.
Timeout
=
6500
;
}
if
(
Path
.
GetExtension
(
filename
).
Contains
(
"jpg"
))
{
client
.
Timeout
=
3500
;
}
semaphore
.
WaitOne
();
client
.
DownloadFile
(
new
Uri
(
url
),
filename
+
".tmp"
);
}
flag
=
true
;
if
(
File
.
Exists
(
filename
))
{
File
.
Delete
(
filename
);
}
...
...
@@ -38,6 +49,10 @@ public class HttpDldFile
{
flag
=
false
;
}
finally
{
semaphore
.
Release
();
}
return
flag
;
}
public
static
bool
MyRemoteCertificateValidationCallback
(
System
.
Object
sender
,
...
...
@@ -68,5 +83,25 @@ public class HttpDldFile
}
return
isOk
;
}
}
public
class
TimeoutWebClient
:
WebClient
{
public
int
Timeout
{
get
;
set
;
}
public
TimeoutWebClient
()
{
Timeout
=
10000
;
}
public
TimeoutWebClient
(
int
timeout
)
{
Timeout
=
timeout
;
}
protected
override
WebRequest
GetWebRequest
(
Uri
address
)
{
WebRequest
request
=
base
.
GetWebRequest
(
address
);
request
.
Timeout
=
Timeout
;
return
request
;
}
}
\ No newline at end of file
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