// TODO: actually don't implement this here bc params change depending on what hitbox needs public virtual void Attack(Directions dir) { activeHitBox = GetHitBoxDirection(dir); activeHitBox.SetResponder(this); activeHitBox.StartCheckingCollision(); }
public override void CollisionedWith(Collider collider, Script_HitBox hitBox) { // only allow one hit for Eat if (didHit) { activeHitBox.StopCheckingCollision(); return; } Script_HurtBox hurtBox = collider.GetComponent <Script_HurtBox>(); if (hurtBox != null) { int dmg = GetAttackStat().GetVal(); print($"CollisionedWith with {hurtBox.gameObject.name} inflicting dmg: {dmg}"); int dmgActuallyGiven = hurtBox.Hurt(dmg, hitBox); if (dmgActuallyGiven > 0) { HitSFX(); } didHit = true; } }
public override int Hurt(int dmg, Script_HitBox hitBox) { dmg = Mathf.Clamp(dmg, 0, int.MaxValue); // reduce health currentHp -= dmg; currentHp = Mathf.Clamp(currentHp, 0, int.MaxValue); Debug.Log($"{transform.name} took damage {dmg}. currentHp: {currentHp}"); if (currentHp == 0) { CrackedAction.SafeInvokeDynamic(this); Script_Game.Game.ChangeStateCutScene(); // Play the Frozen Well Shattering Timeline // This Timeline Flow Should Call the following functions: // 1. DiagonalCut // 2. Shatter & HideWell // 3. AllowPlayerInteract // 4. OnFrozenWellShatterTimelineDone GetComponent <Script_TimelineController>().PlayableDirectorPlayFromTimelines(0, 1); } return(dmg); }
public static void Hurt(string hurtBoxTag, Script_HitBox hitBox) { Debug.Log($"Hurt event: hurtBoxTag {hurtBoxTag}, hitBox {hitBox.tag}"); if (OnHurt != null) { OnHurt(hurtBoxTag, hitBox); } }
public int Hurt(int dmg, Script_HitBox hitBox) { int dmgActuallyTaken = stats.Hurt(dmg, hitBox); Script_HurtBoxEventsManager.Hurt(tag, hitBox); print($"{this.name} took {dmgActuallyTaken} damage from hitbox ${hitBox.Id}."); return(dmgActuallyTaken); // consider doing something with state, closing hurtbox? }
protected override void OnValidate() { // Only need reference to hitboxes Script_EnergySpike[] spikeObjs = GetSpikeChildren(); spikes = new Transform[0]; hitBoxes = new Script_HitBox[spikeObjs.Length]; for (int i = 0; i < spikeObjs.Length; i++) { hitBoxes[i] = spikeObjs[i].hitBox; } }
// Only need to handle Bgm after activating the "drama done" Trigger. // If the player gets hit when checking for drama done, stop checking // and reset the Enter Once Trigger. private void OnPlayerRestartHandleBgm(string tag, Script_HitBox hitBox) { // Ignore if this Hurt Event caused Time to run out if (Script_ClockManager.Control.ClockState == Script_Clock.States.Done) { Debug.Log($"{name} Ignore trying to restart BGM on Hurt because Time has run out"); return; } // Only need to handle this on DramaDone trigger if (!isDramaDoneTriggerOff) { return; } Debug.Log($"OnPlayerRestartHandleBgm() hurtbox tag: {tag}, hitBox tag: {hitBox.tag}"); if (tag == Const_Tags.Player) { // Allow drama cut scene to be played On Trigger again. isDramaCutSceneActivated = false; isDramaDoneTriggerOff = false; // If BgThemePlayer was fading / done fading but player hits a spike. // And also we're in the didActivateDramaticThoughts phase. if ( didActivateDramaticThoughts && ( !bgThemePlayer.gameObject.activeSelf || fadingOutMusicCoroutine != null ) ) { // During fading out music. if (fadingOutMusicCoroutine != null) { StopCoroutine(fadingOutMusicCoroutine); fadingOutMusicCoroutine = null; } Script_BackgroundMusicManager.Control.SetVolume(1f, BGMParam); // If Done fading out music. if (!bgThemePlayer.IsPlaying) { bgThemePlayer.Play(); } } } }
public override int Hurt(int dmg, Script_HitBox hitBox) { // give player a callback to do after eating Script_Player player = hitBox.transform.GetParentRecursive <Script_Player>(); if (player != null) { Debug.Log($"Player trying to attack {this.gameObject.name}"); // recursively find the Script_Attack player.onAttackDone = () => AttackedByPlayerReaction(); } return(0); }
public virtual int Hurt(int dmg, Script_HitBox hitBox) { // reduce dmg by defense dmg -= stats.defense.GetVal(); dmg = Mathf.Clamp(dmg, 0, int.MaxValue); // reduce health currentHp -= dmg; currentHp = Mathf.Clamp(currentHp, 0, int.MaxValue); Debug.Log($"{transform.name} took damage {dmg}. currentHp: {currentHp}"); if (currentHp == 0) { Die(Script_GameOverController.DeathTypes.Default); } return(dmg); }
public override int Hurt(int dmg, Script_HitBox hitBox) { dmg = Mathf.Clamp(dmg, 0, int.MaxValue); // reduce health currentHp -= dmg; currentHp = Mathf.Clamp(currentHp, 0, int.MaxValue); Debug.Log($"{transform.name} took damage {dmg}. currentHp: {currentHp}"); // Show a different spirte depending on how hurt the Interactable is HandleHurtGraphics(currentHp); if (currentHp == 0) { Die(Script_GameOverController.DeathTypes.Default); } return(dmg); }
public override void CollisionedWith(Collider collider, Script_HitBox hitBox) { Script_HurtBox hurtBox = collider.GetComponent <Script_HurtBox>(); if (hurtBox != null && !didHit) { int dmg = GetAttackStat().GetVal(); print($"CollisionedWith with {hurtBox} inflicting dmg: {dmg}"); /// Only hit if did damage if (hurtBox.Hurt(dmg, hitBox) > 0) { HitSFX(); didHit = true; } if (hitBoxBehavior != null) { hitBoxBehavior.Hit(collider); } } }
/// TODO: REMOVE ISSWALLEDDEMON, give demons hitboxes and they pass it in public override int Hurt(int sec, Script_HitBox hitBox) { if (GetComponent <Script_Player>().isInvincible) { return(0); } // reduce dmg by defense sec -= stats.defense.GetVal(); sec = Mathf.Clamp(sec, 0, int.MaxValue); if (Const_Dev.IsNoTimeHurt) { Debug.Log($"DEV MODE (IsNoTimeHurt): Player {name} would take damage {sec} sec. Time: {Script_ClockManager.Control.ClockTime}"); } else { HandleTakeDamage(sec); Debug.Log($"Player {name} took damage {sec} sec. Time: {Script_ClockManager.Control.ClockTime}"); } return(sec); }
/// <summary> /// via the interface, this handles the hurtbox colliding /// </summary> /// <param name="collider">the hurtbox</param> public virtual void CollisionedWith(Collider collider, Script_HitBox hitBox) { // Hurtbox hurtbox = collider.GetComponent<Hurtbox>(); // hurtbox?.getHitBy(damage); }