/// <summary> /// /// </summary> /// <param name="redeemedLaunchKey"></param> /// <param name="spawner"></param> /// <returns></returns> private IEnumerator InsertKey(GameObject redeemedLaunchKey, CharacterSpawner spawner) { var spriteAnimator = redeemedLaunchKey.GetComponent <SpriteAnimator>(); spriteAnimator.Play(spriteAnimator.animations[1]); yield return(new WaitForSecondsCutscene(0.2f)); redeemedLaunchKey.GetComponent <SpriteRenderer>().sortingLayerName = StaticSortingLayer.KeyAtSpawner.ToString(); redeemedLaunchKey.transform.DOMove(spawner.nextKeySlot.transform.position, 0.05f) .SetAsCutscene().onComplete += (() => { GameplayStatics.state = GameplayState.GameRunning; CameraShakeManager.instance.Shake(Bootstrap.instance.data.keyRedeemShake); spawner.EmitSound(KeyRedeemSoundKey); GetComponent <PlayerScoredAnimation>().StartAnimation(spawner.character.characterDescriptor.name, spawner.character.characterDescriptor.mainColor, ++spawner.score >= _maxScore); Step(); var redeemRepulser = new GameObject(nameof(RedeemRepulser), typeof(RedeemRepulser)); redeemRepulser.transform.position = spawner.transform.position; redeemRepulser.layer = LayerMask.NameToLayer("RedeemRepulser"); if (spawner.character.GetComponent <CharacterMarketingZoom>() == null) { GetComponent <CameraScoreZoom>().ZoomOut(spawner.transform.position); } this.EmitSound(RippleSoundKey); }); yield break; }
/// <summary> /// /// </summary> private void SpawnCharacters() { var playersParams = GameModeParams.instance.playerParams.Where(x => x.isPlaying).ToArray(); if (playersParams.Length == 2) { var selectedSpawner = characterSpawners[Random.Range(0, characterSpawners.Count)]; Debug.Assert(selectedSpawner.nemesisSpawner != null); SpawnCharacter(playersParams[0], selectedSpawner); SpawnCharacter(playersParams[1], selectedSpawner.nemesisSpawner); } else { foreach (var playerParams in playersParams) { CharacterSpawner selectedSpawner = null; do { selectedSpawner = characterSpawners[Random.Range(0, characterSpawners.Count)]; } while (selectedSpawner.playerIndex != 0); SpawnCharacter(playerParams, selectedSpawner); } } // Disable every spawner that is not used for this game. foreach (var spawner in characterSpawners) { if (spawner.teamIndex == -1) { spawner.gameObject.SetActive(false); } } }
/// <summary> /// /// </summary> /// <param name="playerParams"></param> /// <param name="selectedSpawner"></param> private void SpawnCharacter(PlayerParams playerParams, CharacterSpawner selectedSpawner) { selectedSpawner.playerIndex = playerParams.playerIndex; selectedSpawner.teamIndex = playerParams.teamIndex; selectedSpawner.BeginSpawn(); }
/// <summary> /// /// </summary> /// <param name="winner"></param> /// <returns></returns> private IEnumerator GameOver(CharacterSpawner winner) { for (var i = 0; i < characterSpawners.Count; ++i) { if (characterSpawners[i].teamIndex == -1) { continue; } characterSpawners[i].UpdateScoreInfo(); Telemetry.game.Set($"player{i}Score", characterSpawners[i].score); } isGameOver = true; var character = winner.character; var aiBehaviourManager = character.GetComponentInChildren <AIBehaviourManager>(); if (aiBehaviourManager != null) { Destroy(aiBehaviourManager.gameObject); } yield return(winner.OpenPod()); character.SetGameplayState(CharacterGameplayState.Leaving); yield return((character.gameplayStateHandler as CharacterGameplayState_Leaving).coroutine); yield return(winner.ClosePod()); StartCoroutine(TriggerExplosions()); yield return(new WaitForSeconds(1.0f)); for (var i = 0; i < characterSpawners.Count; ++i) { if (characterSpawners[i].teamIndex == -1) { continue; } Telemetry.game.Set($"player{i}Score", characterSpawners[i].score); if (characterSpawners[i] == winner) { continue; } if (characterSpawners[i].character != null) { characterSpawners[i].character.SetGameplayState(CharacterGameplayState.Panicking); } } yield return(new WaitForSeconds(4.0f)); GameplayStatics.TransitionToScene(GameConstants.VictoryScene); yield break; }
/// <summary> /// /// </summary> protected override void Step() { CharacterSpawner winner = null; foreach (var spawner in characterSpawners) { if (spawner.score >= _maxScore) { winner = spawner; break; } } if (winner == null) { TriggerHazardSteps(); StartCoroutine(Reset(++_stepCount)); return; } foreach (var spawner in characterSpawners) { spawner.canSpawn = false; } foreach (var character in FindObjectsOfType <Character>()) { var input = character.GetComponent <CharacterInput>(); if (input != null) { input.inputLocked = true; } } StartCoroutine(GameOver(winner)); }