public void GeneralHited(SceneDestructible hitedObj, Vector3 hitPoint) { if (RealWeapon.IsAttacking) { float hitAmnt = CalculateHitAmmount(RealWeapon.WeaponData, hitedObj); hitedObj.Hit(gameObject, hitPoint, hitAmnt); Debug.Log("Trafienie w " + hitedObj.gameObject.name + " na " + hitAmnt + " HP"); } }
public void PerformScanHit() { if (UsedItem != null) { SceneWeapon sw = UsedItem.GetComponent <SceneWeapon>(); if (sw != null && UsedItem.ItemData != null && sw.IsAttacking) { if (sw.WeaponData.IsMeleeWeapon && sw.WeaponData["scanHit"] != null && (bool)sw.WeaponData["scanHit"] == true) { SceneWeaponHitter[] hitters = UsedItem.GetComponentsInChildren <SceneWeaponHitter>(); Vector3 hitPoint; GameObject hited = FPPUIManager.Instance.CameraLooksOnScanHit((float)sw.WeaponData["meleeRange"], GetFiringAccuracy(), out hitPoint); if (hited != null && hited.GetComponent <SceneDestructible>() != null) { foreach (SceneWeaponHitter swh in hitters) { swh.GeneralHited(hited.GetComponent <SceneDestructible>(), hitPoint); } } sw.IsAttacking = false; } else if (sw.WeaponData.IsShootingWeapon && sw.CurrentAttackMode == FightSystem.AttackMode.ShootScanAttack && sw.WeaponData["scanHit"] != null && (bool)sw.WeaponData["scanHit"] == true) { SceneWeaponHitter[] hitters = UsedItem.GetComponentsInChildren <SceneWeaponHitter>(); Vector3 hitPoint; GameObject hited = FPPUIManager.Instance.CameraLooksOnScanHit((float)sw.WeaponData["shootRange"], GetFiringAccuracy(), out hitPoint); if (hited != null) { SceneDestructible hitesDestr = FindDestructibleObject(hited); if (hitesDestr != null) { foreach (SceneWeaponHitter swh in hitters) { swh.GeneralHited(hitesDestr, hitPoint); } } } sw.InvokeShootEffects(); } } } }
private float CalculateHitAmmount(BaseDataAddon weaponData, SceneDestructible hited) { float amnt = 0; if ((int)weaponData["meleeMin"] > 0 && (int)weaponData["meleeMax"] > 0 && (int)weaponData["meleeMin"] <= (int)weaponData["meleeMax"]) { amnt = Random.Range((int)weaponData["meleeMin"], (int)weaponData["meleeMax"]); } else if ((int)weaponData["shootMin"] > 0 && (int)weaponData["shootMax"] > 0 && (int)weaponData["shootMin"] <= (int)weaponData["shootMax"]) { amnt = Random.Range((int)weaponData["shootMin"], (int)weaponData["shootMax"]) * RangeModfier(weaponData, GameManager.Instance.ThePlayerController.gameObject); } if ((int)weaponData["critical"] > 0 && Random.Range(0, 100) < (int)weaponData["critical"]) { amnt *= CRITICAL_BONUS; } if (hited != null && hited.DestructibleData["hitType"] != null && weaponData[(string)hited.DestructibleData["hitType"] + "Bonus"] != null) { amnt += (amnt * (int)weaponData[(string)hited.DestructibleData["hitType"] + "Bonus"]) / 100; } return(amnt); }