Beispiel #1
0
    // Load the inventory from the global save data struct to this instance
    public bool loadFromDisk(string owner)
    {
        var slot = SaveDataScript.inventory_owner_to_slot(owner);

        _items = SaveDataScript.save_data.item_inventory[slot];
        return(true);
    }
Beispiel #2
0
    /**
     * Load a map from a file
     * @param filename name of the file relative to the "Assets/Resources" folder
     */
    public void loadMap(string filename)
    {
        var map_color = filename.Substring(0, filename.IndexOf('_'));
        var map_index = SaveDataScript.map_to_slot(map_color);

        _tileMapData = SaveDataScript.save_data.map_data[map_index];
    }
    /*
     * This method is called before leaving the scene.
     * It shows the player and enables movement for the overworld player object.
     * After that it sets the player's sceneload data to the correct source and destination
     */
    protected override void prepare_to_leave_scene(string destination, string source)
    {
        // save rupees
        var save_index = SaveDataScript.map_to_slot(dungeon_color);
        var rupees     = SaveDataScript.save_data.dungeon_data[save_index];

        GameObject[] g = GameObject.FindGameObjectsWithTag("Rupee");
        for (int i = 0; i < g.Length; i++)
        {
            RupeeSaveData save_data;
            save_data.id        = g[i].GetComponent <CurrencyMain>().id;
            save_data.picked_up = g[i].GetComponent <CurrencyMain>().picked_up;
            rupees[i]           = save_data;
        }
        SaveDataScript.save();

        // prepare player to leave
        _player.GetComponent <PlayerController>().enabled           = true;
        _player.gameObject.GetComponent <Collider>().enabled        = true;
        _player.gameObject.GetComponent <PauseMenuScript>().enabled = true;
        _player.gameObject.transform.Find("Camera").gameObject.SetActive(true);
        _player.gameObject.transform.Find("spriteU").gameObject.SetActive(true);
        _player.gameObject.transform.Find("spriteD").gameObject.SetActive(true);
        _player.gameObject.transform.Find("spriteR").gameObject.SetActive(true);
        _player.gameObject.transform.Find("spriteL").gameObject.SetActive(true);
        //DEBUG JUMP PLAYER SO THEY DON'T TELEPORT RIGHT AWAY
        _player.gameObject.transform.position += new Vector3(1f, 0f, 0f);
    }
Beispiel #4
0
    void OnMouseUp()
    {
        if (newGame)
        {
            // clear the old save data
            if (!Directory.Exists(".\\Assets\\Resources") && File.Exists(".\\Assets\\Resources\\save_data.bin"))
            {
                File.Delete(".\\Assets\\Resources\\save_data.bin");
            }

            SaveDataScript.save_data = new SaveDataScript.SaveData();

            world_generator    = gameObject.AddComponent <WorldGenerator>();
            schedule_generator = gameObject.AddComponent <ScheduleGenerator>();

            var map_width  = 50;
            var map_height = 50;

            world_generator.generate_world("red_overworld", map_width, map_height);
            world_generator.generate_world("blue_overworld", map_width, map_height);
            world_generator.generate_world("green_overworld", map_width, map_height);
            world_generator.generate_world("purple_overworld", map_width, map_height);
            world_generator.generate_world("yellow_overworld", map_width, map_height);

            schedule_generator.generate_schedule();

            Application.LoadLevel("StartingPortalRoom");
        }
        if (loadGame)
        {
            var loaded = SaveDataScript.load();
            if (loaded)
            {
                Application.LoadLevel("StartingPortalRoom");
            }
        }
        if (addPlayer)
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent <PauseMenuScript>().hostNetwork();
        }
        if (enterAddress)
        {
            Application.LoadLevel("ServerConnect");
        }
        if (connect)
        {
            man.networkAddress = GameObject.FindGameObjectWithTag("Text").GetComponent <Text>().text;
            Debug.Log("Adding player 2");
            Application.LoadLevel("NSceneGenTest");
        }
        if (back)
        {
            Destroy(GameObject.FindGameObjectWithTag("Player"));
            Application.LoadLevel("MainMenu");
        }
        if (exit)
        {
            Application.Quit();
        }
    }
    void Start()
    {
        SaveDataObj = GameObject.Find( "SaveData" );
        SaveDataScript = SaveDataObj.GetComponent<SaveDataScript>();

        UpdateButtonText();
    }
