getTexture() public static method

public static getTexture ( int health ) : Microsoft.Xna.Framework.Graphics.Texture2D
health int
return Microsoft.Xna.Framework.Graphics.Texture2D
        private void addEnemy()
        {
            float x = 0, z = 0;
            float y = Constants.TERRAIN_HEIGHT;
            //while(y > .5 * Constants.TERRAIN_HEIGHT)
            //{
            bool flag = true;

            while (flag)
            {
                x = (float)(rnd[0].NextDouble() * Constants.FIELD_MAX_X_Z * 2 - Constants.FIELD_MAX_X_Z);
                z = (float)(rnd[0].NextDouble() * Constants.FIELD_MAX_X_Z * 2 - Constants.FIELD_MAX_X_Z);
                //x = (float)(rnd[0].NextDouble() * 50);
                //z = (float)(rnd[0].NextDouble() * 50);
                if (Math.Abs(x - myGame.player.unit.position.X) > 20 && Math.Abs(z - myGame.player.unit.position.Z) > 20)
                {
                    flag = false;
                }
            }
            y = myGame.GetHeightAtPosition(x, z);
            //}
            Vector3 pos    = new Vector3(x, y, z);
            Vector3 rot    = new Vector3(0, (float)(rnd[0].NextDouble() * MathHelper.TwoPi), 0);
            int     choice = (int)(rnd[1].NextDouble() * 4);

            MonsterUnit monsterUnit = new MonsterUnit(myGame, pos, rot, Constants.MONSTER_SCALE, monsterConstants[choice]);

            Monster monster;

            //if(deadMonsters.Count == 0)
            monster = new Monster(myGame, new MonsterModel(myGame, skinnedModel[choice]), monsterUnit);
            //else
            //{
            //    monster = deadMonsters[0];
            //    deadMonsters.RemoveAt(0);
            //    monster.monsterUnit = monsterUnit;
            //    monster.unit = monsterUnit;
            //    monster.health = 100;
            //    ((MonsterModel)monster.cModel).reinitialize(skinnedModel[choice]);
            //}

            monsters.Add(monster);
            hpBillBoardSystem.monstersTextures.Add(HPBillboardSystem.getTexture(monster.health));
            //billBoardSystem.monsters.Add(monster);
        }
Example #2
0
        private void addEnemy()
        {
            float x = 0, z = 0;
            float y = Constants.TERRAIN_HEIGHT;

            //while(y > .5 * Constants.TERRAIN_HEIGHT)
            //{
            x = (float)(rnd.NextDouble() * Constants.FIELD_MAX_X_Z * 2 - Constants.FIELD_MAX_X_Z);
            z = (float)(rnd.NextDouble() * Constants.FIELD_MAX_X_Z * 2 - Constants.FIELD_MAX_X_Z);
            y = myGame.GetHeightAtPosition(x, z);
            //}
            Vector3     pos         = new Vector3(x, y, z);
            Vector3     rot         = new Vector3(0, (float)(rnd.NextDouble() * MathHelper.TwoPi), 0);
            MonsterUnit monsterUnit = new MonsterUnit(myGame, pos, rot, Constants.MONSTER_SCALE);
            Monster     monster     = new Monster(myGame, skinnedModel, monsterUnit);

            monsters.Add(monster);
            hpBillBoardSystem.monstersTextures.Add(HPBillboardSystem.getTexture(monster.health));
            //billBoardSystem.monsters.Add(monster);
        }
Example #3
0
        private void DrawHP()
        {
            Rectangle rect = new Rectangle(0, 0, 300, 50);

            spriteBatch.Draw(HPBillboardSystem.getTexture(health), rect, Color.White);
        }