示例#1
0
        /// <summary>
        /// Initializes the renderer for a new game.
        /// </summary>
        /// <param name="Graphics"></param>
        public void Initialize(GraphicsDevice Graphics)
        {
            MapRenderTarget = new SpriteBatch(Graphics);
            this.Graphics   = Graphics;

            GoldFadeAnimators = new Dictionary <int, StateAnimator>();
            BatFadeAnimators  = new Dictionary <int, StateAnimator>();
            CamZoomAnimator   = new StateAnimator(
                pct => (float)pct.Scale(0, 1, DefaultCamZoom, TrappedInPitCamZoom),
                pct => (float)pct.Scale(0, 1, TrappedInPitCamZoom, DefaultCamZoom),
                1.2);
            OverriddenCameraZoom = null;

            Viewport RenderViewport = Graphics.Viewport;

            VirtualViewSize = new Vector2(RenderViewport.AspectRatio * VirtualViewHeight, VirtualViewHeight);
            this.MapCam     = new Camera2D(this.VirtualViewSize, RenderViewport)
            {
                Zoom = DefaultCamZoom
            };

            BackgroundTiles = new TiledTexture(BackgroundTexture, MapCam);

            Player = new Sprite2D(PlayerTexture)
            {
                RenderWidth  = (PlayerHeight / (double)PlayerTexture.Height * PlayerTexture.Width).ToInt(),
                RenderHeight = PlayerHeight
            };

            // Must set this after initial player creation so that
            // the player's width/height can be accessed
            Player.Position = GetPlayerTargetPosition();

            Player.Initialize();

            Player.AddAnimation(AnimationType.MoveToNewRoom, new SpriteMoveAnimation(dist => dist / 300f));
            Player.StartAnimation(AnimationType.MoveToNewRoom);

            Wumpus = new Sprite2D(WumpusTexture)
            {
                RenderWidth  = (WumpusHeight / (double)WumpusTexture.Height * WumpusTexture.Width).ToInt(),
                RenderHeight = WumpusHeight
            };

            Wumpus.Initialize();

            UpdateCamera();

            BackFogSystem          = new ParticleSystem.FogOfWar(CloudTextures, MapCam);
            FrontFogSystem         = new ParticleSystem.FogOfWar(CloudTextures, MapCam);
            FrontFogSystem.Opacity = 0f;

            BackFogSystem.Initialize();
            FrontFogSystem.Initialize();
        }
示例#2
0
        public XamlBoundAnimation(XamlAnimationDescriptor AnimationDesc, Action <string, string> RaisePropertyChangedForGroup)
        {
            this.RaisePropertyChangedForGroup = RaisePropertyChangedForGroup;
            this.AnimationDesc = AnimationDesc;

            // TODO: Accept custom easing
            InternalAnimator = new StateAnimator(
                Pct =>
            {
                // TODO: Add math to do cubic Bezier curve:
                // (0.165, 0.84), (0.44, 1)
                return((float)Math.Pow(Pct, 2));
            },
                Pct =>
            {
                return((float)-Math.Pow(Pct, 2) + 1);
            },
                AnimationDesc.TransitionDuration);
        }
示例#3
0
        public GameOverHudContext(GameController gameController, Action <string> RaisePropertyChangedForGroup)
        {
            this.RaisePropertyChangedForGroup = RaisePropertyChangedForGroup;
            GameController             = gameController;
            GameController.OnGameOver += GameController_OnGameOver;

            ReturnToMenuCommand = new RelayCommand(new Action <object>(ReturnToMenu));
            SubmitNameCommand   = new RelayCommand(new Action <object>(SubmitName));

            UsernameBoxVisibility = Visibility.Visible;

            GameOverModalMarginAnimation = new StateAnimator(
                Pct =>
            {
                // TODO: Add math to do cubic Bezier curve:
                // (0.165, 0.84), (0.44, 1)
                return((float)(Math.Pow(-Pct + 1, 2) * 200));
            },
                Pct =>
            {
                // Don't need to handle this -- should never fade out
                return(0);
            },
                1);

            GameOverModalOpacityAnimation = new StateAnimator(
                Pct =>
            {
                // TODO: Add math to do cubic Bezier curve:
                // (0.165, 0.84), (0.44, 1)
                return((float)Math.Pow(Pct, 2));
            },
                Pct =>
            {
                // Don't need to handle this -- should never fade out
                return(0);
            },
                0.6);
        }