Exemple #1
0
 public virtual void UnloadContent()
 {
     content.Unload();
     inputManager = null;
     attributes.Clear();
     contents.Clear();
 }
Exemple #2
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;
 }
Exemple #3
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");
 }
Exemple #4
0
 public void AddScreen(GameScreen screen, InputManager inputManager, float alpha)
 {
     transition = true;
     newScreen = screen;
     fade.IsActive = true;
     fade.Alpha = alpha;
     fade.Increase = true;
     fade.ActivateValue = 1.0f;
     this.inputManager = inputManager;
 }
Exemple #5
0
        public override void LoadContent(ContentManager content, List<string> attributes, List<string> contents, InputManager input)
        {
 	        base.LoadContent(content, attributes, contents, input);
            font = content.Load<SpriteFont>("Font1");
            sound = new Audio();
            sound.LoadContent(content);
            bullets1 = new List<Vector2>();
            bullets2 = new List<Vector2>();
            bulletImage = content.Load<Texture2D>("bullet");
            keyPressed = false;
        }
Exemple #6
0
        public override void LoadContent(ContentManager content, List<string> attributes, List<string> contents, InputManager input)
        {
 	        base.LoadContent(content, attributes, contents, input);
            direction = 2;
            origPosition = position;
            if (direction == 1)
                destPosition.X = origPosition.X + range;
            else
                destPosition.X = origPosition.X - range;

            moveAnimation.IsActive = true;
        }
Exemple #7
0
 public override void LoadContent(ContentManager content, InputManager input)
 {
     base.LoadContent(content, input);
     player = new EntityManager();
     enemies = new EntityManager();
     map = new Map();
     font = content.Load<SpriteFont>("Font1");
     map.LoadContent(content, map, "Map1");
     player.LoadContent("Player", content, "Load/Player.k", "", input);
     enemies.LoadContent("Enemy", content, "Load/Enemies.k", "Level1", input);
     illusions = content.Load<Song>("Audio/Illusions");
     MediaPlayer.Volume = 0.3f;
     MediaPlayer.IsRepeating = true;
 }
Exemple #8
0
        public void LoadContent(string entityType, ContentManager Content, string fileName, string identifier, InputManager input)
        {
            this.input = input;
            entities = new List<Entity>();
            attributes = new List<List<string>>();
            contents = new List<List<string>>();
            fileManager = new FileManager();

            if (identifier == String.Empty)
                fileManager.LoadContent(fileName, attributes, contents);
            else
                fileManager.LoadContent(fileName, attributes, contents, identifier);

            for (int i = 0; i < attributes.Count; i++)
            {
                Type newClass = Type.GetType("WindowsGame2." + entityType);
                entities.Add((Entity)Activator.CreateInstance(newClass));
                entities[i].LoadContent(Content, attributes[i], contents[i], this.input);
            }
        }
Exemple #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.k", attributes, contents);

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

            }

            for (int i = 0; i < animation.Count; i++)
            {
                //imageWidth / 2 * scale - imageWidth rescaled screen so now no scaling is needed
                //imageHeight / 2 * scale - imageHeight
                animation[i].LoadContent(content, images[i], "", new Vector2(0, 0));
                animation[i].Scale = 1.25f;
                animation[i].IsActive = true;
            }
        }
Exemple #10
0
        public override void Update(GameTime gameTime, InputManager input, Collision col, Layer layer)
        {
            base.Update(gameTime, input, col, layer);
            moveAnimation.DrawColor = Color.White;
            if(direction == 1)
            {
                velocity.X = moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 0);
            }
            else if(direction == 2)
            {
                velocity.X = -moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 1);
            }

            if (activateGravity)
                velocity.Y += gravity * (float)gameTime.ElapsedGameTime.TotalSeconds;
            else
                velocity.Y = 0;

            position += velocity;

            if(direction == 1 && position.X >= destPosition.X)
            {
                direction = 2;
                destPosition.X = origPosition.X - range;
            }
            else if(direction == 2 && position.X <= destPosition.X)
            {
                direction = 1;
                destPosition.X = origPosition.X + range;
            }

            moveAnimation.Position = position;
            ssAnimation.Update(gameTime, ref moveAnimation);
        }