Beispiel #6
0
    void Start()
    {
        // get the name of this level
        myLevelScoreData.LevelName = ActiveSceneManager.GetSceneName();

        // load score and level data
        SaveDataScript.Load();

        // chech if this level already exsists in the list of levels
        bool foundLevel = false;

        foreach (SaveDataScript.LevelScoreData levelData in SaveDataScript.MySaveData.levelScoreDataSet)
        {
            if (myLevelScoreData.LevelName == levelData.LevelName)
            {
                foundLevel       = true;
                myLevelScoreData = levelData;
                break;
            }
        }

        // if we dont find this levels data create a new one
        if (!foundLevel)
        {
            SaveDataScript.MySaveData.levelScoreDataSet.Add(myLevelScoreData);
        }
        // set this level to last completed * change this to last attempted?*
        SaveDataScript.MySaveData.LastCompletedLevel = myLevelScoreData.LevelName;

        // save data
        SaveDataScript.Save();
    }
    void Start()
    {
        //switch( currentButtonState )
        //{
        //case ButtonState.Available:
        //gameObject.GetComponent<Image>().sprite = AvailableImage;
        ////SaveDataObjScript.MusicSetOneState = 0;
        //SetToggle.interactable = false;
        //this.GetComponent<Button>().interactable = true;
        //PriceText.text = SetPrice.ToString();
        //break;
        //case ButtonState.NotAvailable:
        //gameObject.GetComponent<Image>().sprite = NotAvailableImage;
        //SetToggle.interactable = false;
        //this.GetComponent<Button>().interactable = false;
        //PriceText.text = "N/A";
        //break;
        //case ButtonState.Purchased:
        ////gameObject.GetComponent<Image>().sprite = PurchasedImage;
        //SetToggle.interactable = true;
        //this.GetComponent<Button>().interactable = false;
        //PriceText.text = "PURCHASED";
        //break;
        //}

        ControllerObjectScript = GameObject.Find( "BGMusicMenu" ).GetComponent<BGMusicSetController>();
        SaveDataObj = GameObject.Find( "SaveData" );
        SaveDataObjScript = SaveDataObj.GetComponent<SaveDataScript>();
    }
Beispiel #8
0
    // Save the inventory to disk
    public void saveToDisk(string owner)
    {
        var slot = SaveDataScript.inventory_owner_to_slot(owner);

        SaveDataScript.save_data.item_inventory[slot] = _items;
        SaveDataScript.save();
    }
Beispiel #9
0
 public void AddLevelDataset(string name)
 {
     SaveDataScript.LevelScoreData newLevelScoreData = new SaveDataScript.LevelScoreData();
     newLevelScoreData.LevelName = name;
     SaveDataScript.MySaveData.levelScoreDataSet.Add(newLevelScoreData);
     SaveDataScript.Save();
 }
    void Start()
    {
        SaveDataObj    = GameObject.Find("SaveData");
        SaveDataScript = SaveDataObj.GetComponent <SaveDataScript>();

        UpdateButtonText();
    }
Beispiel #11
0
    void Start()
    {
        //switch( currentButtonState )
        //{
        //case ButtonState.Available:
        //gameObject.GetComponent<Image>().sprite = AvailableImage;
        ////SaveDataObjScript.MusicSetOneState = 0;
        //SetToggle.interactable = false;
        //this.GetComponent<Button>().interactable = true;
        //PriceText.text = SetPrice.ToString();
        //break;
        //case ButtonState.NotAvailable:
        //gameObject.GetComponent<Image>().sprite = NotAvailableImage;
        //SetToggle.interactable = false;
        //this.GetComponent<Button>().interactable = false;
        //PriceText.text = "N/A";
        //break;
        //case ButtonState.Purchased:
        ////gameObject.GetComponent<Image>().sprite = PurchasedImage;
        //SetToggle.interactable = true;
        //this.GetComponent<Button>().interactable = false;
        //PriceText.text = "PURCHASED";
        //break;
        //}

        ControllerObjectScript = GameObject.Find("BGMusicMenu").GetComponent <BGMusicSetController>();
        SaveDataObj            = GameObject.Find("SaveData");
        SaveDataObjScript      = SaveDataObj.GetComponent <SaveDataScript>();
    }
 // Start is called before the first frame update
 void Start()
 {
     spRenderer = GetComponentInChildren <SpriteRenderer>();
     saver      = GameObject.FindGameObjectsWithTag("SaveObject")[0].GetComponent <SaveDataScript>();
     tmp        = GetComponentInChildren <TextMeshPro>();
     tmp.alpha  = 0;
     player     = GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <Player>();
 }
