Ejemplo n.º 1
0
        public void Update(
            ref List<Bullet> BulletList,
            ref GameTime gameTime,
            ref List<EnemyParatrooper> ParatrooperList,
            ref Vector2 AmountOfTroopersOnTurret,
            ref Vector2 TimePassed,
            ref GameState gamestate,
            ref SaveAndLoadGame Sally,
            ref int Score,
            ref TimeSpan TotalPauseTime,
            ref List<EnemyHelo> ChopperList

            )
        {
            for (int i = 0; i < BulletList.Count; i++)
            {
                BulletList[i].Update(gameTime);
            }
            for (int i = 0; i < ParatrooperList.Count; i++)
            {
                AmountOfTroopersOnTurret = ParatrooperList[i].Update(gameTime, AmountOfTroopersOnTurret);
                if (AmountOfTroopersOnTurret.X == (-1337) || AmountOfTroopersOnTurret.Y == (-1337))
                {
                    TimePassed = new Vector2((gameTime.TotalGameTime - TotalPauseTime).Minutes, (gameTime.TotalGameTime - TotalPauseTime).Seconds);
                    gamestate = GameState.SetScore;

                }
            }

            for (int i = 0; i < ChopperList.Count; i++)
            {
                ChopperList[i].Update(gameTime);
            }
        }
Ejemplo n.º 2
0
        protected override void Initialize()
        {
            this.IsMouseVisible = true;
            //Graphics
            graphics.PreferredBackBufferHeight = 505;
            graphics.PreferredBackBufferWidth = 800;
            graphics.ApplyChanges();

            //General
            gamestate = GameState.Playing;
            BakkePos = new Vector2(0, 475);
            GroundRotation = -(float)((Math.PI / 180) * 90);
            rnd = new Random();

            //Extra features
            LineMovement = 0;
            trippy1 = false;
            trippy2 = false;
            Retract = true;
            Background = new Animation2();//          640 448                 //Graphics settings
            Background.Initialize(new Vector2(0, 0), 500, 500, 5, new Rectangle(0,0,800,475), Color.Black, true);

            //FPS
            fps = 0;
            fpscount = 0;
            fpsmeasurement = TimeSpan.FromSeconds(1);
            prevFPSmeasurement = TimeSpan.Zero;

            //Turret
            turret = new Turret();
            TurretRotAtSpace = 0;
            AmountOfTroopersOnTurret = new Vector2(0, 0);//Left and right
            FireContinously = 0;
            BulletOrigin = new Vector2(398f, 427);
            BulletOriginAtZero = BulletOrigin;
            TurrentOrigin = new Vector2(5, 25);//Omrisse av kanonen
            TurrentMidRect = new Vector2(380, 409);
            TurrentUnderdelRect = new Vector2(360, 425);//Plassering for bakken blir 475
            MoveLimit = ((float)(Math.PI / 180)) * 65;//var 88

            //Time
            TimePassed = new Vector2(0, 0);
            TripTime =TimeSpan.FromSeconds(0.5f);
            PreviousTripTime = TimeSpan.Zero;
            PauseTimeCooldown = TimeSpan.Zero;
            TotalPauseTime = TimeSpan.Zero;
            FireRate=TimeSpan.FromSeconds(0.4f);//0.4
            EnemyRate = TimeSpan.FromMilliseconds(1500);
            MoveRate = TimeSpan.FromSeconds(0.00002f);
            PreviousMoveTime = TimeSpan.Zero;
            PreviousEnemyTime = TimeSpan.Zero;
            PreviousFireTime = TimeSpan.Zero;

            //Lists
            BulletList = new List<Bullet>();
            ChopperList = new List<EnemyHelo>();
            ParatrooperList = new List<EnemyParatrooper>();

            //Classes
            PlayKeyboard    = new StatePlayKeyboard();
            SpecialF        = new SpecialFeatures();
            Spawn           = new Spawner();
            ListUpdater     = new UpdateLists();
            CollisionDetect = new CollisionDetection();
            text            = new TextOnScreen();
            draw            = new Draw();
            Sally           = new SaveAndLoadGame();
            PauseKeyboard   = new StatePauseKeyboard();
            //Sally.SaveGame(47);
            Sally.LoadGame();
            base.Initialize();
        }
Ejemplo n.º 3
0
        public void text(
            ref GameState gamestate,
            ref Vector2 TimePassed,
            ref SpriteBatch spriteBatch,
            ref SpriteFont font,
            ref int Score,
            ref GameTime gameTime,
            ref SaveAndLoadGame Sally,
            ref TimeSpan TotalPauseTime,
            ref TimeSpan EnemyRate

            )
        {
            //new vetor(400,475)
            spriteBatch.DrawString(font, "E.R.:" + EnemyRate, new Vector2(200, 470), Color.White);
            spriteBatch.DrawString(font, "Score:" + Score, new Vector2(10, 470), Color.White);
            switch (gamestate)
            {
                case GameState.GameOver:

                    minutes=TimePassed.X.ToString();
                    if (TimePassed.X < 10)
                    {
                        minutes = "0" + minutes;
                    }

                    seconds=TimePassed.Y.ToString();
                    if (TimePassed.Y < 10)
                    {
                        seconds = "0" + seconds;
                    }

                        spriteBatch.DrawString(font, "You survived in " + minutes + ":" + seconds, SurvivedPlacement, Color.White);
                        spriteBatch.DrawString(font, "Score:" + Score, new Vector2(SurvivedPlacement.X, SurvivedPlacement.Y+50), Color.White);

                    spriteBatch.DrawString(font, "HIGHSCORES:", new Vector2(500,SurvivedPlacement.Y), Color.White);

                    for (int i = 0; i < 10; i++)
                    {
                        spriteBatch.DrawString(font, (i+1)+" : "+Sally.GetScore(i), new Vector2(520, SurvivedPlacement.Y + 30*(i+1)), Color.White);
                    }

                    spriteBatch.DrawString(font, minutes + ":" + seconds, new Vector2(600, 470), Color.White);

                    break;

                case GameState.Playing:
                    minutes = (gameTime.TotalGameTime-TotalPauseTime).Minutes.ToString();
                    if ((gameTime.TotalGameTime - TotalPauseTime).Minutes < 10)
                    {
                        minutes = "0" + minutes;
                    }

                    seconds = (gameTime.TotalGameTime - TotalPauseTime).Seconds.ToString();
                    if ((gameTime.TotalGameTime - TotalPauseTime).Seconds < 10)
                    {
                        seconds = "0" + seconds;
                    }

                    spriteBatch.DrawString(font, minutes + ":" + seconds, new Vector2(600, 470), Color.White);
                    break;
            }
        }