// Input Loop ----------------------------- void Update() { if (cardHolder.IsReleaseOver()) { input.Clear(); inputText = ""; } if (listen) { foreach (char c in Input.inputString) { // if the char is valid if (Array.IndexOf(forbidenChars, c) < 0) { if (c == "\b"[0] && input.Count > 0) { // backspace input.RemoveAt(input.Count - 1); } else if (input.Count < 20 && c != "\b"[0] && c != "\n"[0] && c != "\r"[0]) { // if the players input is shorter then 20 and he doesn't inputs 'enter' or 'space' input.Add(c); } } } // builds the string & updates the inputfield inputText = MakeString(input).ToLower(); cardHolder.UpdateCard(inputText); } }
void Update() { if (!IsGameOver()) { // if there is no CountDown if (!ui.CountDown()) { // checks game over IsGameOver(); if (cardHolder.IsReleaseOver()) { // if the release animation is over if (!cardHolder.IsCanceled()) { // & attack is not canceled: deal damage int damage = cardHolder.TotalDamage(); opponent.UpdateHealth(damage); photonView.RPC("UpdateHealth", PhotonTargets.Others, damage); player.lastDamage = damage; ui.UpdateOpponentHealthBar(opponent.health); } // init cardholder with a card cardHolder.Init(); ui.NewTagCloud(); } // if some card is active if (cardHolder.IsInputReady()) { // listen to input InputListener.Listen(true); if (Input.GetKeyDown("return") && cardHolder.IsReleaseReady()) { InputListener.Listen(false); string newTag = InputListener.GetInput(); if (player.lastTag == "") { player.lastTag = "nothing_here"; } StartCoroutine(QueryManager.QueryDamageDistribution(newTag, player.lastTag, player.lastDamage, OnResponce)); ui.RemoveTagCloud(); player.lastTag = newTag; } } else { // Cancel or Release attack cardHolder.HandleAttack(); } } } else { gameOver = true; if (!disconnected) { photonView.RPC("GameOver", PhotonTargets.All); } else { if (ui.ExitGame() || ui.concede) { Application.LoadLevel("MainMenu"); } } } }