Example #1
0
        void CreateBackground(int curBG, int zPosition, Transform parentTransform = null)
        {
            GameObject obj = new GameObject(Backgrounds[curBG].name);

            obj.transform.SetParent(parentTransform ? parentTransform : transform);
            var tempTransform = obj.transform.position;

            tempTransform.z             = zPosition;
            obj.transform.localPosition = tempTransform;
            obj.transform.localScale    = new Vector3(1, 1, 1);

            MeshFilter meshFilter = obj.AddComponent <MeshFilter>();

            CreateQuad(meshFilter);

            MeshRenderer meshRenderer = obj.AddComponent <MeshRenderer>();
            var          material     = new Material(BaseMaterial)
            {
                mainTexture = Backgrounds[curBG]
            };

            meshRenderer.material = material;

            ScrollingBackground scrollingBackground = obj.AddComponent <ScrollingBackground>();

            scrollingBackground.Speed          = Speeds[curBG];
            scrollingBackground.infiniteScroll = ScrollInfinetly[curBG];
            scrollingBackground.Follow         = Follow;

            scrollingBackground.XBounds.x = -BoundingShape2D.bounds.size.x / 2 + BoundingShape2D.transform.position.x;
            scrollingBackground.XBounds.y = BoundingShape2D.bounds.size.x / 2 + BoundingShape2D.transform.position.x;

            scrollingBackground.YBounds.x = -BoundingShape2D.bounds.size.y / 2 + BoundingShape2D.transform.position.y;
            scrollingBackground.YBounds.y = BoundingShape2D.bounds.size.y / 2 + BoundingShape2D.transform.position.y;
        }
Example #2
0
        public PlayVideoGameState()
        {
            validationobjectengine = new ValidationObjectEngine();
            bool isLooped   = true;
            bool isDisposed = false;

            leapcollisionmax          = new Rectangle(0, 0, 128, 96);
            scrollingbackgroundtop    = new ScrollingBackgroundTopPV();
            scrollingbackgroundbottom = new ScrollingBackgroundBottomPV();
            forward   = new ScrollingBackground();
            playsound = false;
            //intiilaliexz display enter
            displayenter = false;
            bool isscorehit;

            // leap = new LeapComponet(this);
            //this.Components.Add(leap);
            fingertextures   = new Texture2D[5];
            score            = 0;
            colorcontrol     = false;
            ballobjectengine = new BallObjectEngine();
            //  homebase = new HomeBaseObject();
            timer = new TimeEngine();
            // TODO: Add your initialization logic here
            timer.Initialize();
            fingertextures = new Texture2D[5];
            // mainsong = new Song();
        }
Example #3
0
 public BossLevel(Dictionary <int, int> staringDistances)
 {
     stars = -1;
     starD = staringDistances;
     HudManager.init(new HudManager.HudElement[] { HudManager.HudElement.Life, HudManager.HudElement.Stars,
                                                   HudManager.HudElement.Clock, HudManager.HudElement.DistanceIcon });
     door = new GameObject(0, 0, 0, 0);
     key  = new Key(new Point(0, 0));
     coin = new Coin(new Point(0, 0));
     sea  = null;
     RemoveFromGame(player);
     ListHandler();
     bg = new ScrollingBackground(AssetManager.getSprite("Level" + levelNum), new Point(0, 0));
     secondaryBackground = new ScrollingBackground(AssetManager.getSprite("SuperLong"), new Point(0, groundLevel));
     ground   = new Platform(0, groundLevel, winWidth, winWidth);
     groundVx = speeds[0];
     toCreate = new Queue <Tree.TreeShape>();
     lastObst = TreeShape.Small;
     ///ground must be created before the boss and the player
     player    = new BossPlayer(ground);
     bestBrain = DataHandler.ReadFromBinaryFile <Network>(NeatManager.bestPlayerUrl);
     boss      = new Boss(bestBrain, ground);
     obsticles = new List <Tree>();
     clouds    = new List <Drawable>();
     AddToGame(boss);
     AddToGame(player);
     AddToGame(ground);
     AddToGame(secondaryBackground);
     getGame().bossLevel = this;
 }
        // constructor 2
        public OpeningTitleScreen()
        {
            backwardscode       = new ScrollingBackgroundBackwardsTwo();
            virusplayer         = new VideoPlayer();
            secondscreen        = false;
            virusvidtexturerect = new Rectangle(0, 0, 512, 512);
            leapfingersrect     = new Rectangle[6];
            leapfingersrect[0]  = new Rectangle(0, 0, 128, 128);
            leapfingersrect[1]  = new Rectangle(0, 0, 128, 128);
            leapfingersrect[2]  = new Rectangle(0, 0, 128, 128);
            leapfingersrect[3]  = new Rectangle(0, 0, 128, 128);
            leapfingersrect[4]  = new Rectangle(0, 0, 128, 128);
            leapfingersrect[5]  = new Rectangle(0, 0, 128, 128);
            fingertextures      = new Texture2D[5];
            hitboxrect          = new Rectangle[11];

            backwards = new ScrollingBackgroundBackwards();
            forward   = new ScrollingBackground();
            //  scrollingbackgroundtop = new ScrollingBackgroundTop();
            for (int x = 0; x < 11; x++)
            {
                hitboxrect[x].X = 200;
                hitboxrect[x].Y = (x + 2) * 50;
            }

            // scrollingbackgroundbottom = new ScrollingBackgroundBottom();

            broken = new bool[11];
            for (int g = 0; g < 11; g++)
            {
                broken[g] = false;
            }
        }
Example #5
0
        public Level(Input input, TextureManager textureManager, PersistantGameData gameData)
        {
            _input = input;
            _gameData = gameData;
            _textureManager = textureManager;

            _background = new ScrollingBackground(textureManager.Get("background"));
            _background.SetScale(2, 2);
            _background.Speed = 0.15f;

            _backgroundLayer = new ScrollingBackground(textureManager.Get("background_layer_1"));
            _backgroundLayer.Speed = 0.1f;
            _backgroundLayer.SetScale(2.0, 2.0);

            _playerCharacter = new PlayerCharacter(_textureManager, _bulletManager);

            _effectsManager = new EffectsManager(_textureManager);
            //  _enemyList.Add(new Enemy(_textureManager, _effectsManager)); <- Removed

            // -1300 is bad for two reasons
            // 1. It's a magic number in the middle of the code
            // 2. It's based on the size of the form but doesn't directly reference the size of the form
            // this means duplication and two places to edit the code if the form size changes.
            // The form size and the enemy manager play area size should both get their value
            // from one central place.
            _enemyManager = new EnemyManager(_textureManager, _effectsManager, -1300);
        }