Exemple #11
0
        public override void Update(GameTime gameTime, InputManager input, Collision col, Layer layer)
        {
            base.Update(gameTime, input, col, layer);
            moveAnimation.DrawColor = Color.White;
            moveAnimation.IsActive = true; //will be true and makes player move through row of animations as long as the the last else isn't true which turns animation back off
            if (health > 0)
            {
                if (input.KeyDown(Keys.Right, Keys.D))
                {
                    moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 0); //moves to row 0 the row looking right on sprite sheet
                    velocity.X = moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    Direction = 0;
                    if (sound.WalkingInstance.State == SoundState.Stopped)
                    {
                        sound.WalkingInstance.Volume = 0.75f;
                        sound.WalkingInstance.IsLooped = true;
                        sound.WalkingInstance.Play();
                    }
                    else
                        sound.WalkingInstance.Resume();

                }
                else if (input.KeyDown(Keys.Left, Keys.A))
                {
                    moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 1); //moves to row 1 the row looking left on sprite sheet
                    velocity.X = -moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    Direction = 1;
                    if (sound.WalkingInstance.State == SoundState.Stopped)
                    {
                        sound.WalkingInstance.Volume = 0.75f;
                        sound.WalkingInstance.IsLooped = true;
                        sound.WalkingInstance.Play();
                    }
                    else
                        sound.WalkingInstance.Resume();
                }
                else
                {
                    moveAnimation.IsActive = false; //if key isn't pressed turn off X axis scrolling on sprite sheet  
                    velocity.X = 0;
                    if (sound.WalkingInstance.State == SoundState.Playing)
                        sound.WalkingInstance.Pause();
                }
                if (input.KeyDown(Keys.Up, Keys.W) && !activateGravity)
                {
                    velocity.Y = -jumpSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    activateGravity = true;
                    sound.Jump.Play();
                }
                if (activateGravity)
                    velocity.Y += gravity * (float)gameTime.ElapsedGameTime.TotalSeconds;
                else
                    velocity.Y = 0;

                if (input.KeyDown(Keys.R) && keyPressed == false) //if R is pressed add a bullet as long as key isn't already pressed
                {
                    if (Direction == 0)
                        bullets1.Add(position);
                    else
                        bullets2.Add(position);
                    keyPressed = true;
                }
                if (Keyboard.GetState().IsKeyUp(Keys.R)) //only way to fire again is to unpress key
                    keyPressed = false;

                for (int i = 0; i < bullets1.Count; i++)
                {
                    float x = bullets1[i].X;
                    x += bulletSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    bullets1[i] = new Vector2(x, bullets1[i].Y);
                }

                for (int i = 0; i < bullets2.Count; i++)
                {
                    float x = bullets2[i].X;
                    x -= bulletSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    bullets2[i] = new Vector2(x, bullets2[i].Y);
                }
                position += velocity;
                moveAnimation.Position = position;
                ssAnimation.Update(gameTime, ref moveAnimation);
                Camera.Instance.SetFocalPoint(new Vector2(position.X, ScreenManager.Instance.Dimensions.Y / 2));
            }
        }
Exemple #12
0
        public virtual void LoadContent(ContentManager content, List<string> attributes, List<string> contents, InputManager input)
        {
            this.content = new ContentManager(content.ServiceProvider, "Content");
            moveAnimation = new Animation();
            ssAnimation = new SpriteSheetAnimation();
            for (int i = 0; i < attributes.Count; i++)
            {
                switch (attributes[i])
                {
                    case "Health":
                        health = int.Parse(contents[i]);
                        break;
                    case "Frames":
                        string[] frames = contents[i].Split(',');
                        moveAnimation.Frames = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                        break;
                    case "Image":
                        image = this.content.Load<Texture2D>(contents[i]);
                        break;
                    case "Position":
                        frames = contents[i].Split(',');
                        position = new Vector2(int.Parse(frames[0]), int.Parse(frames[1]));
                        break;
                    case "MoveSpeed":
                        moveSpeed = float.Parse(contents[i]);
                        break;
                    case "Range":
                        range = int.Parse(contents[i]);
                        break;
                }
            }

            gravity = 100f;
            velocity = Vector2.Zero;
            syncTilePostion = false;
            activateGravity = true;
            moveAnimation.LoadContent(content, image, "", position);
        }
Exemple #13
0
 public virtual void Update(GameTime gameTime, InputManager input, Collision col, Layer layer)
 {
     syncTilePostion = false;
     prevPosition = position;
 }
Exemple #14
0
        public void Update(GameTime gameTime, InputManager inputManager)
        {
            if (axis == 1)
            {
                if (inputManager.KeyPressed(Keys.Right, Keys.D))
                    itemNumber++;
                else if (inputManager.KeyPressed(Keys.Left, Keys.A))
                    itemNumber--;
            }
            else 
            {
                if (inputManager.KeyPressed(Keys.Down, Keys.S))
                    itemNumber++;
                else if (inputManager.KeyPressed(Keys.Up, Keys.W))
                    itemNumber--;
            }

            if (inputManager.KeyPressed(Keys.Enter, Keys.Z))
            { 
                if(linkType[itemNumber] == "Screen")
                {
                    Type newClass = Type.GetType("WindowsGame2." + linkID[itemNumber]);
                    ScreenManager.Instance.AddScreen((GameScreen)Activator.CreateInstance(newClass), inputManager);
                }
            }

            if (itemNumber < 0) //doesn't allow menu to go below or above targets
                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[j])
                    { 
                        case "Fade":
                            fAnimation.Update(gameTime, ref a);
                            break;
                        case "SSheet":
                            ssAnimation.Update(gameTime, ref a);
                            break;
                    }

                    animation[i] = a;
                }
            }
        }
Exemple #15
0
 public void Initialize() 
 {
     currentScreen = new GameplayScreen();
     fade = new FadeAnimation();
     inputManager = new InputManager();
 }