コード例 #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 void Initialize()
        {
            // Create the sprites for the Wumpus and character
            PlayerCharacter = new Sprite2D(PlayerTexture, Scale: 0.1f);
            Wumpus          = new Sprite2D(WumpusTexture, Scale: 0.1f);

            PlayerCharacter.CenterOrigin();
            Wumpus.CenterOrigin();

            // Add the movement animations to make it less abrupt
            PlayerCharacter.AddAnimation(AnimationType.MoveToNewMenuTile, new SpriteMoveAnimation(dist => dist / 75f));
            Wumpus.AddAnimation(AnimationType.MoveToNewMenuTile, new SpriteMoveAnimation(dist => dist / 75f));

            // Initialize the animations
            PlayerCharacter.Initialize();
            Wumpus.Initialize();

            // Start the animations
            PlayerCharacter.StartAnimation(AnimationType.MoveToNewMenuTile);
            Wumpus.StartAnimation(AnimationType.MoveToNewMenuTile);
        }
コード例 #3
0
 /// <summary>
 /// Initializes the animation and assigns a target.
 /// </summary>
 /// <param name="Target"></param>
 public abstract void Initialize(Sprite2D Target);
コード例 #4
0
 public override void Initialize(Sprite2D Target)
 {
     this.Target    = Target;
     CurrentOpacity = InitialOpacity;
 }
コード例 #5
0
        public override void Initialize(Sprite2D Target)
        {
            this.Target = Target;

            CurrentPosition = Target.Position.Clone();
        }