void DamageEnemy() { if (hm == null) { Log("[DamageOverride:DamageOvertime] Game Object/HealthManager null, cannot apply damage overtime"); stack = 0; return; } if (!playFireAnim) { particleSystem.Play(); playFireAnim = true; } GameObject HitPrefab = hm.GetAttr <GameObject>("strikeNailPrefab"); Vector3? effectOrigin = hm.GetAttr <Vector3?>("effectOrigin"); if (HitPrefab != null && effectOrigin != null) { HitPrefab.Spawn(hm.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } hm.hp -= damage * stack; SpriteFlash f = hm.gameObject.GetComponent <SpriteFlash>(); if (f != null) { f.flashBenchRest(); } if (hm.hp <= 0) { DamageOverride.EnemyDeathEvent(hm, 90, false); } }
public virtual void Awake() { damageFlash = GetComponent<SpriteFlash>(); rigidbody2D = GetComponent<Rigidbody2D>(); groundCheck = transform.Find("GroundCheck"); if (moveSpeed < 0) { direction = -direction; moveSpeed = -moveSpeed; } }
public void Flash() { SpriteFlash.SetMaterialFlashColor(spriteRenderer, flashColour); if (tween.isRunning()) { tween.stop(true, true); } tween.jumpToElapsedTime(0f); tween.setDuration(duration); tween.setEaseType(easeType); tween.start(); }
private void Awake() { _fsm = gameObject.LocateMyFSM("FSM"); _de = gameObject.AddComponent <EnemyDeathEffectsUninfected>(); _he = gameObject.AddComponent <EnemyHitEffectsUninfected>(); _hm = gameObject.AddComponent <HealthManager>(); _sf = gameObject.AddComponent <SpriteFlash>(); _sf.enabled = true; gameObject.AddComponent <NonBouncer>(); _hornet = CagneyCarnation.GameObjects["Hornet"]; AssignFields(); On.HealthManager.TakeDamage += OnTakeDamage; }
private void Awake() { _movement = gameObject.LocateMyFSM("Movement"); _shootControl = gameObject.LocateMyFSM("Shoot Control"); _de = gameObject.AddComponent <EnemyDeathEffectsUninfected>(); _he = gameObject.AddComponent <EnemyHitEffectsUninfected>(); _hm = gameObject.AddComponent <HealthManager>(); _sf = gameObject.AddComponent <SpriteFlash>(); gameObject.AddComponent <NonBouncer>(); _hornet = CagneyCarnation.GameObjects["Hornet"]; AssignFields(); On.HealthManager.TakeDamage += OnTakeDamage; }
// Use this for initialization void Start() { Script = GetComponent<SpriteFlash>(); }
// Start is called before the first frame update void Start() { gameManager = FindObjectOfType <GameManager>(); spriteFlash = GetComponent <SpriteFlash>(); }
void Awake() { damageFlash = GetComponent<SpriteFlash>(); }
// Awake is called when the script instance is being loaded. void Awake() { healthPoint = maxHealthPoint; sp = GetComponent <SpriteFlash>(); }
// This function does damage to the enemy using the damage numbers given by the weapon type public static void hitEnemy(HealthManager targetHP, int expectedDamage, HitInstance hitInstance, int soulGain) { int realDamage = expectedDamage; // TODO: Add possible optional damage multiplier information below. /* * double multiplier = 1; * if (PlayerData.instance.GetBool("equippedCharm_25")) * { * multiplier *= 1.5; * } * if (PlayerData.instance.GetBool("equippedCharm_6") && PlayerData.instance.GetInt("health") == 1) * { * multiplier *= 1.75f; * } * * if (gng_bindings.hasNailBinding()) * { * multiplier *= 0.3; * } * realDamage = (int) Math.Round(realDamage * multiplier); * */ if (realDamage <= 0) { return; } if (targetHP == null) { return; } /* * Play animations and such... * Mostly code copied from the healthmanager class itself. */ try { int cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform)); FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO"); if (sendHitGO != null) { FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); } GameObject fireballHitPrefab = targetHP.GetAttr <GameObject>("fireballHitPrefab"); Vector3? effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin"); if (fireballHitPrefab != null && effectOrigin != null) { fireballHitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false); if ((UnityEngine.Object)targetHP.GetComponent <Recoil>() != (UnityEngine.Object)null) { targetHP.GetComponent <Recoil>().RecoilByDirection(cardinalDirection, hitInstance.MagnitudeMultiplier); } FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false); FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false); } catch (Exception e) { Modding.Logger.Log("[HOLLOW POINT DEBUG] Over here at line 50~ " + e); } // Actually do damage to target. try { if (targetHP.damageOverride) { targetHP.hp -= 1; } else { targetHP.hp -= realDamage; HeroController.instance.AddMPCharge(soulGain); } } catch (Exception e) { Modding.Logger.Log("[HOLLOW POINT DEBUG] Over here at line 80~ at the Actually Do Damage section " + e); } // Trigger Kill animation try { if (targetHP.hp <= 0f) { targetHP.Die(0f, AttackTypes.Nail, true); return; } bool? hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation"); string alternateHitAnimation = targetHP.GetAttr <string>("alternateHitAnimation"); if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null) { targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation); } } catch (Exception e) { Modding.Logger.Log("[HOLLOW POINT DEBUG] Over here at line 100~ at the Trigger Kill Animation section" + e); } try { PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component => component.FsmName == "Stun Control" || component.FsmName == "Stun"); if (stunControlFSM != null) { stunControlFSM.SendEvent("STUN DAMAGE"); } } catch (Exception e) { Modding.Logger.Log("[HOLLOW POINT DEBUG] Over here at line 120~ at the Stun Damage" + e); } /* * Uncomment below for a sick looking enter the gungeon style freeze frame or for camera shake. */ //GameManager.instance.FreezeMoment(1); //GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake"); try{ SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>(); if (f != null) { f.flashWhiteQuick(); } } catch (Exception e) { Modding.Logger.Log("[HOLLOW POINT DEBUG] Over here at line 140~ at the flash quick" + e); } }
// This function does damage to the enemy using the damage numbers given by the weapon type public static void HitEnemy(HealthManager targetHP, int damageDealt, HitInstance hitInstance, int soulGain, BulletBehaviour hpbb) { //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more if (targetHP == null) { return; } int cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform)); GameObject blockHitPrefab = targetHP.GetAttr <GameObject>("blockHitPrefab"); bool specialEnemy = (targetHP.name.Contains("Charger")); if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy || damageDealt <= 0) { FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false); GameObject blockHit = blockHitPrefab.Spawn(); blockHit.transform.position = targetHP.transform.position; blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection)); return; } if (damageDealt <= 0) { return; } //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler")); /* * if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25) * { * GameObject blockHit = blockHitPrefab.Spawn(); * blockHit.transform.position = targetHP.transform.position; * return; * } */ if (targetHP.gameObject.name.Contains("Blocker")) //double damage baldurs { damageDealt = damageDealt * 4; } Recoil recoil = targetHP.gameObject.GetComponent <Recoil>(); //if (recoil != null && PlayerData.instance.equippedCharm_15) if (recoil != null) { recoil.RecoilByDirection(cardinalDirection, 0.25f); } /* * Mostly code copied from the healthmanager class itself. */ FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO"); if (sendHitGO != null) { FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); } GameObject HitPrefab = targetHP.GetAttr <GameObject>("strikeNailPrefab"); GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab"); Vector3? effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin"); if (HitPrefab != null && effectOrigin != null) { HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } if (ImpactPrefab != null && effectOrigin != null) { ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>(); if (f != null) { f.flashWhiteQuick(); } //Log("SEVERITY: " + ds + " DAMAGE: " + damageDealt); FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false); FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false); FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false); FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false); // Actually do damage to target. LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + soundRandom.Next(1, 4) + ".wav", out AudioClip hurtSound); HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(hurtSound); if (targetHP.damageOverride) { targetHP.hp -= 1; } else { targetHP.hp -= damageDealt; // the actual damage //int sg = (ds.Equals(DamageSeverity.Minor)) ? 0 : soulGain; HeroController.instance.AddMPCharge(6); Stats.IncreaseAdrenalinePoints(damageDealt); } // Trigger Kill animation if (targetHP.hp <= 0f) { LoadAssets.sfxDictionary.TryGetValue("enemydead" + soundRandom.Next(1, 4) + ".wav", out AudioClip deadSound); HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(deadSound); targetHP.Die(cardinalDirection * 90, AttackTypes.Spell, true); HeroController.instance.AddMPCharge(4); GameManager.instance.FreezeMoment(1); return; } bool? hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation"); string alternateHitAnimation = targetHP.GetAttr <string>("alternateHitAnimation"); if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null) { targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation); } PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component => component.FsmName == "Stun Control" || component.FsmName == "Stun"); if (stunControlFSM != null) { //stunControlFSM.SendEvent("STUN DAMAGE"); } /* * Uncomment below for a sick looking enter the gungeon style freeze frame or for camera shake. */ }
private void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); tween = SpriteFlash.CreateOneWayTween(spriteRenderer, 1.0f, 0.0f, duration, easeType); }
private void Awake() { spriteFlash = GetComponentInChildren <SpriteFlash>(); }
void Awake() { instance = this; ResetEvents(); anim = GetComponent<Animator>(); audio = GetComponent<PlayerAudio>(); damageFlash = GetComponent<SpriteFlash>(); feedback = GetComponent<PlayerForceFeedback>(); health = GetComponent<PlayerHealth>(); input = GetComponent<PlayerInput>(); interaction = GetComponent<PlayerInteraction>(); physics = GetComponent<PlayerPhysics>(); weapon = GetComponent<PlayerWeapon>(); meleeAttackBox = transform.FindChild("MeleeAttackBox").gameObject; }
//+++DAMAGE OVERRIDE+++ public static void DamageEnemyOverride(HealthManager targetHP, int damageDealt, HitInstance hitInstance, int soulGain, BulletBehaviour hpbb) { //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more if (targetHP == null) { return; } int cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform)); GameObject blockHitPrefab = targetHP.GetAttr <GameObject>("blockHitPrefab"); bool specialEnemy = (targetHP.name.Contains("Charger")); if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy) { FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false); GameObject blockHit = blockHitPrefab.Spawn(); blockHit.transform.position = targetHP.transform.position; blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection)); return; } if (false && !targetHP.IsInvincible) //enable disable damage overtime { EnemyDamageOvertime dm = targetHP.gameObject.GetComponent <EnemyDamageOvertime>(); if (dm == null) { targetHP.gameObject.AddComponent <EnemyDamageOvertime>(); } else { dm.IncreaseStack(); } } //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler")); /* * if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25) * { * GameObject blockHit = blockHitPrefab.Spawn(); * blockHit.transform.position = targetHP.transform.position; * return; * } */ if (targetHP.gameObject.name.Contains("Blocker")) //double damage baldurs { damageDealt = damageDealt * 4; } Recoil recoil = targetHP.gameObject.GetComponent <Recoil>(); //if (recoil != null && PlayerData.instance.equippedCharm_15) if (recoil != null) { recoil.RecoilByDirection(cardinalDirection, 0.25f); } /* * Mostly code copied from the healthmanager class itself. */ FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO"); if (sendHitGO != null) { FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); } GameObject HitPrefab = targetHP.GetAttr <GameObject>("strikeNailPrefab"); GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab"); Vector3? effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin"); if (HitPrefab != null && effectOrigin != null) { HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } if (ImpactPrefab != null && effectOrigin != null) { ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>(); if (f != null) { f.flashWhiteQuick(); } FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false); FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false); FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false); FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false); // Actually do damage to target. LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + rand.Next(1, 4) + ".wav", out AudioClip hurtSound); HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(hurtSound); if (targetHP.damageOverride) { targetHP.hp -= 1; } else { targetHP.hp -= damageDealt; // the actual damage if (hpbb.canGainEnergyCharges) { HeroController.instance.AddMPCharge(Stats.instance.current_soulGainedPerHit); } Stats.instance.IncreaseAdrenalineChargeEnergy(); //TODO: change this audio source location to the sound handler AudioHandler.instance.PlayMiscSoundEffect(AudioHandler.HollowPointSoundType.EnemyHitSFXGO); } // Trigger Enemy Kill if (targetHP.hp <= 0f) { EnemyDeathEvent(targetHP, cardinalDirection, true); return; } bool? hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation"); string alternateHitAnimation = targetHP.GetAttr <string>("alternateHitAnimation"); if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null) { targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation); } PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component => component.FsmName == "Stun Control" || component.FsmName == "Stun"); //if (stunControlFSM != null) stunControlFSM.SendEvent("STUN DAMAGE"); }
private void Awake() { spriteRenderer = GetComponent <SpriteRenderer>(); soundManager = FindObjectOfType <SoundManager>().GetComponent <SoundManager>(); spriteFlash = GetComponentInChildren <SpriteFlash>(); }
// Use this for initialization void Start() { Script = GetComponent <SpriteFlash>(); }
// Awake is called when the script instance is being loaded. void Awake() { sp = GetComponent <SpriteFlash>(); }
public static IEnumerator StartInfusion() { artifactActivatedEffect.SetActive(false); LoadAssets.sfxDictionary.TryGetValue("infusionsound.wav", out AudioClip ac); AudioSource aud = infusionSoundGO.GetComponent <AudioSource>(); aud.PlayOneShot(ac); buff_duration = (PlayerData.instance.screamLevel > 1) ? 150f : 80f; //Charm 9 lifeblood core buff_duration += (PlayerData.instance.equippedCharm_9) ? 200f : 0; //Joni's Blessing /* * if (PlayerData.instance.equippedCharm_27) * { * buff_duration = -40f; * int mpCharge = PlayerData.instance.MPCharge; * int grenadeAmount = (int)(mpCharge/15f); * * HP_Stats.grenadeAmnt += grenadeAmount; * HeroController.instance.TakeMP(mpCharge); * } */ buffActive = true; if (PlayerData.instance.equippedCharm_34) { buff_duration = -40f; HeroController.instance.AddHealth(4); } //To make sure the minimum buff duration is always at 30f buff_duration = (buff_duration < 30f) ? 30f : buff_duration; GameCameras.instance.cameraShakeFSM.SendEvent("BigShake"); //Gives fancy effects to when you infuse yourself, should add a sound soon Instantiate(sharpFlash, HeroController.instance.transform).SetActive(true); Instantiate(focusBurstAnim, HeroController.instance.transform).SetActive(true); SpriteFlash knightFlash = HeroController.instance.GetAttr <SpriteFlash>("spriteFlash"); knightFlash.flashBenchRest(); GameObject artChargeEffect = Instantiate(HeroController.instance.artChargedEffect, HeroController.instance.transform.position, Quaternion.identity); artChargeEffect.SetActive(true); artChargeEffect.transform.SetParent(HeroController.instance.transform); Destroy(artChargeEffect, buff_duration / 10f); GameObject artChargeFlash = Instantiate(HeroController.instance.artChargedFlash, HeroController.instance.transform.position, Quaternion.identity); artChargeFlash.SetActive(true); artChargeFlash.transform.SetParent(HeroController.instance.transform); Destroy(artChargeFlash, 0.5f); GameObject dJumpFlash = Instantiate(HeroController.instance.dJumpFlashPrefab, HeroController.instance.transform.position, Quaternion.identity); dJumpFlash.SetActive(true); dJumpFlash.transform.SetParent(HeroController.instance.transform); Destroy(dJumpFlash, 0.5f); yield return(null); }
void Start() { spriteFlasher = GetComponent <SpriteFlash>(); health = GetComponent <Health>(); startTintColor = spriteFlasher.tintColor; }
// This function does damage to the enemy using the damage numbers given by the weapon type public static void HitEnemy(HealthManager targetHP, int expectedDamage, HitInstance hitInstance, int soulGain) { int realDamage = expectedDamage; //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more int cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform)); GameObject blockHitPrefab = targetHP.GetAttr <GameObject>("blockHitPrefab"); bool specialEnemy = (targetHP.name.Contains("Charger")); if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy || realDamage <= 0) { FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false); GameObject blockHit = blockHitPrefab.Spawn(); blockHit.transform.position = targetHP.transform.position; blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection)); return; } //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler")); //if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25) //{ // GameObject blockHit = blockHitPrefab.Spawn(); // blockHit.transform.position = targetHP.transform.position; // return; //} if (targetHP.gameObject.name.Contains("Blocker")) { realDamage = realDamage * 4; } Recoil recoil = targetHP.gameObject.GetComponent <Recoil>(); if (recoil != null && PlayerData.instance.equippedCharm_15) { recoil.RecoilByDirection(cardinalDirection, 0.8f); } if (realDamage <= 0) { return; } if (targetHP == null) { return; } /* * Play animations and such... * Mostly code copied from the healthmanager class itself. */ //Modding.Logger.Log("Cardinal is " + cardinalDirection); FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO"); if (sendHitGO != null) { FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false); } GameObject HitPrefab = targetHP.GetAttr <GameObject>("strikeNailPrefab"); GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab"); Vector3? effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin"); if (HitPrefab != null && effectOrigin != null) { HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } if (ImpactPrefab != null && effectOrigin != null) { ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f); } FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false); FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false); FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false); FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false); // Actually do damage to target. try { //TODO: change this audio source //HeroController.instance.spellControl.gameObject.GetComponent<AudioSource>().PlayOneShot(LoadAssets.enemyHurtSFX[soundRandom.Next(0, 2)]); LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + soundRandom.Next(1, 4) + ".wav", out AudioClip ac); HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(ac); } catch (Exception e) { Modding.Logger.Log("Enemy Hurt Exception Thrown " + e); } if (targetHP.damageOverride) { targetHP.hp -= 1; } else { targetHP.hp -= realDamage; // the actual damage HeroController.instance.AddMPCharge(soulGain); } // Trigger Kill animation if (targetHP.hp <= 0f) { LoadAssets.sfxDictionary.TryGetValue("enemydead" + soundRandom.Next(1, 4) + ".wav", out AudioClip ac); HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(ac); targetHP.Die(cardinalDirection * 90, AttackTypes.Spell, true); HeroController.instance.AddMPCharge(3); return; } bool? hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation"); string alternateHitAnimation = targetHP.GetAttr <string>("alternateHitAnimation"); if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null) { targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation); } PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component => component.FsmName == "Stun Control" || component.FsmName == "Stun"); if (stunControlFSM != null) { //stunControlFSM.SendEvent("STUN DAMAGE"); } /* * Uncomment below for a sick looking enter the gungeon style freeze frame or for camera shake. */ //GameManager.instance.FreezeMoment(1); //GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake"); SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>(); if (f != null) { f.flashInfected(); } }
// Start is called before the first frame update void Start() { gameManager = FindObjectOfType <GameManager>(); spriteFlash = FindObjectOfType <SpriteFlash>(); }