private Decoration ParseDecoration(string path, Vector3 loc) { Decoration dec = null; // Instantiate the list Assembly assembly = Assembly.GetExecutingAssembly(); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; string _d_path = "U5Designs.Resources.Data.Decorations." + path; Stream fstream = assembly.GetManifestResourceStream(_d_path); XmlDocument doc = new XmlDocument(); XmlReader reader = XmlReader.Create(fstream, settings); doc.Load(reader); Vector3 scale = LoadLevel.parseVector3(doc.GetElementsByTagName("scale")[0]); bool _draw2 = Convert.ToBoolean(doc.GetElementsByTagName("draw2")[0].InnerText); bool _draw3 = Convert.ToBoolean(doc.GetElementsByTagName("draw3")[0].InnerText); // Check to see if the current Obstacle is 2D or 3D and handle accordingly if (Convert.ToBoolean(doc.GetElementsByTagName("is2d")[0].InnerText)) { // Create the SpriteSheet SpriteSheet ss = LoadLevel.parseSpriteFile(doc.GetElementsByTagName("sprite")[0].InnerText); 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; } dec = new Decoration(loc, scale, _draw2, _draw3, bb, ss); } else { 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 _bmp = new MeshTexture(texFrames); _bmp.init(); dec = new Decoration(loc, scale, _draw2, _draw3, _mesh, _bmp); } fstream.Close(); return dec; }
public Player(SpriteSheet sprite, SpriteSheet arms, List<ProjectileProperties> projectiles, PlayState ps) : base(Int32.MaxValue) //player always has largest ID for rendering purposes { p_state = new PlayerState("TEST player"); //p_state.setSpeed(130); this.playstate = ps; _speed = runSpeed; _location = new Vector3(25, 12.5f, 50); _scale = new Vector3(25f, 25f, 25f); _pbox = new Vector3(5f, 11.0f, 5f); _cbox = new Vector3(4f, 10.0f, 4f); spinSize = 12; //?? experiment with this, TODO: change it to match the sprites size velocity = new Vector3(0, 0, 0); accel = new Vector3(0, 0, 0); kbspeed = new Vector3(70, 100, 70); jumpspeed = 250.0f; _cycleNum = 0; _frameNum = 0; _sprite = sprite; _hascbox = true; _type = 0; //type 0 is the player and only the player _existsIn2d = true; _existsIn3d = true; onGround = true; //arms this.arms = new Decoration(_location + new Vector3(0.005f, 0.0f, 0.005f), _scale, true, true, Billboarding.Yes, arms); ps.renderList.Add(this.arms); //combat things _damage = 1; spinDamage = 2; maxHealth = _health = 7; stamina = 5.0; maxStamina = 5.0; spaceDown = false; eDown = false; pDown = false; isMobile = true; Invincible = false; HasControl = true; Invincibletimer = 0.0; NoControlTimer = 0.0; fallTimer = 0.0; viewSwitchJumpTimer = 0.0; projectileTimer = 0.0; spinTimer = 0.0; lookDownTimer = -1.0; squishTimer = -1.0; lastPosOnGround = new Vector3(_location); _animDirection = 1; this.projectiles = projectiles; curProjectile = projectiles[0]; curProjectile.damage = _damage; markerList = new List<Decoration>(); Assembly assembly = Assembly.GetExecutingAssembly(); jumpSound = new AudioFile(assembly.GetManifestResourceStream("U5Designs.Resources.Sound.jump_sound.ogg")); bananaSound = new AudioFile(assembly.GetManifestResourceStream("U5Designs.Resources.Sound.banana2.ogg")); HurtSound = new AudioFile(assembly.GetManifestResourceStream("U5Designs.Resources.Sound.hurt.ogg")); HitSound = new AudioFile(assembly.GetManifestResourceStream("U5Designs.Resources.Sound.hit.ogg")); SpinSound = new AudioFile(assembly.GetManifestResourceStream("U5Designs.Resources.Sound.spin.ogg")); }