public void ClearAllDanmu(bool getScore) { for (int i = state.Danmus.Count - 1; i >= 0; i--) { Danmu danmu = state.Danmus[i]; danmu.OnDestroy(); state.Danmus.Remove(danmu); mUICtrl.ShowDanmuEffect(danmu.transform.position); if (danmu.isBad) { GainScore(-2); } else { GainScore(1); } } for (int i = state.SuperDanmus.Count - 1; i >= 0; i--) { if (state.SuperDanmus[i].HasDisapeared) { continue; } state.SuperDanmus[i].Disappear(); } state.SuperDanmus.Clear(); mUICtrl.ClearSuperDanmu(); }
private static void OpenWindow() { Danmu window = GetWindow <Danmu>(); window.position = GUIHelper.GetEditorWindowRect().AlignCenter(700, 700); //Init(); }
private async void Danmu_PrintEvt(object sender, EventModel e) { try { int totalline = printBox.GetLineIndexFromCharacterIndex(printBox.Text.Length); if (totalline > 1000) { var length = printBox.GetLineLength(500); printBox.Text.Remove(0, length); } string msg = string.Format("{0},时间:{1}", e.PrintMsg, e.DateTime.ToString("yyyy-MM-dd HH:mm:ss")); if (e.Send) { await Danmu.SendDanmu(msg); } printBox.Text += string.Format("{0}{1}", msg, BreakLine); printBox.ScrollToLine(printBox.GetLineIndexFromCharacterIndex(printBox.SelectionStart)); printBox.Focus(); printBox.Select(printBox.Text.Length, 0); printBox.ScrollToLine(printBox.GetLineIndexFromCharacterIndex(printBox.SelectionStart)); } catch (Exception ex) { LogManager.Instance.LogError("Danmu_PrintEvt", ex); } }
/// <summary> /// 构造器 /// </summary> /// <param name="danmu"></param> public DanmuHandlerEventArgs(Danmu danmu) { if (danmu == null) { throw new ArgumentNullException(nameof(danmu)); } _danmu = danmu; }
private async Task Login(string user, string passwd) { var result = await User.Login(user, passwd); if (result) { await Danmu.ConnectAsync(); } }
private void Window_Unloaded(object sender, RoutedEventArgs e) { try { Danmu.PrintEvt -= Danmu_PrintEvt; Danmu.PlaySongEvt -= Danmu_PlaySongEvt; Danmu.Dispose(); HttpClient.Dispose(); } catch { } }
public void DestroyBadRandomly(int num) { List <Danmu> toClean = randomPickBadDanmu(num); for (int i = 0; i < toClean.Count; i++) { Danmu danmu = toClean[i]; danmu.OnDestroy(); state.Danmus.Remove(danmu); GainScore(10); } }
private void AutoDisappear(Danmu danmu) { RecycleDanmu(danmu); state.Danmus.Remove(danmu); if (danmu.isBad) { GainScore(-2); } else { GainScore(1); } }
public void DestroyDanmu(Danmu danmu) { if (!danmu.isBad) { GainScore(danmu.isBig ? 3 : 1); danmu.view.Content.color = Color.gray; danmu.view.Hengfu.raycastTarget = false; mUICtrl.ShowDanmuEffect(danmu.transform.position); } else { danmu.OnDestroy(); state.Danmus.Remove(danmu); } }
public Danmu GenDanmu(bool isBad) { List <int> DanmuSlots = new List <int>(); for (int i = 2; i < numOfGridVertical - 2; i++) { if (Time.time - preDanmuTime[i] > MinDanmuInterval) { DanmuSlots.Add(i); } } int gridY; if (DanmuSlots.Count == 0) { gridY = Random.Range(2, numOfGridVertical - 2); } else { gridY = DanmuSlots[Random.Range(0, DanmuSlots.Count)]; } preDanmuGrid = gridY; float posY = gridY * 1.0f / numOfGridVertical * height; //posY += Random.Range(-3f, 3f); preDanmuTime[gridY] = Time.time; GameObject danmuGo = mResLoader.Instantiate("Zhibo/Danmu"); Danmu danmu = danmuGo.GetComponent <Danmu>(); danmu.init(gameMode.getRandomDanmu(), isBad, gameMode); danmuGo.transform.SetParent(view.DanmuFieldNormal, false); danmu.rect.anchoredPosition = new Vector3(width + 30, -posY, 0); return(danmu); }
private bool ProcessTxtMsg(string xml) { MsgObject msg = new MsgObject(xml); if (msg.MsgType != "text") { return(false); } string content = msg.Content; if (content.Length > 0) { using (var dbContext = new WeixinDBContext()) { bool filter = false; var blackList = dbContext.BlackList.Select(p => p.Value).ToList(); foreach (var value in blackList) { if (content.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { filter = true; break; } } if (filter == false) { Danmu danmu = new Danmu(); danmu.UserName = string.Empty; danmu.OpenId = msg.FromUserName; danmu.CreateTime = msg.CreateTime; danmu.Content = content; dbContext.Danmus.Add(danmu); dbContext.SaveChanges(); } } } return(true); }
public void RecycleDanmu(Danmu danmu) { mResLoader.ReleaseGO("Zhibo/Danmu", danmu.gameObject); }
public void GenDanmu() { DanmuGroup dd = null; if (state.danmuGroups.Count > 0) { int[] preSum = new int[state.danmuGroups.Count]; preSum[0] = state.danmuGroups[0].TotalNum; for (int i = 1; i < state.danmuGroups.Count; i++) { preSum[i] = preSum[i - 1] + state.danmuGroups[i].TotalNum; } int randInt = Random.Range(0, preSum[state.danmuGroups.Count - 1]); int choose = 0; for (int i = 0; i < preSum.Length; i++) { if (randInt < preSum[i]) { choose = i; dd = state.danmuGroups[i]; break; } } state.danmuGroups[choose].TotalNum -= 1; if (state.danmuGroups[choose].TotalNum <= 0) { state.danmuGroups.RemoveAt(choose); } } bool bad = false; if (dd == null) { //固定10几率刷新 int rand = Random.Range(0, 100); float c; int badLevel = state.BadLevel + mBuffManager.BadRateDiff; if (state.BadLevel > 8) { c = WeisuijiDict[8]; } else { c = WeisuijiDict[state.BadLevel]; } if (rand < pNow * 100) { bad = true; pNow = c; } else { pNow += c; if (pNow > 1) { pNow = 1; } } } else { int rand = Random.Range(0, dd.TotalNum + 1); if (rand < dd.BadNum) { bad = true; dd.BadNum -= 1; } else { bad = false; } } //if(dd != null) //{ // badLine = dd.badRate; //} //int rand = Random.Range(0, 100); //if (rand < badLine) //{ // bad = true; //} Danmu danmu = mUICtrl.GenDanmu(bad); bigOneCount++; if (bigOneCount > bigOneNext) { danmu.SetAsBig(); bigOneCount = 0; bigOneNext = Random.Range(5, 8); } state.Danmus.Add(danmu); }
// Update is called once per frame void Update() { if (!GlobalVariables.gameOver && !GlobalVariables.win) { Score.text = GlobalVariables.score.ToString(); if (recordedPlayerHP != GlobalVariables.playerHP) { recordedPlayerHP = GlobalVariables.playerHP; for (int i = 0; i < HPs.Length; i++) { if (i < recordedPlayerHP) { HPs[i].SetActive(true); } else { HPs[i].SetActive(false); } } } if (bossHP != GlobalVariables.bossHP) { bossHP = GlobalVariables.bossHP; bossHPBar.sizeDelta = new Vector2(bossHP / bossTotalHP * GlobalVariables.bossHPBar_totalW, bossHPBar.sizeDelta.y); } if (recordedUltimateTimes != GlobalVariables.ultimateTimes) { recordedUltimateTimes = GlobalVariables.ultimateTimes; for (int i = 0; i < Ultimates.Length; i++) { if (i < recordedUltimateTimes) { Ultimates[i].SetActive(true); } else { Ultimates[i].SetActive(false); } } } if (GlobalVariables.playerHP > 0 && GlobalVariables.bossHP > 0) { if (nowDanmuIndex < danmus.Length) { if (Time.time >= nextDanmuExactTime) { Danmu danmuTemp = danmus[nowDanmuIndex]; danmuTemp.danmu.StartDanmu(); nextDanmuWaitTime = danmuTemp.幾秒後下一個彈幕; nextDanmuExactTime = Time.time + nextDanmuWaitTime; nowDanmuIndex += 1; } } else { nowDanmuIndex = 0; } } else if (GlobalVariables.playerHP <= 0) { //lose GlobalVariables.gameOver = true; LoseGameObject.SetActive(true); } else if (GlobalVariables.bossHP <= 0) { GlobalVariables.win = true; WinGameObject.SetActive(true); } } if (GlobalVariables.win == true) { if (Input.GetKeyDown(KeyCode.Z)) { SceneManager.LoadScene(通關後的下一關); } } else if (GlobalVariables.gameOver == true) { if (Input.GetKeyDown(KeyCode.Z)) { SceneManager.LoadScene("Title"); } } }