示例#1
0
文件: User.cs 项目: franciscofm/TFG
        public static bool LoadConfiguration()
        {
            string path = DataPath();

            Debug.Log(path);
            if (!System.IO.File.Exists(path))
            {
                volume_master  = 1f;
                volume_effects = 1f;
                volume_music   = 1f;
                volume_voice   = 1f;
                classic_nodes  = false;
                classic_ifaces = false;
                first_time     = true;
                cleared_levels = new List <string> ();
                lenguage       = GetUserLanguage();
                SaveConfiguration();
                return(false);
            }

            SaveFile saveFile = JsonUtility.FromJson <SaveFile> (System.IO.File.ReadAllText(path));

            volume_master  = saveFile.volume_master;
            volume_effects = saveFile.volume_effects;
            volume_music   = saveFile.volume_music;
            volume_voice   = saveFile.volume_voice;
            lenguage       = saveFile.lenguage;
            classic_ifaces = saveFile.classic_ifaces;
            classic_nodes  = saveFile.classic_nodes;
            cleared_levels = saveFile.cleared_levels;
            first_time     = false;
            return(true);
        }
示例#2
0
    public void Load_Direct_Scene(string Scene_direction)
    {
        // Desuscripcion
        Lenguage.Off_Event();

        // Comprobando : Game_Paused
        Pause_Is_True();

        SceneManager.LoadScene(Scene_direction);
    }
    public void Show()
    {
        //add
        bool     enterPressed = false;
        bool     escPressed   = false;
        Lenguage len          = new Lenguage();
        int      option       = SelectLenguage.option;

        do
        {
            hardware.ClearScreen();
            hardware.DrawImage(imgWelcome);
            hardware.DrawImage(imgChosenOption);
            fontPlay = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                   len.Change(option, 0), yellow);
            hardware.WriteText(fontPlay, 325, 430);
            fontCreation = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                       len.Change(option, 1), yellow);
            hardware.WriteText(fontCreation, 325, 475);
            fontControl = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                      len.Change(option, 2), yellow);
            hardware.WriteText(fontControl, 325, 520);
            fontCredits = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                      len.Change(option, 3), yellow);
            hardware.WriteText(fontCredits, 325, 565);
            fontExit = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                   len.Change(option, 4), yellow);
            hardware.WriteText(fontExit, 325, 610);

            int keyPressed = hardware.KeyPressed();
            if (keyPressed == Hardware.KEY_UP && chosenOption > 1)
            {
                audio.PlayWAV(0, 1, 0);
                chosenOption--;
                imgChosenOption.MoveTo(245, (short)(imgChosenOption.Y - 45));
            }
            else if (keyPressed == Hardware.KEY_DOWN && chosenOption < 5)
            {
                audio.PlayWAV(0, 1, 0);
                chosenOption++;
                imgChosenOption.MoveTo(245, (short)(imgChosenOption.Y + 45));
            }
            else if (keyPressed == Hardware.KEY_ENTER && chosenOption == 5)
            {
                enterPressed = true;
                exit         = true;
            }
            else if (keyPressed == Hardware.KEY_ENTER)
            {
                enterPressed = true;
                exit         = false;
            }
            hardware.UpdateScreen();
        }while (!enterPressed);
    }
示例#4
0
    public void Load_Continue()
    {
        // Desuscripcion
        Lenguage.Off_Event();

        string Saved_world = PlayerPrefs.GetString("World: ");

        Static_Implements.Scene_direction = Saved_world;

        SceneManager.LoadScene("Loading");
    }
示例#5
0
 public void ChangeLenguaje()
 {
     if (currentLenguage == Lenguage.English)
     {
         currentLenguage = Lenguage.Español;
     }
     else if (currentLenguage == Lenguage.Español)
     {
         currentLenguage = Lenguage.English;
     }
 }
示例#6
0
    public void Load(string Scene_direction)
    {
        // Desuscripcion
        Lenguage.Off_Event();

        Static_Implements.Scene_direction = Scene_direction;

        // Comprobando : Game_Paused
        Pause_Is_True();

        SceneManager.LoadScene("Loading");
    }