Example #6
0
        private void CreatePlayerAndBackground()
        {
            _player = new Player();
            _player.Initialize(_contentManager);

            _playerCollisionTimerRate = GameInfo.PlayerTimerChangeRate;

            Texture2D backgroundTexture   = _contentManager.Load <Texture2D>(AssetManager.GameBG);
            Texture2D wrestlingBackground = _contentManager.Load <Texture2D>(AssetManager.WrestingBackground);

            _backgroundSprite = new Sprite(backgroundTexture, true);
            _backgroundSprite.SetOriginCenter();
            _backgroundSprite.SetSize(GameInfo.FixedWindowWidth, GameInfo.FixedWindowHeight);
            _backgroundSprite.Position =
                new Vector2(GameInfo.FixedWindowWidth / 2.0f, GameInfo.FixedWindowHeight / 2.0f);

            _backgroundAudience = new ScrollingBackground();
            _backgroundAudience.Initialize(wrestlingBackground, GameInfo.MaxBackgroundElements,
                                           new Vector2(GameInfo.FixedWindowWidth / 2.0f, GameInfo.FixedWindowHeight), 1, true);
            _backgroundAudience.SetSize(GameInfo.FixedWindowWidth, GameInfo.FixedWindowHeight);

            Texture2D scrollingBackgroundTexture = _contentManager.Load <Texture2D>(AssetManager.BackgroundRopes);

            _scrollingBackground = new ScrollingBackground();
            _scrollingBackground.Initialize(scrollingBackgroundTexture, GameInfo.MaxBackgroundElements,
                                            new Vector2(GameInfo.FixedWindowWidth / 2.0f, GameInfo.FixedWindowHeight), 0.5f);

            Texture2D stage       = _contentManager.Load <Texture2D>(AssetManager.Stage);
            Sprite    stageSprite = new Sprite(stage)
            {
                Scale = GameInfo.StageScale
            };

            stageSprite.SetOriginCenter();
            _stage = new GameObject(stageSprite, stageSprite.Width, stageSprite.Height)
            {
                Position = new Vector2(GameInfo.FixedWindowWidth / 2.0f, GameInfo.FixedWindowHeight + 300)
            };

            Texture2D winWrestler = _contentManager.Load <Texture2D>(AssetManager.WinWrestler);
            Sprite    winSprite   = new Sprite(winWrestler)
            {
                Scale = GameInfo.WrestlerScale
            };

            winSprite.SetOriginCenter();
            _winWrestler = new GameObject(winSprite, winSprite.Width, winSprite.Height)
            {
                Position = new Vector2(GameInfo.FixedWindowWidth / 2.0f, GameInfo.FixedWindowHeight + 250)
            };

            _starSpriteSheetAnimationManager = new SpriteSheetAnimationManager();
            _starSpriteSheetAnimationManager.Initialize(_contentManager, AssetManager.StarBase,
                                                        AssetManager.StarTotalCount, 0, true);
            _starSpriteSheetAnimationManager.FrameTime = AssetManager.StarAnimationSpeed;
            _starSprite       = _starSpriteSheetAnimationManager.Sprite;
            _starSprite.Scale = 0.4f;
            _starsOffset      = new Vector2(_winWrestler.Sprite.Width - 50, 70);
        }
Example #7
0
 void Start()
 {
     GameManager.Instance.AddLevelManager(this);
     _background = GetComponent <ScrollingBackground>();
     LevelSetup();
     _lastSpawnTime = 0;
     UpdateEnemiesSpawnFrequency();
 }
Example #8
0
 // Use this for initialization
 void Awake()
 {
     OriginHorSpeed   = HorSpeed;
     rb               = GetComponent <Rigidbody>();
     anim             = GetComponent <Animator>();
     ScrollBackground = FindObjectOfType <ScrollingBackground>();
     //cloudanim = GetComponent<Animator>();
     //cloudanim = GameObject.Find("Cloud(Clone)").GetComponent<Animator>();
 }
Example #9
0
 // Use this for initialization
 void Awake()
 {
     OriginHorSpeed = HorSpeed;
     rb = GetComponent<Rigidbody>();
     anim = GetComponent<Animator>();
     ScrollBackground = FindObjectOfType<ScrollingBackground>();
     //cloudanim = GetComponent<Animator>();
     //cloudanim = GameObject.Find("Cloud(Clone)").GetComponent<Animator>();
 }
        public void Initialize()
        {
            scrollingBackgroundImages = new ScrollingBackground[2];

            for (int i = 0; i < 2; i++)
            {
                scrollingBackgroundImages[i] = new ScrollingBackground(layerTexture);

                scrollingBackgroundImages[i].position = new Vector2(0, thisScene.ScreenArea.Height - (scrollingBackgroundImages[i].texture.Height * i));
            }
        }
Example #11
0
 public virtual void Initialize()
 {
     // TODO: Ajouter votre logique d’initialisation ici
     Heros.InitializeHéros(fenêtre);
     ensemble1.Initialize();
     ensemble1.Apparaitre(new Vector2(fenêtre.Width / 2, 5), ennemis);
     accelerometre.Start();
     score       = 0;
     background1 = new ScrollingBackground("fond1", MenuScreen.getInstance(fenêtre).background1.rectangle, 10);
     background2 = new ScrollingBackground("fond2", MenuScreen.getInstance(fenêtre).background2.rectangle, 10);
 }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Example #13
0
 private void CallSpaceReset(float playerDistance)
 {
     foreach (Transform item in space)
     {
         ScrollingBackground scrollingBG = item.GetComponent <ScrollingBackground>();
         if (scrollingBG != null)
         {
             scrollingBG.SetResetSpeed(Vector2.Distance(scrollingBG.transform.position, Ground.transform.position), playerDistance);
             scrollingBG.EnableReset(true);
         }
     }
 }
Example #14
0
        protected override void Initialize()
        {
            //SoundEffectManger
            SoundEffectManager soundeffectmanager = new SoundEffectManager(this);
            this.Services.AddService(typeof(ISoundEffect), soundeffectmanager);
           

            //Scrolling background
            scrollingbackground = new ScrollingBackground();
            this.Services.AddService(typeof(IScrollingBackground), scrollingbackground);
            screenManager.AddScreen(scrollingbackground);         
            
            //Visualiser
            visualiser = new Visualiser();
            screenManager.AddScreen(visualiser);
            this.Services.AddService(typeof(IVisualiser), visualiser);
            
            
            //PopUp
            popupmanager = new PopUpManager();
            this.Services.AddService(typeof(IPopUpManager), popupmanager);
            screenManager.AddScreen(popupmanager);

            //HUD
            hud = new HUD();
            screenManager.AddScreen(hud);
            this.Services.AddService(typeof(IHUD), hud);

            //HookPointManger
            HookPointManager hookpointmanager = new HookPointManager();
            screenManager.AddScreen(hookpointmanager);
            
            //GameScreen
            SwingSetsGameScreen ssgs = new SwingSetsGameScreen(this);
            
            //Trail
            ssgs.trail = new Trail(this);
            this.Components.Add(ssgs.trail);

            //Menu Screen
            MainMenuScreen mainmenuscreen = new MainMenuScreen(new MusicSelectScreen(new LevelSelectScreen(ssgs)));
            screenManager.AddScreen(mainmenuscreen);
            base.Initialize();
            ssgs.LoopCompleted += hud.FireLoopCompleted;
            ssgs.LoopCompleted += visualiser.FireLoopCompleted;
            ssgs.LoopCompleted += popupmanager.FireLoopCompleted;
            ssgs.LoopCompleted += hookpointmanager.FireLoopCompleted;
        }
