private void AddItemsToAllLists(Obstacle objToAdd)
 {
     if (objToAdd != null)
     {
         objList.Add(objToAdd);
         physList.Add(objToAdd);
         renderList.Add(objToAdd);
     }
 }
 private void RemoveItemFromAllLists(Obstacle objToRemove)
 {
     if (objToRemove != null)
     {
         objList.Remove(objToRemove);
         physList.Remove(objToRemove);
         renderList.Remove(objToRemove);
     }
 }
        private Obstacle ParseObstacle(string path, Vector3 loc)
        {
            Obstacle o = null;
            Assembly assembly = Assembly.GetExecutingAssembly();
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            XmlDocument doc = new XmlDocument();
            string _o_path = "U5Designs.Resources.Data.Obstacles." + path;
            Stream fstream = assembly.GetManifestResourceStream(_o_path);
            XmlReader reader = XmlReader.Create(fstream, settings);
            doc.Load(reader);

            Vector3 scale = LoadLevel.parseVector3(doc.GetElementsByTagName("scale")[0]);
            Vector3 pbox = LoadLevel.parseVector3(doc.GetElementsByTagName("pbox")[0]);

            bool _draw2 = Convert.ToBoolean(doc.GetElementsByTagName("draw2")[0].InnerText);
            bool _draw3 = Convert.ToBoolean(doc.GetElementsByTagName("draw3")[0].InnerText);

            bool _collides2d = Convert.ToBoolean(doc.GetElementsByTagName("collidesIn2d")[0].InnerText);
            bool _collides3d = Convert.ToBoolean(doc.GetElementsByTagName("collidesIn3d")[0].InnerText);

            // Check to see if the current Obstacle is 2D or 3D and handle accordingly
            XmlNodeList _type = doc.GetElementsByTagName("is2d");
            if (Convert.ToBoolean(_type.Item(0).InnerText))
            {
                String ss_path = doc.GetElementsByTagName("sprite")[0].InnerText;
                fstream.Close();
                SpriteSheet ss = LoadLevel.parseSpriteFile(ss_path);

                Billboarding bb = Billboarding.Yes;  //Have to put something here for it to compile
                switch (doc.GetElementsByTagName("billboards")[0].InnerText)
                {
                    case "yes":
                    case "Yes":
                        bb = Billboarding.Yes;
                        break;
                    case "lock2d":
                    case "Lock2d":
                        bb = Billboarding.Lock2d;
                        break;
                    case "lock3d":
                    case "Lock3d":
                        bb = Billboarding.Lock3d;
                        break;
                    default:
                        Console.WriteLine("Bad obstacle file: " + path);
                        Environment.Exit(1);
                        break;
                }
                o = new Obstacle(loc, scale, pbox, _draw2, _draw3, _collides2d, _collides3d, bb, ss);
            }
            else
            {
                fstream.Close();
                XmlNodeList _m = doc.GetElementsByTagName("mesh");
                ObjMesh _mesh = new ObjMesh(assembly.GetManifestResourceStream("U5Designs.Resources.Geometry." + _m.Item(0).InnerText));

                XmlNodeList _b = doc.GetElementsByTagName("bmp");
                List<Bitmap> texFrames = new List<Bitmap>();
                foreach (XmlNode n in _b)
                {
                    texFrames.Add(new Bitmap(assembly.GetManifestResourceStream("U5Designs.Resources.Textures." + n.InnerText)));
                }
                MeshTexture _tex = new MeshTexture(texFrames);
                _tex.init();

                o = new Obstacle(loc, scale, pbox, _draw2, _draw3, _collides2d, _collides3d, _mesh, _tex);
                fstream.Close();
            }

            return o;
        }
		internal Crate(Player player, PlayState ps, Vector3 location, int maxheight, ProjectileProperties invisProj, Obstacle crate, Obstacle ground, Obstacle rope)
			: base(player, ps, location, maxheight, invisProj, crate, ground, rope) {
		}
		internal ZooBoss(Player player, PlayState ps, Vector3 location, int maxheight, ProjectileProperties invisProj, Obstacle crate, Obstacle ground, Obstacle rope, SpriteSheet bossSprite)
            : base(player, ps, location, maxheight, invisProj, crate, ground, rope) {

            //animation
            _sprite = bossSprite;
            _cycleNum = 0;
            _frameNum = 0;
            _animDirection = 1;

			//combat stuff
			_cbox = new Vector3(6, 6, 6);
            _health = 5;
            _damage = 1;
            _speed = 1;
            _alive = true;
            _hascbox = true;
            _type = 3; //Type 3 means this is the boss

			//Offset boss location
			centerLoc = new Vector3(_location);
			_location.X += 8.0f;
			_location.Z -= 0.01f;
			in3d = false;
			bb = Billboarding.Lock2d;

            invincible = false;
        }
		internal FallingBox(Player player, PlayState ps, Vector3 location, int maxheight, ProjectileProperties invisProj, Obstacle crate, Obstacle ground, Obstacle rope)
			: base() {
            //physics stuff
            velocity = new Vector3(0, 0, 0);
            accel = new Vector3(0, 0, 0);
            doesGravity = false;
            _scale = new Vector3(30.0f, 33.84f, 30.0f);
            _pbox = new Vector3(15.0f, 16.92f, 0.0f);
            _existsIn3d = true;
            _existsIn2d = true;
            maxHeight = maxheight;
            falling = false;
            rising = false;
            prefalling = false;
            idle = true;

            //animation
			_sprite = null;
            _cycleNum = 0;
            _frameNum = 0;
            _animDirection = 1;

			//timers
			downtime = 3;
			pretime = 1.5;
			shadowtimer = 0;

            //setup the sub-objects of the boss
			projectile = invisProj;
            
            mybox = crate;
            ps.objList.Add(mybox);
            ps.physList.Add(mybox);
            ps.renderList.Add(mybox);

			myGround = ground;
			ps.objList.Add(myGround);
			ps.physList.Add(myGround);
			ps.renderList.Add(myGround);

            myRope = rope;
            ps.objList.Add(myRope);
            ps.renderList.Add(myRope);

            //initialize everything's location based on the seed location
            mybox.canSquish = true;
            mybox.location = location + new Vector3(0, mybox.pbox.Y, 0);
            _location = location + new Vector3(0, (mybox.pbox.Y * 2) + pbox.Y, 0); 
            myRope.location = location + new Vector3(0, (mybox.pbox.Y * 2) + pbox.Y + ropeOffset, 0);//rope sprite
			myGround.location = new Vector3(myGround.location.X, 100.0f, myGround.location.Z);
            minHeight = 125;
            preHeight = 210;
		}