Commit 2960cc1f authored by nanahira's avatar nanahira

Merge branch 'Android' of https://github.com/Unicorn369/YGOPro2_Droid into Android

parents d0397c23 5faaf46a
......@@ -58,3 +58,4 @@ strings.conf
AI_core_vs2017solution/core.VC.db
AI_core_vs2017solution/core.VC.VC.opendb
AI_core_vs2017solution/System.Servicemodel.Faltexception.dll
Assets/StreamingAssets/update.zip*
......@@ -144,13 +144,13 @@ public class Menu : WindowServantSP
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.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");
if (!File.Exists("updates/closeup_version1.2.txt")) {//用于检查更新
if (File.Exists("closeup_version1.2.zip")) {//如果有则直接解压
jo.Call("doExtractZipFile", "closeup_version1.2.zip", Program.ANDROID_GAME_PATH);
} else if (File.Exists("updates/closeup_version1.1.txt")){//如果有则下载更新包
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/up_closeup_version1.2.zip");
} else {//否则下载并解压,锁定目录:ANDROID_GAME_PATH
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.1.zip");
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.2.zip");
}
} else {
jo.Call("showToast", "已下载,无需再次下载!");
......
......@@ -334,7 +334,7 @@ public static class TcpHelper
deckStrings.Clear();
Package message = new Package();
message.Fuction = (int)CtosMessage.JoinGame;
Config.ClientVersion = (uint)GameStringManager.helper_stringToInt(version);
//Config.ClientVersion = (uint)GameStringManager.helper_stringToInt(version);
message.Data.writer.Write((Int16)Config.ClientVersion);
message.Data.writer.Write((byte)204);
message.Data.writer.Write((byte)204);
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using UnityEngine;
using YGOSharp.OCGWrapper.Enums;
public class Ocgcore : ServantWithCardDescription
......@@ -3250,18 +3251,32 @@ public class Ocgcore : ServantWithCardDescription
code = r.ReadInt32();
gps = r.ReadShortGPS();
r.ReadByte();
int cr = 95;
if (Config.ClientVersion >= 0x233c)
{
int cp = r.ReadInt32();
if (cp > 0)
cr = cp;
}
desc = GameStringManager.get(cr);
int cr = r.ReadInt32();
card = GCS_cardGet(gps, false);
desc = desc.Replace("[%ls]", "「" + card.get_data().Name + "」");
if (card != null)
{
string displayname = "「" + card.get_data().Name + "」";
if (cr == 0)
{
desc = GameStringManager.get(200);
Regex forReplaceFirst = new Regex("\\[%ls\\]");
desc = forReplaceFirst.Replace(desc, GameStringManager.formatLocation(gps), 1);
desc = forReplaceFirst.Replace(desc, displayname, 1);
}
else if (cr == 221)
{
desc = GameStringManager.get(221);
Regex forReplaceFirst = new Regex("\\[%ls\\]");
desc = forReplaceFirst.Replace(desc, GameStringManager.formatLocation(gps), 1);
desc = forReplaceFirst.Replace(desc, displayname, 1);
desc = desc + "\n" + GameStringManager.get(223);
}
else
{
desc = GameStringManager.get(cr);
Regex forReplaceFirst = new Regex("\\[%ls\\]");
desc = forReplaceFirst.Replace(desc, displayname, 1);
}
string hin = ES_hint + ",\n" + desc;
RMSshow_yesOrNo("return", hin, new messageSystemValue { value = "1", hint = "yes" }, new messageSystemValue { value = "0", hint = "no" });
card.add_one_decoration(Program.I().mod_ocgcore_decoration_chain_selecting, 4, Vector3.zero, "chain_selecting");
......
......@@ -295,7 +295,7 @@ public class Program : MonoBehaviour
#elif UNITY_ANDROID //Android
/**
* public String GamePath(String path) {
* GAME_DIR = Environment.getExternalStorageDirectory().toString(); + path;
* GAME_DIR = Environment.getExternalStorageDirectory().toString() + path;
* return GAME_DIR;
* }
*/
......@@ -304,7 +304,7 @@ public class Program : MonoBehaviour
Screen.sleepTimeout = SleepTimeout.NeverSleep;
if (!File.Exists(ANDROID_GAME_PATH + "updates/version2.2.txt"))
{
string filePath = Application.streamingAssetsPath + "/ygocore.zip";
string filePath = Application.streamingAssetsPath + "/ygopro2-data.zip";
var www = new WWW(filePath);
while (!www.isDone) { }
byte[] bytes = www.bytes;
......@@ -321,7 +321,17 @@ public class Program : MonoBehaviour
byte[] bytes = www.bytes;
ExtractZipFile(bytes, ANDROID_GAME_PATH);
}
/* //选择性更新
if (!File.Exists(ANDROID_GAME_PATH + "updates/version2.2.2.txt"))
{
string filePath = Application.streamingAssetsPath + "/update.zip";
var www = new WWW(filePath);
while (!www.isDone) { }
byte[] bytes = www.bytes;
ExtractZipFile(bytes, ANDROID_GAME_PATH);
//File.Create(ANDROID_GAME_PATH + ".nomedia");
}
*/
Environment.CurrentDirectory = ANDROID_GAME_PATH;
System.IO.Directory.SetCurrentDirectory(ANDROID_GAME_PATH);
......@@ -329,8 +339,8 @@ public class Program : MonoBehaviour
string GamePaths = Application.persistentDataPath + "/ygopro2/";
if (!File.Exists(GamePaths + "updates/version2.2.txt"))
{
string filePath = Application.streamingAssetsPath + "/ygocore.zip";
ExtractZipFile(System.IO.File.ReadAllBytes(filePath), GamePaths);
string filePath = Application.streamingAssetsPath + "/ygopro2-data.zip";
ExtractZipFile(System.IO.File.ReadAllBytes(filePath), GamePaths);
}
Environment.CurrentDirectory = GamePaths;
System.IO.Directory.SetCurrentDirectory(GamePaths);
......@@ -417,26 +427,26 @@ public class Program : MonoBehaviour
loadResources();
#if !UNITY_EDITOR && UNITY_ANDROID //Android Java Test
if (!File.Exists("updates/image_version1.1.txt"))//用于检查更新
if (!File.Exists("updates/image_version1.2.txt"))//用于检查更新
{
if (File.Exists("pics.zip")) {//YGOMobile内置的卡图包
if (File.Exists("pics.zip")) {
jo.Call("doExtractZipFile", "pics.zip", ANDROID_GAME_PATH);
File.Copy("updates/version2.0.txt", "updates/image_version1.1.txt", true);
File.Copy("updates/version2.0.txt", "updates/image_version1.2.txt", true);
} else {
//Application.OpenURL("https://www.taptap.com/app/37972");
jo.Call("showToast", "没有发现卡图包,是否未安装YGOMobile");
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/pics.zip");
}
}
/**
* 使用Termux编译生成的:libgdiplus.so (https://github.com/Unicorn369/libgdiplus-Android)
* 经测试,只有Android 6.0以上才能正常使用。为了让Android 6.0以下的也能凑合使用立绘效果,需做判断
* 部分6.0机型可能无法正常使用,如需支持需要额外判断型号:华为、OPPO、VIVO、乐视等机型
*
* public boolean APIVersion() {
* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
* return true;
* } else {
* return true;
* return false;
* }
* }
*/
......@@ -1052,7 +1062,7 @@ public class Program : MonoBehaviour
_padScroll = 0;
}
GUI.Label(new Rect(10, 5, 200, 200), "[Version 2.2] " + "FPS: " + m_FPS);
GUI.Label(new Rect(10, 5, 200, 200), "[Ver 2.2.2] " + "FPS: " + m_FPS);
}
void Update()
......
......@@ -12,7 +12,7 @@ public static class GameStringManager
public static List<hashedString> hashedStrings = new List<hashedString>();
public static List<hashedString> xilies = new List<hashedString>();
public static List<hashedString> xilies = new List<hashedString>();
public static int helper_stringToInt(string str)
{
......@@ -86,7 +86,7 @@ public static class GameStringManager
return re;
}
internal static string get_unsafe(int hashCode)
internal static string get_unsafe(int hashCode)
{
string re = "";
foreach (hashedString s in hashedStrings)
......@@ -100,7 +100,7 @@ public static class GameStringManager
return re;
}
internal static string get(int description)
internal static string get(int description)
{
string a = "";
if (description < 10000)
......@@ -122,5 +122,30 @@ public static class GameStringManager
}
return a;
}
internal static string formatLocation(uint location, uint sequence)
{
if (location == 0x8)
{
if (sequence < 5)
return get(1003);
else if (sequence == 5)
return get(1008);
else
return get(1009);
}
uint filter = 1;
int i = 1000;
for (; filter != 0x100 && filter != location; filter <<= 1)
++i;
if (filter == location)
return get(i);
else
return "???";
}
internal static string formatLocation(GPS gps)
{
return formatLocation(gps.location, gps.sequence);
}
}
......@@ -530,14 +530,16 @@ public class Room : WindowServantSP
}
UIHelper.shiftButton(startButton(), true);
lazyRoom.start.localScale = Vector3.one;
lazyRoom.ready.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f + 30f, 0);
lazyRoom.duelist.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f, 0);
lazyRoom.observer.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f-30f, 0);
lazyRoom.observer.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f, 0);
lazyRoom.start.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f - 30f, 0);
}
else
{
UIHelper.shiftButton(startButton(), false);
lazyRoom.start.localScale = Vector3.zero;
lazyRoom.ready.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f, 0);
lazyRoom.duelist.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f, 0);
lazyRoom.observer.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f - 30f, 0);
lazyRoom.start.localPosition = new Vector3(lazyRoom.duelist.localPosition.x, -94.2f - 30f - 30f - 30f, 0);
......@@ -747,9 +749,9 @@ public class Room : WindowServantSP
r.ReadByte();
r.ReadByte();
code = r.ReadInt32();
string hexOutput = "0x"+String.Format("{0:X}", code);
Program.I().selectServer.set_version(hexOutput);
RMSshow_none(InterString.Get("你输入的版本号和服务器不一致,[7CFC00]KoishiPro2已经智能切换版本号[-],请重新链接。"));
//string hexOutput = "0x"+String.Format("{0:X}", code);
//Program.I().selectServer.set_version(hexOutput);
//RMSshow_none(InterString.Get("你输入的版本号和服务器不一致,[7CFC00]YGOPro2已经智能切换版本号[-],请重新链接。"));
break;
default:
break;
......@@ -1021,6 +1023,7 @@ public class Room : WindowServantSP
UIHelper.registUIEventTriggerForClick(exitButton().gameObject, listenerForClicked);
UIHelper.registUIEventTriggerForClick(duelistButton().gameObject, listenerForClicked);
UIHelper.registUIEventTriggerForClick(observerButton().gameObject, listenerForClicked);
UIHelper.registUIEventTriggerForClick(readyButton().gameObject, listenerForClicked);
realize();
superScrollView.refreshForOneFrame();
}
......@@ -1067,12 +1070,32 @@ public class Room : WindowServantSP
return UIHelper.getByName<UIButton>(gameObject, "observer_");
}
private UIButton readyButton()
{
return UIHelper.getByName<UIButton>(gameObject, "ready_");
}
void listenerForClicked(GameObject gameObjectListened)
{
if (gameObjectListened.name == "exit_")
{
Program.I().ocgcore.onExit();
}
if (gameObjectListened.name == "ready_")
{
if (selftype < realPlayers.Length && realPlayers[selftype] != null)
{
if (realPlayers[selftype].getIfPreped())
{
TcpHelper.CtosMessage_HsNotReady();
}
else
{
TcpHelper.CtosMessage_UpdateDeck(new YGOSharp.Deck("deck/" + Config.Get("deckInUse", "wizard") + ".ydk"));
TcpHelper.CtosMessage_HsReady();
}
}
}
if (gameObjectListened.name == "duelist_")
{
TcpHelper.CtosMessage_HsToDuelist();
......
......@@ -53,7 +53,7 @@ public class PrecyOcg
}
else
{
Config.ClientVersion = 0x233c;
//Config.ClientVersion = 0x233c;
Program.I().shiftToServant(Program.I().ocgcore);
}
((CardDescription)Program.I().cardDescription).setTitle(path);
......@@ -78,7 +78,7 @@ public class PrecyOcg
}
else
{
Config.ClientVersion = 0x233c;
//Config.ClientVersion = 0x233c;
Program.I().shiftToServant(Program.I().ocgcore);
}
}
......
......@@ -19,7 +19,6 @@ public class SelectServer : WindowServantSP
UIHelper.registEvent(gameObject, "exit_", onClickExit);
UIHelper.registEvent(gameObject, "face_", onClickFace);
UIHelper.registEvent(gameObject, "join_", onClickJoin);
//UIHelper.registEvent(gameObject, "roomList_", onClickRoomList);
UIHelper.getByName<UIInput>(gameObject, "name_").value = Config.Get("name","一秒一喵机会");
list = UIHelper.getByName<UIPopupList>(gameObject, "history_");
UIHelper.registEvent(gameObject,"history_", onSelected);
......@@ -27,7 +26,8 @@ public class SelectServer : WindowServantSP
inputIP = UIHelper.getByName<UIInput>(gameObject, "ip_");
inputPort = UIHelper.getByName<UIInput>(gameObject, "port_");
inputPsw = UIHelper.getByName<UIInput>(gameObject, "psw_");
inputVersion = UIHelper.getByName<UIInput>(gameObject, "version_");
//inputVersion = UIHelper.getByName<UIInput>(gameObject, "version_");
set_version("0x" + String.Format("{0:X}", Config.ClientVersion));
SetActiveFalse();
}
......@@ -76,7 +76,7 @@ public class SelectServer : WindowServantSP
inputIP.value = ip;
inputPort.value = port;
inputPsw.value = psw;
inputVersion.value = version;
//inputVersion.value = version;
}
public override void show()
......@@ -143,11 +143,6 @@ public class SelectServer : WindowServantSP
string portString = UIHelper.getByName<UIInput>(gameObject, "port_").value;
string pswString = UIHelper.getByName<UIInput>(gameObject, "psw_").value;
string versionString = UIHelper.getByName<UIInput>(gameObject, "version_").value;
if (versionString=="")
{
UIHelper.getByName<UIInput>(gameObject, "version_").value = "0x1349";
versionString = "0x1349";
}
KF_onlineGame(Name, ipString, portString, versionString, pswString);
}
......@@ -162,11 +157,6 @@ public class SelectServer : WindowServantSP
string portString = UIHelper.getByName<UIInput>(gameObject, "port_").value;
string pswString = "L";
string versionString = UIHelper.getByName<UIInput>(gameObject, "version_").value;
if (versionString == "")
{
UIHelper.getByName<UIInput>(gameObject, "version_").value = "0x1349";
versionString = "0x1349";
}
KF_onlineGame(Name, ipString, portString, versionString, pswString);
}
......
......@@ -594,7 +594,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 195152}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 300, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 419752}
......@@ -745,7 +745,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 196122}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3, y: 0, z: 0}
m_LocalPosition: {x: 303, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 428902}
......@@ -1762,7 +1762,7 @@ MonoBehaviour:
keepCrispWhenShrunk: 1
mTrueTypeFont: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
mFont: {fileID: 0}
mText: "\u623F\u95F4\u540D\uFF1A"
mText: "\u623F\u95F4\u5BC6\u7801\uFF1A"
mFontSize: 25
mFontStyle: 0
mAlignment: 1
......
......@@ -2,6 +2,7 @@
using System.Collections;
public class lazyRoom : MonoBehaviour {
public Transform ready;
public Transform duelist;
public Transform observer;
public Transform start;
......
This diff is collapsed.
......@@ -148,7 +148,7 @@ PlayerSettings:
tvOS: cn.ygopro2.ygopro2android
buildNumber:
iOS:
AndroidBundleVersionCode: 4
AndroidBundleVersionCode: 5
AndroidMinSdkVersion: 16
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 0
......
# Download game
https://github.com/Unicorn369/YGOPro2_Droid/releases
# You have just found ygopro v2 in Unity 3D!
YGOPro v2 is a card simulation game created in Unity Engine, with same protocol to ygopro.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment