/// <summary>
 /// Constructs a new menu entry with the specified text.
 /// </summary>
 public MenuEntry(MenuScreen menu, string text, EntryType type, GameScreen screen)
 {
     _text = text;
     _screen = screen;
     _type = type;
     _menu = menu;
     _scale = 0.9f;
     _alpha = 1.0f;
 }
 /// <summary>
 /// Constructs a new menu entry with the specified text.
 /// </summary>
 public MenuButton(Texture2D sprite, bool flip, Vector2 position, GameScreen screen)
 {
     _screen = screen;
     _scale = 1f;
     _sprite = sprite;
     _baseOrigin = new Vector2(_sprite.Width / 2f, _sprite.Height / 2f);
     _hover = false;
     _flip = flip;
     Position = position;
 }
Example #3
0
		public Bullet(GameScreen scrn, Cannon shooter, Vector2 pos, Vector2 velo, float entityScale)
			: base(scrn)
		{
			BulletPosition = pos;
			initialVelocity = velo;
			Source = shooter;
			Fraction = Source.Fraction;
			Scale = entityScale;

			DrawingBoundingBox = new FSize(BULLET_DIAMETER, BULLET_DIAMETER);
		}
		public BulletSplitter(GameScreen scrn, Bullet b, Direction8 d) : base(scrn)
		{
			scale = b.Scale;
			ShapePosition = b.BulletPosition;
			ShapeAlpha = 1f;
			Fraction = b.Fraction;
			velocity = VELOCITIES[(int)d] * FloatMath.GetRangedRandom(0.5f, 2f) + ConvertUnits.ToDisplayUnits(b.PhysicsBody.LinearVelocity)/10f;
			maxLifetime = FloatMath.GetRangedRandom(SPLITTER_LIFETIME_MIN, SPLITTER_LIFETIME_MAX);
			ShapeRotation = FloatMath.ToRadians((int) d * 45f);
			rotationSpeed = FloatMath.GetRangedRandom(-FloatMath.TAU, FloatMath.TAU);

			DrawingBoundingBox = new FSize(Bullet.BULLET_DIAMETER, Bullet.BULLET_DIAMETER) * scale;
		}
Example #5
0
        public PhysicsSystem(GameScreen screen)
        {
            this.screen = screen;

            GnomicGame game = screen.ParentGame;

            // Todo: pass in a PhysicsSystemSetting with gravity, worldMin and worldMax
            world = new World(
                new Vector2(0.0f, 20.0f),
                new FarseerPhysics.Collision.AABB(Vector2.One * -500.0f, Vector2.One * 500.0f));

            debugView = new DebugViewXNA(world);
            debugView.AppendFlags(DebugViewFlags.Shape);
            debugView.DefaultShapeColor = Color.White;
            debugView.SleepingShapeColor = Color.LightGray;
            debugView.LoadContent(game.GraphicsDevice, game.Content, "GameFont");

            projection = Matrix.CreateOrthographicOffCenter(
                0f,
                ConvertUnits.ToSimUnits(game.ScreenWidth),
                ConvertUnits.ToSimUnits(game.ScreenHeight),
                0f, 0f, 1f);
        }
 public void AddMenuItem(string name, EntryType type, GameScreen screen)
 {
     MenuEntry entry = new MenuEntry(this, name, type, screen);
     _menuEntries.Add(entry);
 }
Example #7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //			if (Keyboard.GetState().IsKeyDown(Keys.Z))
            //				this.TargetElapsedTime = TimeSpan.FromSeconds(0.3f);
            //			else
            //				this.TargetElapsedTime = TimeSpan.FromSeconds(0.016f);

            // Allows the game to exit
            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed && !(currentScreen is MainMenu))|| Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (!escapePressed)
                {
                    escapePressed = true;
                    currentScreen = currentScreen == null ? null : currentScreen.GoBack();
                }
            }
            else
                escapePressed = false;

            currentScreen = currentScreen == null ? null : currentScreen.Update(gameTime);
            if (currentScreen == null)
                this.Exit();

            base.Update(gameTime);
        }
