fix:玩家添加盔甲和头盔 调整玩家掉血问题
This commit is contained in:
173
Assets/_MrCs/Scripts/Manager/GameLocal.cs
Normal file
173
Assets/_MrCs/Scripts/Manager/GameLocal.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using BestHTTP;
|
||||
using Common;
|
||||
using DarkTonic.MasterAudio;
|
||||
using Unity.XR.PXR;
|
||||
using UnityEngine;
|
||||
|
||||
public enum Place
|
||||
{
|
||||
Company1Floor= 0,
|
||||
LiaoNing_AnShan=1,
|
||||
Liaoning_Anshan_Lishan_Dayuecheng = -1,
|
||||
HangZhou_LongHuTianJie =2,
|
||||
Nanjing_Yuhua_Wanxiang=3,
|
||||
Nanjing_Xianlin_WanDaMao=4,
|
||||
Yangzhou_Hanjiang_Tansuozhongxin=5,
|
||||
Yangzhou_Hanjiang_Tansuozhongxin_wai=-5,
|
||||
Zhejiang_Jinhua_KeJiGuan=6,
|
||||
Guangzhou_Panyv_Zhanting=7,
|
||||
Anhui_Wuhu_Guanwei=8,
|
||||
Shandong_Jining_Shangchang = 9,
|
||||
Shandong_Jining_Shangchang_nei = -9,
|
||||
Shandong_Langfang_QingzhouTaihuacheng = 10,
|
||||
Hubei_Xiangyang_Kejiguan=11,
|
||||
Zhejiang_Shaoxing_Shengzhou_WuyueGuangchang= 12,
|
||||
Hunan_Jishou_Qianzhou_Tianhong = 13,
|
||||
Jilin_Tonghua_Liuhe = 14,
|
||||
Shandong_Jinan_Huaiyin_ShengfutongShangmao = 15,
|
||||
Shandong_Jinan_Huaiyin_ShengfutongShangmao_wai = -15,
|
||||
Henan_Xinzheng_Shuanghudadao_Longhujinyicheng = 16,
|
||||
Nanjing_Qixia_Yaohuamen_Jindiguangchang = 17,
|
||||
Nanjing_Qixia_Yaohuamen_Jindiguangchang_nei = -17,
|
||||
Anhui_Suzhou_Yuashan_Guchengshangyejie=18,
|
||||
Gansu_Longnan_Shicheng_Dongsheng = 19,
|
||||
Shandong_Heze_Yuncheng_Gefuli = 20,
|
||||
Wulanhaote_Ouya_Shangchang = 21,
|
||||
Wulanhaote_Wanda_Shangchang = -21,
|
||||
Yunnan_Mile_Jinchen_Shidaiguangchang = 22,
|
||||
Xinjiang_Yili_Yining_Wanrong = 23,
|
||||
Hunan_Hengyang_Zhuhui_Dongzhoudao = 24,
|
||||
Hunan_Hengyang_Zhuhui_Dongzhoudao_nei = -24,
|
||||
Yunnan_Lincang_Linxiang_Hengji = 25,
|
||||
Yunnan_Lincang_Linxiang_Hengji_Dixia = -25,
|
||||
Guangxi_Guilin_Gongcheng_Shijixincheng = 26,
|
||||
Guangdong_Shenzhen_Guangming_Wanda = 27,
|
||||
Gansu_Jinchang_Jinchuan_Shijiguangchang = 28,
|
||||
Jiangsu_Xvzhou_Fengxian_Wuyueguangchang = 29,
|
||||
}
|
||||
|
||||
public class GameLocal : MonoBehaviour
|
||||
{
|
||||
public static GameLocal Ins { get; private set; }
|
||||
|
||||
public Camera MRCamera;
|
||||
public Transform Aim;
|
||||
public Transform MRLeftControl;
|
||||
public Transform MRRightControl;
|
||||
public State BGMState;
|
||||
|
||||
// 验证信息
|
||||
private AuthInfo authInfo = new AuthInfo();
|
||||
|
||||
[NonSerialized]
|
||||
public Player self;
|
||||
[Header("版本号")]
|
||||
public string Version = "1.0.1";
|
||||
[Header("场地")]
|
||||
public Place place = Place.Company1Floor;
|
||||
|
||||
public GameObject Scene;
|
||||
public GameObject Settle;
|
||||
public GameObject BlueWin;
|
||||
public GameObject RedWin;
|
||||
|
||||
public Transform redDoorPos;
|
||||
public Transform blueDoorPos;
|
||||
public Transform startGameItemPos;
|
||||
public Transform[] startPlanePos;
|
||||
|
||||
[NonSerialized]
|
||||
public GameObject HitUI;
|
||||
|
||||
[NonSerialized]
|
||||
public GameObject DieUI;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Ins = this;
|
||||
Application.targetFrameRate = 60;
|
||||
ConPanel.Show();
|
||||
BGMState.StateChange(0);
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
||||
//PXRManager.enabled = true;
|
||||
PXR_MixedReality.EnableVideoSeeThrough(true);
|
||||
#elif !UNITY_EDITOR && UNITY_ANDROID && VIVE
|
||||
//PXRManager.enabled = false;
|
||||
Interop.WVR_ShowPassthroughUnderlay(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鉴权
|
||||
/// </summary>
|
||||
public void RequestAuth(Action<HTTPRequest, HTTPResponse> cb = null)
|
||||
{
|
||||
string url = "http://www.pineappletech.cn/startcount";
|
||||
HTTPRequest request = new HTTPRequest(new Uri(url), HTTPMethods.Post, (req, response) =>
|
||||
{
|
||||
if (response != null)
|
||||
{
|
||||
Debug.Log("收到数据 ->" + response.DataAsText);
|
||||
}
|
||||
cb?.Invoke(req, response);
|
||||
});
|
||||
//request.AddHeader("Authorization", Author);
|
||||
authInfo.deviceSn = GetSn();
|
||||
authInfo.startAt = ConvertTimestampToDateTime(GetTimestamp()) + "";
|
||||
//authInfo.paid = 2;
|
||||
//authInfo.uuid = GetSn() + GetTimestamp();
|
||||
authInfo.shop = 0;
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
||||
authInfo.shop = (int)place;
|
||||
if (place == Place.Liaoning_Anshan_Lishan_Dayuecheng)
|
||||
authInfo.shop = 1;
|
||||
if (place == Place.Yangzhou_Hanjiang_Tansuozhongxin_wai)
|
||||
authInfo.shop = 5;
|
||||
if (place == Place.Shandong_Jining_Shangchang_nei)
|
||||
authInfo.shop = 9;
|
||||
if (place == Place.Shandong_Jinan_Huaiyin_ShengfutongShangmao_wai)
|
||||
authInfo.shop = 15;
|
||||
if (place == Place.Nanjing_Qixia_Yaohuamen_Jindiguangchang_nei)
|
||||
authInfo.shop = 17;
|
||||
if (place == Place.Wulanhaote_Wanda_Shangchang)
|
||||
authInfo.shop = 21;
|
||||
if (place == Place.Hunan_Hengyang_Zhuhui_Dongzhoudao_nei)
|
||||
authInfo.shop = 24;
|
||||
if (place == Place.Yunnan_Lincang_Linxiang_Hengji_Dixia)
|
||||
authInfo.shop = 25;
|
||||
#endif
|
||||
authInfo.gameId = 3;
|
||||
string authJson = JsonUtility.ToJson(authInfo);
|
||||
Debug.Log("发送数据 -> " + authJson);
|
||||
request.RawData = System.Text.Encoding.UTF8.GetBytes(authJson);
|
||||
request.AddHeader("Content-Type", "application/json");
|
||||
request.Send();
|
||||
}
|
||||
|
||||
public long GetTimestamp()
|
||||
{
|
||||
return (long)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
}
|
||||
|
||||
public string ConvertTimestampToDateTime(long timestamp)
|
||||
{
|
||||
// Unix时间戳是从1970年1月1日00:00:00开始的秒数或毫秒数
|
||||
// 这里以秒为单位,如果时间戳是毫秒则除以1000
|
||||
DateTime dateTime = DateTimeOffset.FromUnixTimeSeconds(timestamp).DateTime;
|
||||
return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取sn号
|
||||
/// </summary>
|
||||
public string GetSn()
|
||||
{
|
||||
string res = "UnityEditor";
|
||||
// string res = "PA8E10MGH7210380D";
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
||||
res = PXR_Enterprise.StateGetDeviceInfo(SystemInfoEnum.EQUIPMENT_SN);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user