private void addFirstAidKit()
        {
            float y = Constants.TERRAIN_HEIGHT;
            float x = 0, z = 0;

            while (y > .7 * Constants.TERRAIN_HEIGHT)
            {
                x = (float)(rnd.NextDouble() * 4700 - Constants.FIELD_MAX_X_Z);
                z = (float)(rnd.NextDouble() * 4700 - Constants.FIELD_MAX_X_Z);
                y = myGame.GetHeightAtPosition(x, z);
            }
            Vector3  pos      = new Vector3(x, y + 30, z);
            Unit     unit     = new Unit(myGame, pos, Vector3.Zero, Constants.MEDKIT_SCALE);
            FirstAid firstAid = new FirstAid(myGame, myGame.Content.Load <Model>(@"model/First Aid Kit2"), unit);

            firstAidKits.Add(firstAid);
        }
        protected void UpdateShots(GameTime gameTime)
        {
            // Loop through shots
            for (int i = 0; i < bullets.Count; ++i)
            {
                // Update each shot
                bullets[i].Update(gameTime);

                //If shot is out of bounds, remove it from game
                Vector3 pos = bullets[i].unit.position;
                if (Math.Abs(pos.Length()) > bulletRange ||
                    pos.Y < myGame.GetHeightAtPosition(pos.X, pos.Z) ||
                    myGame.checkCollisionWithBullet(bullets[i].unit))
                {
                    bullets.RemoveAt(i);
                    --i;
                }
            }
        }
Пример #3
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);
        }