Ejemplo n.º 1
0
 void createPlayer(XmlReader reader)
 {
     Vector2 pos = Vector2.Zero;
     TextureMap t = new TextureMap();
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             switch (reader.Name)
             {
                 case "position":
                     {
                         reader.ReadToDescendant("x");
                         float x = (float)float.Parse((reader.GetAttribute(0)));
                         reader.ReadToNextSibling("y");
                         float y = (float)float.Parse((reader.GetAttribute(0)));
                         pos = new Vector2(x, y);
                     }
                     break;
                 default:
                     int o = 0;//fer teh deboog
                     break;
             }
         }
     }
     Player p = new Player(pos, t);
 }
Ejemplo n.º 2
0
 public AnimatedSprite(Texture2D texture, int rows, int columns, int time, bool loops)
 {
     mTextureMap = new TextureMap(texture, rows, columns);
     animationTime = time / mTextureMap.totalFrames;
     count = 0;
     mDone = false;
     mLoops = loops;
 }
Ejemplo n.º 3
0
 public Button(TextureMap tex, Vector2 pos, OnClickEvent evt)
 {
     Position = pos;
     OnClick = evt;
     Texture = tex;
     width = tex.width;
     height = tex.height;
 }
Ejemplo n.º 4
0
 public GameEntity(Vector2 position, Vector2 velocity, TextureMap map, ENTITY_TYPE type, int health = 100)
 {
     mPosition = position;
     mVelocity = velocity;
     mMidPoint = new Vector2(mPosition.X + map.width / 2, mPosition.Y + map.height / 2);
     mTexture = map;
     mHealth = health;
     mType = type;
     mAlive = true;
 }
Ejemplo n.º 5
0
 public GameEntity(Vector2 position, TextureMap map, ENTITY_TYPE type)
 {
     mPosition = position;
     mVelocity = Vector2.Zero;
     mMidPoint = new Vector2(mPosition.X + map.width / 2, mPosition.Y + map.height / 2);
     mTexture = map;
     mHealth = 50;
     mType = type;
     mAlive = true;
 }
Ejemplo n.º 6
0
        public GameScreen(ref SpriteBatch sb, ref Player p, TextureMap eMap, 
            params string[] bgNames)
        {
            bg2pos = new Vector2(0.0f, 0.0f);
            SB = sb;
            Player1 = p;
            pressedPause = false;
            Backgrounds = new List<TextureMap>();
            DrawableEntities = new List<GameEntity>();
            foreach (string bg in bgNames)
            {
                DrawableEntities.Add(new GameEntity(Vector2.Zero, Vector2.Zero,
                    new TextureMap(Constants.content.Load<Texture2D>(".\\art\\" + bg), 1, 1), GameEntity.ENTITY_TYPE.AI));
            }

            enemyMap = eMap;
            r = new Random();
        }
Ejemplo n.º 7
0
 public override void addBackground(TextureMap t)
 {
     Backgrounds.Add(t);
 }
Ejemplo n.º 8
0
 public abstract void addBackground(TextureMap t);
Ejemplo n.º 9
0
 public override void addBackground(TextureMap t)
 {
 }
Ejemplo n.º 10
0
 public Player(Vector2 position, TextureMap map)
     : base(position, map, ENTITY_TYPE.PLAYER)
 {
 }
Ejemplo n.º 11
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Constants.init(ref graphics, ref spriteBatch, Content);
            plrMap = new TextureMap(Content.Load<Texture2D>(".\\art\\player1"), 4, 3);
            enemyMap = new TextureMap(Content.Load<Texture2D>(".\\art\\enemy1"), 1, 1);

            Constants.player = new Player(Constants.DEFAULT_POSITION, plrMap);

            Constants.mMainGameScreen = new GameScreen(ref spriteBatch, ref Constants.player, enemyMap, "grass");
            Constants.mSplashScreen = new SplashScreen(".\\art\\opening_splashscreen", ref spriteBatch);
            //Constants.mEndScreenLose = new SplashScreen("splashscreen3", ref spriteBatch, "Press Escape To Exit");
            //Constants.mEndScreenWin = new SplashScreen("splashscreen2", ref spriteBatch, "Press Escape To Exit");

            Vector2 menuPos = new Vector2((graphics.PreferredBackBufferWidth / 2) - 56, (graphics.PreferredBackBufferHeight * 0.50f)-64);
            List<Button> btns = new List<Button>();
            btns.Add(new Button(new TextureMap(Content.Load<Texture2D>(".\\art\\ButtonStart"), 1, 1),
               new Vector2(menuPos.X, menuPos.Y), this.startGame));
            btns.Add(new Button(new TextureMap(Content.Load<Texture2D>(".\\art\\ButtonQuit"), 1, 1),
               new Vector2(menuPos.X, menuPos.Y + 76), this.Exit));

            Constants.mMenuScreen = new MenuScreen(ref spriteBatch, btns);
            Constants.mScreenStack.push(Constants.mSplashScreen);

            mSoundMgr = new SoundManager();
            // TODO: use this.Content to load your game content here
        }