Example #15
0
        protected override void Initialize()
        {
            AssetsManager.LoadContent(this);
            _scrollingBackground = new ScrollingBackground(ScreenWidth, ScreenHeight, AssetsManager.StarfieldBackground);
            _spaceInvadersBoard  = new SpaceInvadersBoard();
            _spaceInvadersBoard.Initialize(this);
            _ship         = new Ship(this, new Vector2((ScreenWidth / 2) + (AssetsManager.ShipTexture.Width / 2), ScreenHeight - 100), Color.White);
            _upgrade      = new Upgrade(this, new Vector2(0, 0));
            _gameOver     = false;
            _playGameOver = false;
            _playYouWin   = false;
            _play         = true;
            _font         = AssetsManager.Tahoma;
            AssetsManager.StartGame.Play();

            base.Initialize();
        }
        //constructor 1
        public OpeningTitleScreen(bool choice)
        {
            //  backwardscode = new ScrollingBackgroundBackwardsTwo();
            secondscreen = false;


            virusplayer = new VideoPlayer();

            virusvidtexturerect = new Rectangle(0, 0, 512, 512);
            backwards           = new ScrollingBackgroundBackwards();
            leapfingersrect     = new Rectangle[6];
            //scrollingbackgroundbottom = new ScrollingBackgroundBottom();
            fingertextures        = new Texture2D[5];
            leapfingersrect[0]    = new Rectangle(0, 0, 128, 128);
            leapfingersrect[1]    = new Rectangle(0, 0, 128, 128);
            leapfingersrect[2]    = new Rectangle(0, 0, 128, 128);
            leapfingersrect[3]    = new Rectangle(0, 0, 128, 128);
            leapfingersrect[4]    = new Rectangle(0, 0, 128, 128);
            leapfingersrect[5]    = new Rectangle(0, 0, 128, 128);
            this.displayEndScenes = choice;

            forward = new ScrollingBackground();

            //<<< graphics pheonomina >>> scrolling background of snow flakes at the bottom or any itemm;
            //  scrollingbackgroundtop = new ScrollingBackgroundTop();

            hitboxrect = new Rectangle[11];

            for (int x = 0; x < 11; x++)
            {
                hitboxrect[x].X = 200;
                hitboxrect[x].Y = (x + 2) * 50;
            }



            broken = new bool[11];
            for (int g = 0; g < 11; g++)
            {
                broken[g] = false;
            }
        }
Example #17
0
    // Use this for initialization
    void Start()
    {
        Roof         = FindObjectOfType <SpawnRoof>();
        GoTarget     = MoveTarget.topRight;
        score        = FindObjectOfType <Score>();
        Background   = FindObjectOfType <ScrollingBackground>();
        MoveTutorial = FindObjectOfType <MoveTutorialDown>();
        anim         = GetComponent <Animator>();
        cube         = FindObjectsOfType <TutorialCube>();

        anim.speed = 0;

        if (score.DoubleCoins == true)
        {
            DoubleCoinsUI.SetActive(true);
        }
        else
        {
            DoubleCoinsUI.SetActive(false);
        }
    }
Example #18
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);

            //TODO: use this.Content to load your game content here
            //Texture2D background = Content.Load<Texture2D>("starfield");
            myBackground      = new ScrollingBackground();
            backgroundTexture = this.Content.Load <Texture2D>("starfield");
            // backgroundRectangle = new Rectangle(0, 0, screenWidth, screenHeight);
            myBackground.Load(GraphicsDevice, backgroundTexture);

            gameController.setTexture(this.Content.Load <Texture2D>("zerotype"));
            gameController.setTexture2(this.Content.Load <Texture2D>("explosion"));
            gameController.setTexture3(this.Content.Load <Texture2D>("Drillexplode"));

            gameController.setProtectTexture(this.Content.Load <Texture2D>("zerotype"));
            gameController.setBomberTexture(this.Content.Load <Texture2D>("JapBomber"));
            gameController.setDestroyer1Texture(this.Content.Load <Texture2D>("destroyer1"));
            gameController.setAircraftCarrierTexture(this.Content.Load <Texture2D>("aircraftcarrier"));
            gameController.setBattleShipTexture(this.Content.Load <Texture2D>("battleship"));

            gameController.setBomberHitTexture(this.Content.Load <Texture2D>("JapBomberhit"));
            gameController.setDestroyer1HitTexture(this.Content.Load <Texture2D>("destroyer1hit"));
            gameController.setAircraftCarrierHitTexture(this.Content.Load <Texture2D>("aircraftcarrierhit"));
            gameController.setBattleShipHitTexture(this.Content.Load <Texture2D>("battleshiphit"));

            playerObject.setTexture(this.Content.Load <Texture2D>("USfighter"));
            playerObject.setVelocity(new Vector2(3f, 3f));

            bonus.setFont(this.Content.Load <SpriteFont>("SpriteFont1"));
            gameInfoObject.setFont(this.Content.Load <SpriteFont>("SpriteFont1"));
            gameInfoBetween.setFont(this.Content.Load <SpriteFont>("SpriteFont1"));
            gameInfoObject2.setFont(this.Content.Load <SpriteFont>("SpriteFont2"));

            playerObject.setBulletTexture(this.Content.Load <Texture2D>("redball"));
            playerObject.setTorpedoTexture(this.Content.Load <Texture2D>("torpedo"));

            gameController.setBombTexture(this.Content.Load <Texture2D>("whiteball"));
        }
Example #19
0
        public override void LoadContent()
        {
            _font = _content.Load <SpriteFont>("Font");

            _bg = _content.Load <Texture2D>("img_bg_level_2");
            List <Texture2D> playerTexture2Ds = new List <Texture2D>
            {
                _content.Load <Texture2D>("img_plane_main"),
                _content.Load <Texture2D>("img_plane_main_invincible"),
            };



            _sprites = new List <Sprite>
            {
                new ScrollingBackground(_content.Load <Texture2D>("img_bg_level_2"))
                {
                    Position   = new Vector2(Game1.ScreenWidth / 2, Game1.ScreenHeight / 2),
                    PositionUP = new Vector2(Game1.ScreenWidth / 2, -Game1.ScreenHeight / 2)
                },
                new Player(playerTexture2Ds)
                {
                    Position  = new Vector2(256, 700),
                    Direction = new Vector2(0, -1),
                    input     = new Input
                    {
                        Up        = Keys.Up,
                        Down      = Keys.Down,
                        Left      = Keys.Left,
                        Right     = Keys.Right,
                        LeftShift = Keys.LeftShift
                    },
                    BulletManager = new BulletManager(_content)
                }
            };

            player      = (Player)_sprites.Where(c => c is Player).Single();
            _background = (ScrollingBackground)_sprites.Where(c => c is ScrollingBackground).Single();
        }
Example #20
0
 /// <summary>
 /// Constructor for Options
 /// </summary>
 /// <param name="game"></param>
 public Options(Game1 game)
 {
     this.game     = game;
     gametime      = new GameTime();
     confirmButton = new BaseButton(Game1.Assets.confirm)
     {
         height = 100, width = 200
     };
     confirmButton.setPosition(new Vector2((int)(100),
                                           (int)(100)));
     scroll = new ScrollingBackground(Game1.Assets.background)
     {
         height = game.getScreenHeight(), width = game.getScreenWidth()
     };
     scroll.setPosition(new Vector2((int)0, (int)0));
     changeGameReso = new BaseButton(Game1.Assets.confirm)
     {
         height = 100, width = 200
     };
     changeGameReso.setPosition(new Vector2((int)(100),
                                            (int)(500)));
 }
