// Use this for initialization void Start() { shootArrows = new ShootArrows() { arrowToShoot = this.projectile, HeightFrom = projectileHeightFrom, HeightTo = projectileHeightTo, Speed = projectileSpeed, projectileFired = false }; }
private void Start() { gamemanager = FindObjectOfType <GameManager>(); hero = FindObjectOfType <Hero>(); speed = hero.moveSpeed; shootArrows = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <ShootArrows>(); activeweapon = 0; // UI Images sword.enabled = false; bow.enabled = false; switchWeaponMouse.enabled = false; switchWeaponText.enabled = false; }
private void OnTriggerEnter(Collider other) { if (isDead) { return; } if (other.name.Contains("Arrow")) { ArrowSpecs specs = other.GetComponent <ArrowSpecs>(); float hitPower = specs.hitPower; float armorPierce = specs.armorPierce; float penetration = specs.penetration; ShootArrows shootScript = player.GetComponent <ShootArrows>(); float rnd = Random.Range(0.7f, 0.8f); Debug.Log((other.attachedRigidbody.velocity.magnitude / shootScript.maxShootPower)); float hitToHealth = hitPower * rnd * (other.attachedRigidbody.velocity.magnitude / shootScript.maxShootPower); float hitToArmor = hitPower * (1f - rnd) * (other.attachedRigidbody.velocity.magnitude / shootScript.maxShootPower); armor -= armorPierce; if (armor < hitToArmor) { hitToHealth += (hitToArmor - armor); armor = 0; } else { armor -= hitToArmor; } health -= hitToHealth; if (other.name.Equals("FireArrow(Clone)")) { StartCoroutine(FireArrowDamage(specs.fireDamage)); } arrowHit(other.attachedRigidbody, penetration); } }