Example #1
0
    private IEnumerator loadShop()
    {
        while (!IAPManager.Instance.IsInitialized())
        {
            yield return(null);
        }
        for (int i = 0; i < panel.transform.childCount; i++)
        {
            panel.transform.GetChild(i).transform.GetChild(0).GetComponent <Image>().sprite = notOwnedItem;
        }
        buttonBuyTrue.SetActive(true);
        buttonBuyFalse.SetActive(false);

        if (!SaveAndLoad.playerHaveAds())
        {
            panel.transform.GetChild(2).transform.GetChild(0).GetComponent <Image>().sprite = ownedItem;
            panel.transform.GetChild(2).transform.GetChild(2).gameObject.SetActive(true);
            panel.transform.GetChild(2).transform.GetChild(4).gameObject.SetActive(false);
        }
        if (selectedIndex == 2)
        {
            if (!SaveAndLoad.playerHaveAds())
            {
                buttonBuyTrue.SetActive(false);
                buttonBuyFalse.SetActive(true);
            }
        }
        panel.transform.GetChild(selectedIndex).transform.GetChild(0).GetComponent <Image>().sprite = selectedItem;
    }
Example #2
0
        private void CreateAudioPrefab(int levelSize)
        {
            GameObject go = new GameObject();

            Manager.AudioTree = AudioNodeWorker.CreateTree(go, levelSize);
            SaveAndLoad.CreateAudioNodeRootPrefab(go);
        }
Example #3
0
        public VoidResult Initialize(SaveAndLoad sal)
        {
            this.SaveAndLoad = sal;
            this.SaveAndLoad.Pyrite = this;

            var result = new VoidResult();

            ScenariosPool = new ScenariosPool();
            ScenariosPool.Pyrite = this;
            ScenariosPool.Initialize();
            Log.Write("ScenariosPool initialized");

            ModulesControl = new ModulesControl();
            ModulesControl.Pyrite = this;
            result.AddExceptions(ModulesControl.Initialize().Exceptions);
            Log.Write("ModulesControl initialized");
            ServerThreading = new PyriteCore.ServerThreading();
            ServerThreading.Pyrite = this;
            ServerThreading.ServerStarted += () => ScenariosPool.StartActiveScenarios();
            Log.Write("ScenariosPool items started");
            ServerThreading.Initialize();
            Log.Write("ServerThreading started");

            result.AddExceptions(SaveAndLoad.Load().Exceptions);
            result.AddExceptions(ServerThreading.BeginStart().Exceptions);

            return result;
        }
Example #4
0
        private void CreateBankLinkPrefab()
        {
            GameObject go = new GameObject();

            Manager.BankLinkTree = AudioBankWorker.CreateTree(go);
            SaveAndLoad.CreateAudioBankLinkPrefab(go);
        }
Example #5
0
 void Start()
 {
     // Load past highscore data
     SaveAndLoad.Load();
     score.text     = "SCORE: " + PlayerStats.LastScore.ToString();
     highscore.text = "HIGHSCORE: " + PlayerStats.Highscore.ToString();
 }
Example #6
0
    public void Load(bool forceReload = false)
    {
        if (AudioRoot == null || BankLinkRoot == null || BusRoot == null || EventRoot == null || forceReload)
        {
            Component[] audioData;
            Component[] eventData;
            Component[] busData;
            Component[] bankLinkData;

            SaveAndLoad.LoadManagerData(out audioData, out eventData, out busData, out bankLinkData);
            BusRoot      = CheckData <InAudioBus>(busData);
            AudioRoot    = CheckData <InAudioNode>(audioData);
            EventRoot    = CheckData <InAudioEventNode>(eventData);
            BankLinkTree = CheckData <InAudioBankLink>(bankLinkData);

            /*if (BusRoot != null)
             *  BusRootGO = BusRoot.gameObject;
             * if (AudioRoot != null)
             *  AudioRootGO = AudioRoot.gameObject;
             * if (EventRoot != null)
             *  EventRootGO = EventRoot.gameObject;
             * if (BankLinkTree != null)
             *  BankLinkRootGO = BankLinkTree.gameObject;*/
        }
    }