示例#7
0
        public UserInfo(string name, string password, string mail)
        {
            this.name     = name;
            this.password = password;
            this.mail     = mail;

            isMute   = false;
            lenguage = Lenguage.Spanish;

            pieces  = new List <string>();
            tropies = new List <string>();
        }
    public override void Show()
    {
        //add
        bool     enterPressed = false;
        Lenguage len          = new Lenguage();

        do
        {
            hardware.ClearScreen();
            hardware.DrawImage(imgWelcome);
            hardware.DrawImage(imgChosenOption);

            fontSpanish = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                      len.Change(option, 19), yellow);
            hardware.WriteText(fontSpanish, 325, 430);
            fontEnglish = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                      len.Change(option, 18), yellow);
            hardware.WriteText(fontEnglish, 325, 475);

            int keyPressed = hardware.KeyPressed();
            if (keyPressed == Hardware.KEY_UP && chosenOption > 1)
            {
                audio.PlayWAV(0, 1, 0);
                chosenOption--;
                option = 0;
                imgChosenOption.MoveTo(245, (short)(imgChosenOption.Y - 45));
            }
            else if (keyPressed == Hardware.KEY_DOWN && chosenOption < 2)
            {
                audio.PlayWAV(0, 1, 0);
                chosenOption++;
                option = 1;
                imgChosenOption.MoveTo(245, (short)(imgChosenOption.Y + 45));
            }
            else if (keyPressed == Hardware.KEY_ENTER && chosenOption == 1)
            {
                enterPressed = true;
                exit         = true;
            }
            else if (keyPressed == Hardware.KEY_ENTER && chosenOption == 2)
            {
                enterPressed = true;
                exit         = true;
            }
            hardware.UpdateScreen();
        }while (!enterPressed);
    }
示例#9
0
    public void Load_New_Game()
    {
        string Saved_world = PlayerPrefs.GetString("World: ");

        if (Saved_world != "")
        {
            foreach (GameObject interactable in Interactable)
            {
                interactable.GetComponent <Button>().interactable = false;
            }
            foreach (GameObject to_active in To_active)
            {
                to_active.SetActive(true);
            }
        }
        else
        {
            // Desuscripcion
            Lenguage.Off_Event();

            SceneManager.LoadScene("World_1");
        }
    }
    public override void Show()
    {
        bool     enterPressed = false;
        bool     escPressed   = false;
        Lenguage len          = new Lenguage();
        int      option       = SelectLenguage.option;

        do
        {
            hardware.ClearScreen();
            hardware.DrawImage(imgController);
            fControls = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                    len.Change(option, 2), yellow);
            hardware.WriteText(fControls, 400, 400);
            fUp = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                              len.Change(option, 10), yellow);
            hardware.WriteText(fUp, 115, 650);
            hardware.WriteText(fUp, 590, 680);
            fDown = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                len.Change(option, 11), yellow);
            hardware.WriteText(fDown, 590, 710);
            hardware.WriteText(fDown, 115, 710);
            fLeft = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                len.Change(option, 12), yellow);
            hardware.WriteText(fLeft, 590, 650);
            hardware.WriteText(fLeft, 725, 680);
            fRight = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                 len.Change(option, 13), yellow);
            hardware.WriteText(fRight, 115, 680);
            hardware.WriteText(fRight, 270, 710);
            fPause = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                 len.Change(option, 14), yellow);
            hardware.WriteText(fPause, 380, 655);
            fEsc = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                               len.Change(option, 15), yellow);
            hardware.WriteText(fEsc, 385, 680);
            fBomb = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                len.Change(option, 22), yellow);
            hardware.WriteText(fBomb, 270, 680);
            hardware.WriteText(fBomb, 725, 710);
            FPW = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                              len.Change(option, 16), yellow);
            hardware.WriteText(FPW, 160, 730);
            FPR = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                              len.Change(option, 17), yellow);
            hardware.WriteText(FPR, 615, 730);
            hardware.UpdateScreen();

            int keyPressed = hardware.KeyPressed();
            if (keyPressed == Hardware.KEY_ESC)
            {
                escPressed = true;
                exit       = false;
            }
            else if (keyPressed == Hardware.KEY_ENTER)
            {
                enterPressed = true;
                exit         = false;
            }
        } while (!escPressed && !enterPressed);
    }
