コード例 #1
0
ファイル: Camera.cs プロジェクト: pwoods55/Changing_Gravity
 public Camera(Player p, GraphicsDevice screen)
 {
     position = Vector2.Zero;
     origin = Vector2.Zero;
     position.X = p.ObjRect.Center.X - 150;
     position.Y = p.ObjRect.Top - 100;
 }
コード例 #2
0
ファイル: Hud.cs プロジェクト: pwoods55/Changing_Gravity
        public Hud(int x, int y, int w, int h, SpriteBatch s, Player p, string[] l, string wL)
            : base(x, y, w, h)
        {
            HudInfo.Add("time", false);
            HudInfo.Add("energy", false);
            HudInfo.Add("items", false);
            HudInfo.Add("level", false); // TODO finish the rest of the possible values found in the HUD

            spriteBatch = s;
            playerLoc = p;
            levelRelevantInfo = l;
            worldLevel = wL; // pass in the world and level (eg. "Menu - Main", "1 - 3")

            // TODO: set HUD starting location

            string[] keys = HudInfo.Keys.ToArray();

            foreach(string hudComponent in levelRelevantInfo)
            {
                foreach(string key in keys)
                {
                    if (hudComponent.Equals(key))
                    {
                        HudInfo[key] = true;
                    }
                }
            }
        }
コード例 #3
0
ファイル: World.cs プロジェクト: crobinson95/GDAPS-Project-2
 /// <summary>
 /// Creates a dictionary of levels for the world. Currently hardcoded for each world.
 /// </summary>
 public World(string world, StreamReader s, Player p, ContentManager content)
 {
     string[] tempLevelList = new string[] { "" };
     levels = new Dictionary<string, Level>();
     if (world == "menu")
     {
         tempLevelList[0] = "main.txt";
     }
     else if (world == "world1")
     {
         tempLevelList[0] = "1-1.txt";
     }
     else if (world == "world2")
     {
         tempLevelList[0] = "2-1.txt";
     }
     foreach ( string current in tempLevelList)
     {
         levels.Add(current, new Level(world + "/" + current, s, p, content));
     }
     //levelFiles.Add = Directory.GetFiles(world); // need to start organizing worlds by directory
     //foreach (string level in levelFiles)
     //{
     //    Level newLevel = new Level(level, s, p, content);
     //    levels.Add(newLevel);
     //}
 }
コード例 #4
0
ファイル: Camera.cs プロジェクト: pwoods55/Changing_Gravity
        public Matrix GetTransform(Player p, int width, int height)
        {
            Move(p, width, height);
            var translationMatrix = Matrix.CreateTranslation(new Vector3(position.X, position.Y, 0));
            var originMatrix = Matrix.CreateTranslation(new Vector3(origin.X, origin.Y, 0));

            return translationMatrix * originMatrix;
        }
コード例 #5
0
ファイル: Hud.cs プロジェクト: crobinson95/GDAPS-Project-2
 public Hud(int x, int y, int w, int h, SpriteBatch s, Player p, Camera g, Level level)
     : base(x, y, w, h)
 {
     sprite = s;
     player = p;
     view = g;
     Check();
 }
コード例 #6
0
ファイル: Camera.cs プロジェクト: crobinson95/GDAPS-Project-2
 public Camera(Player p, GraphicsDevice screen)
 {
     position = Vector2.Zero;
     origin = Vector2.Zero;
     position.X = p.ObjRect.Center.X - 150;
     position.Y = p.ObjRect.Top - 100;
     right = new Rectangle(screen.Viewport.Width / 2, 0, screen.Viewport.Width / 2, screen.Viewport.Height);
     left = new Rectangle(0, 0, screen.Viewport.Width / 4, screen.Viewport.Height);
     up = new Rectangle(0, 0, screen.Viewport.Width, screen.Viewport.Height / 2);
     range = screen;
 }
