コード例 #1
0
        /// <summary>
        /// Create cave point normal mapping
        /// </summary>
        /// <param name="shaderName">Shader name</param>
        public CavePointNormalMapping(string shaderName)
            : base(shaderName)
        {
            // Getting the effect parameters happens in GetParameters.

            // But we can load all the required textures here.
            groundDiffuseTexture = new Texture("CaveDetailGround");
            groundNormalTexture = new Texture("CaveDetailGroundNormal");
            groundHeightTexture = new Texture("CaveDetailGroundHeight");
            wallDiffuseTexture = new Texture("CaveDetailWall");
            wallNormalTexture = new Texture("CaveDetailWallNormal");
            wallHeightTexture = new Texture("CaveDetailWallHeight");
        }
コード例 #2
0
ファイル: EndScreen.cs プロジェクト: kiichi7/DungeonQuestGDC
 /// <summary>
 /// Create credits
 /// </summary>
 public EndScreen()
 {
     bookTexture = new Texture("XnaBook");
 }
コード例 #3
0
        /// <summary>
        /// Reload
        /// </summary>
        protected override void GetParameters()
        {
            // Can't get parameters if loading failed!
            if (xnaEffect == null)
                return;

            windowSize = xnaEffect.Parameters["windowSize"];
            sceneMap = xnaEffect.Parameters["sceneMap"];

            // We need both windowSize and sceneMap.
            if (windowSize == null ||
                sceneMap == null)
                throw new NotSupportedException("windowSize and sceneMap must be " +
                    "valid in PostScreenShader=" + Filename);

            // Init additional stuff
            downsampleMap = xnaEffect.Parameters["downsampleMap"];
            blurMap1 = xnaEffect.Parameters["blurMap1"];
            blurMap2 = xnaEffect.Parameters["blurMap2"];
            timer = xnaEffect.Parameters["Timer"];

            // Load noise texture for stripes xnaEffect
            noiseMap = xnaEffect.Parameters["noiseMap"];
            noiseMapTexture = new Texture("Noise128x128.dds");
            // Set texture
            noiseMap.SetValue(noiseMapTexture.XnaTexture);
        }
コード例 #4
0
ファイル: BaseGame.cs プロジェクト: kiichi7/DungeonQuestGDC
		} // IsVisible(point)
		#endregion

		#region Occlusion testing (not supported in XNA)
		/// <summary>
		/// Occlusion intensity
		/// </summary>
		/// <param name="tex">Tex</param>
		/// <param name="pos">Position</param>
		/// <param name="size">Size</param>
		/// <returns>Float</returns>
		public static float OcclusionIntensity(Texture tex, Point pos, int size)
		{
			return 0.0f;
		} // OcclusionIntensity(tex, pos, size)