Beispiel #13
0
    void Start()
    {
        SaveDataObj    = GameObject.Find("SaveData");
        SaveDataScript = SaveDataObj.GetComponent <SaveDataScript>();

        UpdateButtonImage();

        ColorToggleSprite = GetComponent <Image>();
    }
    void Start()
    {
        SaveDataObj = GameObject.Find( "SaveData" );
        SaveDataScript = SaveDataObj.GetComponent<SaveDataScript>();

        UpdateButtonImage();

        AssistToggleSprite = GetComponent<Image>();
    }
Beispiel #15
0
    void Start()
    {
        GameManager = GameObject.FindGameObjectWithTag("GM");
        SDS         = GameManager.GetComponent <SaveDataScript> ();
        SS          = GameManager.GetComponent <ScoreScript> ();

        HighScore = SDS.GetHighScore();
        Score     = SS.GetScore();

        ScoreText.text = "Score\n" + Score.ToString();

        CheckForHighScore();
    }
    void Start()
    {
        NSController = GameObject.Find("MultiplierCanvas").GetComponent <NoteStreakControllerScript>();

        Section = 0;
        Song    = GameObject.FindGameObjectWithTag("SongObject");
        //LeftHand = GameObject.FindGameObjectWithTag( "LeftHand" );
        SongProgressionManagerObj = GameObject.Find("SongProgressionManager");

        // Find and assign the save data manager object and script
        SaveDataManagerObj    = GameObject.Find("SaveData");
        SaveDataManagerScript = SaveDataManagerObj.GetComponent <SaveDataScript>();
    }
    void Start()
    {
        NSController = GameObject.Find( "MultiplierCanvas" ).GetComponent<NoteStreakControllerScript>();

        Section = 0;
        Song = GameObject.FindGameObjectWithTag( "SongObject" );
        //LeftHand = GameObject.FindGameObjectWithTag( "LeftHand" );
        SongProgressionManagerObj = GameObject.Find( "SongProgressionManager" );

        // Find and assign the save data manager object and script
        SaveDataManagerObj = GameObject.Find( "SaveData" );
        SaveDataManagerScript = SaveDataManagerObj.GetComponent<SaveDataScript>();
    }
Beispiel #18
0
    //keep object persistent
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);

        SongProgressionManagerObj = GameObject.Find("SongProgressionManager");
        SongProgressionScript     = SongProgressionManagerObj.GetComponent <SongProgressionManagerScript>();

        SaveDataObj    = GameObject.Find("SaveData");
        SaveDataScript = SaveDataObj.GetComponent <SaveDataScript>();

        CurrencyCanvas       = GameObject.Find("CurrencyCanvas");
        CurrencyCanvasScript = CurrencyCanvas.GetComponent <PlayerCashTextScript>();
    }
Beispiel #19
0
    /**
     * Serialize the map data to disk
     * @param filename name of the file relative to the "Assets/Resources" folder
     */
    public void saveToDisk(string filename)
    {
        var map_color = filename.Substring(0, filename.IndexOf('_'));
        var map_index = SaveDataScript.map_to_slot(map_color);

        SaveDataScript.save_data.map_data[map_index] = this;
        SaveDataScript.save();

        /*IFormatter formatter = new BinaryFormatter();
         * Stream stream = new FileStream(".\\Assets\\Resources\\" + filename, FileMode.Create, FileAccess.Write, FileShare.None);
         * formatter.Serialize(stream, this);
         * stream.Close(); */
    }