Example #7
0
 private void LoadLocal()
 {
     LocalData.DataPath = AppDomain.CurrentDomain.BaseDirectory;
     ViewModelGlobals.FundAllocation = SaveAndLoad.LoadLocalData <FundAllocation>("Fundallocation.json");
     ViewModelGlobals.Personnels     = SaveAndLoad.LoadLocalData <List <Personnel> >("Personnel.json");
     //ViewModelGlobals.FinancialStatements = SaveAndLoad.LoadLocalData<FinancialStatements>("FinancialStatements.json");
 }
Example #8
0
    IEnumerator GameOverEnumerator(Vector2 cameraPos, float[] damageTaken, bool isQuit)
    {
        if (!isQuit)
        {
            Time.timeScale = 0.25f;
            for (float i = 0; i < (float)3 / 4; i += Time.deltaTime)
            {
                if (oneMoreChance)
                {
                    break;
                }
                yield return(null);
            }
        }
        if (oneMoreChance)
        {
            oneMoreChance = false;
        }
        else
        {
            Time.timeScale = 1;
            cameraCont.GameOver();
            starReward = (int)killSum / 5 + (int)currentGameTime / 6;
            gameOver   = true;
            challengeCont.GameOver(isQuit);
            StartCoroutine(spawnCont.GameOver(isQuit));
            healthAbilityOn = false;
            int recordValue = (data.highScoreTime < currentGameTime ? 1 : 0) + (data.highScoreKill < killSum ? 2 : 0);
            dataCont.SetData((int)currentGameTime, killSum, currentEnemiesKilled, damageTaken, recordValue);
            SaveCurrentGameData(damageTaken, isQuit);
            yield return(new WaitForSeconds(0.5f)); //TO avoid lag

            SaveAndLoad.SaveData(data);
        }
    }
Example #9
0
        private void CreateEventPrefab(int levelSize)
        {
            GameObject go = new GameObject();

            Manager.EventTree = AudioEventWorker.CreateTree(go, levelSize);
            SaveAndLoad.CreateAudioEventRootPrefab(go);
        }
Example #10
0
 public void LoadCharacter()
 {
     SaveAndLoad.Load();
     if (SaveAndLoad.savedGames.Count > 0)
     {
         charLoadPanel.SetActive(true);
         loadCharList = new GameObject[SaveAndLoad.savedGames.Count];
         for (int i = 0; i < SaveAndLoad.savedGames.Count; i++)
         {
             loadCharList[i] = Instantiate(characterPanelPF, charLoadContent.transform);
             loadCharList[i].GetComponentInChildren <Text>().text = SaveAndLoad.savedGames[i].GROUP[0].pcName + " the " + SaveAndLoad.savedGames[i].GROUP[0].pcType;
             int x = i; // This fixes the Closure problem.
             loadCharList[i].GetComponent <Button>().onClick.AddListener(() => ClickOnLoadCharacterPanel(x));
             loadCharList[i].GetComponent <DeleteCharacterButton>().ButtonIndex = i;
             if (SaveAndLoad.savedGames[i].GROUP[0].pcStatus != "Ready")
             {
                 loadCharList[i].SetActive(false);
             }
         }
     }
     else
     {
         NavigateToCreateCharacter();
     }
 }
Example #11
0
    public void SaveNames()
    {
        RandomStuffs rand = new RandomStuffs()
        {
            names = new List <string>()
            {
                "PedrinhoJogador",
                "monitorgrimacing",
                "steercombative",
                "hidemeaning",
                "timberheadview",
                "lutestringbefore",
                "scorebench",
                "wordyspring",
                "brokencalling",
                "pupposse",
                "vanishingconsonant",
                "harasssiege",
                "saidforestay",
                "stradabsolutely",
                "patternfeeling",
                "processionaryhorror",
                "caughtsweeping",
                "unrulyhundred",
                "bankcloistered",
                "handprominent"
            }
        };

        SaveAndLoad.Save <RandomStuffs>("Names", rand);
    }
Example #12
0
        protected override void OnResume()
        {
            // Handle when your app resumes

            // TO DO : save all localy
            SaveAndLoad.SaveLocaly();
        }
Example #13
0
    private void loadBlocked()
    {
        List <int> integer = SaveAndLoad.Read(blockFile);

        blocked = new List <bool>();
        prize   = new List <int>();
        score   = new List <int>();
        int ch = 0;

        foreach (int item in integer)
        {
            if (item == -1)
            {
                ch++;
                continue;
            }
            switch (ch)
            {
            case 0:
                blocked.Add((item == 0) ? true : false);
                break;

            case 1:
                prize.Add(item);
                break;

            case 2:
                score.Add(item);
                break;

            default:
                break;
            }
        }
    }
