IEnumerator waitForPlayerConnection() { float maxTime = 10; float waited = 0; bool allConnected = false; //Wait for all the players to be connected or for 10 seconds and then start the game. while (waited < maxTime && !allConnected) { yield return(new WaitForSeconds(0.5f)); allConnected = true; foreach (Player pd in pm.getPlayers()) { if (pd.data.connectionToClient == null) { allConnected = false; break; } } waited += 0.5f; } startGame(); yield return(null); }
public ActionResult <List <Player> > getPlayers() { PlayerManager PM = new PlayerManager(); List <Player> players = PM.getPlayers(); return(players); }
public IEnumerator handleEventCardClick(PlayerCard card) { overlayUI.StopAllCoroutines(); overlayUI.deactivateInteractableOverlay(); switch (card.getId()) { case Vals.ONE_QUIET_NIGHT: if (Vals.oneQuietNightActive) { yield break; } Debug.Log("Playing One Quiet Night"); Vals.oneQuietNightActive = true; break; case Vals.AIRLIFT: Debug.Log("Playing Airlift"); string message = "Select player to Airlift then select destination"; yield return(StartCoroutine(overlayUI.requestSimpleSelectionFromPlayer(playerManager.getPlayers(), Vals.SELECTABLE_PLAYER, message))); Vals.cardResolving = Vals.AIRLIFT; break; case Vals.RESILIENT_POPULATION: Debug.Log("Playing Resilient Population"); if (board.getInfectionDiscardPile().Count > 0) { yield return(StartCoroutine(resilientPopulation())); } break; case Vals.FORECAST: Debug.Log("Playing Forecast"); yield return(StartCoroutine(forecast())); break; case Vals.GOVERNMENT_GRANT: Debug.Log("Playing Government Grant"); Vals.cardResolving = Vals.GOVERNMENT_GRANT; break; } board.eventCardPlayed(card); yield break; }
// Update is called once per frame void Update() { base.Update(); if (spawnM) { playerM = FindObjectOfType<PlayerManager>(); players = playerM.getPlayers(); size = players.Length; threatLevel = damageDealt = players; damageDealt = new Player[size]; for (int i = 0; i < size; i++) { players[i].Reset(); } one = two = three = four = 0; tempThreat = 0; tempDamage = 0; temp1 = 0; temp2 = 0; Grouper.setPlayerGroup(players, size); grouping = false; getPlayerType(); int initialTarget = UnityEngine.Random.Range(0, size); target = players[initialTarget].gameObject; spawnM = false; } targetPos = target.transform.position; CalcDirection(); if (refresh) { Debug.Log(ranged + " " + grouping + " " + melee + " " + support); refresh = false; } if (teleClawStage > 0) { teleClawUpdate(); } if (isTeleporting) { //ANIMATION STUFF~~~~~~~~~~~~~~~~~ //How teleport works: transform to swarm -> isTel = true, swarm animations for moving around (same as //normal swarm animations, low speed = circular, high speed = more horizontal, accel one way + low speed other way = turning //remember to switch x scale on turn) -> isTel = false, transform to malady. //if tele claw, then claw, tele process to new location (original unless people are clumping there) //positions are already put in with a set time taken to get everywhere (lerp, teleduration, below) so animations have a set time //ANIMATION STUFF~~~~~~~~~~~~~~~~~ isTeleporting set to true at end of transforming into swarm animation //ANIMATION STUFF~~~~~~~~~~~~~~~~~ invincible set to true at start of transforming into swarm animation transform.position = Vector3.Lerp(startPos, teleTarget, teleDuration); if (lerpDuration <= 0) { isTeleporting = false; isInvincible = false; //ANIMATION STUFF~~~~~~~~~~~~~~~~~ //stop current animation, start transform back to human animation //not needed below //isTeleporting set to false at start of transforming into malady animation //invincible set false at end of anim } } else if (!animating) { Act(classification); } if (refreshPriority >= 10) { sortPriority(); refreshPriority = 0; } if (isInvincible && invTime <= 0) { isInvincible = false; } refreshPriority += Time.unscaledDeltaTime; hands_CD += Time.unscaledDeltaTime; animationDelay += Time.unscaledDeltaTime; invTime -= Time.unscaledDeltaTime; lerpDuration -= Time.unscaledDeltaTime; }