コード例 #7
0
ファイル: EnemyF.cs プロジェクト: crobinson95/GDAPS-Project-2
 //float fric = (float)GameVariables.friction;
 //float jump = (float)GameVariables.jump;
 //float accel = (float)GameVariables.playerAcceleration;
 //float maxSpeed = (float)GameVariables.playerMaxSpeed;
 public EnemyF(ContentManager Content, int x, int y, int w, int h, Player p)
     : base(Content, x, y, w, h, p)
 {
     grav = gravDirection.Down;
     gravity = GameVariables.gravity;
     currentDir = myDirection.right;
     xVelocity = 0;
     yVelocity = 0;
     inAir = true;
     alive = true;
     origin = new Point(x, y);
     isDangerous = true;
     vision = new Rectangle(0, 0, 100, 100);
     player = p;
 }
コード例 #8
0
ファイル: EnemyW.cs プロジェクト: crobinson95/GDAPS-Project-2
 public EnemyW(ContentManager Content, int x, int y, int w, int h, Player p)
     : base(Content, x, y, w, h, p)
 {
     grav = gravDirection.Down;
     gravity = GameVariables.gravity;
     currentDir = myDirection.right;
     xVelocity = 0;
     yVelocity = 0;
     inAir = true;
     alive = true;
     isDangerous = true;
     origin = new Point(x, y);
     Move = new AnimatedTexture(Content, @"ContentFiles/Images/Sprites/enemyw_sri", 4, .1f);
     vision = new Rectangle(0, 0, 100, 500);
     atime = new Stopwatch();
     player = p;
 }
コード例 #9
0
ファイル: Enemy.cs プロジェクト: crobinson95/GDAPS-Project-2
 public Enemy(ContentManager Content, int x, int y, int w, int h, Player p)
     : base(x, y, w, h)
 {
     grav = gravDirection.Down;
     gravity = GameVariables.gravity;
     currentDir = myDirection.right;
     xVelocity = 0;
     yVelocity = 0;
     inAir = true;
     alive = true;
     origin = new Point(x, y);
     isDangerous = true;
     player = p;
     Move = new AnimatedTexture(Content, @"ContentFiles/Images/Sprites/enemy_sri", 10, 1f);
     atime = new Stopwatch();
     enemyEmitter = new AudioEmitter();
     enemyEmitter.Position = new Vector3(x, y, 0.0f);
 }
コード例 #10
0
ファイル: Door.cs プロジェクト: crobinson95/GDAPS-Project-2
 public void Open(Player p)
 {
     if (p.isColliding(this))
     {
         if (state == State.closed)
         {
             time.Reset();
             state = State.opening;
             GameVariables.doorOpenInstance.Play();
         }
     }
     else
     {
         if (state == State.open)
         {
             time.Reset();
             state = State.closing;
             GameVariables.doorCloseInstance.Play();
         }
     }
 }
コード例 #11
0
ファイル: Camera.cs プロジェクト: pwoods55/Changing_Gravity
 public void Move(Player p, int width, int height)
 {
     position.X = -p.ObjRectX + width/2;
     position.Y = -p.ObjRectY + height/2;
 }
コード例 #12
0
ファイル: Game1.cs プロジェクト: pwoods55/Changing_Gravity
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            player = new Player(100,100,60,60); // TODO: give player actual rectangle values

            g = GameState.Menu;

            world = new World(GameVariables.menuWorld, s); // Menu "world"
            pause = false;

            // x y width height are temporary filler values
            //gameHUD = new Hud(50, 20, 700, 180, spriteBatch, player, world.Levels[0].HudInfo , (GameVariables.menuWorld + " - " + (world.currentLevel + 1).ToString()));

            player.ObjPos.X = world.Levels[0].playerSpawn.X;
            player.ObjPos.Y = world.Levels[0].playerSpawn.Y;

            moveCamera = new Camera(player, GraphicsDevice);

            width = GraphicsDevice.Viewport.Width;
            height = GraphicsDevice.Viewport.Height;

            base.Initialize();
        }