Beispiel #20
0
    public void AddScore(string name)
    {
        //newScoreData.scoreName = name;
        //scoreDataset.Add(newScoreData);
        //scoreDataset.Sort(SortFunc);

        newScoreData.scoreName = name;
        SaveDataScript.MySaveData.levelScoreDataSet[levelIndex].scoreDataset.Add(newScoreData);
        SaveDataScript.MySaveData.levelScoreDataSet[levelIndex].scoreDataset.Sort(SortFunc);
        if (SaveDataScript.MySaveData.levelScoreDataSet[levelIndex].scoreDataset.Count > displayNum)
        {
            SaveDataScript.MySaveData.levelScoreDataSet[levelIndex].scoreDataset.RemoveRange(6, SaveDataScript.MySaveData.levelScoreDataSet[levelIndex].scoreDataset.Count - 6);
        }

        displayText.text = DisplayScores();
        myMenuManager.HidePanel("CharacterInput");

        SaveDataScript.Save();
    }
Beispiel #21
0
    void Start()
    {
        GameManager = GameObject.FindGameObjectWithTag("GM");
        SDS         = GameManager.GetComponent <SaveDataScript> ();
        SS          = GameManager.GetComponent <ScoreScript> ();

        HighScore   = SDS.GetHighScore();
        HSText.text = "Best\n" + HighScore.ToString();

        if (AudioListener.volume == 0)
        {
            SoundButton.image.overrideSprite = SoundOffButtonImage;
            SoundImage.overrideSprite        = SoundOffImage;
        }
        else
        {
            SoundButton.image.overrideSprite = SoundOnButtonImage;
            SoundImage.overrideSprite        = SoundOnImage;
        }
    }
Beispiel #22
0
    public void Start()
    {
        myMenuManager = GetComponentInParent <MenuGeneric>();

        SaveDataScript.Load();

        // find the last completed level and get its index when completing a level
        if (!DisplayOnly)
        {
            //Debug.Log("x");
            levelIndex = GetLevelIndex(SaveDataScript.MySaveData.LastCompletedLevel);
            if (levelIndex < 0)
            {
                // create a new level dataset
                AddLevelDataset(SaveDataScript.MySaveData.LastCompletedLevel);
                levelIndex = GetLevelIndex(SaveDataScript.MySaveData.LastCompletedLevel);
            }
        }
        else
        {
            levelIndex = GetLevelIndex(selectedLevel);
        }

        //sort the level's data set
        //Debug.Log(SaveDataScript.MySaveData.levelScoreDataSet.Count);
        if (levelIndex < SaveDataScript.MySaveData.levelScoreDataSet.Count && levelIndex >= 0)
        {
            //Debug.Log("y");
            SaveDataScript.MySaveData.levelScoreDataSet[levelIndex].scoreDataset.Sort(SortFunc);


            if (!DisplayOnly)
            {
                //Debug.Log("Z");
                CheckAddScore();
            }
            displayText.text = DisplayScores();
        }
    }