コード例 #5
0
ファイル: UIManager.cs プロジェクト: kiichi7/DungeonQuestGDC
        /// <summary>
        /// Draw user interface
        /// </summary>
        public static void DrawUI()
        {
            if (uiBox == null)
                uiBox = new Texture("UIBox");

            #if XBOX360
            int xBorder = BaseGame.Width / 20;
            int yBorder = BaseGame.Height / 20;
            #else
            // For the PC 1% (or 2.5%) is fine
            int xBorder = BaseGame.Width / 100;// 40;
            int yBorder = BaseGame.Height / 100;// 40;
            #endif

            // Find nearest enemy and show effect around him.
            AnimatedGameObject nearestEnemy = null;
            foreach (AnimatedGameObject model in GameManager.animatedObjects)
                if ((nearestEnemy == null ||
                    (BaseGame.camera.PlayerPos - model.positionMatrix.Translation).
                    Length() <
                    (BaseGame.camera.PlayerPos - nearestEnemy.positionMatrix.Translation).
                    Length()) &&
                    // Must not be dead already
                    model.state != AnimatedGameObject.States.Die)
                    nearestEnemy = model;

            // Show enemy on top, just show the nearest one
            if (nearestEnemy != null &&
                // Must be near (20 units or less)
                Vector3.Distance(nearestEnemy.positionMatrix.Translation,
                BaseGame.camera.PlayerPos) <= 20)
            {
                TextureFont.WriteTextCentered(BaseGame.Width / 2,// + RX(6),
                    yBorder,
              StringHelper.SplitFunctionNameToWordString(
                    nearestEnemy.type.ToString()));
                float hitpointsPercentage = nearestEnemy.hitpoints /
                    GameManager.MonsterHitpoints[(int)nearestEnemy.type];
                uiBox.RenderOnScreen(
                    new Rectangle(BaseGame.Width / 2 - RX(75), yBorder + RY(30),
                    RX((int)(150 * hitpointsPercentage)), RY(13)),
                    BarGfxRect,
                    // Use red color
                    new Color(255, 105, 105, 200));

                // Also show 3D effect around that enemy
                EffectManager.AddEnemyRing(
                    nearestEnemy.positionMatrix.Translation + new Vector3(0, 0,
                    0.5f + (float)Math.Sin(Player.GameTime / 0.256f) * 0.175f),
                    0.7f);//0.75f);
                EffectManager.AddEnemyRing(
                    nearestEnemy.positionMatrix.Translation + new Vector3(0, 0,
                    0.5f + (float)Math.Sin((0.68f + Player.GameTime) / 0.256f) * 0.1625f),
                    0.8f);//0.75f);
                EffectManager.AddEnemyRing(
                    nearestEnemy.positionMatrix.Translation + new Vector3(0, 0,
                    0.5f + (float)Math.Sin((1.36f + Player.GameTime) / 0.256f) * 0.15f),
                    0.9f);//0.75f);
            } // if (nearestEnemy)

            // Show right box (skills and level ups)
            int rightBoxWidth =
                BigBoxGfxRect.Width * BaseGame.Width / 800;// 1024;
            int rightBoxHeight = 2 * // more place for the text on the right
                BigBoxGfxRect.Height * BaseGame.Height / 600;// 768;
            Rectangle rightBoxRect = new Rectangle(
                BaseGame.Width - (xBorder + rightBoxWidth),
                BaseGame.Height - (yBorder + rightBoxHeight),
                rightBoxWidth, rightBoxHeight);
            uiBox.RenderOnScreen(rightBoxRect, BigBoxGfxRect,
                new Color(255, 255, 255, 200));

            // Do we got the key?
            if (Player.gotKey)
            {
                // Show it (above the skills box)
                uiBox.RenderOnScreen(new Rectangle(
                    rightBoxRect.Right-RX(KeyGfxRect.Width*2),
                    rightBoxRect.Y-RY(KeyGfxRect.Height*2+5),
                    RX(KeyGfxRect.Width*2), RY(KeyGfxRect.Height*2)),
                    KeyGfxRect);
            } // if (Player.gotKey)

            TextureFont.WriteTextCentered(
                rightBoxRect.X + rightBoxRect.Width / 2 - RX(6),
                rightBoxRect.Y + RY(7),
                "Skills ("+Player.levelPointsToSpend+" left)");

            uiBox.RenderOnScreen(new Rectangle(
                rightBoxRect.X + RX(5), rightBoxRect.Y + RY(32 + 6), RX(20), RY(20)),
                XButtonGfxRect);
            TextureFont.WriteText(rightBoxRect.X + RX(36), rightBoxRect.Y + RY(32+5),
                "Defence ("+Player.defenseIncrease+")");
            uiBox.RenderOnScreen(new Rectangle(
                rightBoxRect.X + RX(5), rightBoxRect.Y + RY(58 + 10), RX(20), RY(20)),
                YButtonGfxRect);
            TextureFont.WriteText(rightBoxRect.X + RX(36), rightBoxRect.Y + RY(58+10),
                "Speed (" + Player.speedIncrease + ")");
            uiBox.RenderOnScreen(new Rectangle(
                rightBoxRect.X + RX(5), rightBoxRect.Y + RY(83 + 15), RX(20), RY(20)),
                BButtonGfxRect);
            TextureFont.WriteText(rightBoxRect.X + RX(36), rightBoxRect.Y + RY(83+15),
                "Attack (" + Player.damageIncrease + ")");

            // Left side shows health bar, next level bar and points
            int leftBoxWidth =
                BigBoxGfxRect.Width * BaseGame.Width / 800;// 1024;
            int leftBoxHeight =
                SmallBoxGfxRect.Height * BaseGame.Height / 600;// 768;
            Rectangle lightBoxRect3 = new Rectangle(
                xBorder, BaseGame.Height - (yBorder + leftBoxHeight + RY(10)),
                leftBoxWidth, leftBoxHeight + RY(10));
            Rectangle lightBoxRect2 = new Rectangle(
                xBorder, lightBoxRect3.Y - (leftBoxHeight +RY(4)),
                leftBoxWidth, leftBoxHeight);
            Rectangle lightBoxRect1 = new Rectangle(
                xBorder, lightBoxRect2.Y - (leftBoxHeight + RY(4)),
                leftBoxWidth, leftBoxHeight);
            uiBox.RenderOnScreen(lightBoxRect1, SmallBoxGfxRect,
                new Color(255, 255, 255, 200));
            uiBox.RenderOnScreen(lightBoxRect2, SmallBoxGfxRect,
                new Color(255, 255, 255, 200));
            uiBox.RenderOnScreen(lightBoxRect3, SmallBoxGfxRect,
                new Color(255, 255, 255, 200));

            TextureFont.WriteTextCentered(
                lightBoxRect1.X + lightBoxRect1.Width / 2,// + RX(4),
                lightBoxRect1.Y + RY(5),
                "Health");
            float healthPercentage = Player.health / Player.MaxHealth;
            uiBox.RenderOnScreen(
                new Rectangle(lightBoxRect1.X + RX(5), lightBoxRect1.Y+RY(30),
                (int)((lightBoxRect1.Width - RX(10))*healthPercentage), RY(13)),
                BarGfxRect,
                // Use green color
                new Color(105, 255, 105, 200));

            TextureFont.WriteTextCentered(
                lightBoxRect2.X + lightBoxRect2.Width / 2 - RX(4),
                lightBoxRect2.Y + RY(5),
                "Next Level "+Player.level);
            //obs: float scorePercentage = (float)(Player.score % 50)/50.0f;
            float thisLevelPoints = Player.NeedPointsForLevel(Player.level - 1);
            float nextLevelPoints = Player.NeedPointsForLevel(Player.level);
            float scorePercentage =
                (Player.score - thisLevelPoints) / (nextLevelPoints - thisLevelPoints);
            uiBox.RenderOnScreen(
                new Rectangle(lightBoxRect2.X + RX(5), lightBoxRect2.Y + RY(30),
                (int)((lightBoxRect2.Width - RX(10)) * scorePercentage), RY(13)),
                BarGfxRect,
                // Use yellow color
                new Color(255, 255, 105, 200));

            TextureFont.WriteTextCentered(
                lightBoxRect3.X + lightBoxRect3.Width / 2 - RX(4),
                lightBoxRect3.Y + RY(5),
                "Points: "+Player.score);
            TextureFont.WriteTextCentered(
                lightBoxRect3.X + lightBoxRect3.Width / 2 - RX(4),
                lightBoxRect3.Y + RY(5 + 28),
                "Time: " +
                (((int)Player.GameTime) / 60).ToString("00") + ":" +
                (((int)Player.GameTime) % 60).ToString("00"));

            /*tst
            uiBox.RenderOnScreen(
                //TODO: screen relative (use 1280 as default?)
                new Rectangle(100, 100, 200, 13),
                BarGfxRect,
                new Color(255, 255, 255, 200));
            /*tst boxes
            uiBox.RenderOnScreen(
                //TODO: screen relative (use 1280 as default?)
                new Rectangle(100, 100, 161*3/2, 63*3/2),
                BigBoxGfxRect);
            uiBox.RenderOnScreen(
                //TODO: screen relative
                new Rectangle(100, 300, 154*3/2, 46*3/2),
                SmallBoxGfxRect);

            /*tst buttons
            uiBox.RenderOnScreen(
                //TODO: screen relative
                new Rectangle(100, 500, 27, 27),
                XButtonGfxRect);
            uiBox.RenderOnScreen(
                //TODO: screen relative
                new Rectangle(150, 500, 27, 27),
                YButtonGfxRect);
            uiBox.RenderOnScreen(
                //TODO: screen relative
                new Rectangle(200, 500, 27, 27),
                BButtonGfxRect);
             */
        }
