示例#1
0
        /// <summary>
        /// Initialize a ship to its default gameplay states.
        /// </summary>
        public override void Initialize()
        {
            if (!active)
            {
                // set the initial gameplay data values
                shipInput           = ShipInput.Empty;
                rotation            = 0f;
                velocity            = Vector2.Zero;
                life                = lifeMaximum;
                shield              = shieldMaximum;
                shieldRechargeTimer = 0f;
                safeTimer           = safeTimerMaximum;
                weapon              = new LaserWeapon(this);
                mineWeapon          = new MineWeapon(this);

                // play the player-spawn sound
                AudioManager.PlaySoundEffect("player_spawn");

                // add the ship-spawn particle effect
                if (ParticleEffectManager != null)
                {
                    ParticleEffectManager.SpawnEffect(ParticleEffectType.ShipSpawn,
                                                      this);
                }

                // clear out the projectiles list
                projectiles.Clear();
            }

            base.Initialize();
        }
示例#2
0
        /// <summary>
        /// Process the local player's input.
        /// </summary>
        private void ProcessLocalPlayerInput()
        {
            if ((networkSession != null) && (networkSession.LocalGamers.Count > 0))
            {
                // create the new input structure
                ShipInput shipInput = new ShipInput(
                    GamePad.GetState(
                       networkSession.LocalGamers[0].SignedInGamer.PlayerIndex),
                    Keyboard.GetState(
                       networkSession.LocalGamers[0].SignedInGamer.PlayerIndex));

                // send it out
                // -- the local machine will receive and apply it from the network just
                //    like the other clients
                shipInput.Serialize(packetWriter);
                networkSession.LocalGamers[0].SendData(packetWriter,
                    SendDataOptions.InOrder);
            }
        }
示例#3
0
        /// <summary>
        /// Initialize a ship to its default gameplay states.
        /// </summary>
        public override void Initialize()
        {
            if (!active)
            {
                // set the initial gameplay data values
                shipInput = ShipInput.Empty;
                rotation = 0f;
                velocity = Vector2.Zero;
                life = lifeMaximum;
                shield = shieldMaximum;
                shieldRechargeTimer = 0f;
                safeTimer = safeTimerMaximum;
                weapon = new LaserWeapon(this);
                mineWeapon = new MineWeapon(this);

                // play the player-spawn sound
                AudioManager.PlaySoundEffect("player_spawn");

                // add the ship-spawn particle effect
                if (ParticleEffectManager != null)
                {
                    ParticleEffectManager.SpawnEffect(ParticleEffectType.ShipSpawn,
                        this);
                }

                // clear out the projectiles list
                projectiles.Clear();
            }

            base.Initialize();
        }