예제 #1
0
        private float shootingTimeElapsed = 0; // Internal counter, leave as-is.

        #endregion Fields

        #region Constructors

        public WeaponManager(AnimPlayer player)
        {
            this.ownerPlayer = player;
            audio = new Audio();
            // Create the collections which will hold our bullets fired/weapons. Mind the clever use of "generics"
            allBullets  = new List<Weapons.AbstractBullet>();

            //defaultWeapon = new Weapons.HeatSeeking();
            defaultWeapon = new Weapons.Pistol();
            //defaultWeapon = new Weapons.BouncyGun();
            pickupWeapon  = null;

            currentWeapon = defaultWeapon;
        }
예제 #2
0
파일: AnimPlayer.cs 프로젝트: Gerjo/Gravwar
 // TODO: implement function.
 public void checkPlayerCollision(AnimPlayer player)
 {
     // Compare "currentHitbox" here.
     if (currentHitbox.Intersects(player.currentHitbox))
     {
         // Detect side and adjust the velocity accordingly.
     }
 }
예제 #3
0
        protected float walkTreshold = 0.1f; // How far should the joystick be moved before the player starts walking.

        #endregion Fields

        #region Constructors

        public GamePadInput(AnimPlayer ownerPlayer)
        {
            this.ownerPlayer = ownerPlayer;
        }
예제 #4
0
파일: Level.cs 프로젝트: Gerjo/Gravwar
 private Rectangle getCrownPos(AnimPlayer p)
 {
     Rectangle rect = new Rectangle((int)p.position.X, (int)p.position.Y, 25, 25);
     switch (p.gravitySide)
     {
         case AnimPlayer.GravitySide.Up:
             rect.Y += p.currentHitbox.Height / 2 + 30;
             break;
         case AnimPlayer.GravitySide.Down:
             rect.Y -= p.currentHitbox.Height / 2 + 30;
             break;
         case AnimPlayer.GravitySide.Left:
             rect.X += p.currentHitbox.Width / 2 + 30;
             break;
         case AnimPlayer.GravitySide.Right:
             rect.X -= p.currentHitbox.Width / 2 + 30;
             break;
     }
     if (p.playerHealth > 0)
         return rect;
     else
         return new Rectangle();
 }
예제 #5
0
파일: Level.cs 프로젝트: Gerjo/Gravwar
        /*
         * The LoadContent function of level is one of the most
         * important functions in the game. It loads the level,
         * players and objects. It also loads all the
         * spawn positions.
         */
        public void LoadContent(Menu gameMenu)
        {
            //Hier wordt de informatie vanuit het menu geladen in het level
            fragLimit = gameMenu.fragLimit;
            timeLimit = gameMenu.timeLimit * 60 * 60;

            //Audio initialization.
            audio = new Audio();
            musicVolume = gameMenu.musicVol;
            soundVolume = gameMenu.soundVol;

            playerTotal = gameMenu.numPlayers;

            if (timeLimit == 0)
            {
                timeLimit = int.MaxValue - countdownTime - countdownTime;
            }
            if (fragLimit == 0)
            {
                fragLimit = int.MaxValue;
            }
            if (gameMenu.levelName != null)
            {
                levelName = gameMenu.levelName;
            }
            currentTime = timeLimit + countdownTime;

            //Console.Write("Timelimit: " + timeLimit + " Fraglimit: " + fragLimit + "\n");
            //Load some resources:
            levelTimer = Game1.INSTANCE.Content.Load<SpriteFont>("LevelTimer");
            countDownFont = Game1.INSTANCE.Content.Load<SpriteFont>("Menu");
            pauzeScreenOverlay = Game1.INSTANCE.Content.Load<Texture2D>("Images/Miscellaneous/pauseScreen");
            crowntex[0] = Game1.INSTANCE.Content.Load<Texture2D>("Images/AnimPlayer/Crown4");
            crowntex[1] = Game1.INSTANCE.Content.Load<Texture2D>("Images/AnimPlayer/Crown3");
            crowntex[2] = Game1.INSTANCE.Content.Load<Texture2D>("Images/AnimPlayer/Crown2");
            crowntex[3] = Game1.INSTANCE.Content.Load<Texture2D>("Images/AnimPlayer/Crown1");

            //Create an filestream.
            FileStream fstream = new FileStream(levelName, FileMode.Open, FileAccess.Read);
            byte[] filecontent = new byte[fstream.Length];

            //Create an array to put our data in.
            string[][] leveldata = new string[filecontent.Length][];

            //Read the file and put data in the filecontent.
            for (int i = 0; i < fstream.Length; i++)
            {
                fstream.Read(filecontent, i, 1);
            }

            //Split up the file in "words".
            int currentAt = 0;
            int currentAt2 = 0;
            for (int i = 0; i < filecontent.Length; i++)
            {

                if (leveldata[currentAt] == null)
                {
                    leveldata[currentAt] = new string[255];
                }
                if ((char)filecontent[i] == ' ')
                {
                    currentAt2++;
                }
                else if ((char)filecontent[i] == (char)10)
                {
                    currentAt2 = 0;
                    currentAt++;
                }
                else
                {
                    leveldata[currentAt][currentAt2] += (char)filecontent[i];
                }
            }

            //Go through every data in leveldata.
            for (int i = 0; i < leveldata.Length; ++i)
            {
                if (leveldata[i] != null)
                {
                    if (leveldata[i][0].Contains("background:"))
                    {
                        backgroundTex = Game1.INSTANCE.Content.Load<Texture2D>("Images/Maps/" + leveldata[i][1]);
                    }
                    else if (leveldata[i][0].Contains("backgroundmusic:"))
                    {
                        audio.LoadMusic(leveldata[i][1]);
                    }
                    else if (leveldata[i][0].Contains("object:"))
                    {
                        objects.Add(new Object(leveldata[i][1], int.Parse(leveldata[i][2]), int.Parse(leveldata[i][3]), int.Parse(leveldata[i][4]), int.Parse(leveldata[i][5])));
                    }
                    else if (leveldata[i][0].Contains("moveableobj:"))
                    {
                        objects.Add(new Object(leveldata[i][1], int.Parse(leveldata[i][2]), int.Parse(leveldata[i][3]), int.Parse(leveldata[i][4]), int.Parse(leveldata[i][5]), int.Parse(leveldata[i][6]), int.Parse(leveldata[i][7]), int.Parse(leveldata[i][8])));
                    }
                    else if (leveldata[i][0].Contains("item:"))
                    {
                        items.Add(new Items(int.Parse(leveldata[i][2]), int.Parse(leveldata[i][3]), leveldata[i][1]));
                    }
                    else if (leveldata[i][0].Contains("\r"))
                    {
                    }
                    else if (leveldata[i][0].Contains("spawn:"))
                    {
                        spawnPositions.Add(new SpawnPosition(int.Parse(leveldata[i][1]), int.Parse(leveldata[i][2]), leveldata[i][3]));
                    }
                }
            }

            //What if no background is found?
            if (backgroundTex == null)
            {
                backgroundTex = Game1.INSTANCE.Content.Load<Texture2D>("Images/Maps/BasicShapes/Rectangle");
            }

            // Initiate 4 players:
            for (int i = 0; i < playerTotal; i++)
            {
                animPlayers[i] = new AnimPlayer(this, i);
            }

            // Start the game, we *could* add a start game countdown screen here.
            levelState = LevelStates.StartCountdown;
        }