public void Attack() { for (int i = 0; i < numAttacks; i++) { GameObject attack = (GameObject)Instantiate(attackObject, new Vector2(transform.position.x + (0.1f * directionFacing), transform.position.y + 0.01f), Quaternion.Euler(0, 0, (Random.Range(90 - attackAngle / 2, 90 + attackAngle / 2)))); AttackObjectScript attackScript = attack.GetComponent <AttackObjectScript>(); attackScript.SetAttackValues(AttackOwner.Enemy, damage, attackSize, attackKnockBack, attackRange, (attackSpeed * directionFacing), attackHealth); attack.transform.localScale = attack.transform.localScale * attackSize * 0.2f; //attack.GetComponent<BoxCollider2D>().size = attack.GetComponent<BoxCollider2D>().size * currentSize * 0.2f; //attack.GetComponent<Rigidbody2D>().AddForce(new Vector2(directionFacing, 0)); } }
public void Attack() { if (currentNumAttacks < 1) { currentNumAttacks = 1; } if (currentDamage < 1) { currentDamage = 1; } if (currentSize < 2) { currentSize = 2; } if (currentSize > 20) { currentSize = 20; } if (currentKnockback > 200) { currentKnockback = 200; } //Mathf.Clamp (currentNumAttacks, 1, 50); for (int i = 0; i < currentNumAttacks; i++) { GameObject attack = (GameObject)Instantiate(attackObject, new Vector2(transform.position.x + (0.1f * directionFacing), transform.position.y + 0.045f), Quaternion.Euler(0, 0, (Random.Range(90 - currentAngle / 2, 90 + currentAngle / 2)))); AttackObjectScript attackScript = attack.GetComponent <AttackObjectScript>(); Mathf.Clamp(currentDamage, 1, 50); Mathf.Clamp(currentSize, 1, 20); int tempKnockBack; if (GameModeManager.gameModeToLoad == GameModes.PvP) { tempKnockBack = currentKnockback / 4; } else { tempKnockBack = currentKnockback; } attackScript.SetAttackValues(playerOwner, currentDamage, currentSize, tempKnockBack, currentRange, (currentAttackSpeed * directionFacing), currentAttackHealth); attack.transform.localScale = new Vector2(attack.transform.localScale.x * currentSize * 0.2f, attack.transform.localScale.y * (currentSize / 5 * 0.5f)); //attack.GetComponent<BoxCollider2D>().size = attack.GetComponent<BoxCollider2D>().size * currentSize * 0.2f; //attack.GetComponent<Rigidbody2D>().AddForce(new Vector2(directionFacing, 0)); } }