void DamageBy(Attack attack) { if (attack.damage == 0) { return; } Instantiate(selfHitmarker, this.transform.position, Quaternion.identity, null); SoundManager.PlayerHurtSound(); currentHP -= attack.GetDamage(); if (attack.instakill) { currentHP = 0; } Hitstop.Run(selfDamageHitstop); if (currentHP <= 0) { Die(attack); } else if (currentHP > 0 && attack.GetDamage() > 0) { AlerterText.Alert($"WAVEFORM INTEGRITY {currentHP}"); } else if (currentHP < 4) { AlerterText.Alert("<color=red>WAVEFORM CRITICAL</color>"); } }
public void Parry(Attack attack) { if (parryCount == 0) { FirstParry(attack); } else { Hitstop.Run(0.05f); StartCombatStanceCooldown(); Instantiate( parryEffect, GetParryEffectPosition(attack), Quaternion.identity, this.transform ); } if (!IsFacing(attack.attackerParent.gameObject)) { ForceFlip(); } parryCount += 1; SoundManager.PlaySound(SoundManager.sm.parry); canParry = true; StartCombatCooldown(); // parries can chain together as long as there's a hit every 0.5 seconds CancelInvoke("EndParryWindow"); Invoke("EndParryWindow", 0.5f); }
public override void ActivateSwitch(bool b) { if (b) { Hitstop.Run(duration, priority: true); } }
public override void ExtendedAttackLand(Entity e) { if (e == null) { return; } //run self knockback if (selfKnockBack) { attackerParent.GetComponent <Rigidbody2D>().velocity = selfKnockBackVector; } //give the player some energy if (gainsEnergy) { attackerParent.GetComponent <PlayerController>().GainEnergy(this.energyGained); } //deplete energy if necessary if (costsEnergy) { attackerParent.GetComponent <PlayerController>().LoseEnergy(this.energyCost); } SoundManager.HitSound(); //run hitstop if it's a player attack if (hitstopLength > 0.0f && this.gameObject.CompareTag(Tags.PlayerHitbox)) { Hitstop.Run(this.hitstopLength); } }
public void Parry() { if (parryCount == 0) { FirstParry(); } else { Hitstop.Run(0.05f); StartCombatStanceCooldown(); Instantiate( parryEffect, // move it forward and to the right a bit (Vector2)this.transform.position + (Random.insideUnitCircle * 0.2f) + (Vector2.right * this.ForwardVector() * 0.15f), Quaternion.identity, this.transform ); } parryCount += 1; SoundManager.PlaySound(SoundManager.sm.parry); canParry = true; GainEnergy(1); StartCombatCooldown(); // parries can chain together as long as there's a hit every 0.5 seconds CancelInvoke("EndParryWindow"); Invoke("EndParryWindow", 0.5f); }
virtual public void Open() { if ((exclusive && GlobalController.openUIs > 0)) { return; } if (!open) { GlobalController.openUIs += 1; } this.open = true; Hitstop.Interrupt(); if (interactSound) { SoundManager.InteractSound(); } GlobalController.pc.EnterCutscene(invincible: invincibleDuring); if (targetUI != null) { targetUI.SetActive(true); } if (stopTime) { Time.timeScale = 0f; } if (soloUISound) { SoundManager.SoloUIAudio(); } }
public override void OnHit(Attack attack) { if (dead) { return; } if (invincible && !attack.attackerParent.CompareTag(Tags.EnviroDamage)) { return; } if (attack.attackerParent.CompareTag(Tags.EnviroDamage)) { if (envDmgSusceptible) { OnEnviroDamage(); InterruptMeteor(); } else { return; } } CameraShaker.Shake(0.2f, 0.1f); Hitstop.Run(0.1f); InterruptSupercruise(); DamageFor(attack.GetDamage()); GlobalController.FlashWhite(); if (this.currentHP == 0) { return; } InvincibleFor(this.invincibilityLength); CyanSprite(); //compute potential stun StunFor(attack.GetStunLength()); //compute potential knockback //unfreeze if this enemy is in hitstop to preserve the first knockback vector //they'll be put back in hitstop afterwards by the incoming attack if necessary if (inHitstop) { UnLockInSpace(); inHitstop = false; } if (attack.knockBack) { //knockback based on the position of the attack Vector2 kv = attack.GetKnockback(); bool attackerToLeft = attack.transform.position.x < this.transform.position.x; kv.x *= attackerToLeft ? 1 : -1; KnockBack(kv); } if (cyan) { cyan = false; StartCoroutine(normalSprite()); } }
public void Die() { CloseHurtboxes(); this.frozen = true; this.dead = true; Hitstop.Run(.1f); DropPickups(); if (this.GetComponent <Animator>() != null && !burstOnDeath) { this.GetComponent <Animator>().SetTrigger("Die"); } else { if (burstEffect != null) { Burst(); } else { if (GetComponent <SelfDestruct>() == null) { Destroy(); } } } }
void Awake() { if (instance == null) { instance = this; } }
public static void EnterDialogue(NPC npc, bool fromQueue = false) { Hitstop.Interrupt(); if (dialogueOpen) { queuedNPCs.Enqueue(npc); return; } if (!pc.IsFacing(npc.gameObject)) { pc.ForceFlip(); } pc.EndCombatStanceCooldown(); if (!fromQueue) { dialogueUI.Open(); } currentNPC = npc; dialogueOpenedThisFrame = true; dialogueUI.ShowNameAndPicture(npc.GetCurrentLine()); if (npc.centerCameraInDialogue) { playerFollower.LookAtPoint(npc.gameObject); } pc.EnterCutscene(); }
public void CheckDamage(Collider2D other) { //if it's a player sword if (other.CompareTag(Tags.sword) || other.CompareTag(Tags.playerAttack) && !dead) { if (!invincible) { if (staggerable) { if (hasAnimator) { anim.SetTrigger("hurt"); } int scale = playerObject.GetComponent <PlayerController>().GetForwardScalar(); playerObject.GetComponent <FightController>().AttackConnect(this.gameObject); if (other.GetComponent <HurtboxController>() != null && this.rb2d != null) { this.rb2d.velocity = (new Vector2(other.GetComponent <HurtboxController>().knockbackVector.x *scale, other.GetComponent <HurtboxController>().knockbackVector.y)); } } DamageFor(other.gameObject.GetComponent <HurtboxController>().GetDamage()); WhiteSprite(); white = true; } Hitstop.Run(other.GetComponent <HurtboxController>().hitstop, this.gameObject); OnDamage(); } }
public void FirstParry() { AlerterText.Alert("Autoparry active"); parryParticles.Emit(15); Hitstop.Run(0.5f); anim.SetTrigger("Parry"); }
public void FirstParry() { AlerterText.Alert("Autoparry active"); GetComponent <AnimationInterface>().SpawnFollowingEffect(2); anim.SetTrigger("Parry"); Instantiate(parryParticles, this.transform.position, Quaternion.identity); CameraShaker.Shake(0.1f, 0.1f); Hitstop.Run(0.5f); }
public void FirstParry(Attack attack) { AlerterText.Alert("Autoparry active"); anim.SetTrigger("Parry"); Instantiate( diamondShine, GetParryEffectPosition(attack), Quaternion.identity, null ); Instantiate(parryParticles, this.transform.position, Quaternion.identity); CameraShaker.Shake(0.1f, 0.1f); Hitstop.Run(0.4f); }
public static bool isHitstop(GameObject go) { Hitstop hs = go.GetComponent <Hitstop> (); if (!hs) { Debug.Log("no hs comp in " + go); } if (hs && hs.isHitstop()) { return(true); } return(false); }
public static void EnterDialogue(NPC npc) { Hitstop.Interrupt(); if (dialogueOpen) { queuedNPCs.Enqueue(npc); return; } dialogueUI.Show(); pc.EnterDialogue(); currentNPC = npc; dialogueOpenedThisFrame = true; dialogueUI.ShowNameAndPicture(npc.GetCurrentLine()); }
public static void Stop(this Camera cam, float multi) { Hitstop stop = cam.transform.GetComponent <Hitstop>(); if (stop != null) { stop.Stop(multi); } else { Debug.Log("Camera doesn't have Hitstop component, adding one!"); cam.transform.gameObject.AddComponent <Hitstop>().Stop(multi); //add and stop } }
// Update is called once per frame void Update() { if (Hitstop.isHitstop(gameObject)) { return; } if (stun > 0) { stun -= Time.deltaTime; return; } Move(); Jump(); //Crouch(); }
public static void Pause() { if (pc.inCutscene) { return; } Hitstop.Interrupt(); pc.Freeze(); pc.inCutscene = true; pauseUI.SetBool("Shown", true); //manually first select pauseUI.transform.Find("EventSystem").GetComponent <EventSystem>().SetSelectedGameObject(pauseUI.transform.Find("Resume").gameObject); paused = true; SoundManager.InteractSound(); Time.timeScale = 0f; }
public override void ExtendedAttackLand(Entity e) { if (e == null) { return; } // the succ if (pullInEntity && e.staggerable) { e.transform.position = this.transform.position; } //run self knockback if (selfKnockBack) { attackerParent.GetComponent <Rigidbody2D>().velocity = new Vector2( forceX ? selfKnockBackVector.x * attackerParent.ForwardScalar() : attackerParent.GetComponent <Rigidbody2D>().velocity.x, selfKnockBackVector.y ); } //give the player some energy if (gainsEnergy) { player.GainEnergy(this.energyGained); } //deplete energy if necessary if (costsEnergy) { player.LoseEnergy(this.energyCost); } SoundManager.HitSound(); if (attackLandEvent) { player.OnAttackLand(this); } //run hitstop if it's a player attack if (hitstopLength > 0.0f && this.gameObject.CompareTag(Tags.PlayerHitbox)) { Hitstop.Run(this.hitstopLength); CameraShaker.TinyShake(); } }
// Update is called once per frame void Update() { if (Hitstop.isHitstop(gameObject)) { return; } if (Input.GetAxis("Horizontal_id" + player_id) > 0) { isFacingRight = true; } else if (Input.GetAxis("Horizontal_id" + player_id) < 0) { isFacingRight = false; } GetComponentInChildren <SpriteRenderer>().flipX = !isFacingRight; }
public override void OnHit(Attack attack) { WhiteSprite(); if (attack.GetComponent <PlayerAttack>() != null) { PlayerAttack a = attack.GetComponent <PlayerAttack>(); if (a.hitstopLength > 0 && this.hp > attack.GetDamage()) { Hitstop.Run(a.hitstopLength); } } DamageFor(attack.GetDamage()); StunFor(attack.GetStunLength()); if (attack.knockBack) { KnockBack(attack.GetKnockback()); } }
public override void ExtendedAttackLand(Entity e) { if (e == null) { return; } // the succ Rigidbody2D r = e.GetComponent <Rigidbody2D>(); if (pullInEntity && e.staggerable && r != null) { r.MovePosition(this.transform.position); } //run self knockback if (selfKnockBack) { SelfKnockBack(); } //give the player some energy if (gainsEnergy) { player.GainEnergy(this.energyGained); } //deplete energy if necessary if (costsEnergy) { player.LoseEnergy(this.energyCost); } if (attackLandEvent) { player.OnAttackLand(this); } //run hitstop if it's a player attack if (hitstopLength > 0.0f && this.gameObject.CompareTag(Tags.PlayerHitbox)) { Hitstop.Run(this.hitstopLength); CameraShaker.TinyShake(); } }
protected virtual void Die() { CloseHurtboxes(); this.frozen = true; this.dead = true; Hitstop.Run(.1f); if (!burstOnDeath && anim != null) { anim.SetTrigger("Die"); } else { if (burstEffect != null) { Burst(); } Destroy(this.gameObject); } }
public override void OnHit(Attack attack) { if (attack.GetComponent <PlayerAttack>() != null) { PlayerAttack a = attack.GetComponent <PlayerAttack>(); if (a.hitstopLength > 0 && this.hp > attack.GetDamage()) { Hitstop.Run(a.hitstopLength); } } DamageFor(attack.GetDamage()); if (this.hitSound != null && mainChildRenderer.isVisible) { SoundManager.PlayIfClose(this.hitSound, this.gameObject); } StunFor(attack.GetStunLength()); if (attack.knockBack) { KnockBack(attack.GetKnockback()); } }
void FixedUpdate() { if (Hitstop.isHitstop(gameObject)) { if (oldSpeed == null) { oldSpeed = rb.velocity; } rb.velocity = (Vector2)Vector2.zero; if (oldPos == null) { oldPos = rb.position; } rb.position = (Vector2)oldPos; return; } else { if (oldSpeed != null) { rb.velocity = (Vector2)oldSpeed; oldSpeed = null; } if (oldPos != null) { oldPos = null; } } if (player && !player.isGrounded) { Vector2 v = new Vector2(0, gravity * Time.deltaTime); rb.velocity -= v; } }
void Awake() { instance = this; }
public static void EnterSlowMotion() { Hitstop.Interrupt(); Time.timeScale = 0.3f; }
void Awake() { current = this; }
public void RunHitstop(float duration) { Hitstop.Run(duration); }