Example #14
0
    public void LoadGame()
    {
        dataOfScene = SaveAndLoad.LoadGame();

        DataHandler.data = dataOfScene;
        sceneLoader.ChangeScene(dataOfScene);
    }
Example #15
0
    void Start()
    {
        int i, j;

        storageWidth  = GetComponentInParent <Storage>().storageWidth;
        storageHeight = GetComponentInParent <Storage>().storageHeight;
        myIndex       = GetComponentInParent <Storage>().IndexOfRefrigeratorIndex(gameObject);
        marker        = transform.parent.GetChild(1).gameObject;
        storage       = new Inventory[storageWidth, storageHeight]; //가로 5 x 세로 6 (칸)

        //storage 초기화
        List <Inventory> bufferInventory = SaveAndLoad.LoadInventory(myIndex);   //세이브 파일에서 Inventory정보를 읽어옴
        int hor, ver;

        for (i = 0; i < bufferInventory.Count; i++)
        {
            hor = bufferInventory[i].horIndex;
            ver = bufferInventory[i].verIndex;
            storage[hor, ver] = bufferInventory[i];
        }

        for (i = 0; i < storageHeight; i++)
        {
            for (j = 0; j < storageWidth; j++)
            {
                //채워지지 않은 칸은 초기화
                if (storage[j, i] == null)
                {
                    storage[j, i] = new Inventory('\0', 0, 0, j, i);
                }
            }
        }

        GetComponentInParent <Storage>().AddRefrigeratorStorage(transform.parent.gameObject, storage);
    }
Example #16
0
    public void loadMap()
    {
        TileMap tileMap = GameObject.Find("Map").GetComponent <TileMap>();
        string  level   = GameObject.Find("InputField").GetComponentInChildren <Text>().text;

        SaveAndLoad.loadMap(tileMap, level);
    }
Example #17
0
    public void LoadGame()
    {
        string     content = SaveAndLoad.Load();
        PlayerData player  = JsonUtility.FromJson <PlayerData>(content);

        PlayerController.gameObject.transform.position = player.position;
    }
Example #18
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }

        Debug.Log("Save file: " + Application.persistentDataPath + SaveFileName);

        DontDestroyOnLoad(gameObject);

        if (LoadData() == false)
        {
            Debug.Log("Save file created");
            SaveData();
        }
        else
        {
            Debug.Log("Existing save file used");
        }
    }
Example #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Loggin(object sender, EventArgs e)
 {
     SaveAndLoad.LoadUser(in_userLoggin.Text, in_pwdloggin.Text);
     user_logged.IsVisible      = false;
     user_newORloggin.IsVisible = true;
     CheckUser();
 }
Example #20
0
    // Use this for initialization
    void Start()
    {
        smokeScreen.Stop();

        SelectionChoices.SetActive(false);

        if ((Game.current.Progress.Sword1Cutscene && SwordNumber == SwordPickupNumberGeneral.Sword1) || (Game.current.Progress.Sword2Cutscene && SwordNumber == SwordPickupNumberGeneral.Sword2))
        {
            Destroy(EventTrigger);
        }

        Controls = PlayerController.CreateWithDefaultBindings();
        SaveAndLoad.Save(Game.current.Progress.FileNumber);

        if (Game.current != null)
        {
            if (SwordNumber == SwordPickupNumberGeneral.Sword1 && Game.current.Progress.Sword1 == Player_States.SwordsObtainedStatus.Obtained ||
                SwordNumber == SwordPickupNumberGeneral.Sword2 && Game.current.Progress.Sword2 == Player_States.SwordsObtainedStatus.Obtained)
            {
                SwordPickedUp = true;
            }
        }
        if (SwordPickedUp)
        {
            SwordModel.SetActive(false);
        }
    }
