예제 #1
0
        public static InvWeapon CreateLauncher(Spatial launchNode, PhysicsBody ignoreBody)
        {
            WeaponDef weapDef = new WeaponDef();

            weapDef.name = "Launcher";
            weapDef.primaryRefireTime   = 0.02f;
            weapDef.secondaryRefireTime = 0.75f;
            weapDef.primaryPrjCount     = 1;
            weapDef.secondaryPrjCount   = 12;

            ProjectileDef primaryPrjDef = new ProjectileDef();

            primaryPrjDef.damage      = 25;
            primaryPrjDef.launchSpeed = 35;
            primaryPrjDef.timeToLive  = 1;

            ProjectileDef secondaryPrjDef = new ProjectileDef();

            secondaryPrjDef.damage      = 25;
            secondaryPrjDef.launchSpeed = 35;
            secondaryPrjDef.timeToLive  = 1;

            InvWeapon weapon = new InvWeapon(launchNode, weapDef, primaryPrjDef, secondaryPrjDef, ignoreBody);

            return(weapon);
        }
예제 #2
0
 public void AddWeapon(InvWeapon weap)
 {
     _weapons.Add(weap);
     if (_currentWeaponIndex == -1)
     {
         _currentWeaponIndex = _weapons.Count() - 1;
     }
 }
예제 #3
0
        public void Tick(float delta, bool primaryOn, bool secondaryOn)
        {
            CheckQueuedSwitch();
            InvWeapon weap = GetCurrentWeapon();

            // Tick
            if (weap != null)
            {
                weap.Tick(delta, primaryOn, secondaryOn);
            }
        }
예제 #4
0
        public void FillHudStatus(HUDPlayerState state)
        {
            InvWeapon weap = GetCurrentWeapon();

            if (weap == null)
            {
                state.ammoLoaded = 999;
                state.weaponName = "None";
                return;
            }
            state.weaponName = weap.GetDisplayName();
            state.ammoLoaded = weap.GetLoadedAmmo();
        }
예제 #5
0
        private void CheckQueuedSwitch()
        {
            if (_queuedWeaponSwitchIndex >= 0)
            {
                InvWeapon cur = GetCurrentWeapon();
                if (cur != null)
                {
                    // check that current weapon is okay
                    if (!cur.CanSwitchAway())
                    {
                        return;
                    }
                    cur.SetEquipped(false);
                }

                _currentWeaponIndex      = _queuedWeaponSwitchIndex;
                _queuedWeaponSwitchIndex = -1;
                cur = GetCurrentWeapon();
                cur.SetEquipped(true);
            }
        }