private void Construct(SignalBus signalBus, Player player, FogManager fogManager, MonoBehaviourUtil monoBehaviourUtil, GameplaySettings gameplaySettings, EnemySpawner enemySpawner) { _signalBus = signalBus; _player = player; _fogManager = fogManager; _monoBehaviourUtil = monoBehaviourUtil; _gameplaySettings = gameplaySettings; _enemySpawner = enemySpawner; }
/// <summary> /// Remove all existing effect for the given player object. /// </summary> /// <param name="playerObject">The GameObject representing the player.</param> private void RemoveExistingEffects(GameObject playerObject) { // Remove all effects/attacks/spells related animations MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Attacks")); // Since we still need the baldur shell animation to play, we don't want to destroy it yet MonoBehaviourUtil.DestroyAllChildren( playerObject.FindGameObjectInChildren("Effects"), new List <string>(new[] { "Shell Animation", "Shell Animation Last" }) ); MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Spells")); }
public SceneLoader(MonoBehaviourUtil monoBehaviourUtil) { _monoBehaviourUtil = monoBehaviourUtil; }
public override void Play(GameObject playerObject, bool[] effectInfo) { // Remove all effects/attacks/spells related animations MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Attacks")); MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Effects")); MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Spells")); // Get the player effects object to put new effects in var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // If either the charge audio of the lines animation objects exists, // the player was probably focussing, so we start the Focus End effect if (playerObject.FindGameObjectInChildren("Charge Audio") != null || playerObject.FindGameObjectInChildren("Lines Anim") != null) { AnimationManager.FocusEnd.Play(playerObject); } // Find the shell animation if it exists var shellAnimation = playerEffects.FindGameObjectInChildren("Shell Animation"); var lastShellHit = false; // It might be suffixed with "Last" if it was the last baldur hit the player could take if (shellAnimation == null) { shellAnimation = playerEffects.FindGameObjectInChildren("Shell Animation Last"); lastShellHit = true; } // If either version was found, we need to play some animations and sounds if (shellAnimation != null) { // Get the sprite animator and play the correct sounds if the shell broke or not var shellAnimator = shellAnimation.GetComponent <tk2dSpriteAnimator>(); if (lastShellHit) { shellAnimator.Play("Break"); } else { shellAnimator.Play("Impact"); } // Destroy the animation after some time either way Object.Destroy(shellAnimation, 1.5f); // Get a new audio object and source and play the blocker impact clip var audioObject = AudioUtil.GetAudioSourceObject(playerEffects); var audioSource = audioObject.GetComponent <AudioSource>(); audioSource.clip = HeroController.instance.blockerImpact; audioSource.Play(); // Also destroy this object after some time Object.Destroy(audioObject, 2.0f); // If it was the last hit, we spawn some debris (bits) that fly of the shell as it breaks if (lastShellHit) { var charmEffects = HeroController.instance.gameObject.FindGameObjectInChildren("Charm Effects"); var blockerShieldObject = charmEffects.FindGameObjectInChildren("Blocker Shield"); var shellFsm = blockerShieldObject.LocateMyFSM("Control"); // Since this is replicated 5 times in the FSM, we loop 5 times for (var i = 1; i < 6; i++) { var flingObjectAction = shellFsm.GetAction <FlingObjectsFromGlobalPool>("Bits", i); // These values are from the FSM var config = new FlingUtils.Config { Prefab = flingObjectAction.gameObject.Value, AmountMin = 2, AmountMax = 2, AngleMin = 40, AngleMax = 140, SpeedMin = 15, SpeedMax = 22 }; // Spawn, fling and store the bits var spawnedBits = FlingUtils.SpawnAndFling( config, playerEffects.transform, Vector3.zero ); // Destroy all the bits after some time foreach (var bit in spawnedBits) { Object.Destroy(bit, 2.0f); } } } } // TODO: maybe add an option for playing the hit sound as it is very uncanny // Being used to only hearing this when you get hit // Obtain the hit audio clip var heroAudioController = HeroController.instance.gameObject.GetComponent <HeroAudioController>(); var takeHitClip = heroAudioController.takeHit.clip; // Get a new audio source and play the clip var takeHitAudioObject = AudioUtil.GetAudioSourceObject(playerObject); var takeHitAudioSource = takeHitAudioObject.GetComponent <AudioSource>(); takeHitAudioSource.clip = takeHitClip; // Decrease volume, since otherwise it is quite loud in contrast to the local player hit sound takeHitAudioSource.volume = 0.5f; takeHitAudioSource.Play(); Object.Destroy(takeHitAudioObject, 3.0f); }
public LoadSceneCommand(SignalBus signalBus, SceneLoader sceneLoader, MonoBehaviourUtil monoBehaviourUtil) { _signalBus = signalBus; _sceneLoader = sceneLoader; _monoBehaviourUtil = monoBehaviourUtil; }
public override void Play(GameObject playerObject, bool[] effectInfo) { // Get the effect info var hazardWasSpikes = effectInfo[0]; var hazardWasAcid = effectInfo[1]; // Remove all effects/attacks/spells related animations MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Attacks")); MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Effects")); MonoBehaviourUtil.DestroyAllChildren(playerObject.FindGameObjectInChildren("Spells")); // Disable the player object so it isn't visible anymore playerObject.SetActive(false); if (hazardWasSpikes) { // Spawn the spike death object relative to the player object var spikeDeathPrefab = HeroController.instance.spikeDeathPrefab; var spikeDeath = spikeDeathPrefab.Spawn(playerObject.transform.position); var spikeDeathFsm = spikeDeath.LocateMyFSM("Knight Death Control"); // Get the audio play action and change the spawn point of the audio to be the player object var audioPlayAction = spikeDeathFsm.GetAction <AudioPlayerOneShot>("Stab", 4); audioPlayAction.spawnPoint.Value = playerObject; // Remove the screen shake effect spikeDeathFsm.GetAction <SendEventByName>("Stab", 8).sendEvent.Value = ""; // Start a coroutine to fade out the spike death object MonoBehaviourUtil.Instance.StartCoroutine(FadeObjectOut( spikeDeath.GetComponent <MeshRenderer>(), FadeOutDuration )); // Set the spike direction to the default value as in the HeroController FSMUtility.SetFloat(spikeDeath.GetComponent <PlayMakerFSM>(), "Spike Direction", 57.29578f); // Destroy it after some time Object.Destroy(spikeDeath, FadeOutDuration); } else if (hazardWasAcid) { // Spawn the acid death object relative to the player object var acidDeathPrefab = HeroController.instance.acidDeathPrefab; var acidDeath = acidDeathPrefab.Spawn(playerObject.transform.position); var acidDeathFsm = acidDeath.LocateMyFSM("Knight Acid Death"); // Get the audio play action and change the spawn point of the audio to be the player object var damagePlayAction = acidDeathFsm.GetAction <AudioPlayerOneShot>("Effects", 2); damagePlayAction.spawnPoint.Value = playerObject; // There is another one that plays the splash sound, also change the spawn point var splashPlayAction = acidDeathFsm.GetAction <AudioPlayerOneShot>("Effects", 3); // Also change the audio player, otherwise the sound will play at the local player splashPlayAction.audioPlayer = damagePlayAction.audioPlayer; splashPlayAction.spawnPoint.Value = playerObject; // Remove the screen shake effect acidDeathFsm.GetAction <SendEventByName>("Effects", 5).sendEvent.Value = ""; // Start a coroutine to fade out the spike death object MonoBehaviourUtil.Instance.StartCoroutine(FadeObjectOut( acidDeath.GetComponent <MeshRenderer>(), FadeOutDuration )); // Set the scale to the player scale acidDeath.transform.localScale = playerObject.transform.localScale; // Destroy it after some time Object.Destroy(acidDeath, FadeOutDuration); } }