Example #21
0
    //If you destroy all blocks, you can´t spawn, you end this round(map), unlock next map
    //Set a number of star in function of points and show stars in select level scene
    //Show end buttons and save the game
    public void LevelCompleted()
    {
        _spawn = false;
        adsManagerGame.ShowNoSkipAd();

        int level = GameManager.gameManagerInstace.GetCurrentLevel();

        if (level <= GameManager.gameManagerInstace.GetLevels().Length) //Only have 10 levels
        {
            GameManager.gameManagerInstace.GetLevels()[level]._lock = false;
        }

        if (_points > gameField.GetTotalBlocks() * 30 / 4)
        {
            GameManager.gameManagerInstace.GetLevels()[level - 1]._stars[0] = true;
        }
        if (_points > gameField.GetTotalBlocks() * 30 / 2)
        {
            GameManager.gameManagerInstace.GetLevels()[level - 1]._stars[1] = true;
        }
        if (_points > gameField.GetTotalBlocks() * 40)
        {
            GameManager.gameManagerInstace.GetLevels()[level - 1]._stars[2] = true;
        }
        endScoreText.text = "Points " + _points.ToString();

        SaveAndLoad.Save();
        uiManager.WinLevel();
    }
Example #22
0
    public void LoadPocketsFromTxt()
    {
        for (int i = 0; i < currencies.Count; i++)
        {
            if (currencies[i] == null)
            {
                continue;
            }

            Pocket tempPocket = currencyPockets[currencies[i]];
            Pocket newPocket;
            try
            {
                newPocket = SaveAndLoad.LoadFromTxt <Pocket>(currencies[i].name + ".txt");
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                newPocket = tempPocket;
            }

            if (newPocket != null)
            {
                currencyPockets[currencies[i]] = newPocket;
                onValueChange.Invoke(currencies[i], newPocket.Value);
            }
        }
    }
Example #23
0
    public void OnClickLButton()
    {
        int        num    = 0;
        GameObject Button = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject;

        switch (Button.transform.name)
        {
        case "L0Button":
            num = 0;
            break;

        case "L1Button":
            num = 1;
            break;

        case "L2Button":
            num = 2;
            break;

        case "L3Button":
            num = 3;
            break;
        }
        SaveAndLoad S = new SaveAndLoad();

        S.Load(num);
    }
Example #24
0
 public RockPaperScissors()
 {
     if (SaveAndLoad.FileExists("rockPaperScissors", "rockPaperScissorsSave.json"))
     {
         SaveAndLoad.LoadFile(out users, "rockPaperScissors", "rockPaperScissorsSave.json");
     }
 }
 public void ActivateTutorials()
 {
     //activate the tutorial for the player
     tutorial  = true;
     info.text = "you will see the instructions the next time you play the game"; //tell him when will he sees it
     SaveAndLoad.Save();                                                          //save
 }
Example #26
0
    private void loadLevel()
    {
        List <int> fileData = SaveAndLoad.Read(levelFile);

        levelSelected = new List <Level>();
        int index = 0;

        for (int i = 0; i < fileData.Count; i++)
        {
            if (fileData[i] == -1)
            {
                index++;
                continue;
            }
            if (levelSelected.Count == index)
            {
                levelSelected.Add(new Level());
            }

            Level b = new Level();

            if (levelSelected[index].IsNull())
            {
                b.clicksToChangeLevels = new List <int>();
            }
            else
            {
                b.clicksToChangeLevels = levelSelected[index].clicksToChangeLevels;
            }

            b.clicksToChangeLevels.Add(fileData[i]);
            levelSelected[index] = b;
        }
    }
