Ejemplo n.º 1
0
 public GameObject GetSecondary(SecondaryWeaponType wpType)
 {
     return(SecondariesPfs.FirstOrDefault(x => x.GetComponent <SecondaryWeaponBase>().WeaponType == wpType));
 }
Ejemplo n.º 2
0
 public Texture2D this[SecondaryWeaponType secondaryWeapon, TextureDisplayType textureType]
 {
     get { return(_secondaryWeaponTextures[new KeyValuePair <SecondaryWeaponType, TextureDisplayType>(secondaryWeapon, textureType)]); }
 }
Ejemplo n.º 3
0
        public override void Update(GameTime gt)
        {
            if (shipState != CoreTypes.ShipState.Alive)
            {
                return;
            }

            if (CurrentHealth <= 0)
            {
                if (StateManager.Options.SFXEnabled)
                {
                   ExplosionSFX.Play();
                }
                base.Update(gt);

                _isDead = true;
                return;
            }

            if (RotateTowardsMouse)
            {
            #if WINDOWS
                ms = MouseManager.CurrentMouseState;
                Vector2 mousePos = new Vector2(ms.X, ms.Y);
                Vector2 targetPos = mousePos - Position;

                //Rotate towards mouse
                Rotation.Radians = Math.Atan2(targetPos.X, -targetPos.Y).ToFloat();

                lastms = ms;
            #elif XBOX
                if (new Vector2(Math.Round(GamePadManager.One.Current.ThumbSticks.Right.X * 10).ToFloat() / 10.ToFloat(), Math.Round(GamePadManager.One.Current.ThumbSticks.Right.Y * 10).ToFloat() / 10.ToFloat()) != Vector2.Zero)
                {
                    Rotation.Vector = new Vector2(GamePadManager.One.Current.ThumbSticks.Right.X, -GamePadManager.One.Current.ThumbSticks.Right.Y);
                }
            #endif
            }

            //Shoot
            _elapsedShotTime += gt.ElapsedGameTime;
            if (CanShoot)
            {
                if (StateManager.InputManager.ShootControlDown)
                {
                    Shoot();
                    _elapsedShotTime = TimeSpan.Zero;
                }
            }

            if (StateManager.PowerUps[0].Count > 0 || StateManager.PowerUps[1].Count > 0 || StateManager.PowerUps[2].Count > 0 || StateManager.PowerUps[3].Count > 0)
            {

                if ( StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Count == 0 || StateManager.InputManager.ShouldMoveSecondaryWeaponSelection(1))
                {
                    int selCount = 0;
                    do
                    {
                        SecondaryWeaponIndex++;
                        SecondaryWeaponIndex = (SecondaryWeaponType)(SecondaryWeaponIndex.ToInt() % StateManager.PowerUps.Length);
                    } while (StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Count == 0 && selCount < StateManager.PowerUps.Length);
                }
                if (StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Count == 0 || StateManager.InputManager.ShouldMoveSecondaryWeaponSelection(-1))
                {
                    int selCount = 0;
                    do
                    {
                        SecondaryWeaponIndex--;
                        if (SecondaryWeaponIndex < 0)
                        {
                            SecondaryWeaponIndex = StateManager.PowerUps.Length + SecondaryWeaponIndex;
                        }
                    } while (StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Count == 0 && selCount < StateManager.PowerUps.Length);
                }
            }

            if (StateManager.InputManager.DeploySecondaryWeapon(SecondaryWeaponIndex))
            {
                if ((CurrentHealth < InitialHealth && StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Peek().GetType() == typeof(HealthPack)) || StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Peek().GetType() != typeof(HealthPack))
                {
                    SecondaryWeapon fired = StateManager.DebugData.InfiniteSecondaryWeapons ? StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Peek() : StateManager.PowerUps[SecondaryWeaponIndex.ToInt()].Pop();
                    fired.fired = true;
                    //canDeploySecWeap = false;
                    //StateManager.PowerUps.Remove(ActiveSecondaryWeapon);

                    fired.ParentShip = this;
                    fired.Killed += new EventHandler(ActiveSecondaryWeapon_Killed);

                    //Specifics of certain secondary weapons
                    ActiveSecondaryWeapons.Add(fired); ;
                    switch (fired.GetType().FullName)
                    {

                        case "PGCGame.SpaceMine":
                            fired.Cast<SpaceMine>().SpaceMineState = SpaceMineState.Deploying;
                            break;
                        case "PGCGame.EMP":
                            fired.Cast<EMP>().PublicEMPState = EMPState.Deployed;
                            break;
                        case "PGCGame.ShrinkRay":
                            if (!fired.Cast<ShrinkRay>().ShotBullet)
                            {
                                fired.Position = fired.ParentShip.WorldCoords;
                                ShrinkRayShoot(fired.Cast<ShrinkRay>());
                            }
                            break;
                    }
                }
            }

            if (ActiveSecondaryWeapons.Count > 0)
            {
                _updateI = 0;
                for (; _updateI < ActiveSecondaryWeapons.Count; _updateI++)
                {
                    if (_updateI < 0 && ActiveSecondaryWeapons.Count <= 0)
                    {
                        break;
                    }
                    else if (_updateI < 0)
                    {
                        _updateI = 0;
                    }
                    ActiveSecondaryWeapons[_updateI].Update(gt);
                }
            }

            base.Update(gt);
        }