Example #8
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);

            fnt_basicFont = Content.Load<SpriteFont>("fonts/basicFont");
            fnt_bigFont = Content.Load<SpriteFont>("fonts/bigFont");
            fnt_midFont = Content.Load<SpriteFont>("fonts/midFont");

            tex_bg_castle = Content.Load<Texture2D>("textures/castle");
            tex_bg_pillar = Content.Load<Texture2D>("textures/pillar");
            tex_bg_octopus = Content.Load<Texture2D>("textures/octopus");
            tex_bg_graveyard = Content.Load<Texture2D>("textures/graveyard");
            tex_bg_clocktower = Content.Load<Texture2D>("textures/clocktower");
            tex_bg_circus = Content.Load<Texture2D>("textures/circus");
            tex_fg_circus = Content.Load<Texture2D>("textures/circus foreground");

            tex_box = Content.Load<Texture2D>("textures/box");
            tex_heart = Content.Load<Texture2D>("textures/heart");
            tex_clock = Content.Load<Texture2D>("textures/clock");
            tex_head = Content.Load<Texture2D>("textures/stick figure/head");
            tex_armUpper = Content.Load<Texture2D>("textures/stick figure/armupper");
            tex_armLower = Content.Load<Texture2D>("textures/stick figure/armlower");
            tex_legUpper = Content.Load<Texture2D>("textures/stick figure/legupper");
            tex_legLower = Content.Load<Texture2D>("textures/stick figure/leglower");
            tex_torso = Content.Load<Texture2D>("textures/stick figure/torso");
            tex_evil_head = Content.Load<Texture2D>("textures/evil stick figure/head");
            tex_evil_armUpper = Content.Load<Texture2D>("textures/evil stick figure/armupper");
            tex_evil_armLower = Content.Load<Texture2D>("textures/evil stick figure/armlower");
            tex_evil_legUpper = Content.Load<Texture2D>("textures/evil stick figure/legupper");
            tex_evil_legLower = Content.Load<Texture2D>("textures/evil stick figure/leglower");
            tex_evil_torso = Content.Load<Texture2D>("textures/evil stick figure/torso");
            tex_debugHead = Content.Load<Texture2D>("textures/stick figure/debug head");
            tex_debugTorso = Content.Load<Texture2D>("textures/stick figure/debug torso");
            tex_debugLimb = Content.Load<Texture2D>("textures/stick figure/limb");
            tex_wave = Content.Load<Texture2D>("textures/force wave");
            tex_longRange = Content.Load<Texture2D>("textures/long range");
            tex_trapClosed = Content.Load<Texture2D>("textures/trap_closed");
            tex_trapOpen = Content.Load<Texture2D>("textures/trap_open");
            tex_explosionParticle = Content.Load<Texture2D>("textures/explosion particle");
            tex_endGame = Content.Load<Texture2D>("textures/end game");

            tex_cbChecked = Content.Load<Texture2D>("textures/menu assets/checkbox_checked");
            tex_cbUnchecked = Content.Load<Texture2D>("textures/menu assets/checkbox_unchecked");
            tex_logo = Content.Load<Texture2D>("textures/menu assets/logo");
            tex_mm_comp = Content.Load<Texture2D>("textures/menu assets/mm_competitive");
            tex_mm_coop = Content.Load<Texture2D>("textures/menu assets/mm_cooperative");
            tex_mm_cust = Content.Load<Texture2D>("textures/menu assets/mm_custom");
            tex_mm_exit = Content.Load<Texture2D>("textures/menu assets/mm_exit");

            tex_ps_blank = Content.Load<Texture2D>("textures/menu assets/ps_blank");
            tex_ps_controller = Content.Load<Texture2D>("textures/menu assets/ps_controller");
            tex_ps_keyboard = Content.Load<Texture2D>("textures/menu assets/ps_keyboard");
            tex_ps_off = Content.Load<Texture2D>("textures/menu assets/ps_off");
            tex_ps_next = Content.Load<Texture2D>("textures/menu assets/ps_next");

            tex_btnUp = Content.Load<Texture2D>("textures/menu assets/up");
            tex_btnDown = Content.Load<Texture2D>("textures/menu assets/down");

            sfx_punches = new SoundEffect[] {
                Content.Load<SoundEffect>("sfx/Punch1"),
                Content.Load<SoundEffect>("sfx/Punch2"),
                Content.Load<SoundEffect>("sfx/Thwap") };
            sfx_whoosh = Content.Load<SoundEffect>("sfx/Whoosh");
            sfx_hit = Content.Load<SoundEffect>("sfx/hit");
            sfx_shoot = Content.Load<SoundEffect>("sfx/shoot");
            sfx_explode = Content.Load<SoundEffect>("sfx/boom");
            mus_menu = Content.Load<Song>("menu music");
            mus_castle = Content.Load<Song>("castle music");
            mus_pillar = Content.Load<Song>("pillar music");
            mus_octopus = Content.Load<Song>("octopus music");
            mus_graveyard = Content.Load<Song>("castle music");
            mus_clocktower = Content.Load<Song>("octopus music");
            mus_circus = Content.Load<Song>("castle music");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume = 1f;
            //			MediaPlayer.Volume = 0f;

            tex_blank = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            tex_blank.SetData(new[] { Color.White });

            Map.MapKeys.Add(MainGame.tex_bg_castle, "castle");
            Map.MapKeys.Add(MainGame.tex_bg_pillar, "pillar");
            Map.MapKeys.Add(MainGame.tex_bg_octopus, "octopus");
            Map.MapKeys.Add(MainGame.tex_bg_graveyard, "graveyard");
            Map.MapKeys.Add(MainGame.tex_bg_clocktower, "clocktower");
            Map.MapKeys.Add(MainGame.tex_bg_circus, "circus");

            //			currentScreen = new SingleMap();
            //			currentScreen = new FreeForAll();
            currentScreen = new MainMenu();
        }
        /// <summary>
        /// Adds a new screen to the screen manager.
        /// </summary>
        public void AddScreen(GameScreen screen)
        {
            screen.ScreenManager = this;
            screen.IsExiting = false;

            // If we have a graphics device, tell the screen to load content.
            if (_isInitialized)
            {
                screen.LoadContent();
            }

            _screens.Add(screen);

            // update the TouchPanel to respond to gestures this screen is interested in
            TouchPanel.EnabledGestures = screen.EnabledGestures;
        }
        /// <summary>
        /// Removes a screen from the screen manager. You should normally
        /// use GameScreen.ExitScreen instead of calling this directly, so
        /// the screen can gradually transition off rather than just being
        /// instantly removed.
        /// </summary>
        public void RemoveScreen(GameScreen screen)
        {
            // If we have a graphics device, tell the screen to unload content.
            if (_isInitialized)
            {
                screen.UnloadContent();
            }

            _screens.Remove(screen);
            _screensToUpdate.Remove(screen);

            // if there is a screen still in the manager, update TouchPanel
            // to respond to gestures that screen is interested in.
            if (_screens.Count > 0)
            {
                TouchPanel.EnabledGestures = _screens[_screens.Count - 1].EnabledGestures;
            }
        }
Example #11
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            blank = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            blank.SetData(new[] { Color.White });
            texBox = Content.Load<Texture2D>("objects/box");
            texPlayer = Content.Load<Texture2D>("mrguy");
            SpeechBubble.texSpeech_Corner = Content.Load<Texture2D>("textbox_corner");
            SpeechBubble.texSpeech_Edge = Content.Load<Texture2D>("textbox_edge");
            SpeechBubble.texSpeech_Arrow = Content.Load<Texture2D>("textbox_arrow");
            SpeechBubble.fntSpeech = Content.Load<SpriteFont>("speechFont");

            currentScreen = new GameWorld(new Vector2(300, 600), this, "test");
        }
Example #12
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (!escapePressed)
                {
                    escapePressed = true;
                    currentScreen = currentScreen == null ? null : currentScreen.Exit();
                }
            }
            else
                escapePressed = false;

            currentScreen = currentScreen == null ? null : currentScreen.Update(this, gameTime);
            if (currentScreen == null)
                this.Exit();

            base.Update(gameTime);
        }