예제 #1
0
        bool PlayerJetRemoveFromStage(PlayerJetActor player_jet_actor)
        {
            /// @@@ Pwb: requires more thought.  !! The sprite Remove event Handler will not be called.
            /// Most sprites will "die" due to the update loop.
            _active_sprites.Remove(player_jet_actor.Sprite);           // Add the sprite to the list of moving sprites.
            _game_stage.Children.Remove(player_jet_actor);

            bool removed = false;

            return(removed);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pilot_name"></param>
        /// <param name="position"></param>
        /// <param name="direction"></param>
        /// <param name="speed"></param>
        /// <param name="game_stage_limits"></param>
        /// <returns></returns>
        PlayerJetActor PlayerJetAddToStage(string pilot_name, int player_number, Vector position, Vector direction, double speed, Rect game_stage_limits)
        {
            //////////////////////////////////
            // Make a new sprite.
            PlayerJetSprite sprite = new PlayerJetSprite(position, direction, speed);

            sprite.Reset();                                 // Get the sprite in a default/known state.

            // Setup callbackks used for things like removal and scoring.
            sprite.Removed           += new RemoveHandler(SpriteRemoveHandler);
            sprite.CalmCollision     += new CollisionHandler(PilotCalmCollisionScoring);
            sprite.SpinningCollision += new CollisionHandler(PilotSpinningCollisionScoring);
            sprite.PulsingCollision  += new CollisionHandler(PilotPulsingCollisionScoring);


            // Setup the ship event handling (e.g. for reporting ship status to player).
            sprite.Collision    += new CollisionHandler(PilotCollidedTracking);      // Calls PilotCollidedTracking method when ship collides.
            sprite.NonCollision += new CollisionHandler(PilotNonCollisionTracking);  // Calls PlayerNonCollisionTracking method (once per turn) when ship does NOT collide.


            //////////////////////////////////
            // Make a new actor.
            PlayerJetActor actor = new PlayerJetActor(sprite, player_number);   // Make a new actor and give it a reference to its sprite.

            actor.Visibility = Visibility.Hidden;
            _game_stage.Children.Add(actor);                // Add the actor to the stage.

            sprite.IsMoving  = true;
            sprite.Position  = position;                    // Set the position, direction, speed, etc.
            sprite.Direction = direction;
            sprite.Speed     = speed;
            _active_sprites.Add(sprite);                    // Add the sprite to the list of moving sprites.
            sprite.Move();
            actor.Visibility = Visibility.Visible;          // Make the actor visible in the stage again.


            actor.Sprite.setBounceLimits(_game_stage_limits);
            return(actor);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private bool AddPilot(string pilot_name)
        {
            bool pilot_added = false;

            if (pilot_dictionary.ContainsKey(pilot_name))
            {
                string msg = "!!! Controller already has pilot: " + pilot_name;
                Trace.WriteLine(msg);
            }
            else
            {
                // Add pilot
                string msg = "Controller adding pilot: " + pilot_name;
                Trace.WriteLine(msg);

                int                 player_number = pilot_dictionary.Count;
                PlayerJetActor      player_jet    = PlayerJetAddToStage(pilot_name, player_number);
                PilotControllerInfo pilot_info    = new PilotControllerInfo(player_jet);

                // Add pilot to dictionary of pilots.
                pilot_dictionary.Add(pilot_name, pilot_info);
            }
            return(pilot_added);
        }
예제 #4
0
 public PilotControllerInfo(PlayerJetActor player_jet_actor)
 {
     actor = player_jet_actor;
 }