/// <summary> /// 开始异步请求 /// <para> /// 注意,该方法将会在另一个线程执行,无需再另外定义线程。 /// </para> /// <para> /// 同时,为了保证更好的效果以及正常接收结果,请务必绑定以下事件 /// </para> /// <see cref="OnHttpRequesting"/> /// <see cref="OnHttpResponded"/> /// <para> /// 这里是一些用于拓展的可选事件 /// </para> /// <see cref="OnAllQueueRequestCompletely"/> /// <see cref="OnErrorOccursInDeepLayer"/> /// </summary> /// <param name="rb">请求体</param> /// <param name="key">请求体标识</param> /// <returns></returns> public async Task RequestAsyn(RBody rb, string key) { await Task.Run(() => { _request(rb, key); }); }
private void _request(RBody rb, string key) { string rs = ""; HttpWebResponse wr = null; OnHttpRequesting?.Invoke(key); if (rb.RequestMethod == HttpMethod.GET) { wr = HttpHelper.CreateGetHttpResponse(rb.URL + rb.PatchParameter(), 5000, rb.RequestCookie); if (wr != null) { rs = HttpHelper.GetResponseString(wr); } } else { wr = HttpHelper.CreatePostHttpResponse(rb.URL, rb.RequestParameter, 5000, rb.RequestCookie); if (wr != null) { rs = HttpHelper.GetResponseString(wr); } } if (rs != "") { OnHttpResponded?.Invoke(key, new RResult(rb.URL, rb.RequestMethod, rs, rb.BodyBundle)); } }
private IEnumerator ToLowChecking(float _low) { checking = false; float time = 0; while (transform.position.y < _low) { time++; yield return(new WaitForEndOfFrame()); } if (time > _low) { RBody.AddForce(new Vector3(Random.Range(-1, 1), Random.Range(-1, 2), Random.Range(-1, 1)) * (Speed), ForceMode.Impulse); time = 0; yield return(new WaitForSeconds(_low)); checking = true; } else { yield return(new WaitForSeconds(_low)); checking = true; } }
public void cargarPartes(float anchoX, float altoY, float profZ) { RBody t = new RBody(centro, anchoX, altoY, profZ); RHead h = new RHead(centro, anchoX, altoY, profZ); LArmS as1 = new LArmS(centro, anchoX, altoY, profZ); LArmI as2 = new LArmI(centro, anchoX, altoY, profZ); LLegS ls1 = new LLegS(centro, anchoX, altoY, profZ); LLegI ls2 = new LLegI(centro, anchoX, altoY, profZ); RArmS as11 = new RArmS(centro, anchoX, altoY, profZ); RArmI as22 = new RArmI(centro, anchoX, altoY, profZ); RLegS ls11 = new RLegS(centro, anchoX, altoY, profZ); RLegI ls22 = new RLegI(centro, anchoX, altoY, profZ); partes.Add("body", t); partes.Add("head", h); partes.Add("leftArmS", as1); partes.Add("leftArmI", as2); partes.Add("leftLegS", ls1); partes.Add("leftLegI", ls2); partes.Add("rightArmS", as11); partes.Add("rightArmI", as22); partes.Add("rightLegS", ls11); partes.Add("rightLegI", ls22); }
/// <summary> /// Overriden start method /// </summary> public override void Start() { ///First we call the base base.Start(); try { enemyInput.Equals(enemyInput); } catch { enemyInput = new EnemyData(); } GetComponent <Renderer>().material.color = Random.ColorHSV(); /// We add all children to the splitPoints list stored in the enemyInput data for (int childIndex = 0; childIndex < transform.childCount; childIndex++) { enemyInput.SplitPoints.Add(transform.GetChild(childIndex)); } /// We give a random force so every enemy acts different RBody.AddForce(new Vector3(Random.Range(-5, 5), Random.Range(-5, 5), Random.Range(-5, 5) * 10f), ForceMode.Impulse); ///We always need points if (enemyInput.Points == 0) { enemyInput.Points = 10; } }
public void cargarPartes(float anchoX, float altoY, float profZ) { RBody t = new RBody(centro, anchoX, altoY, profZ); RHead h = new RHead(centro, anchoX, altoY, profZ); RArmS as1 = new RArmS(centro, anchoX, altoY, profZ); RArmI as2 = new RArmI(centro, anchoX, altoY, profZ); RLegS ls1 = new RLegS(centro, anchoX, altoY, profZ); RLegI ls2 = new RLegI(centro, anchoX, altoY, profZ); RArmS as11 = new RArmS(new Vector3(centro.X + 0.075f, centro.Y, centro.Z), anchoX, altoY, profZ); RArmI as22 = new RArmI(new Vector3(centro.X + 0.075f, centro.Y, centro.Z), anchoX, altoY, profZ); RLegS ls11 = new RLegS(new Vector3(centro.X + 0.05f, centro.Y, centro.Z), anchoX, altoY, profZ); RLegI ls22 = new RLegI(new Vector3(centro.X + 0.05f, centro.Y, centro.Z), anchoX, altoY, profZ); partes.Add(t); partes.Add(h); partes.Add(as1); partes.Add(as2); partes.Add(ls1); partes.Add(ls2); partes.Add(as11); partes.Add(as22); partes.Add(ls11); partes.Add(ls22); }
private void FixedUpdate() { if (IsDead) { return; } if (dashTimer > 0) { dashTimer -= Time.fixedDeltaTime; if (dashTimer <= 0) { } } calcVelocity = (myTransform.position - prevPos) / Time.fixedDeltaTime; prevPos = myTransform.position; Vector3 movement = new Vector3(inputs.Horizontal, 0, inputs.Vertical).normalized *speed *Time.fixedDeltaTime; Vector3 velocity = RBody.velocity; //speedVector += movement; //speedVector.y = RBody.velocity.y; //Debug.LogFormat("Speed Vector: {0}", speedVector.magnitude); //RBody.velocity *= Mathf.LerpUnclamped(0.95f, 0, Time.fixedDeltaTime); RBody.AddForce(-velocity * moveDamper); RBody.velocity += movement; }
/// <summary> /// 将请求体添加至请求列队 /// </summary> /// <param name="b">请求体<see cref="RBody"/></param> /// <param name="id">请求体ID</param> public bool AddRequestBody(RBody b, string id) { if (HttpRequestBuffer.ContainsKey(id)) { return(false); } HttpRequestBuffer.Add(id, b); return(true); }
public void OnKickEvent() { if (!IsDead && legActionController.FrontKick()) { RBody.velocity *= 0.5f; RBody.angularVelocity *= 0.5f; RBody.AddForce(mouseDirection.Forward * dashPower * 0.65f, ForceMode.Impulse); } }
public RReport(RdlcWrapper rdlcWrapper) { Margin = new RRect("", "Margin", new Rect(new Unit(1.0, UnitType.Inch))); DataSources = new RDataSources(); DataSets = new RDataSets(); Body = new RBody(); EmbeddedImages = new REmbeddedImages(); DataSources.Add(new RDataSource(rdlcWrapper.Counters)); }
/// <summary> /// 开始异步请求 /// <para> /// 注意,该方法将会在另一个线程执行,无需再另外定义线程。 /// </para> /// <para> /// 同时,为了保证更好的效果以及正常接收结果,请务必绑定以下事件 /// </para> /// <see cref="OnHttpRequesting"/> /// <see cref="OnHttpResponded"/> /// <para> /// 这里是一些用于拓展的可选事件 /// </para> /// <see cref="OnAllQueueRequestCompletely"/> /// <see cref="OnErrorOccursInDeepLayer"/> /// </summary> public async Task RequestAsyn() { await Task.Run(() => { foreach (var v in HttpRequestBuffer) { RBody rb = v.Value; _request(rb, v.Key); } HttpRequestBuffer.Clear(); OnAllQueueRequestCompletely?.Invoke(); }); }
public async Task Get(SearchType st, params string[] args) { string param = ""; string url = ""; string id; //lnc.ClearReqSeq(); switch (st) { case SearchType.SONGS: param = NeParams.SEARCH.FormatE(args); url = NeParams.NE_SEARCH; id = st.ToString(); break; case SearchType.DETAIL: param = NeParams.DETAIL.FormatE(args); url = NeParams.NE_DETAIL; id = st.ToString(); break; case SearchType.DOWNLOAD: param = NeParams.DOWNLOAD.FormatE(args); url = NeParams.NE_DOWNLOAD; id = st.ToString(); break; case SearchType.LYRIC: param = NeParams.LYRIC.FormatE(args); url = NeParams.NE_LYRIC; id = st.ToString(); break; default: return; } param = Utils.GetEncodedParams(param); RBody r = new RBody() { URL = url, RequestMethod = HttpMethod.POST }; r.AddParameter("params", param); r.AddParameter("encSecKey", NeParams.encSecKey); lnc.AddRequestBody(r, id); await lnc.RequestAsyn(); }
private Vector3 Jump(float _movement) { bool isGrounded = IsGrounded(); Debug.Log(isGrounded); Vector3 toReturn = new Vector3(0, 0, _movement); if (Input.GetButton("Jump") && isGrounded) { RBody.AddForce( Vector3.up * m_JumpSpeed, ForceMode.VelocityChange ); } return(toReturn); }
public void OnDashEvent() { if (IsDead || dashTimer > 0) { return; } //RBody.AddTorque(transform.up * 10, ForceMode.Force); //speedVector += mouseDirection.forward * dashPower; //speedVector.y = 0; RBody.AddTorque(transform.up * 5, ForceMode.Force); RBody.AddForce(mouseDirection.Forward * dashPower, ForceMode.Impulse); //RBody.angularVelocity += mouseDirection.up; AudioManager.Instance.PlayAudio(audioSource, Audio.Player.DASH); dashTimer = dashCooldown; }
public override void DamageRecieve(Transform other, IDDamage damageType, Vector3 sourcePos, Vector3 velocity) { if (IsDead) { return; } Vector3 myPos = transform.position; sourcePos.y = myPos.y; Vector3 impactDir = (myPos - sourcePos).normalized; float impact = Mathf.Clamp(velocity.magnitude, 0, maxImpact); RBody?.AddForce(((Vector3.up * 0.5f) + impactDir).normalized * (impactScale + impact), ForceMode.Impulse); AddHealth(-1); AudioManager.Instance.PlayAudio(audioSource, Audio.Enemy.HIT); CheckHealth(); }
public override void DamageRecieve(Transform other, IDDamage damageType, Vector3 sourcePos, Vector3 velocity) { if (IsDead) { return; } if (damageType != MyDamageID()) { Vector3 myPos = myTransform.position; sourcePos.y = myPos.y; Vector3 impactDir = (myPos - sourcePos).normalized; float impact = Mathf.Clamp(velocity.magnitude, 0, 2); RBody?.AddForce(impactDir * (2 + impact), ForceMode.Impulse); AddHealth(-1); AudioManager.Instance.PlayAudio(audioSource, Audio.Player.HIT); } }