Esempio n. 1
0
    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>");
        }
    }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 public override void ActivateSwitch(bool b)
 {
     if (b)
     {
         Hitstop.Run(duration, priority: true);
     }
 }
Esempio n. 4
0
    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);
        }
    }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
    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());
        }
    }
Esempio n. 8
0
 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();
             }
         }
     }
 }
Esempio n. 9
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Esempio n. 10
0
 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();
 }
Esempio n. 11
0
    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");
 }
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
	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);
	}
Esempio n. 15
0
    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);
    }
Esempio n. 16
0
 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
        }
    }
Esempio n. 18
0
 // Update is called once per frame
 void Update()
 {
     if (Hitstop.isHitstop(gameObject))
     {
         return;
     }
     if (stun > 0)
     {
         stun -= Time.deltaTime;
         return;
     }
     Move();
     Jump();
     //Crouch();
 }
Esempio n. 19
0
 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;
 }
Esempio n. 20
0
    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();
        }
    }
Esempio n. 21
0
    // 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;
    }
Esempio n. 22
0
 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());
     }
 }
Esempio n. 23
0
    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();
        }
    }
Esempio n. 24
0
 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);
     }
 }
Esempio n. 25
0
 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());
     }
 }
Esempio n. 26
0
    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;
        }
    }
Esempio n. 27
0
 void Awake()
 {
     instance = this;
 }
Esempio n. 28
0
 public static void EnterSlowMotion()
 {
     Hitstop.Interrupt();
     Time.timeScale = 0.3f;
 }
Esempio n. 29
0
 void Awake()
 {
     current = this;
 }
Esempio n. 30
0
 public void RunHitstop(float duration)
 {
     Hitstop.Run(duration);
 }