262 lines
9.4 KiB
C#
262 lines
9.4 KiB
C#
using Assets.Scripts.Apis.Models;
|
||
using Assets.Scripts.UI.Prefab.Login;
|
||
using Assets.Scenes.Ride.Scripts.Model;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using System.Net;
|
||
using System.Globalization;
|
||
using System.Threading;
|
||
using Assets.Scripts.Devices;
|
||
using Assets.Scripts;
|
||
using System;
|
||
using System.Threading.Tasks;
|
||
using System.Timers;
|
||
using Newtonsoft.Json;
|
||
using Facebook.Unity;
|
||
using Assets.Scenes.Ride.Scripts;
|
||
using System.Linq;
|
||
|
||
public delegate void ChangeLanguageDelegate();
|
||
|
||
public static class App
|
||
{
|
||
public static string Host = "http://192.168.0.102:5082/";
|
||
|
||
public static string AppVersion = Application.version;
|
||
|
||
public static int RouteIdParam = 0;
|
||
public static UserResultModel CurrentUser { get; set; }
|
||
public static string ActivityUrl { get; internal set; }
|
||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||
//pc版微信id
|
||
public static string WxAppId => "wx9e8ca734e024f084";
|
||
#else
|
||
//移动版微信id
|
||
public static string WxAppId => "wxe3573a84e7e29902";
|
||
#endif
|
||
public static string MapBoxAccessToken => "pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA";
|
||
|
||
public static double latitude { get; internal set; }
|
||
public static double longitude { get; internal set; }
|
||
public static string is401 { get; set; }
|
||
public static bool FromLogin => false;
|
||
|
||
/// <summary>
|
||
/// 场景跳转传值
|
||
/// Name,MapListPanel
|
||
/// xxx,bbb
|
||
/// </summary>
|
||
public static System.Collections.Generic.Dictionary<string, string> MainSceneParam = new Dictionary<string, string>();
|
||
public static IDictionary<string, Texture> TextureCache = new Dictionary<string, Texture>();
|
||
public static Texture CurrentUserHeadTexture;
|
||
public static RouteResult routeResult;//骑行记录向骑行场景传值
|
||
public static GameRoomModel gameRoomDetail { get; set; }
|
||
public static Texture DefaultRotateTexture { get; set; }
|
||
//全局用 输入框或者下拉框修改标志位
|
||
public static bool isChanged { get; set; }
|
||
public static string notifyContent { get; internal set; }
|
||
//全局用,如果弹多条消息用这个队列
|
||
public static Queue<string> multiNotifyContent;
|
||
//全局用,弹多个广告
|
||
public static Queue<ActivityModel> adQueue;
|
||
|
||
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);
|
||
public static IPEndPoint TcpAddress { get; private set; } = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
|
||
public static UpdateModel UpdateObject { get; set; }
|
||
public static int CompetionId { get; set; }//比赛id
|
||
//public static string AppDownloadUrl { get; internal set; }
|
||
//public static string AppVersionCode { get; internal set; }
|
||
|
||
public static List<JoinedCompetitionModel> JoinedCompetitionList { get; set; }//我参加的比赛
|
||
public static List<int> CompetitionIdList = new List<int>();
|
||
|
||
private static MainDeviceAdapter mainDeviceAdapter;
|
||
public static MainDeviceAdapter MainDeviceAdapter
|
||
{
|
||
get
|
||
{
|
||
if (mainDeviceAdapter == null)
|
||
{
|
||
mainDeviceAdapter = new MainDeviceAdapter();
|
||
}
|
||
return mainDeviceAdapter;
|
||
}
|
||
}
|
||
|
||
public static string CurrentScene { get; set; }//当前场景
|
||
public static float? topRectStartX { get; internal set; }
|
||
|
||
public static WeChatController weChatController = WeChatController.Instance;
|
||
public static ImageSelectorController imageSelectorController = ImageSelectorController.Instance;
|
||
public static Vector2 MobileResolution = new Vector2(844f, 390f);//移动端分辨率
|
||
public static Vector2 PcResolution = new Vector2(1600f, 900f);//PC端分辨率
|
||
public static int autoClearTimes = 30;
|
||
public readonly static double width = Screen.width;
|
||
public readonly static double height = Screen.height;
|
||
public readonly static bool isFullScreen = width / height > 1.8;
|
||
public static float canvasWidth { get; set; }
|
||
public static string WorkoutsUrl { get; internal set; }
|
||
|
||
public static string TcpRequestUrl { get; internal set; }
|
||
|
||
public static long delayTime { get; set; }
|
||
public static List<OnlineUser> userList = new List<OnlineUser>();
|
||
|
||
public static TempRecordData tempRecordData { get; set; }
|
||
private static string language { get; set; }
|
||
|
||
public static Dictionary<string, string> LanguageManager { get; set; }
|
||
public static string CurrentRouteType { get; set; }
|
||
#region 语言改变事件
|
||
public static event ChangeLanguageDelegate ChangeLanguageEvent;
|
||
static Dictionary<string, Dictionary<string, string>> dic;
|
||
|
||
//全局队列保留最后5条消息
|
||
public static Queue<LinkedMessageEvent> globalMessageQueue = null;
|
||
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;
|
||
}
|
||
|
||
private static void InitLanguage()
|
||
{
|
||
var systemLanguage = Application.systemLanguage.ToString().ToLower();
|
||
Debug.Log(systemLanguage);
|
||
if (systemLanguage.Contains("chinese"))
|
||
{
|
||
language = "zh";
|
||
}
|
||
else
|
||
{
|
||
language = "en";
|
||
}
|
||
#if UNITY_EDITOR
|
||
//language = "en";
|
||
#endif
|
||
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
|
||
//记录当前集合
|
||
public static MapRouteAreaItem currentArea = null;
|
||
public static List<MapRoute> RouteList = new List<MapRoute>();
|
||
public static bool _currentPageIsHome = false;
|
||
public static event EventHandler isHomeChanged;
|
||
public static string DeviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier;
|
||
public static bool currentPageIsHome
|
||
{
|
||
get => _currentPageIsHome;
|
||
set
|
||
{
|
||
_currentPageIsHome = value;
|
||
if (isHomeChanged != null)
|
||
{
|
||
isHomeChanged(value, new EventArgs());
|
||
}
|
||
}
|
||
}
|
||
|
||
public static string Model { get; set; }
|
||
|
||
public static List<MailModel> CurrentUserMails { get; set; }
|
||
//public static event hasNotReadEvent;
|
||
public static event EventHandler HasNotReadChanged;
|
||
public static bool _hasNotRead;
|
||
public static bool hasNotRead
|
||
{
|
||
get => _hasNotRead;
|
||
set
|
||
{
|
||
_hasNotRead = value;
|
||
if (HasNotReadChanged != null)
|
||
{
|
||
HasNotReadChanged(value, new EventArgs());
|
||
}
|
||
}
|
||
}
|
||
public static bool CanOpenAd = false;
|
||
|
||
public static Dictionary<string, string> websiteDict = new Dictionary<string, string>()
|
||
{
|
||
{"https://wx.powerfun.com.cn/","http://www.powerfun.com/" },
|
||
{"http://pf.juze.pro/","http://pfweb.juze.pro/" },
|
||
{"http://192.168.0.101:5087/","http://192.168.0.101:3081/" },
|
||
{"http://192.168.0.101:5083/","http://pfweb.juze.pro/" }
|
||
};
|
||
|
||
public static List<string> cacheList = new List<string>();
|
||
static App()
|
||
{
|
||
InitLanguage();
|
||
Host = "http://pf.juze.pro/";
|
||
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
|
||
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
|
||
#if !UNITY_EDITOR
|
||
//测试服务器 Host = "http://192.168.0.101:5083/";
|
||
Host = "http://pf.juze.pro/";
|
||
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
|
||
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
|
||
//线上
|
||
//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:5087/";
|
||
//UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
|
||
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
|
||
//Debug.unityLogger.logEnabled = false;
|
||
#else
|
||
//Host = "http://pf.juze.pro/";
|
||
//Host = "http://192.168.0.101:5087/";
|
||
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
|
||
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
|
||
//UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
|
||
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
|
||
#endif
|
||
var now = DateTime.Now;
|
||
if (!FB.IsInitialized)
|
||
{
|
||
FB.Init();
|
||
}
|
||
else
|
||
{
|
||
FB.ActivateApp();
|
||
}
|
||
|
||
globalMessageQueue = new Queue<LinkedMessageEvent>();
|
||
multiNotifyContent = new Queue<string>();
|
||
adQueue = new Queue<ActivityModel>();
|
||
Screen.sleepTimeout = SleepTimeout.NeverSleep;
|
||
}
|
||
}
|