예제 #1
0
        protected double _getEnergy;                     //For energy repair


        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public Computer(VehInfo.Computer type, Arena arena)
            : base(type, arena)
        {
            _type = type;

            //Load the appropriate turret settings
            AssetManager am = Helpers._server._assets;

            //What is the gun we're going to be shooting?
            int wepID = type.InventoryItems[0];

            //_arena.sendArenaMessage("wepid: " + wepID);

            if (wepID != 0)
            {                   //Find our primary weapon
                _primaryGun = am.getItemByID(wepID);
                _primaryGun.getAmmoType(out _ammoType, out _ammoCount, out _ammoCapacity);
                _ammoRemaining = _ammoCapacity;

                //What sort of
                if (_primaryGun is ItemInfo.MultiUse)
                {
                    ItemInfo.MultiUse mug = (ItemInfo.MultiUse)_primaryGun;
                    _reloadTime = mug.reloadDelayNormal * 10;
                    _fireDelay  = mug.fireDelay * 10;

                    //Assume the first item is the tracking projectile
                    _primaryProjectile = ((ItemInfo.Projectile)am.getItemByID(mug.childItems[0].id));
                }
                else if (_primaryGun is ItemInfo.Projectile)
                {
                    _primaryProjectile = (ItemInfo.Projectile)_primaryGun;
                    _reloadTime        = _primaryProjectile.reloadDelayNormal * 10;
                    _fireDelay         = _primaryProjectile.fireDelay * 10;
                }
                else
                {
                    //Treat it as no weapon
                    _primaryGun = null;
                }
            }
            else
            {
                _primaryGun = null;
            }

            configureComp();
        }
예제 #2
0
        /// <summary>
        /// Equips the weapon controller with a new item
        /// </summary>
        public bool equip(ItemInfo item)
        {
            _type = item;

            //Find our primary weapon
            AssetManager am = Helpers._server._assets;

            _primaryItem = item;
            _primaryItem.getAmmoType(out _ammoType, out _ammoCount, out _ammoCapacity);
            _ammoRemaining = _ammoCapacity;

            //What sort of item are we dealing with?
            if (_primaryItem is ItemInfo.MultiUse)
            {
                ItemInfo.MultiUse mug = (ItemInfo.MultiUse)_primaryItem;
                _reloadTime = mug.reloadDelayNormal * 10;
                _fireDelay  = mug.fireDelay * 10;

                //Assume the first item is the tracking projectile
                _primaryProjectile = ((ItemInfo.Projectile)am.getItemByID(mug.childItems[0].id));
            }
            else if (_primaryItem is ItemInfo.Projectile)
            {
                _primaryProjectile = (ItemInfo.Projectile)_primaryItem;
                _reloadTime        = _primaryProjectile.reloadDelayNormal * 10;
                _fireDelay         = _primaryProjectile.fireDelay * 10;
            }
            else
            {                   //We can't handle this item
                Log.write(TLog.Warning, "Weapon controller given invalid equip item {0}", item);
                return(false);
            }

            bEquipped = (_primaryProjectile != null);

            return(true);
        }