Beispiel #1
0
 public virtual void LoadContent(ContentManager Content, InputManager inputManager)
 {
     content = new ContentManager(Content.ServiceProvider, "Content");
     attributes = new List<List<string>>();
     contents = new List<List<string>>();
     this.inputManager = inputManager;
 }
Beispiel #2
0
 public virtual void UnloadContent()
 {
     content.Unload();
     inputManager = null;
     attributes.Clear();
     contents.Clear();
 }
Beispiel #3
0
 public virtual void LoadContent(ContentManager content, InputManager input)
 {
     //make new instance instead of doing this.content = content because when we unload this content manager instance
     //we don't want to unload everything else that could been loaded in with that content manager instance
     this.content = new ContentManager(content.ServiceProvider, "Content");
     attributes = new List<List<string>>();
     contents = new List<List<string>>();
 }
        public override void LoadContent(ContentManager content, InputManager input)
        {
            base.LoadContent(content, input);
            player = new Player();
            map = new Map();

            map.LoadContent(content, map, "Map1");
            player.LoadContent(content, input);
        }
Beispiel #5
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);
            inputManager = new InputManager();

            ScreenManager.Instance.LoadContent(Content, inputManager);
            // TODO: use this.Content to load your game content here
        }
Beispiel #6
0
 public override void LoadContent(ContentManager Content, InputManager inputManager)
 {
     base.LoadContent(Content, inputManager);
     if (font == null)
     {
         font = this.content.Load<SpriteFont>("Font1");
     }
     menu = new MenuManager();
     menu.LoadContent(content, "Title");
 }
Beispiel #7
0
 public void AddScreen(GameScreen screen, InputManager inputManager)
 {
     transition = true; //lets us know we are transitioning
     fade.IsActive = true;
     fade.Alpha = 0.0f; //0 is fully transparent
     fade.ActivateValue = 1.0f; //1 is fully opaque
     fade.Increase = true;
     newScreen = screen; //here in case some other function deletes top screen from stack
     this.inputManager = inputManager;
 }
Beispiel #8
0
        public override void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer)
        {
            moveAnimation.IsActive = true;
            if (inputManager.KeyDown(Keys.Right, Keys.D))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 2);
                position.X += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (inputManager.KeyDown(Keys.Left, Keys.A))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 1);
                position.X -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (inputManager.KeyDown(Keys.Down, Keys.S))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 0);
                position.Y += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (inputManager.KeyDown(Keys.Up, Keys.W))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 3);
                position.Y -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else
            {
                moveAnimation.IsActive = false;
            }

            for (int i = 0; i < col.CollisionMap.Count; i++)
            {
                for (int j = 0; j < col.CollisionMap[i].Count; j++)
                {
                    if (col.CollisionMap[i][j] == "x") //check only for obstructed tiles
                    {
                        if (position.X + moveAnimation.FrameWidth < j * layer.TileDimensions.X ||
                            position.X > j * layer.TileDimensions.X + layer.TileDimensions.X ||
                            position.Y + moveAnimation.FrameHeight < i * layer.TileDimensions.Y ||
                            position.Y > i * layer.TileDimensions.Y + layer.TileDimensions.Y)
                        {
                            //no collision
                        }
                        else
                        {
                            position = moveAnimation.Position; //move animation position is last frame position
                        }
                    }
                }
            }

            moveAnimation.Position = position;
            ssAnimation.Update(gameTime, ref moveAnimation);
        }
Beispiel #9
0
        public override void LoadContent(ContentManager Content, InputManager inputManager)
        {
            base.LoadContent(Content, inputManager);
            if (font == null)
            {
                font = this.content.Load<SpriteFont>("Font1");
            }

            imageNumber = 0;
            fileManager = new FileManager();
            animation = new List<Animation>();
            fAnimation = new FadeAnimation();
            images = new List<Texture2D>();

            fileManager.LoadContent("Load/Splash.txt", attributes, contents);

            for (int i = 0; i < attributes.Count; i++)
            {
                for (int j = 0; j < attributes[i].Count; j++)
                {
                    switch(attributes[i][j])
                    {
                        default:
                        case "Image":
                            images.Add(this.content.Load<Texture2D>("SplashScreen/" + contents[i][j]));
                            animation.Add(new FadeAnimation());
                            break;
                        case "Sound": break;
                    }
                }
            }

            for (int i = 0; i < animation.Count; i++)
            {
                animation[i].LoadContent(content, images[i], "", Vector2.Zero);
                //in case image is different size than viewport
                // ImageWidth / 2 * scale - (imageWidth /2)
                // ImageHeight / 2 * scale - (imageHeight / 2)
                animation[i].Scale = 1f; //can scale images here in splash screen
                animation[i].IsActive = true;
            }
        }
