void OnDestroy() { EventDispatcher.TriggerEvent(GameEventDef.EVNET_ASYNC_LOADING_COMPLETE, name); removeEvent(); }
public void UpdatePerFrame() { if (Main.GameMode.RunState() == RunMode.EndingEdit) { for (int index = 0; index < view.image_Edits.Count; ++index) { Player player = Main.PlayerManager.getPlayer(index); if (player == null) { return; } PlayerUpdateTarget(index, player); } } if (start == false) { remainTime -= Main.NonStopTime.deltaTime; if (Main.GameMode.RunState() == RunMode.EndingEdit) { int value = (int)remainTime; int number1 = (value / 10) % 10; int number2 = (value / 1) % 10; Vector2 size1 = new Vector2(37, 52); Vector2 size2 = new Vector2(82, 58); view.image_Time1.sprite = view.image_Numbers[number1].sprite; view.image_Time2.sprite = view.image_Numbers[number2].sprite; view.image_Time1.rectTransform.sizeDelta = size1; view.image_Time2.rectTransform.sizeDelta = size1; if (remainTime <= 0 && !start) { remainTime = 0; start = true; List <string> names = new List <string>(); for (int index = 0; index < Main.PlayerCount(); ++index) { Player player = Main.PlayerManager.getPlayer(index); RankView.EditPanel ui = view.image_Edits[index]; PlayerUIParam uiParam = uiParamList[index]; // 自动输入 for (int count = uiParam.index; count < GameConfig.GAME_CONFIG_NAME_LEN; ++count) { PushName(index, 'A'); } ConfirmName(index); names.Add(uiParam.name); } // 结算 EventDispatcher.TriggerEvent(GameEventDef.EVNET_RANK_EDIT_INPUT_COMPLETE, names[0], names[1], names[2]); } int playerCount = 0; int fullNameCount = 0; for (int index = 0; index < Main.PlayerCount(); ++index) { Player player = Main.PlayerManager.getPlayer(index); RankView.EditPanel ui = view.image_Edits[index]; PlayerUIParam uiParam = uiParamList[index]; if (player.State == Player.StateType.Play) { ++playerCount; // 判断文字 Image image_key = GetKeyImageByPosition(Main.Controller.JoystickPosition(index)); if (image_key != null) { if (ui.image_Key != null && image_key.gameObject.name == ui.image_Key.name && !uiParam.flag) { Animator animator = ui.image_KeyPressed.GetComponent <Animator>(); AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0); if (info.IsName("Play") && info.normalizedTime >= 1.0f) { string keyName = ui.image_Key.name.Substring(9); // 添加 if (keyName.Length == 1) { PushName(index, keyName[0]); } // 删除 else if (keyName.Equals("Del")) { DeleteName(index); } // 确定 else if (keyName.Equals("Enter")) { ConfirmName(index); Main.IOManager.SetPlayerGameBegine(index, false); } GameObject.Destroy(ui.image_KeyPressed.gameObject); ui.image_KeyPressed = null; ui.image_Key = null; } } else { if (ui.image_KeyPressed != null) { GameObject.Destroy(ui.image_KeyPressed); ui.image_KeyPressed = null; } ui.image_Key = image_key; string imageName = image_key.gameObject.name; string keyName = imageName.Substring(9); if (keyName.Length > 1) { ui.image_KeyPressed = GameObject.Instantiate(view.image_KeyPressed2) as Image; } else { ui.image_KeyPressed = GameObject.Instantiate(view.image_KeyPressed1) as Image; } ui.image_KeyPressed.transform.parent = view.panel_KeyParent.transform; ui.image_KeyPressed.rectTransform.anchoredPosition = image_key.rectTransform.anchoredPosition; ui.image_KeyPressed.rectTransform.localScale = Vector3.one; ui.image_KeyPressed.SetNativeSize(); ui.image_KeyPressed.gameObject.SetActive(true); } } else { if (ui.image_KeyPressed != null) { GameObject.Destroy(ui.image_KeyPressed.gameObject); ui.image_KeyPressed = null; ui.image_Key = null; } } // 文字显示 ui.image_Head.gameObject.SetActive(true); for (int count = 0; count < GameConfig.GAME_CONFIG_NAME_LEN; ++count) { if (uiParam.index >= count) { // 显示文字 int imageIndex = GetLetterImageIndexBy(uiParam.name[count]); ui.image_CharSlotList[count].sprite = view.image_EditChars[imageIndex].sprite; if (imageIndex == 26) { ui.image_CharSlotList[count].SetNativeSize(); } else { ui.image_CharSlotList[count].rectTransform.sizeDelta = size2; } ui.image_CharSlotList[count].gameObject.SetActive(true); } else { // 不显示 ui.image_CharSlotList[count].gameObject.SetActive(false); } } if (uiParam.flag) { ++fullNameCount; } } else { ui.image_Head.gameObject.SetActive(false); } view.image_Edits[index] = ui; uiParamList[index] = uiParam; } // 判断是否输入完毕 if (fullNameCount == playerCount) { remainTime = 0; } } } }