Beispiel #23
0
    void Start()
    {
        animator       = GetComponentInChildren <Animator>();
        rigidbody2d    = GetComponent <Rigidbody2D>();
        playerRenderer = GetComponentInChildren <SpriteRenderer>();
        saver          = GameObject.FindGameObjectsWithTag("SaveObject")[0].GetComponent <SaveDataScript>();
        LoadData(saver.LoadData());
        Debug.Log("Start");
        //stats = new StatsStruct(PlayerStats.insight, PlayerStats.prowess, PlayerStats.strength);
        var   type    = PlayerClass.getClassSkill(playerClass);
        Skill skillCl = (Skill)gameObject.AddComponent(type);

        EquipSkill(skillCl, false);
        //constants

        uiController.SetLevelText(level);
        uiController.changeXp(0, 0, ReqXp);



        camOffset = new Vector3(0, 0, Camera.main.transform.position.z);
        UpdateStats();
    }
 private void Start()
 {
     saver = GameObject.FindGameObjectsWithTag("SaveObject")[0].GetComponent <SaveDataScript>();
 }
    //keep object persistent
    void Start()
    {
        DontDestroyOnLoad( this.gameObject );

        SongProgressionManagerObj = GameObject.Find( "SongProgressionManager" );
        SongProgressionScript = SongProgressionManagerObj.GetComponent<SongProgressionManagerScript>();

        SaveDataObj = GameObject.Find( "SaveData" );
        SaveDataScript = SaveDataObj.GetComponent<SaveDataScript>();

        CurrencyCanvas = GameObject.Find( "CurrencyCanvas" );
        CurrencyCanvasScript = CurrencyCanvas.GetComponent<PlayerCashTextScript>();
    }
    /*
     * This method is called when the player loads into the scene.
     * First it hides and disables movement for the overworld player object.
     * Next it sets the destination of all portals in the scene to wherever the player came from.
     * After that it can set the values of currency and keys that open doors (nothing to be done for the templatescene)
     */
    protected override void prepare_scene(string destination, string source)
    {
        _player.gameObject.GetComponent <PlayerController>().enabled = false;
        _player.gameObject.GetComponent <Collider>().enabled         = false;
        _player.gameObject.GetComponent <PauseMenuScript>().enabled  = false;
        _player.gameObject.transform.Find("Camera").gameObject.SetActive(false);
        _player.gameObject.transform.Find("spriteU").gameObject.SetActive(false);
        _player.gameObject.transform.Find("spriteD").gameObject.SetActive(false);
        _player.gameObject.transform.Find("spriteR").gameObject.SetActive(false);
        _player.gameObject.transform.Find("spriteL").gameObject.SetActive(false);

        dungeon_color = destination.Substring(0, destination.IndexOf('_'));

        // figure out what rupees to place

        var save_index         = SaveDataScript.map_to_slot(dungeon_color);
        var rupees             = SaveDataScript.save_data.dungeon_data[save_index];
        var rupee_game_objects = FindObjectsOfType(typeof(CurrencyMain)) as CurrencyMain[];

        foreach (var rupee in rupees)
        {
            foreach (var game_object in rupee_game_objects)
            {
                if (rupee.id == game_object.id)
                {
                    if (rupee.picked_up)
                    {
                        game_object.GetComponent <MeshRenderer>().enabled = false;
                        game_object.picked_up = true;
                    }
                }
            }
        }

        foreach (PortalScript p in (FindObjectsOfType(typeof(PortalScript))) as PortalScript[])
        {
            p.destination = source;
            p.source      = destination;
        }

        var    first_door   = GameObject.Find("Door").GetComponent <DoorMain>();
        var    second_door  = GameObject.Find("Door2").GetComponent <DoorMain>();
        string source_color = source.Substring(0, source.IndexOf('_'));

        if (source_color == "red")
        {
            first_door.keyID  = 101;
            second_door.keyID = 102;
            first_door.gameObject.GetComponent <MeshRenderer>().material  = red;
            second_door.gameObject.GetComponent <MeshRenderer>().material = red;
            Platypus.color = new Color(1f, 77f / 255f, 77f / 255f);
        }
        else if (source_color == "blue")
        {
            first_door.keyID  = 201;
            second_door.keyID = 202;
            first_door.gameObject.GetComponent <MeshRenderer>().material  = blue;
            second_door.gameObject.GetComponent <MeshRenderer>().material = blue;
            Platypus.color = new Color(77f / 255, 85f / 255f, 255f / 255f);
        }
        else if (source_color == "green")
        {
            first_door.keyID  = 301;
            second_door.keyID = 302;
            first_door.gameObject.GetComponent <MeshRenderer>().material  = green;
            second_door.gameObject.GetComponent <MeshRenderer>().material = green;
            Platypus.color = new Color(16f / 255, 180f / 255f, 11f / 255f);
        }
        else if (source_color == "yellow")
        {
            first_door.keyID  = 401;
            second_door.keyID = 402;
            first_door.gameObject.GetComponent <MeshRenderer>().material  = yellow;
            second_door.gameObject.GetComponent <MeshRenderer>().material = yellow;
            Platypus.color = new Color(230f / 255f, 1f, 77f / 255f);
        }
        else if (source_color == "purple")
        {
            first_door.keyID  = 501;
            second_door.keyID = 502;
            first_door.gameObject.GetComponent <MeshRenderer>().material  = purple;
            second_door.gameObject.GetComponent <MeshRenderer>().material = purple;
            Platypus.color = new Color(146f / 255f, 20f / 255f, 212f / 255f);
        }
    }
Beispiel #27
0
 /**
  * Save the database to disk
  * @param filename - name of file on disk
  */
 public void saveToDisk(string filename)
 {
     SaveDataScript.save_data.schedule = this;
     SaveDataScript.save();
 }