Example #27
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, 100, 30), showDebug? "Hide Debug" : "Show Debug"))
        {
            showDebug = !showDebug;
        }

        if (showDebug)
        {
            if (GUI.Button(new Rect(10, 50, 120, 30), "Clear Saved Data"))
            {
                SaveAndLoad.ClearData();
                SaveAndLoad.Load();
            }

            barrelsBeatStr = GUI.TextField(new Rect(10, 90, 70, 20), barrelsBeatStr);

            if (GUI.Button(new Rect(90, 90, 40, 30), ">>"))
            {
                barrelsBeat        = int.Parse(barrelsBeatStr);
                initialBarrelsBeat = barrelsBeat;
            }

            GUI.Label(new Rect(Screen.width - 100, 80, 500, 30), "-- Info -- ");
            GUI.Label(new Rect(Screen.width - 100, 100, 500, 30), "Curr Barrel: " + (barrels.IndexOf(barrelHolingPlayer) + 1));
            GUI.Label(new Rect(Screen.width - 100, 120, 500, 30), "Prev Barrel: " + (barrels.IndexOf(prevBarrelHoldingPlayer) + 1));
            GUI.Label(new Rect(Screen.width - 100, 140, 500, 30), "Lst N of JB: " + lastBarrelsJumped.Count);
            GUI.Label(new Rect(Screen.width - 100, 160, 500, 30), "Game TIme: " + Mathf.Floor(Time.realtimeSinceStartup));
            GUI.Label(new Rect(Screen.width - 100, 180, 500, 30), "Barrls Beat: " + barrelsBeat);
            GUI.Label(new Rect(Screen.width - 100, 200, 500, 30), "Record: " + DifficultyManager.barrelsBeatRecord);
            GUI.Label(new Rect(Screen.width - 100, 220, 500, 30), "Difficulty: " + DifficultyManager.currentDifficulty);
            GUI.Label(new Rect(Screen.width - 100, 240, 500, 30), "CurrB Diff: " + (barrelHolingPlayer ? "" + barrelHolingPlayer.GetComponent <Barrel>().difficulty : "N/A"));
        }
    }
Example #28
0
    // Start is called before the first frame update
    private void Awake()
    {
        //Only if gameManager is null, we init all if it is the first game and then load if there is
        //some data saved before
        if (gameManagerInstace == null)
        {
            gameManagerInstace = this;

            DontDestroyOnLoad(gameObject);


            string        myPath = "Assets/Resources/Maps";
            DirectoryInfo dir    = new DirectoryInfo(myPath);
            FileInfo[]    info   = dir.GetFiles("*.txt");

            _levels = new Level[info.Length];


            _levels[0] = new Level(false, false, false, false);
            for (int i = 1; i < _levels.Length; i++)
            {
                _levels[i] = new Level(false, false, false, true);
            }

            _ruby        = 100;
            _nRayPowerUp = 2;
            SaveAndLoad.Load();
        }

        if (!Advertisement.isInitialized)
        {
            Advertisement.Initialize("2988623", true);
        }
    }
Example #29
0
        private void CreateMusicPrefab(int levelSize)
        {
            GameObject go = new GameObject();

            Manager.MusicTree = MusicWorker.CreateTree(go, levelSize);
            SaveAndLoad.CreateMusicRootPrefab(go);
        }
Example #30
0
        protected override void OnSleep()
        {
            // Handle when your app sleeps

            // TO DO : save all localy
            SaveAndLoad.SaveLocaly();
        }
Example #31
0
        /// <summary>
        /// check the inputs
        /// create and save a new session if all the information are correct
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Submit(object sender, EventArgs e)
        {
            if (in_quantity.Text != null && pic_sportType.SelectedItem != null && pic_unit.SelectedItem != null)
            {
                session.Quantity = float.Parse(in_quantity.Text);
                session.SType    = (SportType)pic_sportType.SelectedItem;
                session.SUnit    = (Unit)pic_unit.SelectedItem;
                session.SDate    = pic_date.Date + pic_time.Time;
                session.Done     = done;
                session.Weight   = float.Parse(in_weight.Text);
                session.WUnit    = (string)pic_weightUnit.SelectedItem;

                if (edit)
                {
                    SaveAndLoad.UpDateSession(oldS, session);
                }
                else
                {
                    SaveAndLoad.SaveSession(session);
                }

                Application.Current.MainPage = Page;
            }
            else
            {
                DependencyService.Get <IMessage>().longtime("Incomplete information");
            }
            //SaveAndLoad.LoadSessions(true);
        }
Example #32
0
 public static Result<Pyrite> Create(SaveAndLoad sal)
 {
     var result = new Result<Pyrite>();
     var pyrite = new Pyrite();
     result.AddExceptions(pyrite.Initialize(sal).Exceptions);
     result.Value = pyrite;
     return result;
 }
Example #33
0
        private void guardarGrafoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveAndLoad mySave = new SaveAndLoad(); //Instancia de objeto SaveAndLoad

            VentanaGuardar.InitialDirectory = "c:\\"; //Directorio inicial para el SaveDialog
            VentanaGuardar.Filter = "graph files (*.graph)|*.graph"; //Filtro de archivos
            VentanaGuardar.FilterIndex = 2; //Indice del filtr
            VentanaGuardar.RestoreDirectory = true; //Volver a abrir donde se cerro

            DialogResult result = VentanaGuardar.ShowDialog(); //Mostrar la ventana de guardado
            if (result == DialogResult.OK) // Si fue satisfactorio
            {
                string file = VentanaGuardar.FileName; //Guardamosla direccion del archivo
                mySave.WriteToBinaryFile<CGrafo>(file, grafo, false); //Guardamos un archivo .graph
                // en la direccion que cotiene un objeto tipo CGrafo en binario
            }
        }
