예제 #1
0
파일: Game1.cs 프로젝트: Keatsotic/Animus
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     debugFont    = Content.Load <SpriteFont>("Fonts/DebugFont");
     font         = Content.Load <SpriteFont>("Fonts/megaman");
     screens.Load(Content);
     loadScreen.Load(Content);
     sceneCreator.LevelLoader(Content, graphics.GraphicsDevice, _objects, levelNumber, checkPoint, true);
 }
예제 #2
0
 public void ChooseSaveFIle(List <GameObject> _objects,
                            SceneCreator sceneCreator,
                            ContentManager content,
                            GraphicsDevice graphics,
                            LoadScreen loadScreen)
 {
     if (loadScreen.menuIndex != 4)
     {
         Game1.saveSlot = loadScreen.menuIndex;
         if (loadScreen.deleteMode)
         {
             XmlSerialization.WriteToXmlFile("SaveFile0" + Game1.saveSlot + ".txt", emptyList);
             XmlSerialization.WriteToXmlFile("HealthFile0" + Game1.saveSlot + ".txt", 3);
             loadScreen.menuIndex  = 1;
             loadScreen.deleteMode = false;
             //Console.WriteLine("file deleted");
         }
         else
         {
             Game1.inMenu              = false;
             Game1.levelNumber         = "0";
             Game1._destroyedPermanent = XmlSerialization.ReadFromXmlFile <List <string> >("SaveFile0" + Game1.saveSlot + ".txt");
             HUD.playerMaxHealth       = XmlSerialization.ReadFromXmlFile <int>("HealthFile0" + Game1.saveSlot + ".txt");
             sceneCreator.UnloadObjects(true, _objects);
             sceneCreator.LevelLoader(content, graphics, _objects, Game1.levelNumber, Game1.checkPoint, true);
         }
     }
     else
     {
         if (loadScreen.deleteMode)
         {
             loadScreen.deleteMode = false;
         }
         else
         {
             loadScreen.deleteMode = true;
             loadScreen.menuIndex  = 1;
         }
     }
 }
예제 #3
0
        //IS PLAYER DEAD?
        public void CheckForDeath(List <GameObject> _objects,
                                  SceneCreator sceneCreator,
                                  GraphicsDeviceManager graphics,
                                  ContentManager content,
                                  string roomNumber)
        {
            if (playerDead)
            {
                if (SceneCreator.soundEffectInstance != null)
                {
                    SceneCreator.soundEffectInstance.Stop(true);
                    SceneCreator.soundEffectInstance.Dispose();
                }

                deathTimer--;

                if (deathTimer <= 0)
                {
                    HUD.playerHealth       = HUD.playerMaxHealth;
                    _objects[0].invincible = false;

                    sceneCreator.UnloadObjects(true, _objects);

                    if (HUD.playerLives > 0)
                    {
                        HUD.playerLives--;
                        Game1.inMenu = false;

                        sceneCreator.LevelLoader(content,
                                                 graphics.GraphicsDevice,
                                                 _objects,
                                                 Game1.levelNumber,
                                                 roomNumber,
                                                 true);

                        Camera.LookAt(_objects[0].position);
                    }

                    if (HUD.playerLives == 0)
                    {
                        HUD.playerLives   = 3;
                        Game1.levelNumber = "GameOver";
                        Game1.checkPoint  = roomNumber = "1";
                        Game1.inMenu      = true;
                        HUD.rupeeCount    = 0;

                        //clear respawn list
                        foreach (var obj in Game1._destroyedObjects)
                        {
                            clearList.Add(obj);
                        }
                        foreach (string o in clearList)
                        {
                            Game1._destroyedObjects.Remove(o);
                        }

                        sceneCreator.LevelLoader(content,
                                                 graphics.GraphicsDevice,
                                                 _objects,
                                                 Game1.levelNumber,
                                                 roomNumber,
                                                 true);

                        XmlSerialization.WriteToXmlFile("SaveFile0" + Game1.saveSlot + ".txt", Game1._destroyedPermanent);
                        XmlSerialization.WriteToXmlFile("HealthFile0" + Game1.saveSlot + ".txt", HUD.playerMaxHealth);
                    }
                    PauseMenu.active = false;
                    deathTimer       = deathTimerMax;
                    playerDead       = false;
                }
            }
        }
예제 #4
0
파일: Screens.cs 프로젝트: Keatsotic/Animus
        public void ScreenTransition(List <GameObject> _objects,
                                     GraphicsDeviceManager graphics,
                                     ContentManager content,
                                     SceneCreator sceneCreator,
                                     string direction,
                                     string roomNumber)
        {
            //sliding screens
            if (roomPlaceHolder != "Overworld" && Game1.levelNumber != "Overworld" && !fading)
            {
                if (direction == "right")
                {
                    Camera.cameraMin.X      = Camera.position.X;
                    _objects[0].position.Y  = _objects[0].position.Y;
                    _objects[0].position.X += 0.5f;
                    Camera.cameraMin.X     += 8;
                    Camera.cameraMax.X     += 8;
                }
                if (direction == "left")
                {
                    Camera.cameraMax.X      = Camera.position.X;
                    _objects[0].position.Y  = _objects[0].position.Y;
                    _objects[0].position.X -= 0.5f;
                    Camera.cameraMin.X     -= 8;
                    Camera.cameraMax.X     -= 8;
                }
                screenTimer--;

                if (screenTimer < 0)
                {
                    sceneCreator.UnloadObjects(false, _objects);
                    roomNumber       = roomPlaceHolder;
                    Game1.checkPoint = roomNumber;
                    Door.doorEnter   = false;
                    screenTimer      = 50;
                    sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, roomNumber, false);
                    Entity.applyGravity = true;
                }
            }

            if ((roomPlaceHolder == "Overworld" || Game1.levelNumber == "Overworld") || fading)
            {
                FadeInOut();

                if (fadeComplete && screenTimer <= 0 && roomPlaceHolder == "Overworld")
                {
                    sceneCreator.UnloadObjects(true, _objects);
                    Game1.levelNumber   = roomPlaceHolder;
                    Entity.applyGravity = false;
                    sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, "1", true);
                }
                else if (fadeComplete && screenTimer <= 0 && Game1.levelNumber == "Overworld")
                {
                    sceneCreator.UnloadObjects(true, _objects);
                    Game1.levelNumber   = roomPlaceHolder;
                    Entity.applyGravity = true;
                    sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, "1", true);
                }
                if (fadeComplete)
                {
                    fadeComplete = false;
                    fadeOut      = true;
                    screenTimer  = 50;

                    // save the game
                    XmlSerialization.WriteToXmlFile("SaveFile0" + Game1.saveSlot + ".txt", Game1._destroyedPermanent);
                    XmlSerialization.WriteToXmlFile("HealthFile0" + Game1.saveSlot + ".txt", HUD.playerMaxHealth);
                }
            }
        }