//public void startMenus() //{ // _fadeInTimer = 0; // _fadeIntro = true; // _drawOptionsWindow = _drawQuickGameWindow = false; // _globalAlpha = 0; // cCamera.Instance.Position = new Vector2(0, 0); // mouseState = new MouseState(); //} public cMenuWindow(GraphicsDeviceManager gd, ContentManager cm) { _MenuWindowButton = new cMenuWindowButton(gd, cm); _MenuOptionsWindowButton = new cMenuOptionsWindowButton(gd, cm); _textParser = new cTextParser(); //_button = new cMenuButton("Resources/Menu/button"); _aLevel = new string[6]; _aLevel[0] = "Training"; _aLevel[1] = "Training2"; _aLevel[2] = "Training3"; //_quickgamebuttons = new List<cMenuButton>(); //_optionsSelection = new List<cMenuWindow>(); _titleFont = cFontManager.Instance.getFont("Treb8"); _mainFont = cFontManager.Instance.getFont("Treb11"); cSpriteManager.Instance.addTexture("Resources/Menu/quickgamewindow", "quick_game_window"); _tQuickGameWindow = new cSprite("quick_game_window"); cSpriteManager.Instance.addTexture("Resources/Menu/quickgamewindow2", "quick_game_window2"); _tQuickGameWindow2 = new cSprite("quick_game_window2"); cSpriteManager.Instance.addTexture("Resources/Menu/quickgamehighlight", "quick_game_highlight"); _tQuickGameHighlight = new cSprite("quick_game_highlight"); cSpriteManager.Instance.addTexture("Resources/Menu/optionswindow", "options_window"); _tOptionsWindow = new cSprite("options_window"); cSpriteManager.Instance.addTexture("Resources/Menu/controlswindow", "controls_window"); _tControlsWindow = new cSprite("controls_window"); }
public cHUD() { _instance = this; cSpriteManager.Instance.addTexture(@"Resources/HUD/hud_lives", "hud_lives"); _lives = new cSprite("hud_lives"); _lives.ScreenFixed = true; _lives.Position = new Vector2((_lives.Width / 2) + 16, cCamera.Instance.WidthHeight.Y - (_lives.Height / 2) - 6); _font = cFontManager.Instance.getFont("Treb11"); cSpriteManager.Instance.addTexture(@"Resources/HUD/hudboarder", "hudboarder"); _hudBoarder = new cSprite("hudboarder"); _hudBoarder.Position = new Vector2(400, 300); _hudBoarder.ScreenFixed = true; }
/// <summary> /// constructor /// </summary> public cPortal() : base(10, 50, 1) { //RigidBody.CanCollide = false; RigidBody.IsStatic = true; //this.CanAttachPortalTo = false; //this.IsPortalTransparrent = false; _attachedTo = null; _openingAnim = false; cLightMapManager.Instance.add(this); // Make sure the textures are available to use cSpriteManager.Instance.addTexture(@"Resources/Sprites/portal", "portal"); cSpriteManager.Instance.addTexture(@"Resources/LightMaps/portalLightMap", "portalLightMap"); base.setStaticSprite("portal"); _sprite.Visible = false; _lightMap = new cSprite("portalLightMap"); }
public cScene() { _instance = this; _sceneObjects = new List<cGameObject>(); _shaderObjects = new List<iShaderObject>(); _bitmapFont = cFontManager.Instance.getFont("Treb11"); cSpriteManager.Instance.addTexture(@"Resources/HUD/descripwindow", "descripwindow"); _blankWindow = new cSprite("descripwindow"); _blankWindow.ScreenFixed = true; cSpriteManager.Instance.addTexture("Resources/Menu/half-life2_pointer", "mouse_pointer"); _mousePointer = new cSprite("mouse_pointer"); _mousePointer.ScreenFixed = true; cSpriteManager.Instance.addTexture("Resources/Menu/button1", "button1"); _startButton = new cMenuTextButton("button1", "Start"); _startButton.setHoverOverColor(new Color(17, 194, 253)); _startButton.setOnClickListener(this); _startButton.ScreenFixed = true; _continueButton = new cMenuTextButton("button1", "Continue"); _continueButton.setHoverOverColor(new Color(17, 194, 253)); _continueButton.setOnClickListener(this); _continueButton.ScreenFixed = true; }
/// <summary> /// Constructor, player initially in standing state /// </summary> public cPlayer() : base(26,46,1) { _instance = this; Position = Vector2.Zero; _state = (int)STATES.STANDING; _vel = Vector2.Zero; //RigidBody.IsPlayer = true; //this.CanAttachPortalTo = false; //this.IsPortalTransparrent = true; // Make sure all the correct graphics get loaded cSpriteManager.Instance.addAnimation(@"Resources/Sprites/egon_anim.xml", "egon_anim"); cEffectManager.Instance.defineEffect(@"Resources/Sprites/player_spawn_anim.xml", "player_spawn"); //cSpriteManager.Instance.addTexture(@"Resources/Sprites/bazooka", "portal_gun"); cSpriteManager.Instance.addTexture(@"Resources/Sprites/portalblob", "portal_target"); base.setAnimatedSprite("egon_anim"); ((cAnimatedSprite)_sprite).play("stand"); _sprite.Origin = new Vector2(15, 23); //_portalGunSprite = new cSprite("portal_gun"); _targeter = new cSprite("portal_target"); }
public void loadLevel(String levelName) { // TODO: We need to dump the graphics from a previously loaded // level before we load new ones, or instead when we load the // graphics below we check that they dont already exist. #region XMLParsing // If the XML document isnt in the correct format that we expect then // an XmlException will be thrown to alert the user to the fact. try { // Load the XML document into the reader XmlTextReader reader = new XmlTextReader(@"Resources/Levels/"+levelName+".xml"); Dictionary<String, objDef> spriteVerts = new Dictionary<String, objDef>(); // Loop through all the elements while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { String elementName = reader.Name; // If its our top-level elemennt if (elementName == "level") { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "type") { if (reader.Value == "lab") { // Load the parallax graphics cSpriteManager.Instance.addTexture("Resources/Textures/wall01-800-600", "parallax_lab_back"); //cSpriteManager.Instance.addTexture(gd, "Resources/floor.bmp", "parallax_lab_front"); // Create new sprites _paralaxBack = new cSprite("parallax_lab_back"); //_paralaxFront = new cSprite("parallax_lab_front"); } } if (reader.Name == "name") { _currentLevelName = reader.Value; } } } if (elementName == "description") { string str = reader.ReadInnerXml(); str = str.Replace("\r",""); str = str.Replace("\t",""); string[] s = { "\n" }; _currentLevelDescription = str.Split(s, StringSplitOptions.RemoveEmptyEntries); } // If its a frame of the animation if (elementName == "sprite") { String spriteURL = ""; String type = ""; String collisionType = ""; String spriteName = ""; bool spritecollision = false; int width = 0; int height = 0; float mass = 1; float friction = 1; float restitution = 0; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); // Getting the properties of the sprite if (reader.Name == "url") { spriteURL += reader.Value; } if (reader.Name == "type") { type = reader.Value; } if (reader.Name == "collision") { collisionType = reader.Value; } if (reader.Name == "w") { width = Int32.Parse(reader.Value); } if (reader.Name == "h") { height = Int32.Parse(reader.Value); } if (reader.Name == "mass") { mass = float.Parse(reader.Value); } if (reader.Name == "friction") { mass = float.Parse(reader.Value); } if (reader.Name == "restitution") { mass = float.Parse(reader.Value); } if (reader.Name == "name") { spriteName = reader.Value; } } } if (type == "static") { cSpriteManager.Instance.addTexture(spriteURL, spriteName); } if (collisionType == "rectangle") { Vertices v = Vertices.CreateRectangle(width,height); objDef od = new objDef(); od.v = v; od.mass = mass; od.friction = friction; od.restitution = restitution; spriteVerts.Add(spriteName, od); } } // If its a frame of the animation if (elementName == "obj") { String type = ""; String resource = ""; int x = 0; int y = 0; float orientation = 0; bool canAttachPortalTo = false; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); // Getting the properties of the object if (reader.Name == "type") { type = reader.Value; } if (reader.Name == "x") { x = Int32.Parse(reader.Value); } if (reader.Name == "y") { y = Int32.Parse(reader.Value); } if (reader.Name == "orientation") { orientation = float.Parse(reader.Value); } if (reader.Name == "resource") { resource = reader.Value; } if (reader.Name == "canAttachPortalTo") { canAttachPortalTo = bool.Parse(reader.Value); } } } objDef od = spriteVerts[resource]; cRigidBodyGameObject obj = new cRigidBodyGameObject(od.mass,od.v); if (type == "static") { obj.RigidBody.IsStatic = true; } obj.setStaticSprite(resource); obj.Position = new Vector2(x, y); obj.Orientation = orientation*(float)(Math.PI*2/360); obj.RigidBody.RestitutionCoefficient = od.restitution; obj.RigidBody.FrictionCoefficient = od.friction; obj.RigidBody.RotationalDragCoefficient = 10; obj.RigidBody.LinearDragCoefficient = .00001f; obj.CanAttachPortalTo = canAttachPortalTo; _sceneObjects.Add(obj); } // If its a frame of the animation if (elementName == "trigger") { String type = ""; int x = 0; int y = 0; int w = 0; int h = 0; String nextLevel = ""; String audio = ""; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); // Getting the properties of the object if (reader.Name == "type") { type = reader.Value; } if (reader.Name == "x") { x = Int32.Parse(reader.Value); } if (reader.Name == "y") { y = Int32.Parse(reader.Value); } if (reader.Name == "w") { w = Int32.Parse(reader.Value); } if (reader.Name == "h") { h = Int32.Parse(reader.Value); } if (reader.Name == "audio") { audio = reader.Value; } if (reader.Name == "nextLevel") { nextLevel = reader.Value; } } } if (type == "player_spawn") { cPlayer.Instance.spawnIn(new Vector2(x,y)); } if (type == "flame") { cFlameEffect fe = new cFlameEffect(Portal2D.GD, Portal2D.CM, w, h); fe.Position = new Vector2(x, y); _shaderObjects.Add(fe); } if (type == "exit") { cExit e = new cExit(nextLevel,audio); e.Position = new Vector2(x,y); _sceneObjects.Add(e); } } // If its a frame of the animation if (elementName == "light") { String type = ""; String resource = ""; String lightMap = ""; int x = 0; int y = 0; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); // Getting the properties of the object if (reader.Name == "type") { type = reader.Value; } if (reader.Name == "resource") { resource = reader.Value; } if (reader.Name == "lightMap") { lightMap = reader.Value; } if (reader.Name == "x") { x = Int32.Parse(reader.Value); } if (reader.Name == "y") { y = Int32.Parse(reader.Value); } } } if (type == "point") { cLight l = new cLight(); l.setStaticSprite(resource); l.setLightMap(lightMap); l.AffectedByGravity = false; l.Position = new Vector2(x, y); cLightMapManager.Instance.add(l); _sceneObjects.Add(l); } } } } } catch (XmlException e) { Console.WriteLine("error occured: " + e.Message); } #endregion _levelFastestTime = this.getLevelFastestTime(_currentLevelName); }
public void setLightMap(string map) { _lightMap = new cSprite(map); }
public void setStaticSprite(String name) { _sprite = new cSprite(name); }
public void setAnimatedSprite(String name) { _sprite = new cAnimatedSprite(name); }
public void setLightMap(string map) { _lightMap = new cSprite(map); cLightMapManager.Instance.add(this); }
public cSprite clone() { cSprite s = new cSprite(_texName); s.HorizontalFlip = HorizontalFlip; s.Orientation = Orientation; s.Position = Position; s.Visible = Visible; return s; }
/// <summary> /// Load graphics /// </summary> /// <param name="gd">the graphics device</param> private void LoadGraphicsContent() { GraphicsDevice gd = _graphics.GraphicsDevice; Color c = new Color(17, 194, 253); cSpriteManager.Instance.addTexture("Resources/Menu/PortalLogoHiRes", "portal_logo"); _tPortalLogo = new cSprite("portal_logo"); cSpriteManager.Instance.addTexture("Resources/Menu/textnewgame", "new_game"); _tNewGame = new cMenuButton("new_game"); _tNewGame.setHoverOverColor(c); _tNewGame.setOnClickListener(this); _tNewGame.Position = new Vector2(800 / 5 - 73, 600 / 2+39); _buttons.Add(_tNewGame); cSpriteManager.Instance.addTexture("Resources/Menu/textcontinue", "continue"); _tContinue = new cMenuButton("continue"); _tContinue.setHoverOverColor(c); _tContinue.setOnClickListener(this); _tContinue.Position = new Vector2(800 / 5 - 73, 600 / 2 + 59); _buttons.Add(_tContinue); cSpriteManager.Instance.addTexture("Resources/Menu/textquickgame", "quick_game"); _tQuickGame = new cMenuButton("quick_game"); _tQuickGame.setHoverOverColor(c); _tQuickGame.setOnClickListener(this); _tQuickGame.Position = new Vector2(800 / 5 - 73, 600 / 2 + 79); _buttons.Add(_tQuickGame); cSpriteManager.Instance.addTexture("Resources/Menu/textoptions", "options"); _tOptions = new cMenuButton("options"); _tOptions.setHoverOverColor(c); _tOptions.setOnClickListener(this); _tOptions.Position = new Vector2(800 / 5 - 73, 600 / 2 + 99); _buttons.Add(_tOptions); cSpriteManager.Instance.addTexture("Resources/Menu/textquit", "quit"); _tQuit = new cMenuButton("quit"); _tQuit.setHoverOverColor(c); _tQuit.setOnClickListener(this); _tQuit.Position = new Vector2(800 / 5 - 73, 600 / 2 + 119); _buttons.Add(_tQuit); cSpriteManager.Instance.addTexture("Resources/Menu/half-life2_pointer", "mouse_pointer"); _tMousePointer = new cSprite("mouse_pointer"); }