MyGame.HPBillboardSystem.getTexture C# (CSharp) Method

getTexture() public static method

public static getTexture ( int health ) : Microsoft.Xna.Framework.Graphics.Texture2D
health int
return Microsoft.Xna.Framework.Graphics.Texture2D
        public static Texture2D getTexture(int health)
        {
            switch (health/10*10)
            {
                case 00 : return HP000;
                case 10 : return HP010;
                case 20 : return HP020;
                case 30 : return HP030;
                case 40 : return HP040;
                case 50 : return HP050;
                case 60 : return HP060;
                case 70 : return HP070;
                case 80 : return HP080;
                case 90 : return HP090;
                case 100: return HP100;
            }

            return HP000;
        }

Usage Example

        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);
        }
All Usage Examples Of MyGame.HPBillboardSystem::getTexture