コード例 #1
0
        /// <summary>
        /// Creates a new level editor.
        /// </summary>
        /// <param name="audioPlayer">The AudioPlayer intance 
        ///                           that playes all the sound effects</param>
        /// <param name="content">Used ContentManager</param>
        /// <param name="pSpriteBatch">Used SpriteBatch</param>
        public LevelEditor(AudioPlayer audioPlayer, ContentManager content)
            : base(audioPlayer, content)
        {
            bikePosTexture = content.Load<Texture2D>("Images/bikePos");
            bikePosDestination = bikePosUnActiveDestination;
            bike.SetInitPos(bikePosDestination.X, bikePosDestination.Y);

            CreateUI(content);

            activeZoomButton = unZoomButton;
            TireFail += new Action<Level>(CloseTesting);
            HeadFail += new Action<Level>(CloseTesting);
            Win += new Action<Level>(CloseTesting);
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: hizorro/moto-trial-racer-wp
        /// <summary>
        /// Creates a new predefined level
        /// </summary>
        /// <param name="number">The number of the level (1, 2 or 3)</param>
        /// <param name="pAudioPlayer">The AudioPlayer intance that playes all the sound 
        ///                            effects</param>
        /// <param name="pContent">Used ContentManager</param>
        /// <param name="pSpriteBatch">Used SpriteBatch</param>
        public Level(int number, AudioPlayer pAudioPlayer, ContentManager pContent)
        {
            content = pContent;
            audioPlayer = pAudioPlayer;
            world = new World(new Vector2(0.0f, 5.0f), true);
            world.ContactListener = this;
            rotationData = new RotationData();
            bike = new Bike(bikeSpeed, rotationData, world, camPos, content);
            provider.NumberDecimalSeparator = ".";

            try
            {
                using (Stream stream = TitleContainer.OpenStream("Content/Levels/Level_" + number + ".lvl"))
                {
                    LoadLevel(stream);
                }
            }
            catch (FileNotFoundException)
            {
            }
        }
コード例 #3
0
ファイル: Level.cs プロジェクト: hizorro/moto-trial-racer-wp
        /// <summary>
        /// Creates a new user defined custom level
        /// </summary>
        /// <param name="fileName">The name of the file that defines the level</param>
        /// <param name="pAudioPlayer">The AudioPlayer intance that playes all the sound 
        ///                            effects</param>
        /// <param name="pContent">Used ContentManager</param>
        public Level(String fileName, AudioPlayer pAudioPlayer, ContentManager pContent)
        {
            content = pContent;
            audioPlayer = pAudioPlayer;
            world = new World(new Vector2(0.0f, 5.0f), true);
            world.ContactListener = this;
            rotationData = new RotationData();
            bike = new Bike(bikeSpeed, rotationData, world, camPos, content);
            provider.NumberDecimalSeparator = ".";

            IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication();

            // open isolated storage, and read the savefile.
            if (savegameStorage.FileExists(fileName))
            {
                using (IsolatedStorageFileStream fs = savegameStorage.OpenFile(fileName, System.IO.FileMode.Open))
                {
                    LoadLevel(fs);
                }
            }
        }
コード例 #4
0
ファイル: Level.cs プロジェクト: hizorro/moto-trial-racer-wp
 /// <summary>
 /// Create a new empty level with no components in it
 /// </summary>
 /// <param name="pAudioPlayer">The AudioPlayer intance that playes all the sound 
 ///                            effects</param>
 /// <param name="pContent">Used ContentManager</param>
 public Level(AudioPlayer pAudioPlayer, ContentManager pContent)
 {
     content = pContent;
     audioPlayer = pAudioPlayer;
     world = new World(new Vector2(0.0f, 5.0f), true);
     world.ContactListener = this;
     rotationData = new RotationData();
     bike = new Bike(bikeSpeed, rotationData, world, camPos, content);
 }
コード例 #5
0
ファイル: Game1.cs プロジェクト: hizorro/moto-trial-racer-wp
        /// <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);
            audioPlayer = new AudioPlayer(Content);
            level = new Level(1, audioPlayer, this.Content);
            level.HeadFail += new Action<Level>(HeadFail);
            level.TireFail += new Action<Level>(TireFail);
            level.Win += new Action<Level>(Win);
            background = this.Content.Load<Texture2D>("Images/sky");
            font = this.Content.Load<SpriteFont>("SpriteFont3");
            view = new SplashScreen(this);
            optionsButton = new Button("options",
                                        new Vector2(getWidth() * 0.015f, getHeight() * 0.89f),
                                                    this.Content);
            optionsButton.ButtonPressed += (sender => Pause());

            float aspect = (float)optionsButton.Width / (float)optionsButton.Height;
            optionsButton.Height = (int)(0.1f * getHeight());
            optionsButton.Width = (int)(aspect * optionsButton.Height);
            exitButton = new Button("exit",
                                    new Vector2(getWidth() * 0.89f, getHeight() * 0.88f),
                                    this.Content);
            exitButton.ButtonPressed += (sender => Exit());

            aspect = (float)exitButton.Width / (float)exitButton.Height;
            exitButton.Height = (int)(0.1f * (float)getHeight());
            exitButton.Width = (int)(aspect * (float)exitButton.Height);
            leftButton = new Button("left", new Vector2(10, 20),
                                    this.Content, true);
            leftButton.ButtonPressed += (sender => level.leanBikeBackwards());
            leftButton.Height = 70;

            rightButton = new Button("right", new Vector2(relativeX(735), relativeY(20)),
                                     this.Content, true);
            rightButton.Height = 70;
            rightButton.ButtonPressed += (sender => level.leanBikeForwards());

            clockPos = new Vector2(0.45f * getWidth(), 0.89f * getHeight());
        }