Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="server_proxy"></param>
        public PilotStage(PilotController controller, ServerProxy server_proxy)
        {
            InitializeComponent();

            _controller   = controller;
            _server_proxy = server_proxy;

            _view_translator = new RadarViewTranslator(
                RadarContainer.Width / 2.0, RadarContainer.Height / 2.0, // radar screen canvas center x, y
                (RadarContainer.Width / 2.0) * 0.97                      // radar canvas radial limit - use 97% of radius to allow for a little masking at the edges
                );                                                       // radar limit in world coord (i.e. kilometers)


            // Use the view translate defaults for now.
            _pre_pilot_heading          = _view_translator.RadarWorldHeading;
            _pre_pilot_visibility_range = _view_translator.RadarPilotVisibilityRange;
            _pre_pilot_radar_range      = _view_translator.RadarWorldLimit;

            // Register handlers for Controller callbacks
            _controller.PropertyChanged += Controller_PropertyChangedHandler;
            _controller.AddedSprite     += Controller_AddedSpriteHandler;
            _controller.TurnUpdateBegin += Controller_TurnUpdateBeginHandler;
            _controller.TurnUpdateEnd   += Controller_TurnUpdateEndHandler;

            AttachServerHandlers();
        }
Ejemplo n.º 2
0
        public AresMissileActor(RadarViewTranslator view_translator, AresMissileSprite sprite)
            : base(view_translator, sprite)
        {
            InitializeComponent();

            _ares_missile_sprite = sprite;
            _ares_missile_sprite.NowFallingStateChange += new AresMissileSprite.StateChangeHandler(_Sprite_NowFalling);

            // Find the story boards in the xaml, so we can start/stop the animations when we want to.
            _spinning_falling_death_story = (Storyboard)TryFindResource("SpinningFallingDeathStoryKey");
        }
Ejemplo n.º 3
0
        /// Using a base class for WPF UserControl: http://stackoverflow.com/questions/887519/how-can-a-wpf-usercontrol-inherit-a-wpf-usercontrol
        public ClientActor(RadarViewTranslator view_translator, ClientSprite sprite)
        {
            _sprite = sprite;

            // Translator of world positions and headings to stage locations and angles.
            _view_translator = view_translator;

            // Attach observer/callbacks we need from sprite to actor.
            _sprite.Moved   += new MovedHandler(Sprite_MovedHandler);
            _sprite.Removed += new RemoveHandler(Sprite_RemovedHandler);

            ////////////////////////////////////////////////////////////
            // Insert a transformation group into the *root* UIElment (above the first canvas) to control the
            // actors roation and  position during animation.  Keep a reference to _roate and _translate to
            // change the heading and position on each move (when the "Moved" callback happens).
            TransformGroup _transforms = new TransformGroup();

            _rotate.CenterX = 0.0;             // Calculate the center of rotation as the center of the actor geometery.
            _rotate.CenterY = 0.0;
            _transforms.Children.Add(_rotate); // Note: _rotate MUST be added before _translate or it will not rotate relative to actor center.

            _transforms.Children.Add(_translate);
            this.RenderTransform = _transforms;
        }