public void EquipBestWeapon(GameObject target) { if (weapons.Count <= 0) return; float distance = Vector3.Distance(transform.position, target.transform.position); var bestWeapon = weapons[0]; float bestDamage = 0f; for (int i = 0; i <= weapons.Count; i++) { if (weapons[i].Range >= distance && weapons[i].Damage > bestDamage) bestWeapon = weapons[i]; } currentWeapon = bestWeapon; }
void Start() { if (weaponPosition == null) weaponPosition = transform; foreach (var w in weapons) { w.Enabled = false; w.transform.parent = weaponPosition; w.transform.position = weaponPosition.position; } if (weapons.Count > 0 && weapons[0] != null) currentWeapon = weapons[0]; }
public bool TakeWeapon(AWeapon w) { weapons.Add(w); return true; }