private bool?deletionLayer; // Functional if true, decorative if false protected override void Awake() { base.Awake(); dialogueMenu.DialogueOpened += () => AddLock(dialogueMenu); dialogueMenu.DialogueOpened += () => previewObject.SetAlpha(0); dialogueMenu.DialogueClosed += () => RemoveLock(dialogueMenu); }
private IEnumerator EndTurnCoroutine(Process process) { yield return(new WaitUntil(() => process.HasExited)); // Close prompt dialogueMenu.CloseDialogue(); // Read new additions from file string[] lines = File.ReadAllLines(Application.dataPath + "/StreamingAssets/Model/additions.csv"); float rate = totalDuration / lines.Length; // Was weird to have this change depending on # of additions if (lines.Length < 8) { rate = 0.5f; } foreach (string line in lines) { // - Parse values string[] values = line.Split(','); SpriteData sprite = SpriteManager.Instance.GetSprite(values[0]); int spriteX = int.Parse(values[1]); int spriteY = int.Parse(values[2]); if (GridManager.Instance.CanAddGridObject(sprite, spriteX, spriteY)) { // - Scroll window to addition location windowScroll.ScrollOverTime(spriteX + sprite.Width / 2); float time = 0; while (time < rate * 0.75f) { yield return(null); if (!IsLocked(dialogueMenu)) { time += Time.deltaTime; } } // - Fade addition in GridObject addition = GridManager.Instance.AddGridObject(sprite, spriteX, spriteY); addition.SetAlpha(0); while (time < rate) { yield return(null); if (!IsLocked(dialogueMenu)) { time += Time.deltaTime; addition.SetAlpha((time - rate * 0.75f) / (rate * 0.25f)); } } addition.SetAlpha(1); } } // Unblock input windowScroll.StopScrolling(); gridPlacement.RemoveLock(this); RemoveLock(this); }
private IEnumerator EndTurnCoroutine() { yield return(new WaitForSeconds(0.5f)); /** * int numAttempts = 0; * while (!System.IO.File.Exists(Constants.directory+ "/StreamingAssets/Model/additions.csv") && numAttempts<10){ * numAttempts+=1; * UnityEngine.Debug.Log (numAttempts); * yield return new WaitForSeconds(0.5f); * * } */ //process.Close(); string receivedFromServer = ""; try { Byte[] bytes = new Byte[8112]; bool listening = true; while (listening) { // Get a stream object for reading using (NetworkStream stream = socketConnection.GetStream()) { int length; // Read incomming stream into byte arrary. while ((length = stream.Read(bytes, 0, bytes.Length)) != 0) { var incommingData = new byte[length]; Array.Copy(bytes, 0, incommingData, 0, length); // Convert byte array to string message. string serverMessage = Encoding.ASCII.GetString(incommingData); UnityEngine.Debug.Log("server message received as: " + serverMessage); receivedFromServer += serverMessage; } listening = false; } } } catch (SocketException socketException) { UnityEngine.Debug.Log("Socket exception: " + socketException); } string[] eachAddition = receivedFromServer.Split(new char[] { '*' }); socketConnection.Close(); socketConnection = null; float rate = 2.0f / eachAddition.Length;//Was weird to have this change depending on # of additions if (eachAddition.Length < 8) { rate = 0.3f; } dialogueMenu.CloseDialogue(); foreach (string value in eachAddition) { string[] additionSplitFormat = value.Split(new char[] { ',' }); if (additionSplitFormat.Length == 4) { SpriteData sprite = SpriteManager.Instance.GetSprite(actions[int.Parse(additionSplitFormat[2])]); int spriteX = int.Parse(additionSplitFormat[0]) + startX; int spriteY = int.Parse(additionSplitFormat[1]); // - Scroll window to addition location windowScroll.ScrollOverTime(spriteX + sprite.Width / 2); float time = 0; while (time < rate * 0.75f) { yield return(null); if (!IsLocked) { time += Time.deltaTime; } } // - Fade addition in GridObject addition = GridManager.Instance.AddGridObject(sprite, spriteX, spriteY, true); if (addition != null) { gridObjects.Add(addition); addition.SetAlpha(0); time = 0; while (time < rate) { yield return(null); if (!IsLocked) { time += Time.deltaTime; addition.SetAlpha((time - rate * 0.25f) / (rate * 0.25f)); } } } else { yield return(new WaitForSeconds(rate - time)); } } } // Unblock input windowScroll.StopScrolling(); gridPlacement.RemoveLock(this); LogHandler.Instance.WriteLine("Player Turn: time = " + Time.time); }