コード例 #6
0
ファイル: UIManager.cs プロジェクト: kiichi7/DungeonQuestGDC
        /// <summary>
        /// Test user interface
        /// </summary>
        public static void TestUI()
        {
            Texture backgroundTexture = null;

            TestGame.Start("TestUI",
                delegate
                {
                    backgroundTexture = new Texture("TestScreenshot");
                },
                delegate
                {
                    backgroundTexture.RenderOnScreen(BaseGame.ResolutionRect);

                    UIManager.DrawUI();
                });
        }
コード例 #7
0
        /// <summary>
        /// Create game manager
        /// </summary>
        public GameManager()
        {
            // Load the cave and fill in all static game items (will be done
            // there in the loading process).
            caveModel = new ColladaModel("Cave");
            caveModel.material.ambientColor = Material.DefaultAmbientColor;

            // Load all animated models (player and monsters)
            for (int i = 0; i <= (int)AnimatedTypes.BigOgre; i++)
                animatedModels.Add(new AnimatedColladaModel(
                    //tst: "GoblinWizard"));
                    ((AnimatedTypes)i).ToString()));

            // Also load all static models
            for (int i = 0; i <= (int)StaticTypes.BigSword; i++)
                staticModels.Add(new ColladaModel(
                    ((StaticTypes)i).ToString()));

            screenBorder = new Texture("ScreenBorder");
        }
コード例 #8
0
        /// <summary>
        /// Create effect manager
        /// </summary>
        public EffectManager()
        {
            // Load textures
            effectTextures = new Texture[EffectTextureFilenames.Length];
            for (int num = 0; num < effectTextures.Length; num++)
            {
                effectTextures[num] = new Texture(EffectTextureFilenames[num]);
            } // for (num)

            /*obs
            explosionTextures =
                new AnimatedTexture[ExplosionTextureFilenames.Length];
            for (int num = 0; num < explosionTextures.Length; num++)
            {
                explosionTextures[num] = new AnimatedTexture(
                    ExplosionTextureFilenames[num]);
            } // for (num)
             */
        }
コード例 #9
0
        /// <summary>
        /// Test post screen glow
        /// </summary>
        public static void TestPostScreenGlow()
        {
            Texture backgroundTexture = null;

            TestGame.Start("TestPostScreenGlow",
                delegate
                {
                    backgroundTexture = new Texture("XnaBook");
                },
                delegate
                {
                    // Disable glow with ctrl or X
                    if (Input.Keyboard.IsKeyDown(Keys.LeftControl) == false &&
                        Input.GamePadXPressed == false)
                        BaseGame.GlowShader.Start();

                    backgroundTexture.RenderOnScreen(BaseGame.ResolutionRect,
                        new Rectangle(0, 0, 256, 320));
                    SpriteHelper.DrawSprites();
                });
        }