コード例 #13
0
ファイル: Game1.cs プロジェクト: crobinson95/GDAPS-Project-2
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            player = new Player(100, 100, 30, 54);

            g = GameState.Menu;
            // m = Menus.Start;
            paused = false;

            SoundEffect.DistanceScale = 150f;

            width = GraphicsDevice.Viewport.Width;
            height = GraphicsDevice.Viewport.Height;

            base.Initialize();
        }
コード例 #14
0
ファイル: Level.cs プロジェクト: crobinson95/GDAPS-Project-2
        /// <summary>
        /// Reads text files with info on each line.
        /// Format for Hud line:
        /// hud, strings (strings for information that needs to be displayed)
        /// Format for each line:
        /// identifier,x_position,y_position,(extra attributes depending on objects).
        /// </summary>
        public Level(string levelData, StreamReader s, Player player, ContentManager content)
        {
            levelTimer = new Stopwatch();
            levelTime = 0;
            deathCount = 0;
            levelMusic = new List<MusicController>();
            try
            {
                playerSpawn = new Point ( 0, 0 );
                char[] delim = { ',' };
                string identifier;
                Point p;
                s = new StreamReader("Content/" + levelData);
                string line;
                string[] splitLine;
                while ((line = s.ReadLine()) != null)
                {
                    try
                    {
                        splitLine = line.Split(delim);
                        identifier = splitLine[0].ToLower();
                        if (identifier.Equals("hud"))
                        {
                            hudInfo = splitLine;
                        }
                        else if (identifier.Equals("music"))
                        {
                            int i = 0;
                            string[] musicInfo = splitLine;
                            foreach (MusicController layer in GameVariables.layerList)
                            {
                                if (i < musicInfo.Length - 1)
                                {
                                    layer.layerInLevel = true;
                                }
                                else
                                {
                                    layer.layerInLevel = false;
                                }
                                i++;
                            }
                        }
                        else
                        {
                            p = new Point(int.Parse(splitLine[1]), int.Parse(splitLine[2]));
                            if (identifier.Contains("block"))
                            {
                                objects.Add(new Block(p.X, p.Y, 40, 40, identifier));
                            }
                            else if (identifier.Contains("panel"))
                            {
                                objects.Add(new Panel(p.X, p.Y, 80, 80, identifier));
                            }
                            else if (identifier.Contains("hazard"))
                            {
                                objects.Add(new Hazard(p.X + 4, p.Y, 32, 32, identifier));
                            }
                            else
                            {
                                switch (identifier)
                                {
                                    case "spawn":
                                        playerSpawn = p;
                                        break;
                                    case "door":
                                        string d = splitLine[4];
                                        string vict = splitLine[3];
                                        if (splitLine.Length == 6)
                                        {
                                            string world = splitLine[5];
                                            objects.Add(new Door(content, p.X, p.Y, 43, 70, vict, d, @world));
                                        }
                                        else
                                        {
                                            objects.Add(new Door(content, p.X, p.Y, 43, 70, vict, d));
                                        }
                                        break;
                                    case "enemy":
                                        enemies.Add(new Enemy(content, p.X, p.Y, 50, 70, player));
                                        break;

                                    case "enemyf":
                                        enemies.Add(new EnemyF(content, p.X, p.Y, 50, 70, player));
                                        break;

                                    case "enemyw":
                                        enemies.Add(new EnemyW(content, p.X, p.Y, 45, 40, player));
                                        break;
                                }
                            }
                        }
                    }
                    catch
                    {
                        //Console.WriteLine("File read, unable to load objects, exiting");
                        //System.Threading.Thread.Sleep(2000);
                        //Environment.Exit(0);
                    }
                }
            }
            catch
            {
                //Console.WriteLine("Unable to read file, exiting");
                //System.Threading.Thread.Sleep(2000);
                //Environment.Exit(0);
            }
            finally
            {
                if (s != null)
                {
                    s = null;
                }
            }
        }