207 lines
7.4 KiB
C#
Raw Normal View History

2021-04-06 15:30:36 +08:00
using Assets.Scripts.Apis.Models;
2021-04-15 15:58:37 +08:00
using Assets.Scripts.UI.Prefab.Login;
2021-04-15 10:13:01 +08:00
using Assets.Scenes.Ride.Scripts.Model;
using System.Collections;
2021-03-25 16:53:39 +08:00
using System.Collections.Generic;
using UnityEngine;
using System.Net;
2021-06-04 13:19:37 +08:00
using System.Globalization;
using System.Threading;
2021-05-19 14:38:48 +08:00
using Assets.Scripts.Devices;
2021-09-16 19:49:45 +08:00
using Assets.Scripts;
2021-09-23 18:14:53 +08:00
using System;
using System.Threading.Tasks;
2021-11-02 17:55:49 +08:00
using System.Timers;
2021-11-11 14:20:08 +08:00
using Newtonsoft.Json;
2021-12-23 15:36:11 +08:00
using Facebook.Unity;
2021-11-11 14:20:08 +08:00
public delegate void ChangeLanguageDelegate();
2021-03-25 16:53:39 +08:00
public static class App
{
2021-12-23 09:54:14 +08:00
public static string Host = "http://192.168.0.101:5084/";
2021-03-25 16:53:39 +08:00
2021-05-10 10:21:46 +08:00
public static string AppVersion = Application.version;
2021-03-25 16:53:39 +08:00
public static int RouteIdParam = 0;
public static UserResultModel CurrentUser { get; set; }
2021-08-24 17:50:14 +08:00
#if !(UNITY_ANDROID || UNITY_IOS)
//pc版微信id
public static string WxAppId => "wx9e8ca734e024f084";
#else
//移动版微信id
2021-08-27 15:06:56 +08:00
public static string WxAppId => "wxe3573a84e7e29902";
2021-08-24 17:50:14 +08:00
#endif
2021-04-14 15:02:33 +08:00
public static string MapBoxAccessToken => "pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA";
2021-04-16 17:49:11 +08:00
public static double latitude { get; internal set; }
public static double longitude { get; internal set; }
2021-11-02 17:55:49 +08:00
public static string is401 { get; set; }
2021-09-23 18:14:53 +08:00
public static bool FromLogin => false;
public static bool? _IsRowerMode = null;
public static bool? IsRowerMode
2021-09-23 18:14:53 +08:00
{
get => _IsRowerMode;
set
{
PlayerPrefs.SetString("IsRowerMode",value.ToString());
_IsRowerMode = value;
}
}
2021-04-16 17:49:11 +08:00
2021-04-14 15:02:33 +08:00
/// <summary>
/// 场景跳转传值
/// Name,MapListPanel
/// xxx,bbb
/// </summary>
public static System.Collections.Generic.Dictionary<string, string> MainSceneParam = new Dictionary<string, string>();
2021-09-23 18:14:53 +08:00
public static IDictionary<string, Texture> TextureCache = new Dictionary<string, Texture>();
2021-04-15 17:09:35 +08:00
public static Texture CurrentUserHeadTexture;
public static RouteResult routeResult;//骑行记录向骑行场景传值
2021-11-22 09:51:17 +08:00
public static Texture DefaultRotateTexture { get; set; }
2021-04-28 15:21:06 +08:00
//全局用 输入框或者下拉框修改标志位
public static bool isChanged { get; set; }
public static string notifyContent { get; internal set; }
public static RideSetting RideSetting = new RideSetting();
public static string pageName { get; set; }
public static int firstEnter { get; set; }
public static IPEndPoint UdpAddress { get; private set; } = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
2021-07-09 18:16:50 +08:00
public static IPEndPoint TcpAddress { get; private set; } = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
2021-05-10 10:21:46 +08:00
public static UpdateModel UpdateObject { get; set; }
public static int CompetionId { get; set; }//比赛id
2021-05-10 10:21:46 +08:00
//public static string AppDownloadUrl { get; internal set; }
//public static string AppVersionCode { get; internal set; }
2021-12-15 11:08:18 +08:00
public static List<JoinedCompetitionModel> JoinedCompetitionList { get; set; }//我参加的比赛
public static List<int> CompetitionIdList = new List<int>();
2021-05-19 14:38:48 +08:00
private static MainDeviceAdapter mainDeviceAdapter;
public static MainDeviceAdapter MainDeviceAdapter
{
get
{
2021-09-23 18:14:53 +08:00
if (mainDeviceAdapter == null)
2021-05-19 14:38:48 +08:00
{
mainDeviceAdapter = new MainDeviceAdapter();
}
return mainDeviceAdapter;
}
}
2021-07-29 20:01:38 +08:00
public static string CurrentScene { get; set; }//当前场景
2021-08-27 15:06:56 +08:00
public static float? topRectStartX { get; internal set; }
2021-09-02 14:18:26 +08:00
public static WeChatController weChatController = WeChatController.Instance;
2021-09-07 11:00:32 +08:00
public static ImageSelectorController imageSelectorController = ImageSelectorController.Instance;
2021-09-02 10:08:46 +08:00
public static Vector2 MobileResolution = new Vector2(844f, 390f);//移动端分辨率
public static Vector2 PcResolution = new Vector2(1600f, 900f);//PC端分辨率
public static int autoClearTimes = 30;
2021-09-06 16:53:48 +08:00
public readonly static double width = Screen.width;
public readonly static double height = Screen.height;
2021-09-23 18:14:53 +08:00
public readonly static bool isFullScreen = width / height > 1.8;
public static float canvasWidth { get; set; }
2021-10-21 18:04:01 +08:00
public static string WorkoutsUrl { get; internal set; }
public static long delayTime { get; set; }
2021-11-22 18:04:16 +08:00
public static List<OnlineUser> userList = new List<OnlineUser>();
public static TempRecordData tempRecordData { get; set; }
2021-11-11 14:20:08 +08:00
private static string language { get; set; }
public static Dictionary<string, string> LanguageManager { get; set; }
2021-12-10 09:53:49 +08:00
public static string CurrentRouteType { get; set; }
2021-11-11 14:20:08 +08:00
#region
public static event ChangeLanguageDelegate ChangeLanguageEvent;
static Dictionary<string, Dictionary<string, string>> dic;
public static string GetLocalLanguage()
{
return language;
}
public static void ChangeLanguage(string lan)
{
language = lan;
if (dic.ContainsKey(language))
{
LanguageManager = dic[language];
}
if (ChangeLanguageEvent != null)
{
ChangeLanguageEvent();
}
}
public static string GetLocalString(string value)
{
if (LanguageManager != null && LanguageManager.ContainsKey(value))
{
return LanguageManager[value];
}
return value;
}
2021-10-21 18:04:01 +08:00
2021-11-11 14:20:08 +08:00
private static void InitLanguage()
{
var systemLanguage = Application.systemLanguage.ToString().ToLower();
2021-12-10 09:53:49 +08:00
Debug.Log(systemLanguage);
2021-11-11 14:20:08 +08:00
if (systemLanguage.Contains("chinese"))
{
language = "zh";
}
else
{
language = "en";
}
var a = Resources.Load<TextAsset>("UI/language");
dic = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(a.text);
if (dic.ContainsKey(language))
{
LanguageManager = dic[language];
}
}
#endregion
2021-12-15 11:08:18 +08:00
//记录当前集合
public static MapRouteAreaItem currentArea = null;
2021-12-15 18:18:12 +08:00
internal static Dictionary<int,string> RouteNameDict = new Dictionary<int, string>();
public static bool _currentPageIsHome = false;
public static event EventHandler isHomeChanged;
public static bool currentPageIsHome
{
get => _currentPageIsHome;
set
{
_currentPageIsHome = value;
if (isHomeChanged != null)
{
isHomeChanged(value, new EventArgs());
}
}
}
2021-09-06 16:53:48 +08:00
static App()
{
2021-11-11 14:20:08 +08:00
InitLanguage();
2021-08-12 10:03:29 +08:00
#if !UNITY_EDITOR
2021-10-08 15:22:20 +08:00
//Host = "http://pf.juze.pro/";
//Host = "http://192.168.0.101:5087/";
2021-10-08 15:22:20 +08:00
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
2021-12-15 18:18:12 +08:00
//线上
//Host = "https://wx.powerfun.com.cn/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
Host = "http://192.168.0.101:5085/";
UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
2021-12-17 18:28:02 +08:00
//Debug.unityLogger.logEnabled = false;
2021-08-12 10:03:29 +08:00
#endif
2021-12-23 15:36:11 +08:00
FB.Init();
var isRower = PlayerPrefs.GetString("IsRowerMode");
if (!string.IsNullOrEmpty(isRower))
{
App._IsRowerMode = bool.Parse(isRower);
}
2021-11-23 14:25:36 +08:00
//App.ChangeLanguage("en");
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}
2021-03-25 16:53:39 +08:00
}