Example #21
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        /// shipselectionscreen added by Matthew Baldock
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // All sprites get loaded in to here
            Assets.loadContent(GraphicsDevice);
            explosionEngine = new ExplosionEngine(Assets);

            List <Texture2D> textures = new List <Texture2D>();

            textures.Add(Assets.guiRectangle);
            //textures.Add(Assets.missile);
            particleEngine = new ParticleEngine(textures, new Vector2(400, 240));

            shipselectionScreen = new ShipSelectionScreen(this);

            scroll = new ScrollingBackground(Game1.Assets.background)
            {
                height = getScreenHeight(), width = getScreenWidth()
            };
            scroll.setPosition(UIConstants.ORIGIN);
            IsMouseVisible = true;
        }
Example #22
0
        private MenuScreen(Rectangle fenetre)
        {
            fenêtre       = fenetre;
            ElementsMenus = new List <string> {
                "Play", "Exit"
            };
            policeMenu          = Content_Manager.getInstance().Polices["PoliceMenu"];
            EmplacementsBoutons = new List <Rectangle> {
            };
            int i = 0;

            foreach (string element in ElementsMenus)
            {
                EmplacementsBoutons.Add(new Rectangle((int)(fenêtre.Width / 2 - (policeMenu.MeasureString(element).X / 2)),
                                                      (fenêtre.Height / 2) - (policeMenu.LineSpacing * ElementsMenus.Count / 2) + ((policeMenu.LineSpacing) * i), (int)policeMenu.MeasureString(element).X,
                                                      (int)(policeMenu.MeasureString(element).Y)));
                i++;
            }
            Boutons = new List <Bouton> {
                new BoutonGame(EmplacementsBoutons[0], fenêtre), new BoutonExit(EmplacementsBoutons[1], fenêtre)
            };
            background1 = new ScrollingBackground("fond1", fenêtre, 20);
            background2 = new ScrollingBackground("fond2", new Rectangle(0, -Content_Manager.getInstance().Textures["fond2"].Height, fenêtre.Width, fenêtre.Height), 20);
        }
Example #23
0
 private void checkQueueList()
 {
     if (queueList.Count > 10)
     {
         for (int i = 0; i < 10; i++)
         {
             if (queueList[i].SpawnTime <= timer)
             {
                 if (queueList[i].Type == "Scrolling")
                 {
                     ScrollingBackground bg = new ScrollingBackground(spriteBatch, game, queueList[i].Filename, "bg" + i.ToString(), queueList[i].SpawnTime, queueList[i].DeleteTime, queueList[i].Direction, queueList[i].Layer, queueList[i].PersistScroll);
                     addBackground(bg);
                 }
                 else if (queueList[i].Type == "Pillar")
                 {
                     BackgroundPillar bg = new BackgroundPillar(spriteBatch, game, getPillarFileName(queueList[i].Filename), queueList[i].SpawnTime, queueList[i].Direction, queueList[i].Layer, queueList[i].PersistScroll);
                     addBackground(bg);
                 }
                 else if (queueList[i].Type == "Batch")
                 {
                     PillarBatch bg = new PillarBatch(this, spriteBatch, game, queueList[i].LowestSpawnRate, queueList[i].HighestSpawnRate, (int)queueList[i].DeleteTime, queueList[i].Direction, queueList[i].RandomDirection, queueList[i].RandomSpeed, queueList[i].Layer, queueList[i].PersistScroll);
                     addBackground(bg);
                 }
                 queueList.RemoveAt(i);
                 i--;
             }
             if (i < 0)
             {
                 break;
             }
         }
     }
     else
     {
         for (int i = 0; i < queueList.Count; i++)
         {
             if (queueList[i].SpawnTime <= timer)
             {
                 if (queueList[i].Type == "Scrolling")
                 {
                     ScrollingBackground bg = new ScrollingBackground(spriteBatch, game, queueList[i].Filename, "bg" + i.ToString(), queueList[i].SpawnTime, queueList[i].DeleteTime, queueList[i].Direction, queueList[i].Layer, queueList[i].PersistScroll);
                     addBackground(bg);
                 }
                 else if (queueList[i].Type == "Pillar")
                 {
                     BackgroundPillar bg = new BackgroundPillar(spriteBatch, game, getPillarFileName(queueList[i].Filename), queueList[i].SpawnTime, queueList[i].Direction, queueList[i].Layer, queueList[i].PersistScroll);
                     addBackground(bg);
                 }
                 queueList.RemoveAt(i);
                 i--;
             }
         }
     }
 }
        /// <summary>
        /// Scrolling
        /// </summary>
        /// <param name="?"></param>
        /// <param name="?"></param>
        protected void UpdateMap(ScrollingBackground bg, GameTime gameTime)
        {
            if (bg == null) return;

            bg.Update(gameTime);
        }
