Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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];
        }
Esempio n. 3
0
        public bool TakeWeapon(AWeapon w)
        {
            weapons.Add(w);

            return true;
        }