protected override void UpdateVisuals() { FinishIndicator.SetActive(false); ApproachPercentage = (Delay + NoteStopwatch.ElapsedMilliseconds * PlaybackSpeed / 1000f) / ApproachTime; if (ApproachPercentage < 1) { TopHollowNoteBody.transform.localScale = new Vector3(0.2f + 0.3f * ApproachPercentage, 1); BottomHollowNoteBody.transform.localScale = new Vector3(0.2f + 0.3f * ApproachPercentage, 1); NoteFill.transform.localScale = NoteBorder.transform.localScale = new Vector3(0.6f + 0.4f * ApproachPercentage, 0.6f + 0.4f * ApproachPercentage); InnerNoteBorder.transform.localScale = new Vector3(0.4f + 0.35f * ApproachPercentage, 0.4f + 0.35f * ApproachPercentage); } else { CompletionPercentage = (Delay + NoteStopwatch.ElapsedMilliseconds * PlaybackSpeed / 1000f - ApproachTime) / HoldTime; TopFillNoteBodyMask.transform.localScale = new Vector3(Size * 50, TopHeight * CompletionPercentage * 100); BottomFillNoteBodyMask.transform.localScale = new Vector3(Size * 50, BottomHeight * CompletionPercentage * 100); if (CompletionPercentage > 1) { NoteStopwatch.Stop(); ParentPool.ReturnToPool(gameObject, Notetype); } } }
protected override void UpdateVisuals() { ApproachPercentage = (Delay + NoteStopwatch.ElapsedMilliseconds * PlaybackSpeed / 1000f) / ApproachTime; NoteFill.transform.localScale = new Vector3(ApproachPercentage, ApproachPercentage); NoteBorder.transform.localScale = new Vector3(0.6f + ApproachPercentage * 0.4f, 0.6f + ApproachPercentage * 0.4f); if (ApproachPercentage > 1) { NoteStopwatch.Stop(); ParentPool.ReturnToPool(gameObject, Notetype); } }
/// <summary> /// IEnumeratable HTTP POST to URI. /// </summary> /// <returns>Enumeratable Function</returns> /// <param name="URI">The Target URI.</param> /// <param name="contentType">The Content-Type Header</param> /// <param name="payload">The data to be posted.</param> /// <param name="cookie">Any previous cookie data to be used for authentication.</param> /// <param name="callback">A callback function (int hash, Hashtable headers, string payload).</param> IEnumerator PostReturnedText(string URI, string contentType, string payload, string cookie, System.Action <int, Dictionary <string, string>, string> callback) { // Assign Busy Flag _busy = true; // Message Data byte[] postData = System.Text.Encoding.ASCII.GetBytes(payload.ToCharArray()); // Process Headers var headers = new Dictionary <string, string> (); //headers.Add ("Content-Type", contentType); //headers.Add ("Content-Length", postData.Length); //if (cookie != null) // headers.Add ("Cookie", cookie); var newCall = new WWW(URI, postData, headers); yield return(newCall); while (!newCall.isDone) { yield return(new WaitForSeconds(0.01f)); } if (callback != null) { if (newCall.responseHeaders ["STATUS"].Contains(" 200 ")) { callback(_hash, new Dictionary <string, string> (newCall.responseHeaders), newCall.text); } else { callback(_hash, new Dictionary <string, string> (newCall.responseHeaders), ""); } } _busy = false; ParentPool.Despawn(gameObject); }
/// <summary> /// IEnumeratable HTTP GET Request to URI. /// </summary> /// <returns>Enumeratable Function</returns> /// <param name="URI">The Target URI.</param> /// <param name="cookie">Any previous cookie data to be used for authentication.</param> /// <param name="callback">A callback function (int hash, Hashtable headers, string payload).</param> IEnumerator GetReturnedText(string URI, string cookie, System.Action <int, Dictionary <string, string>, string> callback) { // Assign Busy Flag _busy = true; // Process Headers var headers = new Dictionary <string, string> (); if (cookie != null) { headers.Add("Cookie", cookie); } // Make the call var newCall = new WWW(URI, null, headers); yield return(newCall); while (!newCall.isDone) { yield return(new WaitForSeconds(0.01f)); } // Callback! (Avoid Unity Bitching) if (callback != null) { if (newCall.responseHeaders.ContainsKey("STATUS") && newCall.responseHeaders ["STATUS"].Contains(" 200 ")) { callback(_hash, new Dictionary <string, string> (newCall.responseHeaders), newCall.text); } else { callback(_hash, new Dictionary <string, string> (newCall.responseHeaders), ""); } } _busy = false; ParentPool.Despawn(gameObject); }
public Population(List <GameObject> bl) { enemyList = bl; botList = new List <Bot>(); gm = GameObject.Find("GameManager").GetComponent <GameManager>(); foreach (GameObject go in enemyList) { botList.Add(go.GetComponent <Bot>()); } nInput = gm.nInputs; nOutput = gm.nOutputs; nHidden = gm.nHidden; nLayers = gm.nLayers; parentPoolSize = (gm.parentPoolSize < gm.numberOfPlayers) ? gm.parentPoolSize : gm.numberOfPlayers; heritageMethod = gm.heritageMethod; pp = gm.useParentPool; mutationRate = gm.mutationRate; specialsMutationRate = gm.specialsMutationRate; savedPerGen = gm.savedPerGen; specialsPerGen = gm.specialsPerGen; //Specials are heavily mutated children to introduce more variation in the gene samples. }
public void Return() { ParentPool.Return(this); }
/// <summary> /// IEnumeratable HTTP POST Form to URI. /// </summary> /// <returns>IEnumeratable Function</returns> /// <param name="URI">The Target URI.</param> /// <param name="formStringData">A Dictionary<string,string> of Form Data</param> /// <param name="formBinaryData">A custom binary dataset. Useful for uploading pictures.</param> /// <param name="cookie">Any previous cookie data to be used for authentication.</param> /// <param name="callback">A callback function (int hash, Hashtable headers, string payload).</param> IEnumerator FormReturnedText(string URI, Dictionary <string, string> formStringData, WebPool.FormBinaryData[] formBinaryData, string cookie, System.Action <int, Dictionary <string, string>, string> callback) { // Assign Busy Flag _busy = true; var newForm = new WWWForm(); // Add string data if (formStringData != null) { foreach (string s in formStringData.Keys) { newForm.AddField(s, formStringData [s]); } } // Add binary data if (formBinaryData != null) { foreach (WebPool.FormBinaryData b in formBinaryData) { newForm.AddBinaryData(b.FieldName, b.Data, b.FileName, b.MimeType); } } var headers = new Dictionary <string, string> (); foreach (KeyValuePair <string, string> entry in newForm.headers) { headers.Add(entry.Key, entry.Value); } if (cookie != null) { headers.Add("Cookie", cookie); } var newCall = new WWW(URI, newForm.data, headers); yield return(newCall); while (!newCall.isDone) { yield return(new WaitForSeconds(0.01f)); } // Callback! if (callback != null) { if (newCall.responseHeaders.ContainsKey("STATUS") && newCall.responseHeaders ["STATUS"].Contains(" 200 ")) { callback(_hash, new Dictionary <string, string> (newCall.responseHeaders), newCall.text); } else { callback(_hash, new Dictionary <string, string> (newCall.responseHeaders), ""); } } _busy = false; ParentPool.Despawn(gameObject); }
protected override void UpdateVisuals() { float time = Delay + NoteStopwatch.ElapsedMilliseconds * PlaybackSpeed / 1000f; ApproachPercentage = time / ApproachTime; if (!DragConnector.activeSelf && NextID > 0) { DragConnector.SetActive(true); } if (ApproachPercentage > 1) { NoteFill.transform.localScale = NoteBorder.transform.localScale = new Vector3(0.8f, 0.8f); if (CurrentPath < Paths.Count) { float pathcompletion = (Delay + NoteStopwatch.ElapsedMilliseconds * PlaybackSpeed / 1000f - (CurrentPath > 0 ? Paths[CurrentPath - 1].time : 0)) / (Paths[CurrentPath].time - (CurrentPath > 0 ? Paths[CurrentPath - 1].time : 0)); while (float.IsInfinity(pathcompletion)) { CurrentPath++; if (CurrentPath < Paths.Count) { pathcompletion = (Delay + NoteStopwatch.ElapsedMilliseconds * PlaybackSpeed / 1000f - (CurrentPath > 0 ? Paths[CurrentPath - 1].time : 0)) / (Paths[CurrentPath].time - (CurrentPath > 0 ? Paths[CurrentPath - 1].time : 0)); gameObject.transform.rotation = Quaternion.AngleAxis(90 + (float)(Math.Atan2(Paths[CurrentPath - 1].y - Paths[CurrentPath].y, Paths[CurrentPath - 1].x - Paths[CurrentPath].x) * 180 / Math.PI), Vector3.forward); } else { pathcompletion = 0; } } while (pathcompletion > 1) { if (CurrentPath > 0 && CurrentPath + 1 < Paths.Count && Notetype == (int)NoteType.CDRAG_HEAD) { gameObject.transform.rotation = Quaternion.AngleAxis(90 + (float)(Math.Atan2(Paths[CurrentPath].y - Paths[CurrentPath + 1].y, Paths[CurrentPath].x - Paths[CurrentPath + 1].x) * 180 / Math.PI), Vector3.forward); } CurrentPath++; if (CurrentPath < Paths.Count) { pathcompletion = (Delay + NoteStopwatch.ElapsedMilliseconds * PlaybackSpeed / 1000f - (CurrentPath > 0 ? Paths[CurrentPath - 1].time : 0)) / (Paths[CurrentPath].time - (CurrentPath > 0 ? Paths[CurrentPath - 1].time : 0)); } else { pathcompletion = 0; } } if (CurrentPath < Paths.Count) { gameObject.transform.position = new Vector3(Paths[CurrentPath - 1].x + pathcompletion * (Paths[CurrentPath].x - Paths[CurrentPath - 1].x), Paths[CurrentPath - 1].y + pathcompletion * (Paths[CurrentPath].y - Paths[CurrentPath - 1].y)); if (CurrentPath > 0) { DragConnector.GetComponent <SpriteRenderer>().size = new Vector2(0.175f, (1.0f - pathcompletion) * GlobalState.GetDistance(Paths[CurrentPath - 1].x, Paths[CurrentPath - 1].y, Paths[CurrentPath].x, Paths[CurrentPath].y) / gameObject.transform.localScale.x); DragConnector.transform.rotation = Quaternion.AngleAxis(90 + (float)(Math.Atan2(Paths[CurrentPath - 1].y - Paths[CurrentPath].y, Paths[CurrentPath - 1].x - Paths[CurrentPath].x) * 180 / Math.PI), Vector3.forward); } } } if (CurrentPath >= Paths.Count) { ParentPool.ReturnToPool(gameObject, Notetype); } } else { NoteFill.transform.localScale = NoteBorder.transform.localScale = new Vector3(0.4f + ApproachPercentage * 0.4f, 0.4f + ApproachPercentage * 0.4f); } }