示例#11
0
    public void Show(string filename)
    {
        short oldXWhite, oldYWhite, oldXMapWhite, oldYMapWhite;
        short oldXRed, oldYRed, oldXMapRed, oldYMapRed;
        bool  escPressed = false;

        level = new Level("levels/" + filename);
        playerWhite.MoveTo(40, 40);
        playerRed.MoveTo(760, 560);
        var timer = new Timer(this.DecreaseTime, null, 1000, 1000);

        audio.PlayMusic(0, -1);
        Lenguage len    = new Lenguage();
        int      option = SelectLenguage.option;

        do
        {
            // 1. Draw Map
            hardware.ClearScreen();
            hardware.DrawImage(imgInfo);
            hardware.DrawImage(imgFloor);
            hardware.WriteText(fontTime, 362, 700);
            fontPause = SdlTtf.TTF_RenderText_Solid(font28.GetFontType(),
                                                    len.Change(option, 14), white);
            hardware.WriteText(fontPause, 525, 705);

            foreach (Brick brick in level.Bricks)
            {
                hardware.DrawSprite(Sprite.spritesheet,
                                    (short)(brick.X - level.XMap),
                                    (short)(brick.Y - level.YMap),
                                    brick.SpriteX, brick.SpriteY,
                                    Sprite.SPRITE_WIDTH,
                                    Sprite.SPRITE_HEIGHT);
            }

            foreach (BrickDestroyable bdes in level.BricksDestroyable)
            {
                hardware.DrawSprite(Sprite.spritesheet,
                                    (short)(bdes.X - level.XMap),
                                    (short)(bdes.Y - level.YMap),
                                    bdes.SpriteX, bdes.SpriteY,
                                    Sprite.SPRITE_WIDTH,
                                    Sprite.SPRITE_HEIGHT);
            }

            foreach (Weapons bomb in playerWhite.Bombs)
            {
                hardware.DrawSprite(Sprite.spritesheet,
                                    (short)(bomb.X - level.XMap),
                                    (short)(bomb.Y - level.YMap),
                                    bomb.SpriteX, bomb.SpriteY,
                                    Sprite.SPRITE_WIDTH,
                                    Sprite.SPRITE_HEIGHT);
            }

            foreach (Weapons bomb in playerRed.Bombs)
            {
                hardware.DrawSprite(Sprite.spritesheet,
                                    (short)(bomb.X - level.XMap),
                                    (short)(bomb.Y - level.YMap),
                                    bomb.SpriteX, bomb.SpriteY,
                                    Sprite.SPRITE_WIDTH,
                                    Sprite.SPRITE_HEIGHT);
            }

            hardware.DrawSprite(Sprite.spritesheet,
                                (short)(playerWhite.X - level.XMap),
                                (short)(playerWhite.Y - level.YMap),
                                playerWhite.SpriteXWhite, playerWhite.SpriteYWhite,
                                Sprite.SPRITE_WIDTH, Sprite.SPRITE_HEIGHT);

            hardware.DrawSprite(Sprite.spritesheet,
                                (short)(playerRed.X - level.XMap),
                                (short)(playerRed.Y - level.YMap),
                                playerRed.SpriteXRed, playerRed.SpriteYRed,
                                Sprite.SPRITE_WIDTH, Sprite.SPRITE_HEIGHT);

            hardware.UpdateScreen();

            int keyPressed = hardware.KeyPressed();
            if (keyPressed == Hardware.KEY_ESC)
            {
                escPressed = true;
            }

            // 2.  Move character from keyboard input
            // Coordinates Player White
            oldXWhite    = playerWhite.X;
            oldYWhite    = playerWhite.Y;
            oldXMapWhite = level.XMap;
            oldYMapWhite = level.YMap;

            // Coordinates Player Red
            oldXRed    = playerRed.X;
            oldYRed    = playerRed.Y;
            oldXMapRed = level.XMap;
            oldYMapRed = level.YMap;

            movePlayer();
            if (keyPressed == Hardware.KEY_NENTER)
            {
                playerWhite.AddBomb();
            }
            if (keyPressed == Hardware.KEY_SPACE)
            {
                playerRed.AddBomb();
            }
            if (hardware.IsKeyPressed(Hardware.KEY_P))
            {
                timer.Dispose();
                controller.Show();
                timer = new Timer(this.DecreaseTime, null, 1000, 1000);
            }
            // 3.  Check collisions and update game state
            if (playerWhite.CollidesWith(level.Bricks) ||
                playerWhite.CollidesWith(level.BricksDestroyable))
            {
                playerWhite.X = oldXWhite;
                playerWhite.Y = oldYWhite;
                level.XMap    = oldXMapWhite;
                level.YMap    = oldYMapWhite;
            }

            if (playerRed.CollidesWith(level.Bricks) ||
                playerRed.CollidesWith(level.BricksDestroyable))
            {
                playerRed.X = oldXRed;
                playerRed.Y = oldYRed;
                level.XMap  = oldXMapRed;
                level.YMap  = oldYMapRed;
            }

            //Pause Game
            Thread.Sleep(20);
        }while (!escPressed);
        timer.Dispose();
        audio.StopMusic();
    }
