|
|
@@ -11,37 +11,44 @@ public class LoginMgr : MonoBehaviour
|
|
|
|
|
|
public static UserInfo myUserInfo = new UserInfo();
|
|
|
|
|
|
- public void showRegisterView() {
|
|
|
+ public void showRegisterView()
|
|
|
+ {
|
|
|
loginView.SetActive(false);
|
|
|
registerView.SetActive(true);
|
|
|
forgetPWD_View.SetActive(false);
|
|
|
AgreenmentOption.ins.gameObject.SetActive(true);
|
|
|
}
|
|
|
|
|
|
- public void showLoginView() {
|
|
|
+ public void showLoginView()
|
|
|
+ {
|
|
|
loginView.SetActive(true);
|
|
|
registerView.SetActive(false);
|
|
|
forgetPWD_View.SetActive(false);
|
|
|
AgreenmentOption.ins.gameObject.SetActive(true);
|
|
|
}
|
|
|
|
|
|
- public void showForgetPWD_View() {
|
|
|
+ public void showForgetPWD_View()
|
|
|
+ {
|
|
|
loginView.SetActive(false);
|
|
|
registerView.SetActive(false);
|
|
|
forgetPWD_View.SetActive(true);
|
|
|
AgreenmentOption.ins.gameObject.SetActive(false);
|
|
|
}
|
|
|
public const string LoginTokenKey = "LoginToken";
|
|
|
- public static bool HasToken() {
|
|
|
+ public static bool HasToken()
|
|
|
+ {
|
|
|
string loginToken = PlayerPrefs.GetString(LoginMgr.LoginTokenKey, "");
|
|
|
return string.IsNullOrEmpty(loginToken) ? false : true;
|
|
|
}
|
|
|
|
|
|
- void Awake() {
|
|
|
+ void Awake()
|
|
|
+ {
|
|
|
transform.Find("AgreementPopup").gameObject.SetActive(true);
|
|
|
+ ViewMgr.Instance.DestroyAllViews();
|
|
|
}
|
|
|
}
|
|
|
-public class UserInfo {
|
|
|
+public class UserInfo
|
|
|
+{
|
|
|
public int id;
|
|
|
public int avatarID = 0;
|
|
|
public string nickname = "超级射手";
|
|
|
@@ -66,47 +73,61 @@ public class UserInfo {
|
|
|
{
|
|
|
try { UserComp.Instance.saveUserInfo(this); } catch (System.Exception e) { Debug.LogError(e.Message); }
|
|
|
}
|
|
|
- public void SetChallengeLevelPass(int gameType, int level) {
|
|
|
+ public void SetChallengeLevelPass(int gameType, int level)
|
|
|
+ {
|
|
|
if (gameType != 3 && gameType != 4 && gameType != 5) return;
|
|
|
- if (challengeLevels.ContainsKey(gameType)) {
|
|
|
- if (level <= challengeLevels[gameType]) {
|
|
|
+ if (challengeLevels.ContainsKey(gameType))
|
|
|
+ {
|
|
|
+ if (level <= challengeLevels[gameType])
|
|
|
+ {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
challengeLevels.Remove(gameType);
|
|
|
challengeLevels.Add(gameType, level);
|
|
|
}
|
|
|
- public int GetChallengeLevelPass(int gameType) {
|
|
|
- if (challengeLevels.ContainsKey(gameType)) {
|
|
|
+ public int GetChallengeLevelPass(int gameType)
|
|
|
+ {
|
|
|
+ if (challengeLevels.ContainsKey(gameType))
|
|
|
+ {
|
|
|
return challengeLevels[gameType];
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
//判断引导是否完成(服务端保存)
|
|
|
//index0: 新手引导NewUserGuide
|
|
|
- public bool IsGuideFinish(int index) {
|
|
|
- if (index == 0) {
|
|
|
+ public bool IsGuideFinish(int index)
|
|
|
+ {
|
|
|
+ if (index == 0)
|
|
|
+ {
|
|
|
return PlayerPrefs.GetInt("NewUserGuideFinish_" + LoginMgr.myUserInfo.id, 0) == 1;
|
|
|
}
|
|
|
char[] chars = guideRecord.ToCharArray();
|
|
|
- if (index < chars.Length) {
|
|
|
+ if (index < chars.Length)
|
|
|
+ {
|
|
|
return chars[index] == '1';
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- public void SaveGuideFinish(int index) {
|
|
|
- if (index == 0) {
|
|
|
+ public void SaveGuideFinish(int index)
|
|
|
+ {
|
|
|
+ if (index == 0)
|
|
|
+ {
|
|
|
PlayerPrefs.SetInt("NewUserGuideFinish_" + LoginMgr.myUserInfo.id, 1);
|
|
|
return;
|
|
|
}
|
|
|
char[] chars = guideRecord.ToCharArray();
|
|
|
- if (index < chars.Length) {
|
|
|
+ if (index < chars.Length)
|
|
|
+ {
|
|
|
if (chars[index] == '1') return;
|
|
|
chars[index] = '1';
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
int newLen = index + 1;
|
|
|
char[] newChars = new char[newLen];
|
|
|
- for (int i = 0; i < newLen; i++) {
|
|
|
+ for (int i = 0; i < newLen; i++)
|
|
|
+ {
|
|
|
newChars[i] = i < chars.Length ? chars[i] : '0';
|
|
|
}
|
|
|
newChars[index] = '1';
|
|
|
@@ -116,7 +137,8 @@ public class UserInfo {
|
|
|
UserPlayer.ins?.call("userComp.saveGuideRecord", this.guideRecord);
|
|
|
}
|
|
|
}
|
|
|
-public class UserSettings {
|
|
|
+public class UserSettings
|
|
|
+{
|
|
|
//打开BGM
|
|
|
public bool openBGM = true;
|
|
|
//打开音效
|
|
|
@@ -126,7 +148,7 @@ public class UserSettings {
|
|
|
//射击难度
|
|
|
public int shootLevel = 0;
|
|
|
//游戏里的箭重,单位克
|
|
|
- public float actualArrowWeight = 20;
|
|
|
+ public float actualArrowWeight = 20;
|
|
|
//弓箭旋转转化
|
|
|
public BowRotateConvert bowRotateConvert = new BowRotateConvert();
|
|
|
//游戏中是否固定镜头
|
|
|
@@ -140,19 +162,26 @@ public class UserSettings {
|
|
|
public HashSet<int> gameRuleGuideFinish = new HashSet<int>();
|
|
|
|
|
|
private static UserSettings _ins;
|
|
|
- public static UserSettings ins {
|
|
|
- get {
|
|
|
- if (_ins == null) {
|
|
|
+ public static UserSettings ins
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (_ins == null)
|
|
|
+ {
|
|
|
string dataStr = PlayerPrefs.GetString("UserSettings", "{}");
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
_ins = JsonConvert.DeserializeObject<UserSettings>(dataStr);
|
|
|
}
|
|
|
- catch (System.Exception) {}
|
|
|
- if (_ins == null) {
|
|
|
+ catch (System.Exception) { }
|
|
|
+ if (_ins == null)
|
|
|
+ {
|
|
|
_ins = new UserSettings();
|
|
|
}
|
|
|
- if (CommonConfig.SpecialVersion1) {
|
|
|
- if (PlayerPrefs.GetInt("sv1_UserSettings_2", 0) == 0) {
|
|
|
+ if (CommonConfig.SpecialVersion1)
|
|
|
+ {
|
|
|
+ if (PlayerPrefs.GetInt("sv1_UserSettings_2", 0) == 0)
|
|
|
+ {
|
|
|
PlayerPrefs.SetInt("sv1_UserSettings_2", 1);
|
|
|
UserSettings us = _ins;
|
|
|
us.bowRotateConvert.screenSize = 60;
|
|
|
@@ -165,7 +194,8 @@ public class UserSettings {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void Save() {
|
|
|
+ public void Save()
|
|
|
+ {
|
|
|
PlayerPrefs.SetString("UserSettings", JsonConvert.SerializeObject(this));
|
|
|
}
|
|
|
}
|
|
|
@@ -192,13 +222,15 @@ public class UserSettings {
|
|
|
结果:
|
|
|
游戏转动角度:实际转动角度 = r / e
|
|
|
*/
|
|
|
-public class BowRotateConvert {
|
|
|
+public class BowRotateConvert
|
|
|
+{
|
|
|
public float screenSize = 60; //屏幕尺寸(英寸)
|
|
|
public float screenDistance = 2.5f; //玩家距离屏幕多远(米)
|
|
|
[NonSerialized] public float fieldOfView = 25;
|
|
|
|
|
|
//获取建议的屏幕距离
|
|
|
- public float GetAdviseScreenDistance() {
|
|
|
+ public float GetAdviseScreenDistance()
|
|
|
+ {
|
|
|
float w = 16;
|
|
|
float h = 9;
|
|
|
float s1 = screenSize * 0.0254f;
|
|
|
@@ -208,7 +240,8 @@ public class BowRotateConvert {
|
|
|
}
|
|
|
|
|
|
// 游戏旋转角度 : 实际旋转角度 (这个版本丢弃掉这个功能-所以直接返回1)
|
|
|
- public float GetRate() {
|
|
|
+ public float GetRate()
|
|
|
+ {
|
|
|
return 1;
|
|
|
}
|
|
|
|