Example #25
0
        public override void Init()
        {
            #region A LOT OF SINGLETONS
            PlayerCar playerCar = PlayerCar.Singleton;
            Player player = Player.Singleton;
            RivalCar rivalCar = RivalCar.Singleton;
            CarGarage garage = CarGarage.Singleton;
            NpcManager npcManager = NpcManager.Singleton;
            ItemManager itemManager = ItemManager.Singleton;
            Game1 game = Game1.Singleton;
            ContentManager content = game.Content;
            #endregion

            player.Reward = 0;

            game.IsMouseVisible = false;

            ScrollingBackground background = new ScrollingBackground();
            background.TexturePath = "Backgrounds\\Stage2";
            entities.Add(background);

            cashSound = content.Load<SoundEffect>("Sounds\\Cash");
            boostSound = content.Load<SoundEffect>("Sounds\\Boost");
            playerCar.CopyCat(garage.Get(player.CarName));

            entities.Add(playerCar);

            rivalCar.CopyCat(garage.Get("Rival_Normal"));
            rivalCar.AiType = 1;
            entities.Add(rivalCar);

            npcManager.MaxCount = 8;
            npcManager.Interval = 20.0f;
            itemManager.Interval = 80.0f;

            npcManager.OnAdd = new NpcManager.NpcManagerOnAddDelegate(NpcManager_OnAdd);
            npcManager.OnRemove = new NpcManager.NpcManagerOnRemoveDelegate(NpcManager_OnRemove);
            npcManager.OnCollisionCheck = new NpcCar.NpcCarOnWantsCollisionCheckDelegate(NpcManager_OnCollisionCheck);

            itemManager.OnAdd = new ItemManager.ItemManagerOnAddDelegate(ItemManager_OnAdd);
            itemManager.OnRemove = new ItemManager.ItemManagerOnRemoveDelegate(ItemManager_OnRemove);
            itemManager.OnCollisionCheck = new Item.ItemOnWantsCollisionCheckDelegate(ItemManager_OnCollisionCheck);

            Entity statusBackground = new Entity();
            statusBackground.TexturePath = "HUD\\Status";
            statusBackground.X = 580;
            entities.Add(statusBackground);

            Text newText;
            newText = new Text();
            newText.FontPath = "Fonts\\DefaultFont";
            newText.Color = Color.Black;
            newText.Position = new Vector2(585, 80);
            newText.String = "Pickup:";
            entities.Add(newText);

            newText = new Text();
            newText.FontPath = "Fonts\\DefaultFont";
            newText.Color = Color.Black;
            newText.Position = new Vector2(585, 100);
            newText.String = "$" + player.Money;
            newText.Type = "PlayerMoneyText";
            entities.Add(newText);

            newText = new Text();
            newText.FontPath = "Fonts\\DefaultFont";
            newText.Color = Color.Black;
            newText.Position = new Vector2(585, 130);
            newText.String = "Speed:";
            entities.Add(newText);

            newText = new Text();
            newText.FontPath = "Fonts\\DefaultFont";
            newText.Color = Color.Black;
            newText.Position = new Vector2(585, 150);
            newText.String = 0 + "km/h";
            newText.Type = "PlayerSpeedText";
            entities.Add(newText);

            Entity minimapBackground = new Entity();
            minimapBackground.TexturePath = "HUD\\Minimap";
            minimapBackground.X = 695;
            entities.Add(minimapBackground);

            Entity minimapCar;

            minimapCar = new Entity();
            minimapCar.Type = "PlayerMiniCar";
            minimapCar.TexturePath = "HUD\\Car_Player";
            minimapCar.Position = new Vector2(704, 586);
            entities.Add(minimapCar);

            minimapCar = new Entity();
            minimapCar.Type = "RivalMiniCar";
            minimapCar.TexturePath = "HUD\\Car_Enemy";
            minimapCar.Position = new Vector2(755, 586);
            entities.Add(minimapCar);
            counter.Init();
            entities.Add(counter);

            PopupWindow exitPopup = new PopupWindow();
            exitPopup.Style = PopupStyle.YesNo;
            exitPopup.Text = "      Exit to menu?";
            exitPopup.OnResult = new PopupWindow.PopupOnResultEventDelegate(PopupWindow_OnPopupResult);
            pausedEntities.Add(exitPopup);

            base.Init();
        }
        /// <summary>
        /// Display context.Map with parallax backgrounds
        /// </summary>
        /// <param name="bg"></param>
        /// <param name="gameTime"></param>
        protected void DrawMap(ScrollingBackground bg, GameTime gameTime)
        {
            if (bg == null) return;

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            bg.Draw(spriteBatch);
            spriteBatch.End();
        }
        /// <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);

            // TODO: use this.Content to load your game content here
            //Background
            Texture2D level1     = this.Content.Load <Texture2D>("Images/BG_02");
            Texture2D level2     = this.Content.Load <Texture2D>("Images/BG_03");
            Texture2D startImage = this.Content.Load <Texture2D>("Images/startImage");
            Texture2D village    = this.Content.Load <Texture2D>("Images/houses3");

            stage = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            Rectangle srcRec = new Rectangle(0, 0, level1.Width, level1.Height);
            Vector2   pos    = new Vector2(0, 0);
            Vector2   speed  = new Vector2(2, 0);

            //SoundEffect menuMusic = this.Content.Load<SoundEffect>("Sounds/JazzJingleBell");
            //SoundEffect level1Music = this.Content.Load<SoundEffect>("Sounds/Jingle-Bell-Rock-Bobby-Helms");

            Song menuMusic   = this.Content.Load <Song>("Sounds/JazzJingleBell");
            Song level1Music = this.Content.Load <Song>("Sounds/Jingle-Bell-Rock-Bobby-Helms");
            Song level2Music = this.Content.Load <Song>("Sounds/Rudolph-The-Red-Nosed-Reindeer-Gene-Autry");

            MediaPlayer.IsRepeating = true;
            ScrollingBackground scrollingBackground = new ScrollingBackground(this, spriteBatch, level2, pos, srcRec, speed);
            ScrollingBackground houses = new ScrollingBackground(this, spriteBatch, village, pos, srcRec, speed);

            this.Components.Add(scrollingBackground);
            this.Components.Add(houses);

            //Santa
            //Texture2D santaTexture = Content.Load<Texture2D>("Images/modify_Santa_with_sledgh");
            Texture2D   santaTextureBig      = Content.Load <Texture2D>("Images/santaBig2");
            SoundEffect santaVoice           = this.Content.Load <SoundEffect>("Sounds/SantaVoice");
            Vector2     santaInitialPosition = new Vector2(0, stage.Y / 2);
            Vector2     santaSpeed           = new Vector2(4, 4);
            int         santaDelay           = 3;

            santa = new Santa(this, spriteBatch, santaTextureBig, santaInitialPosition, santaDelay, santaSpeed, stage, santaVoice);
            this.Components.Add(santa);
            MediaPlayer.Play(level1Music);

            //CandyCane
            Texture2D candyCaneTexture  = this.Content.Load <Texture2D>("Images/candyCane1");
            Vector2   candyCanePosition = new Vector2(stage.X, randomPosition.Next((int)stage.Y));

            //Present
            presentTexture = this.Content.Load <Texture2D>("Images/present2");
            Texture2D present2 = this.Content.Load <Texture2D>("Images/present3");
            Texture2D present3 = this.Content.Load <Texture2D>("Images/present4");

            gettingSound = this.Content.Load <Song>("Sounds/zapsplat_foley_present_gift_wrapped_pick_up_grab_001_42924");
            positionX    = graphics.PreferredBackBufferWidth;
            Random random = new Random();

            positionY       = random.Next(0, graphics.PreferredBackBufferHeight - presentTexture.Height);
            presentPosition = new Vector2(positionX, positionY);

            present = new Present(this, spriteBatch, presentTexture, presentPosition, new Vector2(presentSpeed, 0), stage);
            this.Components.Add(present);
        }
