public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Try to find and destroy the dung particle if it exists Object.Destroy(playerEffects.FindGameObjectInChildren("Dung Particle")); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Enable the player collider again playerObject.GetComponent <BoxCollider2D>().enabled = true; var playerEffects = playerObject.FindGameObjectInChildren("Effects"); if (playerEffects == null) { return; } var dashParticles = playerEffects.FindGameObjectInChildren("Dash Particles"); if (dashParticles != null) { #pragma warning disable 0618 // Disable emission dashParticles.GetComponent <ParticleSystem>().enableEmission = false; #pragma warning restore 0618 } var shadowDashParticles = playerEffects.FindGameObjectInChildren("Shadow Dash Particles"); if (shadowDashParticles != null) { #pragma warning disable 0618 // Disable emission shadowDashParticles.GetComponent <ParticleSystem>().enableEmission = false; #pragma warning restore 0618 } }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Obtain the Nail Arts FSM from the Hero Controller var nailArts = HeroController.instance.gameObject.LocateMyFSM("Nail Arts"); // Get an audio source relative to the player var audioObject = AudioUtil.GetAudioSourceObject(playerObject); var audioSource = audioObject.GetComponent <AudioSource>(); // Get the audio clip of the Great Slash var greatSlashClip = (AudioClip)nailArts.GetAction <AudioPlay>("G Slash", 0).oneShotClip.Value; audioSource.PlayOneShot(greatSlashClip); Object.Destroy(audioObject, greatSlashClip.length); // Get the attacks gameObject from the player object var localPlayerAttacks = HeroController.instance.gameObject.FindGameObjectInChildren("Attacks"); var playerAttacks = playerObject.FindGameObjectInChildren("Attacks"); // Get the prefab for the Great Slash and instantiate it relative to the remote player object var greatSlashObject = localPlayerAttacks.FindGameObjectInChildren("Great Slash"); var greatSlash = Object.Instantiate( greatSlashObject, playerAttacks.transform ); greatSlash.SetActive(true); greatSlash.layer = 22; SkinManager.updateTextureInMaterialPropertyBlock(greatSlash, skin.Knight); // Set the newly instantiate collider to state Init, to reset it // in case the local player was already performing it greatSlash.LocateMyFSM("Control Collider").SetState("Init"); var damage = GameSettings.GreatSlashDamage; if (GameSettings.IsPvpEnabled && ShouldDoDamage && damage != 0) { // Instantiate the Hive Knight Slash var greatSlashCollider = Object.Instantiate( HKMP.PreloadedObjects["HiveKnightSlash"], greatSlash.transform ); greatSlashCollider.SetActive(true); greatSlashCollider.layer = 22; // Copy over the polygon collider points greatSlashCollider.GetComponent <PolygonCollider2D>().points = greatSlash.GetComponent <PolygonCollider2D>().points; greatSlashCollider.GetComponent <DamageHero>().damageDealt = damage; } // Get the animator, figure out the duration of the animation and destroy the object accordingly afterwards var greatSlashAnimator = greatSlash.GetComponent <tk2dSpriteAnimator>(); var greatSlashAnimationDuration = greatSlashAnimator.DefaultClip.frames.Length / greatSlashAnimator.ClipFps; Object.Destroy(greatSlash, greatSlashAnimationDuration); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // TODO: replicate the HardLandEffect.cs code and modify it so it can be used // with effectInfo // var hardLandingEffectPrefab = HeroController.instance.hardLandingEffectPrefab; // if (hardLandingEffectPrefab != null) { // var hardLandingEffect = hardLandingEffectPrefab.Spawn(playerEffects.transform.position); // Object.Destroy(hardLandingEffect, 3.0f); // } // Get a new audio source object relative to the player object var hardLandAudioObject = AudioUtil.GetAudioSourceObject(playerEffects); // Get the actual audio source var hardLandAudioSource = hardLandAudioObject.GetComponent <AudioSource>(); // Get the wall slide clip and play it var heroAudioController = HeroController.instance.GetComponent <HeroAudioController>(); if (heroAudioController != null) { hardLandAudioSource.clip = heroAudioController.hardLanding.clip; hardLandAudioSource.Play(); } Object.Destroy(hardLandAudioObject, 3.0f); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // We only have to make the player visible again playerObject.SetActive(true); // TODO: perhaps implement the sprite flash }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get remote player effects object and play the end animation for the crystal dash trail var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Play the end animation for the crystal dash trail if it exists var sdTrail = playerEffects.FindGameObjectInChildren("SD Trail"); if (sdTrail != null) { sdTrail.GetComponent <tk2dSpriteAnimator>().Play("SD Trail End"); } var audioSourceObject = AudioUtil.GetAudioSourceObject(playerObject); var superDashFsm = HeroController.instance.gameObject.LocateMyFSM("Superdash"); var airCancelAction = superDashFsm.GetAction <AudioPlay>("Air Cancel", 0); audioSourceObject.GetComponent <AudioSource>().PlayOneShot((AudioClip)airCancelAction.oneShotClip.Value); var superDashAudio = playerObject.FindGameObjectInChildren("Superdash Audio"); if (superDashAudio != null) { superDashAudio.GetComponent <AudioSource>().Stop(); } }
protected void Play(GameObject playerObject, clientSkin skin, string chargeStateName, int chargeEffectIndex) { var coroutine = MonoBehaviourUtil.Instance.StartCoroutine(PlayAnimation(playerObject, skin, chargeStateName, chargeEffectIndex)); playerObject.GetComponent <CoroutineCancelComponent>().AddCoroutine("Crystal Dash Charge", coroutine); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { var charmEffects = HeroController.instance.gameObject.FindGameObjectInChildren("Charm Effects"); if (charmEffects == null) { return; } // Find the Thorn Hit object var thornHitObject = charmEffects.FindGameObjectInChildren("Thorn Hit"); if (thornHitObject == null) { return; } var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Instantiate the Thorn Hit object relative to the player effects object var thornHit = Object.Instantiate( thornHitObject, playerEffects.transform ); SkinManager.updateTextureInMaterialPropertyBlock(thornHit, skin.Knight); thornHit.SetActive(true); // Mirror the thorns if the player is flipped var thornScale = thornHit.transform.localScale; thornHit.transform.localScale = new Vector3( playerObject.transform.localScale.x > 0 ? 1 : -1, thornScale.y, thornScale.z ); // For each child, add a DamageHero component when PvP is enabled var damage = GameSettings.ThornOfAgonyDamage; if (GameSettings.IsPvpEnabled && ShouldDoDamage && damage != 0) { for (var i = 0; i < thornHit.transform.childCount; i++) { var child = thornHit.transform.GetChild(i).gameObject; child.AddComponent <DamageHero>().damageDealt = damage; } } // Destroy after 0.3 seconds as in the FSM Object.Destroy(thornHit, 0.3f); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get the remote player attacks object var playerAttacks = playerObject.FindGameObjectInChildren("Attacks"); // Find the object in the children of the attacks object var cycloneObject = playerAttacks.FindGameObjectInChildren("Cyclone Slash"); if (cycloneObject != null) { // Destroy the Cyclone Slash object Object.Destroy(cycloneObject); } }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { var playerEffects = playerObject.FindGameObjectInChildren("Effects"); var wallPuffPrefab = HeroController.instance.wallPuffPrefab; var wallPuff = Object.Instantiate( wallPuffPrefab, playerEffects.transform ); wallPuff.SetActive(true); // Invert the x scale, because for some reason, the effect is flipped by default var puffScale = wallPuff.transform.localScale; wallPuff.transform.localScale = new Vector3( puffScale.x * -1f, puffScale.y, puffScale.z ); // This means that the reposition action in the FSM is also inverted, // so we subtract twice the amount that was added wallPuff.LocateMyFSM("FSM").InsertMethod("Reposition?", 3, () => { var position = wallPuff.transform.localPosition; wallPuff.transform.localPosition = position - new Vector3( 0.91f * 2, 0f, 0f ); }); // Get a new audio source object relative to the player object var wallJumpAudioObject = AudioUtil.GetAudioSourceObject(playerEffects); // Get the actual audio source var wallJumpAudioSource = wallJumpAudioObject.GetComponent <AudioSource>(); // Get the wall jump clip var heroAudioController = HeroController.instance.GetComponent <HeroAudioController>(); wallJumpAudioSource.clip = heroAudioController.walljump.clip; // Randomize the pitch, as in the HeroAudioController wallJumpAudioSource.pitch = Random.Range(0.9f, 1.1f); // Play it wallJumpAudioSource.Play(); // Destroy the objects after 2 seconds to prevent them from lingering around Object.Destroy(wallPuff, 2.0f); Object.Destroy(wallJumpAudioObject, 2.0f); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { var charmEffects = HeroController.instance.gameObject.FindGameObjectInChildren("Charm Effects"); if (charmEffects == null) { return; } var dungObject = charmEffects.FindGameObjectInChildren("Dung"); if (dungObject == null) { return; } var dungControlFsm = dungObject.LocateMyFSM("Control"); var spawnObjectAction = dungControlFsm.GetAction <SpawnObjectFromGlobalPoolOverTime>("Equipped", 0); // Spawn the dung trail object, which will despawn itself spawnObjectAction.gameObject.Value.Spawn( playerObject.transform.position, Quaternion.identity ); // Check whether we have already created a dung particle, and if so, we don't need to create another var playerEffects = playerObject.FindGameObjectInChildren("Effects"); if (playerEffects.FindGameObjectInChildren("Dung Particle") != null) { return; } var setParticleEmissionAction = dungControlFsm.GetAction <SetParticleEmission>("Emit Pause", 1); var dungParticleEffect = Object.Instantiate( setParticleEmissionAction.gameObject.GameObject.Value, playerEffects.transform ); dungParticleEffect.name = "Dung Particle"; #pragma warning disable 0618 dungParticleEffect.GetComponent <ParticleSystem>().enableEmission = true; #pragma warning restore 0618 }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Find and spawn the wings object var doubleJumpWingsPrefab = HeroController.instance.dJumpWingsPrefab; var doubleJumpWings = Object.Instantiate( doubleJumpWingsPrefab, playerEffects.transform ); doubleJumpWings.SetActive(true); // Find and spawn the flash object var doubleJumpFlashPrefab = HeroController.instance.dJumpFlashPrefab; var doubleJumpFlash = Object.Instantiate( doubleJumpFlashPrefab, playerEffects.transform ); doubleJumpFlash.SetActive(true); // Find and spawn the feathers particle system var doubleJumpFeathersObject = HeroController.instance.dJumpFeathers; var doubleJumpFeathers = Object.Instantiate( doubleJumpFeathersObject, playerEffects.transform ); doubleJumpFeathers.Play(); // Get a new audio source object relative to the player object var doubleJumpAudioObject = AudioUtil.GetAudioSourceObject(playerEffects); // Get the actual audio source var doubleJumpAudioSource = doubleJumpAudioObject.GetComponent <AudioSource>(); // Get the wall slide clip and play it doubleJumpAudioSource.PlayOneShot(HeroController.instance.doubleJumpClip); // Destroy all objects after 2 seconds, which is when every effect should be done Object.Destroy(doubleJumpWings, 2.0f); Object.Destroy(doubleJumpFlash, 2.0f); Object.Destroy(doubleJumpFeathers, 2.0f); Object.Destroy(doubleJumpAudioObject, 2.0f); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Call the base play method with the correct indices and state names // This looks arbitrary, but is based on the FSM state machine of the fireball Play( playerObject, effectInfo, "Fireball 2", 1, 4, 3, 0, 4, 1.8f, false, GameSettings.ShadeSoulDamage ); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Call the base play method with the correct indices and state names // This looks arbitrary, but is based on the FSM state machine of the fireball Play( playerObject, effectInfo, "Fireball 1", 0, 7, 6, 1, 3, 1.0f, true, GameSettings.VengefulSpiritDamage ); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get the player attacks object var playerAttacks = playerObject.FindGameObjectInChildren("Attacks"); // If the player attacks object already contains a Nail Art Charge object, we skip creating a new one if (playerAttacks.FindGameObjectInChildren("Nail Art Charge") != null) { return; } // Create a new art charge object from the prefab in the hero controller // This is the soul-like particles that flow towards the player var artChargeObject = HeroController.instance.artChargeEffect; var artCharge = Object.Instantiate( artChargeObject, playerAttacks.transform ); // Give it a name, so we can reference it when it needs to be destroyed artCharge.name = "Nail Art Charge"; // Set is to active to start the animation artCharge.SetActive(true); // set current player's skin on current slash gameObject SkinManager.updateTextureInMaterialPropertyBlock(artCharge, skin.Knight); // Get a new audio source object relative to the player object var artChargeAudioObject = AudioUtil.GetAudioSourceObject(playerAttacks); // Again give a name, so we can destroy it later artChargeAudioObject.name = "Nail Art Charge Audio"; // Get the actual audio source var artChargeAudioSource = artChargeAudioObject.GetComponent <AudioSource>(); // Get the nail art charge clip and play it var heroAudioController = HeroController.instance.GetComponent <HeroAudioController>(); artChargeAudioSource.clip = heroAudioController.nailArtCharge.clip; artChargeAudioSource.Play(); // As a failsafe, destroy the charge after 4 seconds Object.Destroy(artCharge, 4f); }
protected void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo, string qTrailPrefabName) { // Obtain the local player spell control object var localPlayerSpells = HeroController.instance.spellControl.gameObject; // Get the remote player spell object var playerSpells = playerObject.FindGameObjectInChildren("Spells"); // Get the remote player effects object var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Instantiate the Q Flash Start from the prefab in the remote player spells object var qFlashStart = Object.Instantiate( localPlayerSpells.FindGameObjectInChildren("Q Flash Start"), playerSpells.transform ); qFlashStart.SetActive(true); // And destroy it after a second Object.Destroy(qFlashStart, 1); // Instantiate the SD Sharp Flash from the prefab in the remote player effects object var sdSharpFlash = Object.Instantiate( localPlayerSpells.FindGameObjectInChildren("SD Sharp Flash"), playerEffects.transform ); sdSharpFlash.SetActive(true); // And destroy it after a second Object.Destroy(sdSharpFlash, 1); // Instantiate the trail object from the prefab and spawn it in the remote player spells object // This is the texture that the knight has continually while diving down var qTrail = Object.Instantiate( localPlayerSpells.FindGameObjectInChildren(qTrailPrefabName), playerSpells.transform ); qTrail.SetActive(true); // Assign a name so we reference it later, when we need to delete it qTrail.name = qTrailPrefabName; // Destroy the existing Q Charge from the antic Object.Destroy(playerSpells.FindGameObjectInChildren("Q Charge")); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Stop playing the charge audio var superDashAudio = playerObject.FindGameObjectInChildren("Superdash Charge Audio"); if (superDashAudio != null) { superDashAudio.GetComponent <AudioSource>().Stop(); } // We cancelled early, so we need to destroy the charge effect now already var playerEffects = playerObject.FindGameObjectInChildren("Effects"); var chargeEffect = playerEffects.FindGameObjectInChildren("Charge Effect"); Object.Destroy(chargeEffect); // Make sure that the coroutine of the crystal dash charge does not continue playerObject.GetComponent <CoroutineCancelComponent>().CancelCoroutine("Crystal Dash Charge"); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Find the dust object and disable emission it if it exists var wallSlideDustObject = playerEffects.FindGameObjectInChildren("Wall Slide Dust"); if (wallSlideDustObject != null) { #pragma warning disable 0618 wallSlideDustObject.GetComponent <ParticleSystem>().enableEmission = false; #pragma warning restore 0618 } var audioObject = playerEffects.FindGameObjectInChildren("Wall Slide Audio"); if (audioObject != null) { Object.Destroy(audioObject); } }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get the player effects object to put new effects in var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Obtain the gameObject containing damage effects var damageEffect = HeroController.instance.gameObject.FindGameObjectInChildren("Damage Effect"); // Instantiate a hit crack effect var hitCrack = Object.Instantiate( damageEffect.FindGameObjectInChildren("Hit Crack"), playerEffects.transform ); hitCrack.SetActive(true); // Instantiate a object responsible for particle effects var hitPt1 = Object.Instantiate( damageEffect.FindGameObjectInChildren("Hit Pt 1"), playerEffects.transform ); hitPt1.SetActive(true); // Play the particle effect hitPt1.GetComponent <ParticleSystem>().Play(); // Instantiate a object responsible for particle effects var hitPt2 = Object.Instantiate( damageEffect.FindGameObjectInChildren("Hit Pt 2"), playerEffects.transform ); hitPt2.SetActive(true); // Play the particle effect hitPt2.GetComponent <ParticleSystem>().Play(); // Destroy all objects after 1 second Object.Destroy(hitCrack, 1); Object.Destroy(hitPt1, 1); Object.Destroy(hitPt2, 1); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Also play the crystal dash cancel animation, because it is cancelled when we do a wallslide AnimationManager.CrystalDashChargeCancel.Play(playerObject, skin, effectInfo); var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Find an existing dust object var wallSlideDustObject = playerEffects.FindGameObjectInChildren("Wall Slide Dust"); // Otherwise, create a new one from the prefab in the HeroController if (wallSlideDustObject == null) { var wallSlideDustPrefab = HeroController.instance.wallslideDustPrefab.gameObject; wallSlideDustObject = Object.Instantiate( wallSlideDustPrefab, playerEffects.transform ); // Give it a name, so we can find it later wallSlideDustObject.name = "Wall Slide Dust"; } // Disable compiler warning and enable dust emission #pragma warning disable 0618 wallSlideDustObject.GetComponent <ParticleSystem>().enableEmission = true; #pragma warning restore 0618 // Get a new audio source object relative to the player object var wallSlideAudioObject = AudioUtil.GetAudioSourceObject(playerEffects); // Again give a name, so we can destroy it later wallSlideAudioObject.name = "Wall Slide Audio"; // Get the actual audio source var wallSlideAudioSource = wallSlideAudioObject.GetComponent <AudioSource>(); // Get the wall slide clip and play it var heroAudioController = HeroController.instance.GetComponent <HeroAudioController>(); wallSlideAudioSource.clip = heroAudioController.wallslide.clip; wallSlideAudioSource.Play(); }
private IEnumerator PlayRechargeAnimation(GameObject playerObject, clientSkin skin, GameObject playerEffects) { yield return(new WaitForSeconds(0.65f)); var shadowRechargePrefab = HeroController.instance.shadowRechargePrefab; var rechargeFsm = shadowRechargePrefab.LocateMyFSM("Recharge Effect"); // Obtain the recharge audio clip var audioPlayAction = rechargeFsm.GetAction <AudioPlay>("Burst", 0); var rechargeAudioClip = (AudioClip)audioPlayAction.oneShotClip.Value; // Get a new audio source and play the clip var rechargeAudioSourceObject = AudioUtil.GetAudioSourceObject(playerObject); var rechargeAudioSource = rechargeAudioSourceObject.GetComponent <AudioSource>(); rechargeAudioSource.clip = rechargeAudioClip; rechargeAudioSource.Play(); var rechargeObject = Object.Instantiate( shadowRechargePrefab, playerEffects.transform ); SkinManager.updateTextureInMaterialPropertyBlock(rechargeObject, skin.Knight); Object.Destroy(rechargeObject.LocateMyFSM("Recharge Effect")); rechargeObject.SetActive(true); rechargeObject.GetComponent <MeshRenderer>().enabled = true; var rechargeAnimator = rechargeObject.GetComponent <tk2dSpriteAnimator>(); rechargeAnimator.PlayFromFrame("Shadow Recharge", 0); yield return(new WaitForSeconds(rechargeAnimator.GetClipByName("Shadow Recharge").Duration)); Object.Destroy(rechargeObject); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get the player attacks object, which is where the nail art objects are stored var playerAttacks = playerObject.FindGameObjectInChildren("Attacks"); // Make a list of all object names that need to be destroyed var toDestroy = new [] { "Nail Art Charge", "Nail Art Charged", "Nail Art Charged Flash" }; // Loop over the names and destroy the object if it exists foreach (var objectName in toDestroy) { var artObject = playerAttacks.FindGameObjectInChildren(objectName); if (artObject != null) { Object.Destroy(artObject); } } // Make a list of all audio objects that need to be destroyed var audioToStop = new[] { "Nail Art Charge Audio", "Nail Art Charged Audio" }; // Loop over the names and destroy the audio object if it exists foreach (var audioName in audioToStop) { var audioObject = playerAttacks.FindGameObjectInChildren(audioName); if (audioObject != null) { Object.Destroy(audioObject); } } }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get both the local player and remote player effects object var heroEffects = HeroController.instance.gameObject.FindGameObjectInChildren("Effects"); var playerEffects = playerObject.FindGameObjectInChildren("Effects"); // Play the end animation for the crystal dash trail if it exists var sdTrail = playerEffects.FindGameObjectInChildren("SD Trail"); if (sdTrail != null) { sdTrail.GetComponent <tk2dSpriteAnimator>().Play("SD Trail End"); } // Instantiate the wall hit effect and make sure to destroy it once the FSM is done var wallHitEffect = Object.Instantiate( heroEffects.FindGameObjectInChildren("Wall Hit Effect"), playerEffects.transform ); wallHitEffect.LocateMyFSM("FSM").InsertMethod("Destroy", 1, () => Object.Destroy(wallHitEffect)); var audioSourceObject = AudioUtil.GetAudioSourceObject(playerObject); var superDashFsm = HeroController.instance.gameObject.LocateMyFSM("Superdash"); var wallHitAction = superDashFsm.GetAction <AudioPlay>("Hit Wall", 4); audioSourceObject.GetComponent <AudioSource>().PlayOneShot((AudioClip)wallHitAction.oneShotClip.Value); var superDashAudio = playerObject.FindGameObjectInChildren("Superdash Audio"); if (superDashAudio != null) { superDashAudio.GetComponent <AudioSource>().Stop(); } }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get the spell control object from the local player object var localSpellControl = HeroController.instance.spellControl; // Get the AudioPlay action from the Quake Antic state var quakeAnticAudioPlay = localSpellControl.GetAction <AudioPlay>("Quake Antic", 0); var audioObject = AudioUtil.GetAudioSourceObject(playerObject); var audioSource = audioObject.GetComponent <AudioSource>(); // Lastly, we get the clip we need to play var quakeAnticClip = (AudioClip)quakeAnticAudioPlay.oneShotClip.Value; // Now we can play the clip audioSource.PlayOneShot(quakeAnticClip); // Destroy the audio object after the clip is done Object.Destroy(audioObject, quakeAnticClip.length); // Get the remote player spell control object, to which we can assign the effect var playerSpellControl = playerObject.FindGameObjectInChildren("Spells"); // Instantiate the Q Charge object from the prefab in the local spell control // Instantiate it relative to the remote player position var qCharge = Object.Instantiate( localSpellControl.gameObject.FindGameObjectInChildren("Q Charge"), playerSpellControl.transform ); qCharge.SetActive(true); // Set the name, so we can reference it later, when we need to destroy it qCharge.name = "Q Charge"; // Start the animation at the first frame qCharge.GetComponent <tk2dSpriteAnimator>().PlayFromFrame(0); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { Play(playerObject, skin, effectInfo, true, true, false); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Call the base function with the correct parameters Play(playerObject, skin, effectInfo, HeroController.instance.slashPrefab, false, false, false); }
protected IEnumerator Play(GameObject playerObject, clientSkin skin, string screamClipName, string screamObjectName, int damage) { var spellControl = HeroController.instance.spellControl; var audioObject = AudioUtil.GetAudioSourceObject(playerObject); var audioSource = audioObject.GetComponent <AudioSource>(); // Get the correct scream audio clip based on the given parameter var screamClip = (AudioClip)spellControl.GetAction <AudioPlay>(screamClipName, 1).oneShotClip.Value; // And play it audioSource.PlayOneShot(screamClip); // Destroy the audio object after the clip is done Object.Destroy(audioObject, screamClip.length); var localPlayerSpells = spellControl.gameObject; var playerSpells = playerObject.FindGameObjectInChildren("Spells"); // Get the correct scream heads object and spawn it relative to the remote player var scrHeadsObject = localPlayerSpells.FindGameObjectInChildren(screamObjectName); var screamHeads = Object.Instantiate( scrHeadsObject, playerSpells.transform ); screamHeads.SetActive(true); // We don't want to deactivate this when the local player is being hit Object.Destroy(screamHeads.LocateMyFSM("Deactivate on Hit")); // For each (L, R and U) of the scream objects, we need to do a few things var objectNames = new [] { "Hit L", "Hit R", "Hit U" }; // Also store a few objects that we need to destroy later var objectsToDestroy = new List <GameObject>(); foreach (var objectName in objectNames) { var screamHitObject = screamHeads.FindGameObjectInChildren(objectName); Object.Destroy(screamHitObject.LocateMyFSM("damages_enemy")); var screamHitDamager = Object.Instantiate( new GameObject(objectName), screamHitObject.transform ); screamHitDamager.layer = 22; // Add the object to the list to destroy it later objectsToDestroy.Add(screamHitDamager); // Create a new polygon collider var screamHitDamagerPoly = screamHitDamager.AddComponent <PolygonCollider2D>(); screamHitDamagerPoly.isTrigger = true; // Obtain the original polygon collider var screamHitPoly = screamHitObject.GetComponent <PolygonCollider2D>(); // Copy over the polygon collider points screamHitDamagerPoly.points = screamHitPoly.points; // If PvP is enabled, add a DamageHero component to the damager objects if (GameSettings.IsPvpEnabled && ShouldDoDamage && damage != 0) { screamHitDamager.AddComponent <DamageHero>().damageDealt = damage; } // Delete the original polygon collider, we don't need it anymore Object.Destroy(screamHitPoly); } // Wait for the duration of the scream animation var duration = playerObject.GetComponent <tk2dSpriteAnimator>().GetClipByName("Scream 2 Get") .Duration; yield return(new WaitForSeconds(duration)); // Then destroy the leftover objects Object.Destroy(screamHeads); foreach (var gameObject in objectsToDestroy) { Object.Destroy(gameObject); } }
public abstract override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo);
/** * The effect when the knight increases their health after healing */ public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Get the local player spell control object var localSpellControl = HeroController.instance.spellControl; // Get the AudioSource from the audio action var audioAction = localSpellControl.GetAction <AudioPlayerOneShotSingle>("Focus Heal", 3); var audioPlayerObj = audioAction.audioPlayer.Value; var audioPlayer = audioPlayerObj.Spawn(playerObject.transform); var audioSource = audioPlayer.GetComponent <AudioSource>(); // Get the audio clip of the Heal and play it var healClip = (AudioClip)audioAction.audioClip.Value; audioSource.PlayOneShot(healClip); // We don't need to audio player anymore Object.Destroy(audioPlayer, healClip.length); // Get the burst animation object through the Focus Heal state of the FSM var activateObjectAction = localSpellControl.GetAction <ActivateGameObject>("Focus Heal", 10); var burstAnimationObject = activateObjectAction.gameObject.GameObject.Value; // Instantiate it relative to the player object var burstAnimation = Object.Instantiate( burstAnimationObject, playerObject.transform ); burstAnimation.SetActive(true); // Destroy after some time Object.DestroyObject(burstAnimation, 2.0f); var hasSporeShroom = effectInfo[0]; var isSporeOnCooldown = effectInfo[3]; // If the spore shroom is on cooldown or we don't have Spore Shroom charm equipped // there is no effect to be played, so we return if (isSporeOnCooldown || !hasSporeShroom) { return; } var playerEffects = playerObject.FindGameObjectInChildren("Effects"); var hasDefenderCrest = effectInfo[1]; var hasDeepFocus = effectInfo[2]; // Since both Spore Cloud and Dung Cloud use the same structure, we find the correct FSM // and then spawn the correct object within that FSM GameObject objectVariant; if (hasDefenderCrest) { var spawnAction = localSpellControl.GetAction <SpawnObjectFromGlobalPool>("Dung Cloud", 0); objectVariant = spawnAction.gameObject.Value; } else { var spawnAction = localSpellControl.GetAction <SpawnObjectFromGlobalPool>("Spore Cloud", 3); objectVariant = spawnAction.gameObject.Value; } // Spawn the correct variant at the player position with default rotation var cloud = Object.Instantiate( objectVariant, playerEffects.transform.position, Quaternion.identity ); cloud.SetActive(true); cloud.layer = 22; // Destroy the FSM so it doesn't use local player variables Object.Destroy(cloud.LocateMyFSM("Control")); // Since we destroyed the FSM, we need to mimic some of its behaviour // Such as activating the correct variant based on Deep Focus cloud.FindGameObjectInChildren("Pt Normal").SetActive(!hasDeepFocus); cloud.FindGameObjectInChildren("Pt Deep").SetActive(hasDeepFocus); // Set the scale based on whether we have Deep Focus if (hasDeepFocus) { cloud.transform.localScale = new Vector3(1.35f, 1.35f, 0f); } else { cloud.transform.localScale = new Vector3(1f, 1f, 0f); } // If PvP is enabled, add the DamageHero component // The damage is based on the GameSettings value var damage = hasDefenderCrest ? GameSettings.SporeDungShroomDamage : GameSettings.SporeShroomDamage; if (GameSettings.IsPvpEnabled && ShouldDoDamage && damage != 0) { cloud.AddComponent <DamageHero>().damageDealt = damage; } // Then after 4.1 seconds (as in the FSM), we remove it again Object.Destroy(cloud, 4.1f); }
public override void Play(GameObject playerObject, clientSkin skin, bool[] effectInfo) { // Call the play method with the correct Q Trail prefab name Play(playerObject, skin, effectInfo, "Q Trail"); }