From 820e8d1b59aceae678f06e4804ad3c1abd0a6249 Mon Sep 17 00:00:00 2001 From: liuzhiwei <liuzhiwei@qq.com> Date: Tue, 22 Dec 2020 10:57:00 +0800 Subject: [PATCH] 贴图名称修改 --- Assets/Scripts/Guide/TestButton.cs | 415 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 411 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Guide/TestButton.cs b/Assets/Scripts/Guide/TestButton.cs index 2841fdb..11b602b 100644 --- a/Assets/Scripts/Guide/TestButton.cs +++ b/Assets/Scripts/Guide/TestButton.cs @@ -1,17 +1,424 @@ -using System.Collections; -using System.Collections.Generic; +using System; +using System.Collections; using UnityEngine; using UnityEngine.UI; +using KTGMGemClient; +using LitJson; +using UnityEngine.Networking; +using System.Net; +using System.IO; +using System.Collections.Generic; public class TestButton : MonoBehaviour { + //public Text t; // Start is called before the first frame update void Start() { - transform.Find("TowerBuyBtn").GetComponent<Button>().onClick.AddListener(OnClickTowerBuyBtn); + + // transform.Find("TowerBuyBtn").GetComponent<Button>().onClick.AddListener(OnClickTowerBuyBtn); + + // transform.Find("GuidePanel/Image_TowerPos2").GetComponent<Button>().onClick.AddListener(GetOneTowerPos); + + // int guide = PlayerPrefs.GetInt("GemBattleGuide"); + + // string s="<color=red>范围伤害</color>"; + // t.text=s; + // Debug.Log(s.Length); + TestFinalPanel(); + // isSending = false; + // score = 0; + + // TestHttp(); + } - private void OnClickTowerBuyBtn(){ + int score; + private void OnGUI() + { + GUILayout.BeginArea(new Rect(5, 330, 150, 300)); + if (GUILayout.Button("SendRequest", GUILayout.Width(150), GUILayout.Height(70))) + { + //SendRequest("aa", 4700, 28); + score += 10; + SendPost(score.ToString(), score, 1, "25关 3波"); + } + + if (GUILayout.Button("SendGet", GUILayout.Width(150), GUILayout.Height(70))) + { + SendGet(); + + } + + if (GUILayout.Button("清理本地存储", GUILayout.Width(150), GUILayout.Height(70))) + { + PlayerPrefs.DeleteAll(); + Debug.Log("清理本地存储"); + + } + + if (GUILayout.Button("生成Nick", GUILayout.Width(150), GUILayout.Height(70))) + { + + CreateNick(); + } + GUILayout.EndArea(); + + } + private void CreateNick() + { + TimeSpan timeStamp = new TimeSpan(DateTime.Now.Ticks); + Debug.Log(timeStamp.TotalMilliseconds); + + DateTime dt = DateTime.Now; + Debug.Log(dt.ToString("fffff")); + + + return; + + //--DateTime各种ToString("")//https://www.cnblogs.com/wangyuelang0526/archive/2012/06/27/2565289.html + Debug.Log("DateTime"); + Debug.Log("MaxValue " + DateTime.MaxValue.ToString()); + Debug.Log("MinValue " + DateTime.MinValue.ToString()); + Debug.Log("Now " + DateTime.Now.ToString()); + Debug.Log("Today " + DateTime.Today.ToString()); + Debug.Log("UtcNow " + DateTime.UtcNow.ToString()); + Debug.Log("Now.Date " + DateTime.Now.Date.ToString()); + Debug.Log("Now.Day " + DateTime.Now.Day.ToString()); + Debug.Log("Now.DayOfWeek " + DateTime.Now.DayOfWeek.ToString()); + Debug.Log("Now.DayOfYear " + DateTime.Now.DayOfYear.ToString()); + // string[] TimeFormats = DateTime.Now.GetDateTimeFormats(); + // for (int i = 0; i < TimeFormats.Length; i++) + // { + // Debug.Log("Now.GetDateTimeFormats() " + i.ToString() + " " + TimeFormats[i]); + // } + Debug.Log("Now.Hour " + DateTime.Now.Hour.ToString()); + Debug.Log("Now.IsDaylightSavingTime() " + DateTime.Now.IsDaylightSavingTime()); + Debug.Log("Now.Kind " + DateTime.Now.Kind.ToString()); + Debug.Log("Now.Millisecond " + DateTime.Now.Millisecond.ToString()); + Debug.Log("Now.Minute " + DateTime.Now.Minute.ToString()); + Debug.Log("Now.Month " + DateTime.Now.Month.ToString()); + Debug.Log("Now.Second " + DateTime.Now.Second.ToString()); + + Debug.Log("Now.Subtract(DateTime) " + DateTime.Now.Subtract(new DateTime(1970, 1, 1)).Ticks.ToString()); + Debug.Log("Now.Ticks " + DateTime.Now.Ticks.ToString()); + Debug.Log("DateTime(1970, 1, 1).Ticks " + new DateTime(1970, 1, 1).Ticks.ToString()); + Debug.Log("Now.TimeOfDay " + DateTime.Now.TimeOfDay.ToString()); + Debug.Log("Now.ToBinary() " + DateTime.Now.ToBinary().ToString()); + Debug.Log("Now.ToFileTime() " + DateTime.Now.ToFileTime().ToString()); + Debug.Log("Now.ToFileTimeUtc() " + DateTime.Now.ToFileTimeUtc().ToString()); + Debug.Log("Now.ToLocalTime() " + DateTime.Now.ToLocalTime().ToString()); + Debug.Log("Now.ToLongDateString() " + DateTime.Now.ToLongDateString()); + Debug.Log("Now.ToLongTimeString() " + DateTime.Now.ToLongTimeString()); + Debug.Log("Now.ToOADate() " + DateTime.Now.ToOADate().ToString()); + Debug.Log("Now.ToShortDateString() " + DateTime.Now.ToShortDateString()); + Debug.Log("Now.ToShortTimeString() " + DateTime.Now.ToShortTimeString()); + Debug.Log("Now.ToUniversalTime() " + DateTime.Now.ToUniversalTime().ToString()); + + Debug.Log("TimeSpan"); + TimeSpan timeSpan = DateTime.Now.TimeOfDay; + Debug.Log("Days " + timeSpan.Days.ToString()); + Debug.Log("Duration() " + timeSpan.Duration().ToString()); + Debug.Log("Hours " + timeSpan.Hours.ToString()); + Debug.Log("Milliseconds " + timeSpan.Milliseconds.ToString()); + Debug.Log("Minutes " + timeSpan.Minutes.ToString()); + Debug.Log("Negate() " + timeSpan.Negate().ToString()); + Debug.Log("Seconds " + timeSpan.Seconds.ToString()); + Debug.Log("Subtract(timeSpan) " + timeSpan.Subtract(timeSpan).ToString()); + Debug.Log("Ticks " + timeSpan.Ticks.ToString()); + Debug.Log(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddTicks(timeSpan.Ticks).Ticks.ToString()); + Debug.Log("TotalDays " + timeSpan.TotalDays.ToString()); + Debug.Log("TotalHours " + timeSpan.TotalHours.ToString()); + Debug.Log("TotalMilliseconds " + timeSpan.TotalMilliseconds.ToString()); + Debug.Log("TotalMinutes " + timeSpan.TotalMinutes.ToString()); + Debug.Log("TotalSeconds " + timeSpan.TotalSeconds.ToString()); + Debug.Log(timeSpan.ToString(@"hh\:mm\:ss")); + + } + private JsonData loginData; + + public string imei0 = "";//设备信息唯一ID + private bool isSending = false; + void TestHttp() + { + if (Application.platform == RuntimePlatform.Android) + { + //GetetDeviceIMEI();//获取安卓手机IMEI + imei0 = TDAA_SDKManager.Ins.GetDeviceId();//使用设备ID + } + else if (Application.platform == RuntimePlatform.WindowsEditor) + { + imei0 = "MyTestGemBattle123"; + } + Debug.Log("设置imei0:" + imei0); + } + + + /// <summary> + /// + /// </summary> + /// <param name="nickname"></param> + /// <param name="score"></param> + /// <param name="level"></param> + private void SendPost(string nickname, int score, int level, string waveInfo) + { + Debug.Log("开始Post"); + if (isSending) return; + isSending = true; + string url = "http://9377-big-data.sbk-h5.com:8600/users/addrank"; + + Dictionary<string, object> keyValues = new Dictionary<string, object>(); + keyValues.Add("username", nickname); + keyValues.Add("nickname", nickname); + keyValues.Add("score", score); + keyValues.Add("level", level); + keyValues.Add("extra", waveInfo); + + //string v = PostWebRequest(url, data.ToJson()); + //LoadPostTxt(v); + //Debug.Log(v); + //byte[] postBytes = System.Text.Encoding.Default.GetBytes(data.ToJson()); + //StartCoroutine(Post(url, postBytes)); + + HttpHelper.Request(this, url, HttpHelper.MethodType.POST, keyValues, delegate (object value) + { + if (value != null) + LoadPostTxt(value.ToString()); + + }, HttpHelper.DownloadHanlderType.kHttpTEXT); + + } + + IEnumerator Post(string url, byte[] postBytes) + { + UnityWebRequest request = UnityWebRequest.Post(url, "POST"); + request.uploadHandler = new UploadHandlerRaw(postBytes); + request.downloadHandler = new DownloadHandlerBuffer(); + request.SetRequestHeader("Content-Type", "application/json"); + yield return request.SendWebRequest(); + + if (request.isDone) + { + LoadPostTxt(request.downloadHandler.text); + } + else + { + + } + } + + private void LoadPostTxt(string value) + { + Debug.Log(value); + loginData = JsonMapper.ToObject(value); + if (loginData["error"].ToString() != "0") + { + Debug.Log("失败了"); + } + else if (loginData["msg"].ToString() == "OK") + { + Debug.Log("成功了当前score:" + score); + //SendGet(); + } + + isSending = false; + } + + /// <summary> + /// 下载排行榜 + /// </summary> + private void SendGet() + { + Debug.Log("开始下载排行榜"); + string url = "http://9377-big-data.sbk-h5.com:8600/users/getrank";//9377-big-data.sbk-h5.com:8600/users/getrank?username=0001&limit=100 + Dictionary<string, object> keyValues = new Dictionary<string, object>(); + keyValues.Add("username", imei0); + keyValues.Add("limit", 100); + + HttpHelper.Request(this, url, HttpHelper.MethodType.GET, keyValues, delegate (object value) + { + if (value != null) + LoadGetTxt(value.ToString()); + }, HttpHelper.DownloadHanlderType.kHttpTEXT); + + } + + private void LoadGetTxt(string value) + { + JsonData getData = JsonMapper.ToObject(value); + int myrank = int.Parse(getData["myrank"].ToString()); + + JsonData rank = getData["rank"]; + + List<HttpGetInfo> allHttpGetInfoLis = new List<HttpGetInfo>(); + HttpGetInfo info; + foreach (JsonData item in rank) + { + info = new HttpGetInfo(item); + allHttpGetInfoLis.Add(info); + } + + foreach (HttpGetInfo item in allHttpGetInfoLis) + { + + Debug.LogError(item.extra); + Debug.LogError(item.nickname); + Debug.LogError(item.waveInfo); + + // if (item.extra.ContainsKey("waveInfo")) + // { + // Debug.LogError(item.extra["waveInfo"]); + // } + // string a = item.extra.ToJson(); + // Debug.LogError(a); + // JsonData tmpData = JsonMapper.ToObject(a); + // Debug.LogError(tmpData); + + // JsonData tmpData = item.extra; + // if (tmpData != null) + // { + // if (tmpData.Count > 0) + // } + // if (item.extra.ContainsKey("waveInfo")) + // { + // Debug.LogError(item.extra["waveInfo"].ToString()); + // } + Debug.Log($"item.username:{item.username} item.nickname:{item.nickname} item.score:{item.score} item.create_time:{item.create_time}"); + } + } + + + void TestFinalPanel() + { + GameObject a = Resources.Load<GameObject>("UI/Final/FinalPanel"); + GameObject go = Instantiate(a, transform); + FinalPanel panelUI = go.GetComponent<FinalPanel>(); + panelUI.SetData("1关 1波", 101); + //panelUI.SetPlayEffectAC(null); + } + + + private void OnEnable() + { + //EventCenter.Ins.Add((int)KTGMGemClient.EventType.AddCard, AddCard); + // EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFireLv2, CreateFireLv2); + // EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFirstWave, CreateFirstWave); + // EventCenter.Ins.Add((int)KTGMGemClient.EventType.RestartWave, RestartWave); + // EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.AddGold, AddGold); + // EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateWaterLv1, CreateWaterLv1); + // EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateSecondWave, CreateSecondWave); + // EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillRelease, SkillRelease); + // EventCenter.Ins.Add((int)KTGMGemClient.EventType.GuideFinish, GuideFinish); + + } + + //购买宝石 + private void OnClickTowerBuyBtn() + { Debug.Log("点击了TowerBuyBtn"); } + + private void AddCard() + { + Debug.Log("这里需要生成一个二级宝石"); + } + + + private void CreateFireLv2() + { + Debug.Log("生成一个2级的火焰塔"); + + } + + private void CreateFirstWave() + { + Debug.Log("第一关小怪出木元素小怪"); + StartCoroutine(CreateWave()); + } + + IEnumerator CreateWave() + { + yield return new WaitForSeconds(1f); + Debug.Log("出怪完毕,等待火元素完成第一次充能"); + yield return new WaitForSeconds(1f); + Debug.Log("火元素充能效果结束,暂停出怪"); + //EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.ChargingEnd); + + } + + + private void RestartWave() + { + Debug.Log("恢复出怪"); + StartCoroutine(RestartWaveCoroutine()); + } + + IEnumerator RestartWaveCoroutine() + { + yield return new WaitForSeconds(1f); + Debug.Log("出怪完毕"); + yield return new WaitForSeconds(1f); + Debug.Log("怪物被杀光,这里需要停止出下一波怪物"); + EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.KillDone); + + } + + private void AddGold(int gold) + { + Debug.Log("增加金钱:" + gold); + + } + + private void GetOneTowerPos() + { + Debug.Log("解锁了第一排第二个塔位"); + //EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.GetOneTowerPos); + + } + + private void CreateWaterLv1() + { + Debug.Log("生成一个1级的水元素塔"); + } + + private void CreateSecondWave() + { + Debug.Log("第二关小怪出火属性小怪"); + StartCoroutine(CreateSecondWaveCoroutine()); + + } + IEnumerator CreateSecondWaveCoroutine() + { + yield return new WaitForSeconds(1f); + Debug.Log("当第二关第8波怪物生成后或玩家塔位收到第一次伤害后,这里需要暂停时间"); + + EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.SkillStep); + + } + + private void SkillRelease() + { + Debug.Log("释放技能"); + + StartCoroutine(SkillReleaseDone()); + + } + + IEnumerator SkillReleaseDone() + { + yield return new WaitForSeconds(1f); + Debug.Log("技能效果播放完毕秒杀小怪后,暂停事件"); + + EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.SkillReleaseDone); + + } + + private void GuideFinish() + { + + Debug.Log("新手引导流程结束"); + } + } + + -- Gitblit v1.9.1