Example #28
0
        /// <summary>
        /// Read .tgpa files outside TGPA Game class
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static Map BuildMapFromTGPAFile(String file, Vector2 screenResolution)
        {
            Map map = new Map();

            StreamReader reader = new StreamReader(TitleContainer.OpenStream(file));

            String line = reader.ReadLine();

            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //Check version
            //try
            //{
            //    if (Convert.ToDouble((line.Split(' '))[1]) > Convert.ToDouble(TheGreatPaperGame.version))
            //    {
            //        reader.Close();
            //        throw new Exception("Insupported game version.");
            //    }
            //}
            //catch (FormatException) { throw new Exception("Invalid game version : " + line); } //Bullshit

            map.GameVersion = TheGreatPaperGame.Version;

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //Map informations
            #region Map Infos

            try
            {
                map.Level = Convert.ToInt32((line.Split(' '))[1]);
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid map level number : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            try
            {
                map.lastPart = Convert.ToBoolean(line.Replace("lastpart ", ""));
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid map level lastpart : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            map.Name = LocalizedStrings.GetString(line.Replace("name ", ""));

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            String filedesc = line.Replace("desc ", "");
            map.Description = LocalizedStrings.GetString(filedesc);

            #endregion

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //Backgrounds
            #region Backgrounds

            for (int i = 1; i < 4; i++)
            {
                ScrollingBackground bg = null;

                if (i == 1)
                {
                    bg = map.Background1;
                }
                else if (i == 2)
                {
                    bg = map.Background2;
                }
                else if (i == 3)
                {
                    bg = map.Background3;
                }


                string[] tokens = line.Split(' ');

                ScrollDirection direction = ScrollDirection.Left;

                try
                {
                    direction = ScrollingBackground.String2ScrollDirection(tokens[1]);
                }
                catch (Exception e)
                {
                    Logger.Log(LogLevel.Error, "TGPA Exception : " + e.Message);
                }

                bool inf = false;
                try
                {
                    inf = Convert.ToBoolean(tokens[4]);
                }
                catch (FormatException) { reader.Close(); throw new Exception("Invalid boolean for Infinite scroll : " + line); }

                Vector2 speed = Vector2.Zero;
                try
                {
                    speed = new Vector2(Convert.ToInt32(tokens[2]), Convert.ToInt32(tokens[3]));
                }
                catch (FormatException) { reader.Close(); throw new Exception("Invalid Vector for scroll speed : " + line); }

                bg = new ScrollingBackground(direction, speed, inf);

                //Parts
                while ((line = reader.ReadLine()).Split(' ')[0].Equals("bgpart"))
                {
                    Logger.Log(LogLevel.Info, "BG Found  " + line.Split(' ')[1]);

                    bg.AddBackground(line.Split(' ')[1]);
                }

                if (bg.BackgroundSprites.Count == 0)
                {
                    reader.Close(); throw new Exception("No BGPart found for Background " + i);
                }

                if (i == 1)
                {
                    map.Background1 = bg;
                }
                else if (i == 2)
                {
                    map.Background2 = bg;
                }
                else if (i == 3)
                {
                    map.Background3 = bg;
                }

                line = reader.ReadLine();
                while (line.Equals("") || line.StartsWith("//"))
                {
                    line = reader.ReadLine();
                }
            }

            #endregion

            //Initialization
            #region Init

            if (!line.Split(' ')[0].Equals("init"))
            {
                reader.Close();
                throw new Exception("Invalid TGPA map : init section not found");
            }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //level music
            string[] tokens2 = line.Split('\"');
            if (tokens2.Length < 4)
            {
                Console.WriteLine("No music loaded");
            }
            else
            {
                map.Music = new MySong(tokens2[0].Split(' ')[1], tokens2[1], tokens2[3]);
            }
            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //Initial datas
            try
            {
                map.InitialScore = Convert.ToInt32(line.Split(' ')[1]);
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid integer for score : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            try
            {
                map.InitialLivesCount = Convert.ToInt32(line.Split(' ')[1]);
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid integer for lives : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            string weaponName = line.Split(' ')[1];
            map.InitialWeapon = Weapon.TypeToWeapon(weaponName);

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //Initial loc
            Vector2 initialPlayerLoc = new Vector2(Convert.ToInt32(line.Split(' ')[1]), Convert.ToInt32(line.Split(' ')[2]));
            map.InitialPlayerLocation = initialPlayerLoc;

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //Initial flip
            string        sFlip = line.Split(' ')[1];
            SpriteEffects flip  = SpriteEffects.None;

            if (sFlip.Equals(SpriteEffects.FlipHorizontally.ToString()))
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else if (sFlip.Equals(SpriteEffects.FlipVertically.ToString()))
            {
                flip = SpriteEffects.FlipVertically;
            }

            map.InitialFlip = flip;

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //End conditions
            Event  endmap  = new Event(Vector2.Zero, null);
            String winflag = line.Split(' ')[1];
            line = reader.ReadLine();
            String loseflag = line.Split(' ')[1];
            endmap.AddCommand(new EndLevelCommand(winflag, loseflag));

            map.Events.Add(endmap);

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            ScrollDirection outDirection = ScrollingBackground.String2ScrollDirection(line.Split(' ')[1]);
            map.OutDirection = outDirection;

            #endregion

            //Script
            #region Script event

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            if (!line.Split(' ')[0].Equals("begin"))
            {
                reader.Close();
                throw new Exception("Invalid TGPA map : begin keyword not found");
            }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//"))
            {
                line = reader.ReadLine();
            }

            //Read all events
            while (!line.Split(' ')[0].Equals("end"))
            {
                tokens2 = line.Split(' ');

                if (!tokens2[0].Equals("event"))
                {
                    reader.Close();
                    throw new Exception("Invalid TGPA map : event section missing (line : " + line + ")");
                }

                Vector2 vector = Vector2.Zero;
                try
                {
                    vector = new Vector2((float)Convert.ToDouble(tokens2[2]), (float)Convert.ToDouble(tokens2[3]));
                }
                catch (FormatException) { reader.Close(); throw new Exception("Invalid Vector for event scroll value : " + line); }

                line    = reader.ReadLine();
                tokens2 = line.Split(' ');
                if (!tokens2[0].Equals("start"))
                {
                    reader.Close();
                    throw new Exception("Invalid TGPA map : start keyword missing");
                }

                String    startFlag = null;
                IfCommand ifc       = null;

                try
                {
                    startFlag = line.Split(' ')[1];
                    if (!startFlag.Equals(""))
                    {
                        ifc = new IfCommand(startFlag);
                    }
                }
                catch (IndexOutOfRangeException) { }

                Event e = new Event(vector, ifc);

                line = reader.ReadLine();
                while (line.Equals("") || line.StartsWith("//"))
                {
                    line = reader.ReadLine();
                }

                List <Command> commands = new List <Command>();

                //Add actions
                while (!line.Split(' ')[0].Equals("endevent"))
                {
                    Command c = null;

                    switch (line.Split(' ')[0])
                    {
                    case "addenemy":
                        c = new AddEnemyCommand(line, screenResolution);

                        AddEnemyRessourcesToLoadIfNecessary(map, (AddEnemyCommand)c);

                        break;

                    case "addbge":
                        c = new AddBackgroundElementCommand(line, screenResolution);
                        AddBGERessourcesToLoadIfNecessary(map, (AddBackgroundElementCommand)c);
                        break;

                    case "if":
                        c = new IfCommand(line);
                        break;

                    case "set":
                        c = new SetFlagCommand(line, true);
                        break;

                    case "unset":
                        c = new UnsetFlagCommand(line, true);
                        break;

                    case "whilenot":
                        c = new WhileNotCommand(line);

                        line = reader.ReadLine();
                        while (line.Equals("") || line.StartsWith("//"))
                        {
                            line = reader.ReadLine();
                        }

                        List <String> lines = new List <String>();
                        while (!line.Split(' ')[0].Equals("done"))
                        {
                            if (line.Split(' ')[0].Equals("addenemy"))
                            {
                                AddEnemyRessourcesToLoadIfNecessary(map, new AddEnemyCommand(line, screenResolution));
                            }
                            lines.Add(line);

                            line = reader.ReadLine();
                            while (line.Equals("") || line.StartsWith("//"))
                            {
                                line = reader.ReadLine();
                            }
                        }

                        ((WhileNotCommand)c).AddCommands(lines);

                        break;

                    case "scrollspeedreset":
                        c = new ResetScrollingSpeedCommand(line);
                        break;

                    case "scrollspeed":
                        c = new NewScrollingSpeedCommand(line);
                        break;

                    case "changemusic":
                        c = new ChangeMusicCommand(line);

                        map.MusicRessourcesToLoad.Add(((ChangeMusicCommand)c).Song);

                        break;

                    case "autogen":
                        c = new EnemyAutoGenerationCommand(line);
                        break;

                    case "addrandombonus":
                        c = new AddRandomBonusCommand(line);
                        break;

                    case "changemusicstate":
                        c = new ChangeMusicStateCommand(line);
                        break;

                    case "wait":
                        c = new WaitCommand(line);
                        break;

                    case "addbomb":
                        c = new AddBombToPlayerCommand(line);
                        break;

                    default:
                        throw new Exception("Unknown TGPA script command " + line);
                    }

                    commands.Add(c);

                    line = reader.ReadLine();
                    while (line.Equals("") || line.StartsWith("//"))
                    {
                        line = reader.ReadLine();
                    }
                } //commands

                e.AddCommands(commands);

                map.Events.Add(e);

                line = reader.ReadLine();
                while (line.Equals("") || line.StartsWith("//"))
                {
                    line = reader.ReadLine();
                }
            } //events

            #endregion

            reader.Close();

            return(map);
        }
Example #29
0
        /// <summary>
        /// Read .tgpa files outside TGPA Game class
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static Map BuildMapFromTGPAFile(String file, Vector2 screenResolution)
        {
            Map map = new Map();

            StreamReader reader = new StreamReader(TitleContainer.OpenStream(file));

            String line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //Check version
            //try
            //{
            //    if (Convert.ToDouble((line.Split(' '))[1]) > Convert.ToDouble(TheGreatPaperGame.version))
            //    {
            //        reader.Close();
            //        throw new Exception("Insupported game version.");
            //    }
            //}
            //catch (FormatException) { throw new Exception("Invalid game version : " + line); } //Bullshit

            map.GameVersion = TheGreatPaperGame.Version;

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //Map informations
            #region Map Infos

            try
            {
                map.Level = Convert.ToInt32((line.Split(' '))[1]);
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid map level number : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            try
            {
                map.lastPart = Convert.ToBoolean(line.Replace("lastpart ", ""));
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid map level lastpart : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            map.Name = LocalizedStrings.GetString(line.Replace("name ", ""));

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            String filedesc = line.Replace("desc ", "");
            map.Description = LocalizedStrings.GetString(filedesc);

            #endregion

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //Backgrounds
            #region Backgrounds

            for (int i = 1; i < 4; i++)
            {
                ScrollingBackground bg = null;

                if (i == 1)
                    bg = map.Background1;
                else if (i == 2)
                    bg = map.Background2;
                else if (i == 3)
                    bg = map.Background3;

                string[] tokens = line.Split(' ');

                ScrollDirection direction = ScrollDirection.Left;

                try
                {
                    direction = ScrollingBackground.String2ScrollDirection(tokens[1]);
                }
                catch (Exception e)
                {
                    Logger.Log(LogLevel.Error, "TGPA Exception : " + e.Message);
                }

                bool inf = false;
                try
                {
                    inf = Convert.ToBoolean(tokens[4]);
                }
                catch (FormatException) { reader.Close(); throw new Exception("Invalid boolean for Infinite scroll : " + line); }

                Vector2 speed = Vector2.Zero;
                try
                {
                    speed = new Vector2(Convert.ToInt32(tokens[2]), Convert.ToInt32(tokens[3]));
                }
                catch (FormatException) { reader.Close(); throw new Exception("Invalid Vector for scroll speed : " + line); }

                bg = new ScrollingBackground(direction, speed, inf);

                //Parts
                while ((line = reader.ReadLine()).Split(' ')[0].Equals("bgpart"))
                {
                    Logger.Log(LogLevel.Info, "BG Found  " + line.Split(' ')[1]);

                    bg.AddBackground(line.Split(' ')[1]);
                }

                if (bg.BackgroundSprites.Count == 0) { reader.Close(); throw new Exception("No BGPart found for Background " + i); }

                if (i == 1)
                    map.Background1 = bg;
                else if (i == 2)
                    map.Background2 = bg;
                else if (i == 3)
                    map.Background3 = bg;

                line = reader.ReadLine();
                while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            }

            #endregion

            //Initialization
            #region Init

            if (!line.Split(' ')[0].Equals("init"))
            {
                reader.Close();
                throw new Exception("Invalid TGPA map : init section not found");
            }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //level music
            string[] tokens2 = line.Split('\"');
            if (tokens2.Length < 4)
            {
                Console.WriteLine("No music loaded");
            }
            else
            {
                map.Music = new MySong(tokens2[0].Split(' ')[1], tokens2[1], tokens2[3]);
            }
            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //Initial datas
            try
            {
                map.InitialScore = Convert.ToInt32(line.Split(' ')[1]);
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid integer for score : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            try
            {
                map.InitialLivesCount = Convert.ToInt32(line.Split(' ')[1]);
            }
            catch (FormatException) { reader.Close(); throw new Exception("Invalid integer for lives : " + line); }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            string weaponName = line.Split(' ')[1];
            map.InitialWeapon = Weapon.TypeToWeapon(weaponName);

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //Initial loc
            Vector2 initialPlayerLoc = new Vector2(Convert.ToInt32(line.Split(' ')[1]), Convert.ToInt32(line.Split(' ')[2]));
            map.InitialPlayerLocation = initialPlayerLoc;

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //Initial flip
            string sFlip = line.Split(' ')[1];
            SpriteEffects flip = SpriteEffects.None;

            if (sFlip.Equals(SpriteEffects.FlipHorizontally.ToString()))
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else if (sFlip.Equals(SpriteEffects.FlipVertically.ToString()))
            {
                flip = SpriteEffects.FlipVertically;
            }

            map.InitialFlip = flip;

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //End conditions
            Event endmap = new Event(Vector2.Zero, null);
            String winflag = line.Split(' ')[1];
            line = reader.ReadLine();
            String loseflag = line.Split(' ')[1];
            endmap.AddCommand(new EndLevelCommand(winflag, loseflag));

            map.Events.Add(endmap);

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            ScrollDirection outDirection = ScrollingBackground.String2ScrollDirection(line.Split(' ')[1]);
            map.OutDirection = outDirection;

            #endregion

            //Script
            #region Script event

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            if (!line.Split(' ')[0].Equals("begin"))
            {
                reader.Close();
                throw new Exception("Invalid TGPA map : begin keyword not found");
            }

            line = reader.ReadLine();
            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            //Read all events
            while (!line.Split(' ')[0].Equals("end"))
            {
                tokens2 = line.Split(' ');

                if (!tokens2[0].Equals("event"))
                {
                    reader.Close();
                    throw new Exception("Invalid TGPA map : event section missing (line : " + line + ")");
                }

                Vector2 vector = Vector2.Zero;
                try
                {
                    vector = new Vector2((float)Convert.ToDouble(tokens2[2]), (float)Convert.ToDouble(tokens2[3]));
                }
                catch (FormatException) { reader.Close(); throw new Exception("Invalid Vector for event scroll value : " + line); }

                line = reader.ReadLine();
                tokens2 = line.Split(' ');
                if (!tokens2[0].Equals("start"))
                {
                    reader.Close();
                    throw new Exception("Invalid TGPA map : start keyword missing");
                }

                String startFlag = null;
                IfCommand ifc = null;

                try
                {
                    startFlag = line.Split(' ')[1];
                    if (!startFlag.Equals("")) ifc = new IfCommand(startFlag);
                }
                catch (IndexOutOfRangeException) { }

                Event e = new Event(vector, ifc);

                line = reader.ReadLine();
                while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

                List<Command> commands = new List<Command>();

                //Add actions
                while (!line.Split(' ')[0].Equals("endevent"))
                {
                    Command c = null;

                    switch (line.Split(' ')[0])
                    {
                        case "addenemy":
                            c = new AddEnemyCommand(line, screenResolution);

                            AddEnemyRessourcesToLoadIfNecessary(map, (AddEnemyCommand)c);

                            break;

                        case "addbge":
                            c = new AddBackgroundElementCommand(line, screenResolution);
                            AddBGERessourcesToLoadIfNecessary(map, (AddBackgroundElementCommand)c);
                            break;

                        case "if":
                            c = new IfCommand(line);
                            break;

                        case "set":
                            c = new SetFlagCommand(line, true);
                            break;

                        case "unset":
                            c = new UnsetFlagCommand(line, true);
                            break;

                        case "whilenot":
                            c = new WhileNotCommand(line);

                            line = reader.ReadLine();
                            while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

                            List<String> lines = new List<String>();
                            while (!line.Split(' ')[0].Equals("done"))
                            {
                                if (line.Split(' ')[0].Equals("addenemy"))
                                {
                                    AddEnemyRessourcesToLoadIfNecessary(map, new AddEnemyCommand(line, screenResolution));
                                }
                                lines.Add(line);

                                line = reader.ReadLine();
                                while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();
                            }

                            ((WhileNotCommand)c).AddCommands(lines);

                            break;

                        case "scrollspeedreset":
                            c = new ResetScrollingSpeedCommand(line);
                            break;

                        case "scrollspeed":
                            c = new NewScrollingSpeedCommand(line);
                            break;

                        case "changemusic":
                            c = new ChangeMusicCommand(line);

                            map.MusicRessourcesToLoad.Add(((ChangeMusicCommand)c).Song);

                            break;

                        case "autogen":
                            c = new EnemyAutoGenerationCommand(line);
                            break;

                        case "addrandombonus":
                            c = new AddRandomBonusCommand(line);
                            break;

                        case "changemusicstate":
                            c = new ChangeMusicStateCommand(line);
                            break;

                        case "wait":
                            c = new WaitCommand(line);
                            break;

                        case "addbomb":
                            c = new AddBombToPlayerCommand(line);
                            break;

                        default:
                            throw new Exception("Unknown TGPA script command " + line);
                    }

                    commands.Add(c);

                    line = reader.ReadLine();
                    while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();
                } //commands

                e.AddCommands(commands);

                map.Events.Add(e);

                line = reader.ReadLine();
                while (line.Equals("") || line.StartsWith("//")) line = reader.ReadLine();

            } //events

            #endregion

            reader.Close();

            return map;
        }
Example #30
0
 void Start()
 {
     _pauseMenu           = GameObject.FindGameObjectWithTag(TAG_PAUSE_MENU_OBJ);
     _scrollingBackground = GameObject.FindGameObjectWithTag(TAG_SCROLLING_BG).GetComponent <ScrollingBackground>();
     _inputManager        = GameObject.FindGameObjectWithTag(TAG_TOUCH).GetComponent <InputManager>();
 }
Example #31
0
        public override void Initialize(ContentManager contentManager)
        {
            _contentManager = contentManager;

            Texture2D stageTexture        = _contentManager.Load <Texture2D>(AssetManager.Stage);
            Texture2D playerTexture       = _contentManager.Load <Texture2D>(AssetManager.PlayerFlipped);
            Texture2D scrollerRope        = _contentManager.Load <Texture2D>(AssetManager.BackgroundRopes);
            Texture2D winWrestler         = _contentManager.Load <Texture2D>(AssetManager.WinWrestler);
            Texture2D backgroundTexture   = _contentManager.Load <Texture2D>(AssetManager.GameBG);
            Texture2D wrestlingBackground = _contentManager.Load <Texture2D>(AssetManager.WrestingBackground);

            _stage = new Sprite(stageTexture)
            {
                Scale = GameInfo.StageScale
            };
            _stage.SetOriginCenter();

            _playerSprite = new Sprite(playerTexture)
            {
                Scale = GameInfo.PlayerAssetScale
            };
            _playerSprite.SetOriginCenter();

            _playerFlasher = new ColorFlashSwitcher()
            {
                StartFlash         = false,
                StartColor         = Color.White * 1,
                EndColor           = Color.White * 0,
                FlashCount         = GameInfo.PlayerFlashCount,
                LerpRate           = GameInfo.PlayerFlashRate,
                ResetAutomatically = true
            };

            _backgroundSprite = new Sprite(backgroundTexture, true);
            _backgroundSprite.SetOriginCenter();
            _backgroundSprite.SetSize(GameInfo.FixedWindowWidth, GameInfo.FixedWindowHeight);

            _audienceScrolling = new ScrollingBackground();
            _audienceScrolling.Initialize(wrestlingBackground, GameInfo.MaxBackgroundElements,
                                          new Vector2(GameInfo.FixedWindowWidth / 2.0f, GameInfo.FixedWindowHeight), 1, true);
            _audienceScrolling.SetSize(GameInfo.FixedWindowWidth, GameInfo.FixedWindowHeight);

            _cinematicBackgroundScroller = new CinematicBackgroundScroller();
            _cinematicBackgroundScroller.Initialize(scrollerRope, 0.5f, GameInfo.TotalCinematicRopes,
                                                    GameInfo.CinematicStageInitialPosition, GameInfo.CinematicRowFinalPosition);

            _winWrestler = new Sprite(winWrestler)
            {
                Scale = GameInfo.WrestlerScale
            };
            _winWrestler.SetOriginCenter();

            _starSpriteSheetAnimationManager = new SpriteSheetAnimationManager();
            _starSpriteSheetAnimationManager.Initialize(_contentManager, AssetManager.StarBase,
                                                        AssetManager.StarTotalCount, 0, true);
            _starSpriteSheetAnimationManager.FrameTime = AssetManager.StarAnimationSpeed;
            _starSprite       = _starSpriteSheetAnimationManager.Sprite;
            _starSprite.Scale = 0.4f;
            _starsOffset      = new Vector2(_winWrestler.Width - 50, 70);

            _dummyPlayer = new Player();
            _dummyPlayer.Initialize(_contentManager);
            _dummyPlayer.OnPlayerHitNotification += HandlePlayerHit;

            CreateAudiences();
            CreateSounds();
        }
 void Start()
 {
     _bg = ScrollingBackground.instance;
 }