Beispiel #10
0
        public override void LoadContent(ContentManager content, InputManager input)
        {
            base.LoadContent(content, input);
            fileManager = new FileManager();
            moveAnimation = new Animation();
            Vector2 tempFrames = Vector2.Zero;
            moveSpeed = 100f;

            fileManager.LoadContent("Load/Player.txt", attributes, contents);

            for (int i = 0; i < attributes.Count; i++)
            {
                for (int j = 0; j < attributes[i].Count; j++)
                {
                    switch (attributes[i][j])
                    {
                        case "Health":
                            health = int.Parse(contents[i][j]);
                            break;
                        case "Frames":
                            string[] frames = contents[i][j].Split(' ');
                            tempFrames = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                            break;
                        case "Image":
                            image = this.content.Load<Texture2D>(contents[i][j]);
                            break;
                        case "Position":
                            frames = contents[i][j].Split(' ');
                            position = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                            break;
                    }
                }
            }

            moveAnimation.Frames = new Vector2(3, 4);
            moveAnimation.LoadContent(content, image, "", position);
        }
Beispiel #11
0
        public void Update(GameTime gameTime, InputManager inputManager)
        {
            if (axis == 1) //axis is horizontal
            {
                if (inputManager.KeyPressed(Keys.Right, Keys.D))
                {
                    itemNumber++; //item we are highlighting
                }
                else if (inputManager.KeyPressed(Keys.Left, Keys.A))
                {
                    itemNumber--;
                }
            }
            else //axis is vertical
            {
                if (inputManager.KeyPressed(Keys.Down, Keys.S))
                {
                    itemNumber++; //item we are highlighting
                }
                else if (inputManager.KeyPressed(Keys.Up, Keys.W))
                {
                    itemNumber--;
                }
            }

            if (inputManager.KeyPressed(Keys.Enter, Keys.Z))
            {
                if (linkType[itemNumber] == "Screen")
                {
                    //create type based on namespace and the linkID (from menus.txt)
                    //thus this assigns Type to the class name established in the file manager txt
                    Type newClass = Type.GetType("TestGame1." + linkID[itemNumber]);
                    //cast classname as a game screen through activator and add that instance of game screen through screen manager
                    ScreenManager.Instance.AddScreen((GameScreen)Activator.CreateInstance(newClass), inputManager);
                }
            }

            //can do menu item wrapping here depending on key strokes
            if (itemNumber < 0)
            {
                itemNumber = 0;
            }
            else if (itemNumber > menuItems.Count - 1)
            {
                itemNumber = menuItems.Count - 1;
            }

            for (int i = 0; i < animation.Count; i++)
            {
                for (int j = 0; j < animationTypes.Count; j++)
                {
                    if (itemNumber == i)
                    {
                        animation[i].IsActive = true;
                    }
                    else
                    {
                        animation[i].IsActive = false;
                    }

                    Animation a = animation[i];

                    switch (animationTypes[i])
                    {
                        case "Fade":
                            fAnimation.Update(gameTime, ref a);
                            break;
                        case "SSheet":
                            ssAnimation.Update(gameTime, ref a);
                            break;
                    }
                    animation[i] = a;
                }
            }
        }
Beispiel #12
0
 public override void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer)
 {
 }
Beispiel #13
0
 public override void LoadContent(ContentManager content, InputManager input)
 {
     base.LoadContent(content, input);
 }
Beispiel #14
0
 public virtual void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer)
 {
 }
Beispiel #15
0
        public void LoadContent(ContentManager Content, InputManager inputManager)
        {
            content = new ContentManager(Content.ServiceProvider, "Content");
            currentScreen.LoadContent(content, inputManager);

            nullImage = this.content.Load<Texture2D>("null");
            fadeTexture = this.content.Load<Texture2D>("fade");
            animation.LoadContent(content, fadeTexture, "", Vector2.Zero);
            animation.Scale = dimensions.X;
        }
Beispiel #16
0
        public void AddScreen(GameScreen screen, InputManager inputManager, float alpha)
        {
            transition = true; //lets us know we are transitioning
            fade.IsActive = true;
            fade.ActivateValue = 1.0f; //1 is fully opaque
            newScreen = screen; //here in case some other function deletes top screen from stack
            this.inputManager = inputManager;

            if (alpha != 1.0f)
            {
                fade.Alpha = 1.0f - alpha;
            }
            else
            {
                fade.Alpha = alpha;
                fade.Increase = true;
            }
        }
Beispiel #17
0
 public void Initialize()
 {
     currentScreen = new SplashScreen();
     fade = new FadeAnimation();
     inputManager = new InputManager();
 }