public override void OnEnter() { GameObject soulPrefab = ObjectCache.Soul; // Workaround because Spawn extension is slightly broken Object.Destroy(soulPrefab.Spawn()); soulPrefab.SetActive(true); FlingUtils.Config flingConfig = new FlingUtils.Config { Prefab = soulPrefab, AmountMin = 100, AmountMax = 101, SpeedMin = 10f, SpeedMax = 20f, AngleMin = 0f, AngleMax = 360f }; FlingUtils.SpawnAndFling(flingConfig, _gameObject.transform, new Vector3(0f, 0f, 0f)); soulPrefab.SetActive(false); Finish(); }
public override void OnEnter() { // Special case for pickups where you don't have an opportunity to pick up the geo string sceneName = Ref.GM.GetSceneNameString(); if (sceneName == SceneNames.Dream_Nailcollection || sceneName == SceneNames.Room_Sly_Storeroom || sceneName == SceneNames.Abyss_08) { Ref.Hero.AddGeo(_count); Finish(); return; } int smallNum; int medNum; int largeNum; if (!_minimize) { Random random = new Random(); smallNum = random.Next(0, _count / 10); _count -= smallNum; largeNum = random.Next(_count / (GEO_VALUE_LARGE * 2), _count / GEO_VALUE_LARGE + 1); _count -= largeNum * GEO_VALUE_LARGE; medNum = _count / GEO_VALUE_MEDIUM; _count -= medNum * 5; smallNum += _count; } else { largeNum = _count / GEO_VALUE_LARGE; _count -= largeNum * GEO_VALUE_LARGE; medNum = _count / GEO_VALUE_MEDIUM; _count -= medNum * GEO_VALUE_MEDIUM; smallNum = _count; } GameObject smallPrefab = ObjectCache.SmallGeo; GameObject mediumPrefab = ObjectCache.MediumGeo; GameObject largePrefab = ObjectCache.LargeGeo; // Workaround because Spawn extension is slightly broken Object.Destroy(smallPrefab.Spawn()); Object.Destroy(mediumPrefab.Spawn()); Object.Destroy(largePrefab.Spawn()); smallPrefab.SetActive(true); mediumPrefab.SetActive(true); largePrefab.SetActive(true); FlingUtils.Config flingConfig = new FlingUtils.Config { Prefab = smallPrefab, AmountMin = smallNum, AmountMax = smallNum, SpeedMin = 15f, SpeedMax = 30f, AngleMin = 80f, AngleMax = 115f }; // Special case for thorns of agony, spore shroom, flukenest, etc to stop geo from flying into unreachable spots if (sceneName == SceneNames.Fungus1_14 || sceneName == SceneNames.Fungus2_20 || sceneName == SceneNames.Waterways_12 || sceneName == SceneNames.Fungus3_26 || sceneName == SceneNames.Fungus1_Slug) { flingConfig.AngleMin = 90; flingConfig.AngleMax = 90; } if (smallNum > 0) { FlingUtils.SpawnAndFling(flingConfig, _gameObject.transform, new Vector3(0f, 0f, 0f)); } if (medNum > 0) { flingConfig.Prefab = mediumPrefab; flingConfig.AmountMin = flingConfig.AmountMax = medNum; FlingUtils.SpawnAndFling(flingConfig, _gameObject.transform, new Vector3(0f, 0f, 0f)); } if (largeNum > 0) { flingConfig.Prefab = largePrefab; flingConfig.AmountMin = flingConfig.AmountMax = largeNum; FlingUtils.SpawnAndFling(flingConfig, _gameObject.transform, new Vector3(0f, 0f, 0f)); } smallPrefab.SetActive(false); mediumPrefab.SetActive(false); largePrefab.SetActive(false); Finish(); }
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); }
private IEnumerator StartFluke(PlayMakerFSM fireballCast, GameObject playerSpells, bool facingRight, int damage) { // Obtain the prefab and instantiate it for the fluke only variation var flukeObject = fireballCast.GetAction <FlingObjectsFromGlobalPool>("Flukes", 0).gameObject.Value; var fluke = Object.Instantiate( flukeObject, playerSpells.transform.position, Quaternion.identity ); if (GameSettings.IsPvpEnabled && ShouldDoDamage && damage != 0) { fluke.AddComponent <DamageHero>().damageDealt = damage; } // Create a config of how to fling the individual flukes // based on the direction the player is facing // This is all from the FSM var config = new FlingUtils.Config { Prefab = fluke, AmountMin = 16, AmountMax = 16, AngleMin = facingRight ? 20 : 120, AngleMax = facingRight ? 60 : 160, SpeedMin = 14, SpeedMax = 22 }; // Spawn the flukes relative to the player object with the created config var spawnedFlukes = FlingUtils.SpawnAndFling( config, playerSpells.transform, Vector3.zero ); On.SpellFluke.hook_Burst burstDelegate = null; if (GameSettings.IsPvpEnabled && ShouldDoDamage && damage != 0) { // Keep track of SpellFluke components that we spawned var spellFlukes = new List <SpellFluke>(); foreach (var spawnedFluke in spawnedFlukes) { var spellFlukeComponent = spawnedFluke.GetComponent <SpellFluke>(); spellFlukes.Add(spellFlukeComponent); } // Make a delegate that fires when the fluke bursts and disable the DamageHero component burstDelegate = (orig, self) => { orig(self); if (spellFlukes.Contains(self)) { var damageHeroComponent = self.gameObject.GetComponent <DamageHero>(); damageHeroComponent.enabled = false; damageHeroComponent.damageDealt = damage; } }; // Assign the delegate On.SpellFluke.Burst += burstDelegate; } yield return(new WaitForSeconds(5.0f)); // As a backup, destroy all spawned flukes after a maximum of 4 seconds foreach (var spawnedFluke in spawnedFlukes) { Object.Destroy(spawnedFluke); } // If we added a delegate, we can now remove it again if (GameSettings.IsPvpEnabled) { // Remove the burst delegate On.SpellFluke.Burst -= burstDelegate; } }
/// <summary> /// Handle the Baldur Shell animation in case the player has the charm equipped. /// </summary> /// <param name="playerEffects">The GameObject for the player effects.</param> /// <returns>True if the shell animation was handled, false otherwise.</returns> private bool HandleShellAnimation(GameObject playerEffects) { // 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 (shellAnimation == null) { return(false); } // If either version was found, we need to play some animations and sounds // 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); } } } return(true); }
public override void GiveImmediate(Container container, FlingType fling, Transform transform) { if (fling == FlingType.DirectDeposit) { HeroController.instance.AddGeo(amount); return; } int smallNum; int medNum; int largeNum; if (amount < 70) { smallNum = amount; medNum = 0; largeNum = 0; } else if (amount < 425) { medNum = amount / 5; smallNum = amount - 5 * medNum; largeNum = 0; } else { largeNum = amount / 25; medNum = (amount - largeNum * 25) / 5; smallNum = amount - largeNum * 25 - medNum * 5; } GameObject smallPrefab = ObjectCache.SmallGeo; GameObject mediumPrefab = ObjectCache.MediumGeo; GameObject largePrefab = ObjectCache.LargeGeo; // Workaround because Spawn extension is slightly broken GameObject.Destroy(smallPrefab.Spawn()); GameObject.Destroy(mediumPrefab.Spawn()); GameObject.Destroy(largePrefab.Spawn()); smallPrefab.SetActive(true); mediumPrefab.SetActive(true); largePrefab.SetActive(true); FlingUtils.Config flingConfig = new FlingUtils.Config { Prefab = smallPrefab, AmountMin = smallNum, AmountMax = smallNum, SpeedMin = 15f, SpeedMax = 30f, AngleMin = 80f, AngleMax = 115f }; if (smallNum > 0) { FlingUtils.SpawnAndFling(flingConfig, transform, new Vector3(0f, 0f, 0f)); } if (medNum > 0) { flingConfig.Prefab = mediumPrefab; flingConfig.AmountMin = flingConfig.AmountMax = medNum; FlingUtils.SpawnAndFling(flingConfig, transform, new Vector3(0f, 0f, 0f)); } if (largeNum > 0) { flingConfig.Prefab = largePrefab; flingConfig.AmountMin = flingConfig.AmountMax = largeNum; FlingUtils.SpawnAndFling(flingConfig, transform, new Vector3(0f, 0f, 0f)); } if (fling == FlingType.StraightUp) { flingConfig.AngleMin = 90; flingConfig.AngleMax = 90; } smallPrefab.SetActive(false); mediumPrefab.SetActive(false); largePrefab.SetActive(false); }
public static void SpawnGeo(int _count, bool _minimize, FlingType fling, Transform _transform) { int smallNum; int medNum; int largeNum; if (!_minimize) { Random random = new Random(); smallNum = random.Next(0, _count / 10); _count -= smallNum; largeNum = random.Next(_count / (GEO_VALUE_LARGE * 2), _count / GEO_VALUE_LARGE + 1); _count -= largeNum * GEO_VALUE_LARGE; medNum = _count / GEO_VALUE_MEDIUM; _count -= medNum * 5; smallNum += _count; } else { largeNum = _count / GEO_VALUE_LARGE; _count -= largeNum * GEO_VALUE_LARGE; medNum = _count / GEO_VALUE_MEDIUM; _count -= medNum * GEO_VALUE_MEDIUM; smallNum = _count; } GameObject smallPrefab = ObjectCache.SmallGeo; GameObject mediumPrefab = ObjectCache.MediumGeo; GameObject largePrefab = ObjectCache.LargeGeo; // Workaround because Spawn extension is slightly broken Object.Destroy(smallPrefab.Spawn()); Object.Destroy(mediumPrefab.Spawn()); Object.Destroy(largePrefab.Spawn()); smallPrefab.SetActive(true); mediumPrefab.SetActive(true); largePrefab.SetActive(true); FlingUtils.Config flingConfig = new FlingUtils.Config { Prefab = smallPrefab, AmountMin = smallNum, AmountMax = smallNum, SpeedMin = 15f, SpeedMax = 30f, AngleMin = 80f, AngleMax = 115f }; if (smallNum > 0) { FlingUtils.SpawnAndFling(flingConfig, _transform, new Vector3(0f, 0f, 0f)); } if (medNum > 0) { flingConfig.Prefab = mediumPrefab; flingConfig.AmountMin = flingConfig.AmountMax = medNum; FlingUtils.SpawnAndFling(flingConfig, _transform, new Vector3(0f, 0f, 0f)); } if (largeNum > 0) { flingConfig.Prefab = largePrefab; flingConfig.AmountMin = flingConfig.AmountMax = largeNum; FlingUtils.SpawnAndFling(flingConfig, _transform, new Vector3(0f, 0f, 0f)); } if (fling == FlingType.StraightUp) { flingConfig.AngleMin = 90; flingConfig.AngleMax = 90; } smallPrefab.SetActive(false); mediumPrefab.SetActive(false); largePrefab.SetActive(false); }