Example #34
0
        private void cargarFondoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveAndLoad myLoad = new SaveAndLoad(); //Instancia de objeto SaveAndLoad

            VentanaCargar.InitialDirectory = "c:\\"; //Directorio inicial para el LoadDialog
            VentanaCargar.Filter = "Images (*.BMP;*.JPG;*.GIF,*.PNG,*.TIFF)|*.BMP;*.JPG;*.GIF;*.PNG;*.TIFF|" +
                "All files (*.*)|*.*"; //Filtro de archivos
            VentanaCargar.FilterIndex = 2; //Indice del filtro
            VentanaCargar.RestoreDirectory = true; //Volver a abrir donde se cerro

            DialogResult result = VentanaCargar.ShowDialog(); //Mostrar la ventana para cargar
            if (result == DialogResult.OK) // Si fue satisfactorio
            {
                string file;
                file = VentanaCargar.FileName; //Guardamos la direccion del archivo
                grafo.Background = (Bitmap) Image.FromFile(VentanaCargar.FileName); //Guardamos la imagen en el grafo
                Pizarra.BackgroundImage = grafo.Background; //Ponemos de fondo la imagen
            }
        }
Example #35
0
        private void cargarGrafoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveAndLoad myLoad = new SaveAndLoad(); //Instancia de objeto SaveAndLoad

            VentanaCargar.InitialDirectory = "c:\\"; //Directorio inicial para el LoadDialog
            VentanaCargar.Filter = "graph files (*.graph)|*.graph"; //Filtro de archivos
            VentanaCargar.FilterIndex = 2; //Indice del filtro
            VentanaCargar.RestoreDirectory = true; //Volver a abrir donde se cerro

            DialogResult result = VentanaCargar.ShowDialog(); //Mostrar la ventana para cargar
            if (result == DialogResult.OK) // Si fue satisfactorio
            {
                string file;
                file = VentanaCargar.FileName; //Guardamos la direccion del archivo
                grafo = myLoad.ReadFromBinaryFile<CGrafo>(file); //Convertimos de binario a CGrafo con la clase SaveAndLoad
                if (grafo.Background != null)
                    Pizarra.BackgroundImage = grafo.Background;
                grafo.DibujarGrafo(Pizarra.CreateGraphics()); //Dibujamos el grafo cargado en el Canvas
            }
        }
 static bool saveAndQuit()
 {
     Console.WriteLine("Are you sure you want to save your customer list? Y/N");
     if (confirm())
     {
         Console.WriteLine("Saving...\n");
         try
         {
             SaveAndLoad save = new SaveAndLoad("customer_list.sav");
             save.Save<SavingsAccount>(customerList);
             Console.WriteLine("Save successful!\n");
         }
         catch
         {
             Console.WriteLine("Something went wrong.  Please try again.");
             Console.WriteLine("Press any key to return to the menu...");
             Console.ReadKey();
             return false;
         }
     }
     Console.WriteLine("Are you sure you want to quit? Y/N");
     return confirm();
 }
    void Awake()
    {
        if (inst == null)
            inst = this;
        //check if necessary save directories exhist
        string[] directories = Directory.GetDirectories (Application.dataPath);
        Debug.Log (Application.dataPath);
        bool hasGoalDirectory = false;
        bool hasPlayerDirectory = false;
        for (int i = 0; i < directories.Length; i++) {
            Debug.Log ("Directory "+directories[i]);
            if(directories[i] == Application.dataPath+"/Levels Data") hasGoalDirectory = true;
            if(directories[i] == Application.dataPath+"/Players Data") hasPlayerDirectory = true;
        }
        if (!hasGoalDirectory){
            Directory.CreateDirectory (Application.dataPath+"/Levels Data");
            Debug.Log("Goals data directory is created");
        }
        else{
            //load goals data
            Debug.Log("Goals have been loaded");
        }
        if (!hasPlayerDirectory){
            Directory.CreateDirectory (Application.dataPath+"/Players Data");
            Debug.Log("Players data directory is created");
        }
        else{
            //load goals data
            Debug.Log("Players have been loaded");
        }

        redRect = new Rect(10, 10, 100, 30);
        greenRect = new Rect(redRect.x + redRect.width + 10, redRect.y, redRect.width, redRect.height);
        blueRect = new Rect(greenRect.x + greenRect.width + 10, redRect.y, redRect.width, redRect.height);
        resetRect = new Rect(blueRect.x + blueRect.width + 10, redRect.y, redRect.width, redRect.height);
        loadRect = new Rect(resetRect.x + resetRect.width + 10, redRect.y, redRect.width, redRect.height);
    }
        static void loadCustomers()
        {
            Console.WriteLine("Are you sure you want to load a saved customer list?\nThis will delete the current list. Y/N");
            if (confirm())
            {
                Console.WriteLine("Loading...\n");
                try
                {
                    SaveAndLoad load = new SaveAndLoad("customer_list.sav");
                    customerList = load.Load<SavingsAccount>();
                    Console.WriteLine("Load successful!\n");

                }
                catch
                {
                    Console.WriteLine("There does not seem to be a valid saved customer list.");
                }
            }
            Console.WriteLine("Press any key to return to the menu...");
            Console.ReadKey();
        }
