private void AttackWithType(int attackType) { StartCoroutine(AttackCoolDown()); myAnimator.SetTrigger("Attack"); if (!wolf) { PlaySFX(humanAttackSFX); playerWep.gameObject.SetActive(true); playerWep.SetDamage(attackType); playerWep.Attack(attackType); } if (wolf) { //PlaySFX(wolfAttackSFX) playerWolfWep.gameObject.SetActive(true); playerWolfWep.SetDamage(attackType); playerWolfWep.Attack(attackType); } switch (attackType) //Sets the attack timer to 0 depending on the type of attack used { case 1: basicAttackTimer = 0; break; case 2: heavyAttackTimer = 0; break; case 3: specialAttackTimer = 0; break; } }
public void OnThrowAttack() { if (m_pickedUp == null || m_pickedUpType == Types.PickupType.AXE) { m_weapon.Attack(); GameController.instance.PlayAttackTree(); return; } Vector3 throwForce = m_throwForce; if (Random.value < m_chanceOfShowOffAfterThrow) { m_shouldShowOff = true; throwForce = Vector2.up * m_throwForce.magnitude; GameController.instance.PlayShowOff(); } if (!m_isFacingRight) { throwForce.x *= -1f; } m_pickedUp.transform.parent = transform.parent; m_pickedUp.GetComponent <Collider2D>().enabled = true; Rigidbody2D pickedUpRigidBody = m_pickedUp.GetComponent <Rigidbody2D>(); pickedUpRigidBody.bodyType = RigidbodyType2D.Dynamic; pickedUpRigidBody.AddForce(throwForce); m_pickedUp = null; m_pickedUpType = Types.PickupType.NONE; GameController.instance.PlayThrow(); }
public int PhysicalAttack(Monster monster) { int attackAmount = 0; try { if (PlayerWeapon.Equipped && PlayerWeapon.WeaponGroup != WeaponType.Bow) { attackAmount = PlayerWeapon.Attack(); } if (PlayerWeapon.Equipped && PlayerWeapon.WeaponGroup == WeaponType.Bow && PlayerQuiver.HaveArrows()) { PlayerQuiver.UseArrow(); attackAmount = PlayerWeapon.Attack(); } if (PlayerWeapon.Equipped && PlayerWeapon.WeaponGroup == WeaponType.Bow && !PlayerQuiver.HaveArrows()) { Quiver.DisplayOutOfArrowsMessage(); attackAmount = 5; } } catch (NullReferenceException) { OutputHelper.Display.StoreUserOutput( Settings.FormatFailureOutputText(), Settings.FormatDefaultBackground(), "Your weapon is not equipped! Going hand to hand!"); attackAmount = 5; } foreach (IEffect effect in Effects) { if (effect is ChangePlayerDamageEffect changeEffect) { attackAmount = changeEffect.GetUpdatedDamageFromChange(attackAmount); } } foreach (IEffect effect in monster.Effects) { if (effect is FrozenEffect frozenEffect) { attackAmount = frozenEffect.GetIncreasedDamageFromFrozen(attackAmount); } } return(attackAmount); }
protected void Swipe() //Melee Attack { weapon.SetActive(true); PlayerWeapon wpnScript = weapon.GetComponent <PlayerWeapon>(); if (wpnScript) { if (wpnScript) { wpnScript.Attack(); } } //Set thread to turn swiping back on in a short amount of time StartCoroutine(DelayNextSwipe(swipeDelay)); }
private IEnumerator AttackBox(float timeToAttack, bool tmpLightAttack) { yield return(new WaitForSeconds(timeToAttack)); //Create a linecast that checks if there is a enemy there var tmp = Physics2D.Linecast(transform.position + new Vector3(0, 0.3f, 0), new Vector2(transform.position.x + tmpDirection, transform.position.y + 0.3f), 1 << LayerMask.NameToLayer("Enemy")); var tmp2 = Physics2D.Linecast(transform.position + new Vector3(0, 0.4f, 0), new Vector2(transform.position.x + tmpDirection, transform.position.y + 0.7f), 1 << LayerMask.NameToLayer("Enemy")); var tmp3 = Physics2D.Linecast(transform.position + new Vector3(0, 0.2f, 0), new Vector2(transform.position.x + tmpDirection, transform.position.y - 0.1f), 1 << LayerMask.NameToLayer("Enemy")); Debug.DrawLine(transform.position + new Vector3(0, 0.3f, 0), new Vector2(transform.position.x + tmpDirection, transform.position.y + 0.3f), Color.red); Debug.DrawLine(transform.position + new Vector3(0, 0.4f, 0), new Vector2(transform.position.x + tmpDirection, transform.position.y + 0.7f), Color.red); Debug.DrawLine(transform.position + new Vector3(0, 0.2f, 0), new Vector2(transform.position.x + tmpDirection, transform.position.y - 0.1f), Color.red); //If the raycast hits a enemy if (tmp || tmp2 || tmp3) { aS.pitch = Random.Range(0.8f, 1.2f); aS.clip = hit; aS.Play(); totalAttacksHit++; weapon.Attack(tmp.transform.gameObject, tmpLightAttack); } }
private void AttackInDirection(Vector2 direction) { weapon.Attack(direction); }