private void SetILHotfixAssemblyDefinition(string filePath) { string contentOld = File.ReadAllText(filePath); JsonData json = GlobalTools.StringToJson(contentOld); json["name"] = "ILHotfix"; json["includePlatforms"] = new JsonData(); json["includePlatforms"].Add("Editor"); json["references"] = new JsonData(); json["references"].Add("HTFramework.RunTime"); json["references"].Add("HTFramework.ILHotfix.RunTime"); string contentNew = GlobalTools.JsonToString(json); if (contentOld != contentNew) { File.WriteAllText(filePath, contentNew); AssetDatabase.Refresh(); AssemblyDefinitionImporter importer = AssetImporter.GetAtPath("Assets" + _ILHotfixAssemblyDefinitionPath) as AssemblyDefinitionImporter; importer.SaveAndReimport(); } }
private void BCA_ColorButton_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e) { if (lb_choice.Items.Count <= 0) { FormExecution.Client_PopMessageBox("Il faut proposer au moins une carte !", "Echange"); return; } if (!validate) { btnProposition.IsEnabled = false; btnValidate.IsEnabled = false; validate = true; _admin.SendTradeProposition(_id, GlobalTools.GetDictionnaryValues(_cardsToOffer)); } else { btnProposition.IsEnabled = false; btnValidate.IsEnabled = false; _admin.SendTradeAnswer(_id, true); } }
public SearchCard() { InitializeComponent(); this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; _cardsSecondTypes = new Dictionary <CardType, CardType[]>(); _cardsSecondTypes.Add(CardType.Monstre, new CardType[] { CardType.Normal, CardType.Effet, CardType.Fusion, CardType.Rituelle, CardType.Synchro, CardType.Xyz, CardType.Pendule, CardType.Link, CardType.SpecialSummon, CardType.Syntoniseur, CardType.Union, CardType.Esprit, CardType.Gemini, CardType.Flip, CardType.Toon, CardType.Jeton, CardType.Monstre_Piège }); _cardsSecondTypes.Add(CardType.Magie, new CardType[] { CardType.Magie, CardType.Jeu_Rapide, CardType.Continue, CardType.Rituelle, CardType.Equipement, CardType.Terrain }); _cardsSecondTypes.Add(CardType.Piège, new CardType[] { CardType.Piège, CardType.Continue, CardType.Contre }); cb_cardtype1.Items.Add(CardType.Monstre); cb_cardtype1.Items.Add(CardType.Magie); cb_cardtype1.Items.Add(CardType.Piège); cb_cardtype1.SelectionChanged += Cb_cardtype1_SelectionChanged; cb_cardtype2.IsEnabled = false; cb_cardattribute.IsEnabled = false; cb_cardrace.IsEnabled = false; foreach (CardRace race in Enum.GetValues(typeof(CardRace))) { cb_cardrace.Items.Add(race); } foreach (CardAttribute attribute in Enum.GetValues(typeof(CardAttribute))) { cb_cardattribute.Items.Add(attribute); } List <string> setnames = GlobalTools.GetDictionnaryValues(CardManager.SetCodes); setnames.Sort(); foreach (string value in setnames) { cb_setnames.Items.Add(value); } LoadStyle(); this.MouseDown += Window_MouseDown; }
//近远背景 protected override void GetYuanBeiJing() { int nums = 1; Vector2 pos1 = tl.position; Vector2 pos2 = new Vector2(rd.position.x, tl.position.y); string ybjArrName = ""; ybjArrName = MapNames.GetInstance().GetJingArrNameByGKKey("jybj"); int nums2 = 1 + GlobalTools.GetRandomNum(3); if (_UpOrDown == "up" || _UpOrDown == "down") { } if (ybjArrName != "") { SetJingByDistanceU(ybjArrName, nums2, pos1, pos2, pos1.y - 0.5f + _YJmoveY - xiajiangNums, 1f, 0.8f, -50, "u"); } if (GlobalTools.GetRandomNum() > 60) { ybjArrName = MapNames.GetInstance().GetJingArrNameByGKKey("ybj"); if (ybjArrName != "") { SetJingByDistanceU(ybjArrName, nums, pos1, pos2, pos1.y + 2.3f + _YJmoveY - xiajiangNums, 2.8f, 1.5f, -70, "u"); } } if (GlobalTools.GetRandomNum() > 60) { ybjArrName = MapNames.GetInstance().GetJingArrNameByGKKey("ybj2"); if (ybjArrName != "") { SetJingByDistanceU(ybjArrName, nums, pos1, pos2, pos1.y + 3.2f + _YJmoveY - xiajiangNums, 4.6f, 1.5f, -80, "u"); } } }
public static void CreateEmptyParent() { if (EditorApplication.timeSinceStartup - lastToggleTime > 0.5f) { lastToggleTime = EditorApplication.timeSinceStartup; Transform[] targets = Selection.transforms; if (targets.Length == 1) { Transform target = targets[0]; string name = targets[0].gameObject.name; GameObject emptyParent = new GameObject(name); Undo.RegisterCreatedObjectUndo(emptyParent, "Create empty parent"); Undo.SetTransformParent(emptyParent.transform, target, "Move parent"); Undo.RecordObject(emptyParent.transform, "Reset transform"); GlobalTools.ResetTransform(emptyParent.transform, false, true); Undo.SetTransformParent(emptyParent.transform, target.parent, "Move parent"); Undo.SetTransformParent(target, emptyParent.transform, "Move to new parent"); Selection.activeGameObject = emptyParent; } else if (targets.Length > 1) { string name = targets[0].gameObject.name; GameObject emptyParent = new GameObject(name + "Root"); Undo.RegisterCreatedObjectUndo(emptyParent, "Create empty parent"); Undo.SetTransformParent(emptyParent.transform, targets[0], "Move parent"); Undo.RecordObject(emptyParent.transform, "Reset transform"); GlobalTools.ResetTransform(emptyParent.transform, false, true); Undo.SetTransformParent(emptyParent.transform, targets[0].parent, "Move parent"); foreach (var target in targets) { Undo.SetTransformParent(target, emptyParent.transform, "Move to new parent"); } Selection.activeGameObject = emptyParent; } } }
private static IEnumerator RecognitionCoroutine(CharacterRecognitionModeBase recognitionMode) { string url = string.Format("{0}?access_token={1}", recognitionMode.API, TOKEN); WWWForm form = new WWWForm(); form.AddField("image", recognitionMode.GetImageSourceByBase64()); form.AddField("recognize_granularity", recognitionMode.Granularity == CharacterRecognitionModeBase.RecognizeGranularity.Big ? "big" : "small"); form.AddField("language_type", recognitionMode.Language.ToString()); form.AddField("detect_direction", recognitionMode.IsDetectDirection ? "true" : "false"); form.AddField("detect_language", recognitionMode.IsDetectLanguage ? "true" : "false"); using (UnityWebRequest request = UnityWebRequest.Post(url, form)) { request.SetRequestHeader("Content-Type", recognitionMode.ContentType); yield return(request.SendWebRequest()); if (!request.isNetworkError && !request.isHttpError) { JsonData jsonData = GlobalTools.StringToJson(request.downloadHandler.text); if (jsonData.Keys.Contains("error_code")) { GlobalTools.LogError("文字识别失败:" + jsonData["error_code"].ToString() + " " + jsonData["error_msg"].ToString()); recognitionMode.FailHandler?.Invoke(); } else { recognitionMode.SuccessHandler?.Invoke(new OCRResponse(jsonData)); } } else { GlobalTools.LogError("文字识别失败:" + request.responseCode + " " + request.error); recognitionMode.FailHandler?.Invoke(); } } }
//是否有 顶 和背墙 public override void ShowDingDB(float __posY = 0, float __posX = 0) { if (!dibanDing.activeSelf) { dibanDing.SetActive(true); } if (dibanDing.activeSelf) { IsShowDingDB = true; } __dingDBPosX = __posX; float wuchaY = GlobalTools.GetRandomDistanceNums(2); __dingDBPosY = __posY - wuchaY; //SetDingDBPos(); //print("顶部景控制***** " + dibanDing.activeSelf); //生成 顶部时候 不许出树 或者 大概率不许出树 //dibanDing.SetActive(true); }
public void GetTX(string txName) { tx = null; tx = GlobalTools.GetGameObjectByName(txName); Vector2 v = this.GetComponent <GameBody>().groundCheck.position; //tx.transform.parent = this.transform; //print(this.transform.localScale); tx.transform.position = new Vector2(v.x, v.y - 0.2f); if (tx.GetComponent <JN_TXgensui>()) { tx.GetComponent <JN_TXgensui>().GetGenSuiObj(this.gameObject); } //if (this.transform.localScale.x == -1) //{ // tx.transform.position = new Vector2(v.x, v.y - 0.6f); //} //else { // tx.transform.position = new Vector2(v.x, v.y); //} ;//new Vector2(0, -3); //print("tx.transform.position "+ tx.transform.position); //tx.transform.position = new Vector2(0,-3); //print("position "+tx.transform.position); //if(this.gameObject!=null && this.gameObject.activeSelf) print("this player "+this.gameObject.name+" "+ this.gameObject.activeSelf); //if(this.gameObject.activeInHierarchy) if (this.gameObject != null && this.gameObject.activeSelf) { if (this.gameObject.activeSelf) { StartCoroutine(IEDestory2ByTime(tx, 0.8f)); } } }
private void UnityWebRequestAsyncOperationDone(AsyncOperation asyncOperation) { UnityWebRequestAsyncOperation async = asyncOperation as UnityWebRequestAsyncOperation; if (async != null) { if (string.IsNullOrEmpty(async.webRequest.error)) { JsonData json = GlobalTools.StringToJson(async.webRequest.downloadHandler.text); TOKEN = json["access_token"].ToString(); Repaint(); } else { GlobalTools.LogError("获取Token失败:" + async.webRequest.responseCode + " " + async.webRequest.error); } } else { GlobalTools.LogError("获取Token失败:错误的请求操作!"); } }
public override void OnInspectorGUI() { GUILayout.BeginHorizontal(); GUILayout.Label("Evaluation Type ", GUILayout.Width(100)); if (GUILayout.Button(_target.EvaluationType, "MiniPopup")) { GenericMenu gm = new GenericMenu(); List <Type> types = GlobalTools.GetTypesInRunTimeAssemblies(); for (int i = 0; i < types.Count; i++) { if (types[i].BaseType == typeof(AStarEvaluation)) { int j = i; gm.AddItem(new GUIContent(types[j].FullName), _target.EvaluationType == types[j].FullName, () => { Undo.RecordObject(target, "Set Evaluation"); _target.EvaluationType = types[j].FullName; HasChanged(); }); } } gm.ShowAsContext(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Size", GUILayout.Width(100)); Vector2Field(_target.Size, out _target.Size, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Node Radius", GUILayout.Width(100)); FloatField(_target.NodeRadius, out _target.NodeRadius, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); Toggle(_target.IsIgnoreOblique, out _target.IsIgnoreOblique, "Ignore Oblique"); GUILayout.EndHorizontal(); }
void GetTalkBar() { if (_cBar) { _cBar.GetComponent <UI_talkBar>().RemoveSelf(); } _cBar = ObjectPools.GetInstance().SwpanObject2(Resources.Load("TalkBar") as GameObject); //print("--->_talkObjName ? "+ _talkObjName); GameObject talkObj = GlobalTools.FindObjByName(_talkObjName); Transform talkPos; if (talkObj) { print("talkObj name " + talkObj.name); _talkPos = talkObj.GetComponent <GameBody>().GetTalkPos(); talkPos = talkObj.GetComponent <GameBody>().TalkPos.transform; } else { _talkPos = this.TalkPosObj.transform.position; talkPos = this.TalkPosObj.transform; } if (IsBarGensui) { _cBar.GetComponent <UI_talkBar>().ShowTalkText(_msg, _talkPos, times, _talkObjName, talkPos); } else { _cBar.GetComponent <UI_talkBar>().ShowTalkText(_msg, _talkPos, times, _talkObjName); } _clickJishiSatrt = true; }
protected override bool Enter() { base.Enter(); bool isTrigger = GlobalTools.IsTrigger(Ratio); if (isTrigger == false) { return(false); } List <ActorBase> list = Owner.GetActorsByAffectType(Affect); if (list == null) { return(false); } for (int i = 0; i < list.Count; i++) { list[i].ActorBuff.AddBuff(BuffID, Owner); } return(true); }
private void btnKeepSave_Click(object sender, EventArgs e) { try { SystemConfig config = FT.Commons.Cache.StaticCacheManager.GetConfig <SystemConfig>(); config.UseHardwareKeyboard = this.checkUseHardKeyboard.Checked; config.UseMaskPanel = this.checkUseMask.Checked; config.UseRfid = this.checkAllowRfid.Checked; config.UseVirtualKeyboard = this.checkVitualKeyboard.Checked; config.UnOperationTime = Convert.ToInt32(this.txtUnOperationTime.Text); config.Province = this.cbProvince.Text; config.City = this.cbCity.Text; config.CityId = this.cbCity.SelectedValue.ToString(); config.CinemaId = this.cbCinema.SelectedValue.ToString(); config.Cinema = this.cbCinema.Text; config.UpdateMovieTime = Convert.ToInt32(this.txtRefreshCacheTime.Text); config.PrinterType = this.cbPrinterType.Text; config.FullScreenSecond = Convert.ToInt32(this.txtFullScreenSecond.Text); config.AllowNumberKeyboard = this.checkAllowNumberKeyboard.Checked; config.IsDingXin = this.checkIsDingXin.Checked; config.AdSeconds = Convert.ToInt32(this.txtAdSeconds.Text); config.FullScreenAddWidth = Convert.ToInt32(this.txtFullScreenAddWidth.Text); config.AllowFullScreen = this.checkAllowFullScreen.Checked; FT.Commons.Cache.StaticCacheManager.SaveConfig <SystemConfig>(config); this.lbReturnMsg.Text = "修改成功!"; } catch { GlobalTools.Pop("设置时间不是数字!"); } }
//机关喷火 protected virtual void JiGuan_Penghuo() { //生成喷火机关的 判断 根据坐标 关卡nums数 大关卡数来判断 //生成喷火机关 GameObject JG_PenHuo; int jilvs = GlobalTools.GetRandomNum(); if (jilvs > 80) { JG_PenHuo = GlobalTools.GetGameObjectByName("JG_huoyan"); //在上 还是在下 float __x = 0; float __y = 0; if (GlobalTools.GetRandomNum() > 50) { //在顶部 __x = DingDBPosL.transform.position.x + 1 + GlobalTools.GetRandomDistanceNums(GetWidth() - 2f); __y = DingDBPosL.transform.position.y - 1f; JG_PenHuo.transform.localScale = new Vector3(JG_PenHuo.transform.localScale.x, -JG_PenHuo.transform.localScale.y, JG_PenHuo.transform.localScale.z); } else { __x = tl.transform.position.x + 1 + GlobalTools.GetRandomDistanceNums(GetWidth() - 1); __y = tl.transform.position.y + 1f; } JG_PenHuo.transform.position = new Vector2(__x, __y); JG_PenHuo.transform.parent = maps.transform; float jiangeshijian = 0.5f + GlobalTools.GetRandomDistanceNums(1); float penfashijian = 0.5f + GlobalTools.GetRandomDistanceNums(1); JG_PenHuo.GetComponent <JG_huoyan>().jiangeshijian = jiangeshijian; JG_PenHuo.GetComponent <JG_huoyan>().penfashijian = penfashijian; } }
void TimeTest() { //Application.targetFrameRate = 30; //float s = 8 * 365/7*6; //float t = 1000000; //print("--------------------------------------------->每个月的收入 " + t / s * 8 * 31+"元"+" 每天价值 "+t/s*8+" 每小时价值 "+t/s); //float dj = 39*0.7f*0.55f; //float zong = 10000000; //print("1000万收入 需要卖出多少份 "+zong/dj); for (int i = 0; i < 20; i++) { float jl = GlobalTools.GetRandomDistanceNums(1000); print(i + " ---- jl >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + jl); if (jl <= 8) { print(i + " zhong!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } } }
private void timer1_Tick(object sender, EventArgs e) { if (this.FindForm() == null || this.Parent == null) { #if DEBUG Console.WriteLine(this.Name + "控件不属于窗体,停止计时器"); #endif this.timer1.Stop(); this.timer1.Enabled = false; } else if (!CounterTime) { CounterTime = true; this.timer1.Stop(); this.timer1.Enabled = false; int count = Convert.ToInt32(this.lbTimeSecond.Text); #if DEBUG Console.WriteLine(System.DateTime.Now.Second.ToString() + "操作界面倒计时时间:" + this.lbTimeSecond.Text); #endif if (count > 1) { this.lbTimeSecond.Text = (count - 1).ToString(); this.timer1.Enabled = true; this.timer1.Start(); } else { //GlobalTools.StopUnOperationCounter(); timer1.Stop(); timer1.Enabled = false; #if DEBUG Console.WriteLine("操作界面本身的操作时间已经到了!"); #endif GlobalTools.ReturnMain(); } CounterTime = false; } }
protected virtual void GetEWaiZYBJ() { //现在 只有一个 草皮 string CaopiName = "ZYBJ_caopi_1"; GameObject jing = GlobalTools.GetGameObjectByName(CaopiName); jing.transform.parent = maps.transform; float W = GlobalTools.GetJingW(jing); float __x = tl.position.x + W * 0.5f - 1 + GlobalTools.GetRandomDistanceNums((GetWidth() - W + 2)); float __y = tl.position.y + GlobalTools.GetRandomDistanceNums(0.6f); float __z = 1.53f; jing.GetComponent <SpriteRenderer>().sortingOrder = -30; jing.transform.position = new Vector3(__x, __y, __z); }
// Update is called once per frame void Update() { //DPiaoDpnr(); if (UI_Save || IsInGame) { return; } if (GlobalSetDate.instance.IsChangeScreening || IsChoseInGame) { return; } verticalDirection = Input.GetAxis(VERTICAL); if (verticalDirection >= -0.6f && verticalDirection <= 0.6f) { IsFX = false; } if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W) || (!IsFX && verticalDirection > 0.6f)) { IsFX = true; FindNearestQR("up"); GlobalTools.PlayAudio("xz", this); } else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S) || (!IsFX && verticalDirection < -0.6f)) { IsFX = true; FindNearestQR("down"); //print("in------>"); GlobalTools.PlayAudio("xz", this); } else if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.J) || Input.GetKeyDown(KeyCode.Joystick1Button1) || Input.GetKeyDown(KeyCode.Joystick1Button2)) { GetChoseObj(); } }
public FullScreenSeatSelectorForm(MovieSeatSelectorPanel seatPanel, int addWidth, bool leftToRight) { InitializeComponent(); this.seatPanel = seatPanel; this.addWidth = addWidth; this.leftToRight = leftToRight; if (seatPanel.Movie != null && seatPanel.MoviePlan != null) { this.lbMovieName.Text = seatPanel.Movie.Name; this.lbMovieDetail.Text = string.Format(this.lbMovieDetail.Text, seatPanel.MoviePlan.Type, seatPanel.MoviePlan.Language, seatPanel.Movie.TotalMinutes); } if (seatPanel.RoomPlan != null) { this.lbPrice.Text = string.Format(this.lbPrice.Text, seatPanel.RoomPlan.SPrice); this.lbPlanInfo.Text = string.Format(this.lbPlanInfo.Text, seatPanel.Dt.ToString("yyyy-MM-dd"), seatPanel.RoomPlan.Playtime, seatPanel.RoomPlan.RoomName); } this.InitSeat(seatPanel.SeatList); this.RefreshSelectedPanel(); this.BackState(); GlobalTools.fullScreenSeatSelectorForm = this; GlobalTools.MaskFormKeyDown(this); }
protected override void GetStart() { base.GetStart(); roleDate = GetComponent <PlayerRoleDate>(); print("jijia xueliang------ " + roleDate.live); //roleDate.live = 2000; Globals.IsInJijia = true; if (IsInOnGroundSrop) { InOnGroundStop(); GlobalTools.FindObjByName(GlobalTag.PLAYERUI).GetComponent <UI_Nengliangtiao>().HideSelf(); if (IsJijiaGKOver) { //隐藏 推进器 GetComponent <Jijia_Zhutuiqis>().HideZhutuiqi(); } } else { ShowJijiaUI(); GetPlayerRigidbody2D().gravityScale = 0; IsInAirFly = true; IsQifeiOver = true; Globals.IsInJijia = false; TX_penhuo1.Play(); TX_penhuo2.Play(); //2个喷火长短不一 保证循环不断 A_Penhuo.Play(); A_Penhuo2.Play(); Globals.IsInJijiaGK = true; //GlobalTools.FindObjByName(GlobalTag.PLAYERUI).GetComponent<XueTiao>().GetGameObj(GetComponent<RoleDate>()); GlobalTools.FindObjByName(GlobalTag.PLAYERUI).GetComponent <XueTiao>().GetXueNum(0); print(" jijia-------- GetComponent<RoleDate>() " + GetComponent <RoleDate>().live); } //print("jiajia "+ this.transform.localScale.x); ACReset(); //if (this.transform.localScale.x == -1) GetComponent<GameBody>().TurnRight(); }
protected override void GetTopJ3() { string qjuArrName = MapNames.GetInstance().GetJingArrNameByGKKey("qju"); if (qjuArrName == "") { return; } int nums = 8 + GlobalTools.GetRandomNum(4); if (IsChaoChang) { nums += 10; } //DingDBPosL.transform.parent = GlobalTools.FindObjByName("maps").transform; //DingDBPosR.transform.parent = GlobalTools.FindObjByName("maps").transform; //print(" ??>>>>>>>>>**qjuArrName " + qjuArrName+" pos "+ DingDBPosL.transform.position); Vector2 pos1 = DingDBPosL.position; Vector2 pos2 = DingDBPosR.position; SetJingByDistanceU(qjuArrName, nums, pos1, pos2, pos1.y - 2, 0, 0, 50, "d"); }
//水面出怪 void ShuiMianChuGuai() { int GuaiNums = 0; if (ShuiMianDBNums == 100) { GuaiNums = 10 + GlobalTools.GetRandomNum(6); float _distande = Mathf.Abs(thePos2.position.x - thePos1.position.x) / (GuaiNums + 2); float __x = 0; float __y = 0; for (int i = 0; i < GuaiNums; i++) { string GuaiName = MapNames.GetInstance().GetCanRandomUSEJYGName("kongZhongXiaoGuai"); GameObject guai = GlobalTools.GetGameObjectByName(GuaiName); __x = thePos1.position.x + (i + 1) * _distande + GlobalTools.GetRandomDistanceNums(0.6f); __y = thePos1.position.y + 0.8f + GlobalTools.GetRandomDistanceNums(0.6f); guai.transform.position = new Vector2(__x, __y); guai.transform.parent = maps.transform; maps.GetComponent <GetReMap2>().GuaiList.Add(guai); } } }
void JiluSpeed() { if (GenZongJiShi > MaxGenZongTimes) { return; } if (!isFaShe) { if (this.GetComponent <Rigidbody2D>().velocity.y < 0) { //重力清0 速度清0 并且保持播放? if (!isReset) { isReset = true; ReSetSpeedAndGravity(); } isUpStart = false; //print("??? ------------ testN "+ GenZongJiShi); //设置飞行速度 SetZDSpeed(SpeedGS); //print("player ??? "+_player); if (!_player) { _player = GlobalTools.FindObjByName("player"); //return; } isFaShe = true; fire(); } } }
private static float[] Convert8BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int wavSize = BitConverter.ToInt32(source, headerOffset); headerOffset += sizeof(int); if (wavSize <= 0 || wavSize != dataSize) { GlobalTools.LogError("转换AudioClip失败:未获取到有效的WAV字节数据!"); return(null); } float[] data = new float[wavSize]; sbyte maxValue = sbyte.MaxValue; int i = 0; while (i < wavSize) { data[i] = (float)source[i] / maxValue; i += 1; } return(data); }
/// <summary> /// 合成语音,并保存语音文件(编辑器内) /// </summary> /// <param name="text">合成文本</param> /// <param name="savePath">语音文件保存路径</param> /// <param name="timeout">超时时长</param> /// <param name="audioType">音频文件格式</param> /// <param name="speaker">发音人</param> /// <param name="volume">音量</param> /// <param name="speed">音速</param> /// <param name="pitch">音调</param> private void SynthesisInEditor(string text, string savePath, SynthesisType audioType = SynthesisType.MP3, int timeout = 60000, Speaker speaker = Speaker.DuYaYa, int volume = 15, int speed = 5, int pitch = 5) { if (string.IsNullOrEmpty(text) || text == "" || Encoding.Default.GetByteCount(text) >= 1024) { GlobalTools.LogError("合成语音失败:文本为空或长度超出了1024字节的限制!"); return; } if (File.Exists(savePath)) { GlobalTools.LogError("合成语音失败:已存在音频文件 " + savePath); return; } string url = string.Format("{0}?tex='{1}'&tok={2}&cuid={3}&ctp={4}&lan={5}&spd={6}&pit={7}&vol={8}&per={9}&aue={10}", SynthesisAPI, text, TOKEN, SystemInfo.deviceUniqueIdentifier, 1, "zh", speed, pitch, volume, (int)speaker, (int)audioType); UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(url, audioType == SynthesisType.MP3 ? AudioType.MPEG : AudioType.WAV); UnityWebRequestAsyncOperation async = request.SendWebRequest(); async.completed += SynthesisDone; _isSynthesis = true; }
private void pictureBox1_Click(object sender, EventArgs e) { Point pt = MousePosition; pt = pictureBox1.PointToClient(pt); #if DEBUG Console.WriteLine("点击横幅区域为X:" + pt.X + "---Y:" + pt.Y.ToString()); #endif //点击的是选影片 if (pt.X > 144 && pt.X < 295 && pt.Y > 5 && pt.Y < 74) { //btnReturn_Click(null, null); GlobalTools.GoPanel(new MovieSelectorPanel()); // MovieSelectorPanel( } if (pt.X > 318 && pt.X < 456 && pt.Y > 9 && pt.Y < 69) { btnReturn_Click(null, null); } }
protected void PingDiQJ1() { if (GlobalTools.GetRandomNum() < 60) { return; } string zswArrName = MapNames.GetInstance().GetJingArrNameByGKKey(PingdiJingName); print("Jing 获取到的 平地 前景 名字 : " + zswArrName); if (zswArrName == "") { return; } GameObject Jobj = GetJObjByListName(zswArrName); float _w = GetWidth(); float __x = tl.position.x + _w * 0.5f; float __y = tl.position.y - 2.1f - GlobalTools.GetRandomDistanceNums(1); Jobj.transform.position = new Vector3(__x, __y, 0); }
void SanLianSanDan(Vector2 v1, int nums = 1, float hudu = 20) { GameObject zidan; float _hudu = hudu; //(qishiNums+1)-nums zidan = GetZiDan(); if (Audio_ZidanFashe) { print(" ------------------------------------------- 子弹发射 声音 "); Audio_ZidanFashe.Play(); } _hudu = hudu * (qishiNums + 1 - nums) * 3.14f / 180; Vector2 v2 = GlobalTools.GetNewV2ByHuDu(_hudu, v1); zidan.GetComponent <Rigidbody2D>().velocity = GlobalTools.GetVector2ByV2(v2, 10); //for (int i = 0; i < nums; i++) //{ // zidan = GetZiDan(); // _hudu = hudu * (i + 1) * 3.14f / 180; // Vector2 v2 = GlobalTools.GetNewV2ByHuDu(_hudu, v1); // zidan.GetComponent<Rigidbody2D>().velocity = GlobalTools.GetVector2ByV2(v2, 10); //} //for (int i = 0; i < nums; i++) //{ // zidan = GetZiDan(); // _hudu = -hudu * (i + 1) * 3.14f / 180; // Vector2 v2 = GlobalTools.GetNewV2ByHuDu(_hudu, v1); // zidan.GetComponent<Rigidbody2D>().velocity = GlobalTools.GetVector2ByV2(v2, 10); //} }
private static int WriteFileFormat(ref MemoryStream stream, int channels, int sampleRate, ushort bitDepth) { int count = 0; int total = 24; byte[] id = Encoding.ASCII.GetBytes("fmt "); count += WriteBytesToMemoryStream(ref stream, id); int subchunk1Size = 16; count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(subchunk1Size)); ushort audioFormat = 1; count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(audioFormat)); ushort numChannels = Convert.ToUInt16(channels); count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(numChannels)); count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(sampleRate)); int byteRate = sampleRate * channels * BytesPerSample(bitDepth); count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(byteRate)); ushort blockAlign = Convert.ToUInt16(channels * BytesPerSample(bitDepth)); count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(blockAlign)); count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(bitDepth)); if (count != total) { GlobalTools.LogError("转换字节数组失败:写入的字节数组长度异常!"); } return(count); }
private void OnTriggerStay2D(Collider2D Coll) { if (Coll.tag == "Player") { if (IsHitAlertControl) { //print("????????? IsHitAlertControl "+ IsHitAlertControl); if (Input.GetKeyDown(KeyCode.J)) { if (IsPlotOver) { return; } if (!GlobalTools.FindObjByName("player").GetComponent <GameBody>().IsGround) { return; } print("startNums 计时器 " + startNums); if (!IsCanClickRemovePlotKuai) { return; } IsCanClickRemovePlotKuai = false; IsStartPlot = true; if (!IsSHowTalkBar) { IsSHowTalkBar = true; GetStartPlotByTimes(); //print("点击切换 对话 " + playNums); } } } } }