Example #39
0
        private void btnLoadFile_Click(object sender, EventArgs e)
        {
            loading = true; //Se marca la bandera cargando como verdadero
            aristas = 0; //El numero de aristas del grafo se resetea
            nodos = 0; //El numero de nodos del grafo se resetea
            SaveAndLoad myLoad = new SaveAndLoad(); //Instancia de objeto SaveAndLoad

            VentanaCargar.InitialDirectory = "c:\\"; //Directorio inicial para el LoadDialog
            VentanaCargar.Filter = "graph files (*.graph)|*.graph"; //Filtro de archivos
            VentanaCargar.FilterIndex = 2; //Indice del filtro
            VentanaCargar.RestoreDirectory = true; //Volver a abrir donde se cerro

            DialogResult result;
            if (!opening)
                result = VentanaCargar.ShowDialog(); //Mostrar la ventana de carga
            else
                result = DialogResult.OK;
            if (result == DialogResult.OK) // Si fue satisfactorio
            {
                string file;
                if (opening)
                    file = filePath;
                else
                    file = VentanaCargar.FileName; //Guardamos la direccion del archivo
                grafo = myLoad.ReadFromBinaryFile<CGrafo>(file); //Convertimos de binario a CGrafo con la clase SaveAndLoad
                miGrafo.control = true; //Marcamos la varible como true
                btnNewFile.PerformClick(); //Simulamos un click en el boton NewFile
                grafo.DibujarGrafo(pbCanvas.CreateGraphics()); //Dibujamos el grafo cargado en el Canvas
                numeronodos = grafo.nodos.Count; //Actualizamos el numero de nodos
                foreach (CVertice nodo in grafo.nodos)
                {
                    nodos++;
                    foreach (CArco a in nodo.ListaAdyacencia)
                        aristas++;
                }
            }
            if (nodos != 0) //Si el grafo tiene nodos
            {
                btnDelNode.Enabled = true; //Habilitar el boton borrar nodo
                rbnBAgregarArista.Enabled = true; //Habilitar el boton agregar arista
                if (aristas != 0) //Si tiene aristas
                {
                    rbnEliminarArista.Enabled = true; //Habilitar el boton eliminar arista
                    rbnWarshall.Enabled = true; //Habilitar el boton del algoritmo Warshall
                    rbnDijk.Enabled = true; //Habilitar el boton del algoritmo Dijkstra
                    rbnBKruskal.Enabled = true; //Habilitar el boton del algoritmo Kruskal
                    rbnBPrim.Enabled = true; //Habilitar el boton del algoritmo Prim
                    rbnWarshallND.Enabled = true; //Habilitar el boton del algoritmo Warshall no dirigido
                    btnRecorridoAnchura.Enabled = true; //Habilitar recorrido anchura
                    btnRecorridoProfundidad.Enabled = true; //Habilitar recorrido profundidad
                }
            }
            loading = false; //Ya no se esta cargando
        }