示例#12
0
文件: User.cs 项目: franciscofm/TFG
 public static bool ChangeLenguage(Lenguage l)
 {
     lenguage = l;
     return(true);
 }
示例#13
0
    public override void Show()
    {
        bool     enterPressed = false;
        bool     escPressed   = false;
        Lenguage len          = new Lenguage();
        int      option       = SelectLenguage.option;



        LoadMaps();


        do
        {
            hardware.ClearScreen();
            hardware.DrawImage(imgSetting);
            hardware.DrawImage(imgChosenOption);
            fontChange = SdlTtf.TTF_RenderText_Solid(font42.GetFontType(),
                                                     len.Change(option, 5), yellow);
            fontPlayer = SdlTtf.TTF_RenderText_Solid(font42.GetFontType(),
                                                     len.Change(option, 7), yellow);
            hardware.WriteText(fontPlayer, 50, 500);
            hardware.WriteText(fontPlayer, 550, 500);
            hardware.WriteText(fontChange, 200, 240);
            hardware.WriteText(fontMap, 360, 250);


            int keyPressed = hardware.KeyPressed();
            if (keyPressed == Hardware.KEY_UP && chosenOption > 1)
            {
                audio.PlayWAV(0, 1, 0);
                chosenOption--;
                imgChosenOption.MoveTo(140, (short)(imgChosenOption.Y - 180));
            }
            else if (keyPressed == Hardware.KEY_DOWN && chosenOption < 2)
            {
                audio.PlayWAV(0, 1, 0);
                chosenOption++;
                imgChosenOption.MoveTo(220, (short)(imgChosenOption.Y + 180));
            }
            // Option 1: change Map
            else if (chosenOption == 1 && keyPressed == Hardware.KEY_RIGHT)
            {
                if (count < map.Length - 1)
                {
                    count++;
                    DrawOption();
                }
            }
            else if (chosenOption == 1 && keyPressed == Hardware.KEY_LEFT)
            {
                if (count > 0)
                {
                    count--;
                    DrawOption();
                }
            }
            else if (chosenOption == 1 && keyPressed == Hardware.KEY_DELETE)
            {
                File.Delete(@".\levels\" + map[count]);
                LoadMaps();
                string[] tmp = map[count].Split('.');
                fontMap = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                      tmp[0], white);
                hardware.WriteText(fontMap, 360, 250);
            }
            else if (chosenOption == 1)
            {
                DrawOption();
            }

            // Option 2: Start Game
            else if (chosenOption == 2 && keyPressed == Hardware.KEY_ENTER)
            {
                game.Show(map[count]);
            }

            else if (keyPressed == Hardware.KEY_ESC)
            {
                escPressed = true;
                exit       = false;
            }
            else if (keyPressed == Hardware.KEY_ENTER)
            {
                enterPressed = true;
                exit         = false;
            }
            else
            {
                string[] tmp = map[count].Split('.');
                fontMap = SdlTtf.TTF_RenderText_Solid(font.GetFontType(),
                                                      tmp[0], white);
                hardware.WriteText(fontMap, 360, 250);
            }

            hardware.UpdateScreen();
        }while (!escPressed && !enterPressed);
    }