Inheritance: MonoBehaviour
Example #1
0
 public void CreateNewMap()
 {
     bricksList.Clear ();
     Destroy (container);
     playerS = PlayerSave.loadNew ();
     CreateMap ();
 }
Example #2
0
    public void LoadSave(PlayerSave save)
    {
        if (save.timePlayed != 0)
        {
            if (save.characters != null && save.characters.Length != 0)
            {
                // use the save's characters combined with any new characters in the Sector Manager character set
                var sectoManagerChars = new List <WorldData.CharacterData>(SectorManager.instance.characters);
                var newChars          = new List <WorldData.CharacterData>(save.characters);
                foreach (var ch in sectoManagerChars)
                {
                    if (newChars.TrueForAll(c => c.ID != ch.ID))
                    {
                        newChars.Add(ch);
                    }
                }
                SectorManager.instance.characters = newChars.ToArray();
            }
            transform.position = save.position;
        }

        name = entityName = "player";
        positionBeforeOscillation = transform.position.y;
        if (save.currentHealths.Length < 3)
        {
            maxHealth.CopyTo(currentHealth, 0);
        }
        else
        {
            currentHealth = save.currentHealths;
        }
        for (int i = 0; i < currentHealth.Length; i++)
        {
            if (currentHealth[i] > maxHealth[i])
            {
                currentHealth[i] = maxHealth[i];
            }
        }
    }
Example #3
0
    public void Load(int index)
    {
        gameIndex = index;
        if (SceneManager.GetSceneByName(mainMenu).isLoaded)
        {
            SceneManager.UnloadSceneAsync(mainMenu);
        }
        SceneManager.LoadScene(testPauseUI, LoadSceneMode.Additive);
        SceneManager.LoadScene(playerScene, LoadSceneMode.Additive);
        PlayerSave thisSave = SaveLoadHandler.LoadGame(gameIndex);

        if (thisSave == null)
        {
            Debug.Log("Room Not or First Save");
            SceneManager.LoadScene(testLoadScene, LoadSceneMode.Additive);
            occuredEvents    = new List <string>();
            playerStartPos   = Vector2.zero;
            currentMaxHealth = 6;
            keyItemStates    = new List <KeyItemState>();
            foreach (string s in keyItems)
            {
                keyItemStates.Add(new KeyItemState(s, false));
            }
        }
        else
        {
            Debug.Log("Loading at room " + thisSave.lastSavePoint.roomName);

            SceneManager.LoadScene(thisSave.lastSavePoint.roomName, LoadSceneMode.Additive);
            playerStartPos   = thisSave.lastSavePoint.location;
            occuredEvents    = thisSave.eventsTriggered;
            currentMaxHealth = thisSave.currentMaxHealth;
            keyItemStates    = new List <KeyItemState>();
            foreach (KeyItemState s in thisSave.keyItems)
            {
                keyItemStates.Add(s);
            }
        }
    }
        void InitData()
        {
            if (stageManager == null)
            {
                stageManager = Resources.Load("Scriptable/Stage/Stage Manager") as StageManager;
            }

            PlayerData playerProfile = new PlayerData();

            PlayerSave.CreatePlayerData(playerProfile);

            foreach (Stage stage in stageManager.listStages)
            {
                if (stage.zone.isCommingSoon)
                {
                    continue;
                }

                StageData stageData = new StageData(stage.zone, stage.levels);
                StageSave.CreateStageData(stageData);
            }
        }
Example #5
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        PlayerSave  playerSave  = FindObjectOfType <PlayerSave>();
        Vector2     tweak       = new Vector2(Random.Range(0f, 0.2f), Random.Range(0f, 0.2f));
        AudioSource audioSource = GetComponent <AudioSource>();

        if (collision.gameObject.tag == "Breakable")
        {
            AudioSource.PlayClipAtPoint(comboSFX[comboStage], Vector3.zero, playerSave.sfx);
            comboCountDown = comboLinkDuration;
            if (comboStage < maxComboStage)
            {
                comboStage++;
            }
        }
        else
        {
            AudioSource.PlayClipAtPoint(bounceSFX, Vector3.zero, playerSave.sfx);
        }

        GetComponent <Rigidbody2D>().velocity += tweak;
    }
Example #6
0
    void saveData()
    {
        if (levelId == 0)
        {
            if (score > highscore)
            {
                highscore = score;
            }
        }
        else
        {
            //var scoreRatio = (float)score / coinAmount;

            //if (scoreRatio == 0) {
            //	progress [levelId] = 0;
            //} else if (scoreRatio > 0 && scoreRatio < 0.5) {
            //	progress [levelId] = 1;
            //} else if (scoreRatio >= 0.5 && scoreRatio < 1) {
            //	progress [levelId] = 2;
            //} else if (scoreRatio == 1) {
            //	progress [levelId] = 3;
            //} else {
            //	Debug.Log ("An error occured!");
            //}
        }

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/playerSave.dat");

        PlayerSave data = new PlayerSave();

        data.highscore = highscore;
        data.progress  = progress;
        data.secrets   = secrets;

        bf.Serialize(file, data);
        file.Close();
    }
Example #7
0
    private static void Saving(PlayerSave save)
    {
        string path;

        if (Application.isEditor)
        {
            path = Path.Combine(Path.GetDirectoryName(Application.dataPath), "playerData.bin");
        }
        else
        {
            path = Path.Combine(Application.persistentDataPath, "playerData.bin");
        }
        Debug.Log("Save file path: " + path); //DEBUG
        if (!File.Exists(path))               //Create file if does not exist (avoid error in game after installation)
        {
            File.Create(path).Close();
        }

        Stream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);

        new BinaryFormatter().Serialize(stream, save); //Saving of the GameSave object in the binary file
        stream.Close();
    }
Example #8
0
    public PlayerData(PlayerSave pSave)
    {
        //Variables

        statVal     = new float[17];
        statVal[0]  = pSave.statVal_love;
        statVal[1]  = pSave.statVal_charisma;
        statVal[2]  = pSave.statVal_intellect;
        statVal[3]  = pSave.statVal_loveEXP;
        statVal[4]  = pSave.statVal_charismaEXP;
        statVal[5]  = pSave.statVal_intellectEXP;
        statVal[6]  = pSave.statVal_paper;
        statVal[7]  = pSave.gameExists;
        statVal[8]  = pSave.npc_gabbi;
        statVal[9]  = pSave.setting_quality;
        statVal[10] = pSave.setting_resolutionIndex;
        statVal[11] = pSave.setting_isFullscreen;
        statVal[12] = pSave.setting_masterVolume;
        statVal[13] = pSave.setting_soundVolume;
        statVal[14] = pSave.setting_musicVolume;
        statVal[15] = pSave.progressID1;
        statVal[16] = pSave.stateID1;
    }
Example #9
0
        /// <summary>
        /// Returns Formatter to display latest chatacter save info
        /// </summary>
        /// <returns></returns>
        public Formatter[] ContainsSaves()
        {
            try
            {
                PlayerSave latest  = GetLatestSave();
                string     message = String.Format("A saved character with name {0} ({1}HP, {2}STR, {3}AGI, {4}INT) was found.", latest.charName.TrimEnd(), latest.health, latest.strength, latest.agility, latest.intellect);

                Formatter[] characterFormatter = new Formatter[]
                {
                    new Formatter(latest.charName.TrimEnd(), Color.CadetBlue),
                    new Formatter(latest.health + "HP", Color.CadetBlue),
                    new Formatter(latest.strength + "STR", Color.IndianRed),
                    new Formatter(latest.agility + "AGI", Color.Yellow),
                    new Formatter(latest.intellect + "INT", Color.MediumPurple)
                };

                return(characterFormatter);
            }
            catch
            {
                return(null);
            }
        }
    void LoadTexture()
    {
        PlayerData playerdata = PlayerSave.LoadData();

        SetTexture("Skin", playerdata.skin);
        SetTexture("Hair", playerdata.hair);
        SetTexture("Mouth", playerdata.mouth);
        SetTexture("Eyes", playerdata.eyes);
        SetTexture("Clothes", playerdata.clothes);
        SetTexture("Armour", playerdata.armour);
        // Get a gameComponent text that shows it up
        //playerdata.charName;
        //playerdata.selectedClass);
        //playerdata.selectedClass);
        //Bad example down
        //character.GetComponentInParent<Transform>().name = playerdata.charName;

        ///
        //check to see if our save file for this character
        //if it doesn't then load the CustomSet level
        //if it does have a save file then load and SetTexture Skin, Hair, Mouth and Eyes from PlayerPrefs
        //grab the gameObject in scene that is our character and set its Object name to the Characters name
    }
Example #11
0
    private void UpdateWeapon()
    {
        var savedWeapons = PlayerSave.GetWeapons();
        var minPosition  = int.MaxValue;

        foreach (int position in savedWeapons.Keys)
        {
            if (minPosition > position)
            {
                minPosition = position;
            }
        }
        var newWeaponData = GameInstance.GetAvailableWeapon(savedWeapons[minPosition]);

        if (weaponData != newWeaponData)
        {
            weaponData = newWeaponData;
            if (characterModel != null && weaponData != null)
            {
                characterModel.SetWeaponModel(weaponData.rightHandObject, weaponData.leftHandObject, weaponData.shieldObject);
            }
        }
    }
Example #12
0
    public static PlayerSave CreateSave(string name, string checkpointName = null, string resourcePath = "")
    {
        string     currentVersion = VersionNumberScript.version;
        PlayerSave save           = new PlayerSave();

        save.name             = name;
        save.timePlayed       = 0;
        save.presetBlueprints = new string[5];
        save.currentHealths   = new float[] { 1000, 250, 500 };
        save.partInventory    = new List <EntityBlueprint.PartInfo>();
        save.sectorsSeen      = new List <string>();
        save.missions         = new List <Mission>();

        // this section contains default information for a new save. Edit this to change how the default save
        // is created.
        EntityBlueprint blueprint = ScriptableObject.CreateInstance <EntityBlueprint>();

        blueprint.name              = "Player Save Blueprint";
        blueprint.parts             = new List <EntityBlueprint.PartInfo>();
        blueprint.coreSpriteID      = "core1_light";
        blueprint.coreShellSpriteID = "core1_shell";
        blueprint.baseRegen         = CoreUpgraderScript.GetRegens(blueprint.coreShellSpriteID);
        blueprint.shellHealth       = CoreUpgraderScript.defaultHealths;
        save.currentPlayerBlueprint = JsonUtility.ToJson(blueprint);
        save.abilityCaps            = CoreUpgraderScript.minAbilityCap;
        save.shards         = 0;
        save.version        = currentVersion;
        save.resourcePath   = resourcePath;
        save.abilityHotkeys = new AbilityHotkeyStruct();

        var savesDir = System.IO.Path.Combine(Application.persistentDataPath, "Saves");

        Directory.CreateDirectory(savesDir);
        File.WriteAllText(System.IO.Path.Combine(savesDir, name), JsonUtility.ToJson(save));

        return(save);
    }
Example #13
0
    public void LoadGame(string path)
    {
        //Set the current save to the path we retrived
        PlayerSave.SetSaveFile(path);

        //Load the save as it would still contain the previous one.
        PlayerSave.Load();

        //Load all the game data
        for (int i = 0; i < rigidbodies.Length; i++)
        {
            //Apply the position, rotation and scale
            PlayerSave.GetTransform("rigidbody_" + i + "_pos", rigidbodies[i].transform);

            //Apply the colour
            rigidbodies[i].GetComponent <Renderer>().material.color = PlayerSave.GetColor("rigidbody_" + i + "_color", Color.white);

            //Apply the velocity
            rigidbodies[i].velocity = PlayerSave.GetVector3("rigidbody_" + i + "_velocity", Vector3.zero);

            //Apply the angular velocity
            rigidbodies[i].angularVelocity = PlayerSave.GetVector3("rigidbody_" + i + "_angularVelocity", Vector3.zero);
        }
    }
Example #14
0
    void SetUpSaves()
    {
        saves = new List <PlayerSave>();
        paths = new List <string>();
        icons = new List <SaveMenuIcon>();
        string path = System.IO.Path.Combine(Application.persistentDataPath, "Saves");

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        else
        {
            string[] files = Directory.GetFiles(path);
            foreach (string file in files)
            {
                if (file.Contains("TestSave"))
                {
                    continue;
                }

                try
                {
                    string     savejson = File.ReadAllText(file);
                    PlayerSave save     = JsonUtility.FromJson <PlayerSave>(savejson);
                    saves.Add(save);
                    paths.Add(file);
                }
                catch (System.Exception e)
                {
                    Debug.LogError(e);
                    continue;
                }
            }
        }
    }
Example #15
0
    public void LoadSave(PlayerSave save)
    {
        if (save.timePlayed != 0)
        {
            if (save.characters != null && save.characters.Length != 0)
            {
                // use the save's characters combined with any new characters in the Sector Manager character set
                var sectoManagerChars = new List <WorldData.CharacterData>(SectorManager.instance.characters);
                var newChars          = new List <WorldData.CharacterData>(save.characters);
                foreach (var ch in sectoManagerChars)
                {
                    if (newChars.TrueForAll(c => c.ID != ch.ID))
                    {
                        newChars.Add(ch);
                    }
                }
                SectorManager.instance.characters = newChars.ToArray();
            }
            transform.position = save.position;
        }

        name = entityName = "player";
        positionBeforeOscillation = transform.position.y;
    }
Example #16
0
    // Use this for initialization
    void Start()
    {
        paddle      = FindObjectOfType <Paddle>();
        launchArrow = FindObjectOfType <LaunchArrow>();
        launchArrow.GetComponent <Renderer>().enabled = true;
        launchArrow.ball        = this;
        this.transform.position = paddle.transform.position;
        BossEyeAndBrowMovement eyebrows = FindObjectOfType <BossEyeAndBrowMovement>();

        if (eyebrows)
        {
            eyebrows.target = this.gameObject;
        }
        playerSave = FindObjectOfType <PlayerSave>();
        if (playerSave == null)
        {
            sfxVolume = 1;
        }
        else
        {
            sfxVolume = playerSave.sfx;
        }
        GetComponent <AudioSource>().volume = FindObjectOfType <PlayerSave>().sfx;
    }
Example #17
0
 // Use this for initialization
 void Start()
 {
     playerS = PlayerSave.load ();
     CreateMap ();
 }
Example #18
0
 // Use this for initialization
 void Start()
 {
     playerSave = transform.GetComponent <PlayerSave>();
 }
Example #19
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (var character in this._sh._playerSave)
            {
                if (character.Name.Equals(this.comboBox1.SelectedItem.ToString()))
                {
                    _selectedCharacter = character;
                }
            }

            if (_selectedCharacter != null)
            {
                this.charNameText.Text         = _selectedCharacter.Name;
                this.modelSelect.Text          = _selectedCharacter.Proto;
                this.apCounter.Value           = _selectedCharacter.Ap;
                this.relationshipCounter.Value = _selectedCharacter.Relationship;

                this.levelCounter.Value     = _selectedCharacter.Stats.Level;
                this.expCounter.Value       = _selectedCharacter.Stats.Xp;
                this.strenghtCounter.Value  = _selectedCharacter.Stats.Strength;
                this.agilityCounter.Value   = _selectedCharacter.Stats.Agility;
                this.percepCounter.Value    = _selectedCharacter.Stats.Perception;
                this.enduranceCounter.Value = _selectedCharacter.Stats.Endurance;
                this.charismaCounter.Value  = _selectedCharacter.Stats.Charisma;
                this.intelCounter.Value     = _selectedCharacter.Stats.Intelligence;
                this.luckCounter.Value      = _selectedCharacter.Stats.Luck;

                this._skEdit = new SkillEdit(this);
                this._skEdit.LoadSkills(this._selectedCharacter.Stats.Skills);

                this._pEdit = new PerkEdit(this);
                this._pEdit.LoadPerks(this._selectedCharacter.Stats.Perks);

                this.skinSelector.Text      = this._selectedCharacter.Skin;
                this.beardSelector.Text     = this._selectedCharacter.Beard;
                this.hairSelector.Text      = this._selectedCharacter.Hair;
                this.hairColorSelector.Text = this._selectedCharacter.HairColor;

                this.headSelector.Text     = this._selectedCharacter.Cap.Proto;
                this.headSkinSelector.Text = this._selectedCharacter.Cap.Skin;

                this.bagSelector.Text     = this._selectedCharacter.Rucksack.Proto;
                this.bagSkinSelector.Text = this._selectedCharacter.Rucksack.Skin;

                this.faceSelector.Text     = this._selectedCharacter.HeadMask.Proto;
                this.faceSkinSelector.Text = this._selectedCharacter.HeadMask.Skin;

                this.item1Selector.Text     = this._selectedCharacter.Item1.Proto;
                this.item1SkinSelector.Text = this._selectedCharacter.Item1.Skin;
                if (this._selectedCharacter.Item1.Ammo != null)
                {
                    this.item1AmmoSelector.Text = this._selectedCharacter.Item1.Ammo.Proto;
                    this.item1AmmoCount.Value   = this._selectedCharacter.Item1.Ammo.Count;
                }

                this.item2Selector.Text     = this._selectedCharacter.Item2.Proto;
                this.item2SkinSelector.Text = this._selectedCharacter.Item2.Skin;
                if (this._selectedCharacter.Item2.Ammo != null)
                {
                    this.item2AmmoSelector.Text = this._selectedCharacter.Item2.Ammo.Proto;
                    this.item2AmmoCount.Value   = this._selectedCharacter.Item2.Ammo.Count;
                }


                this.keywordsList.Items.Clear();
                // I only added most interesting ones I could find in my save files, but there should be a lot more.
                this.keywordsList.Items.Add("CULT_CODE1: " + this._selectedCharacter.Keywords.CultCode1);
                this.keywordsList.Items.Add("CULT_CODE2: " + this._selectedCharacter.Keywords.CultCode2);
                this.keywordsList.Items.Add("PIN_VILLAGE_BUNKER_SAFE: " + this._selectedCharacter.Keywords.PinVillageBunkerSafe);
            }
            else
            {
                MessageBox.Show("No character selected has been found in the save file.", "No character found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #20
0
    public void Initialize()
    {
        string currentPath;

        if (!File.Exists(Application.persistentDataPath + "\\CurrentSavePath"))
        {
            currentPath = Application.persistentDataPath + "\\TestSave";
        }
        else
        {
            currentPath = File.ReadAllLines(Application.persistentDataPath + "\\CurrentSavePath")[0];
        }

        if (File.Exists(currentPath))
        {
            // Load
            string json = File.ReadAllText(currentPath);
            save = JsonUtility.FromJson <PlayerSave>(json);
            if (save.timePlayed != 0)
            {
                player.spawnPoint = save.position;
            }

            if (SectorManager.testJsonPath != null)
            {
                save.resourcePath = SectorManager.testJsonPath;
            }
            else if (save.resourcePath == "")
            {
                save.resourcePath = SectorManager.jsonPath;
            }
            player.cursave = save;

            SectorManager.instance.LoadSectorFile(save.resourcePath);
            taskManager.Initialize(true);             // Re-init
            DialogueSystem.InitCanvases();

            player.blueprint      = ScriptableObject.CreateInstance <EntityBlueprint>();
            player.blueprint.name = "Player Save Blueprint";
            if (save.currentPlayerBlueprint != null && save.currentPlayerBlueprint != "")
            {
                JsonUtility.FromJsonOverwrite(save.currentPlayerBlueprint, player.blueprint);
            }
            else
            {
                Debug.LogError("Save should have been given a currentPlayerBlueprint by now.");
                player.blueprint.parts             = new List <EntityBlueprint.PartInfo>();
                player.blueprint.coreSpriteID      = "core1_light";
                player.blueprint.coreShellSpriteID = "core1_shell";
                player.blueprint.baseRegen         = CoreUpgraderScript.GetRegens(player.blueprint.coreShellSpriteID);
                player.blueprint.shellHealth       = CoreUpgraderScript.defaultHealths;
            }
            player.abilityCaps = save.abilityCaps;
            player.shards      = save.shards;
            player.SetCredits(save.credits);
            player.reputation = save.reputation;
            if (save.presetBlueprints.Length != 5)
            {
                save.presetBlueprints = new string[5];
            }
            Camera.main.GetComponent <CameraScript>().Initialize(player);

            taskManager.taskVariables.Clear();
            for (int i = 0; i < save.taskVariableNames.Length; i++)
            {
                taskManager.taskVariables.Add(save.taskVariableNames[i], save.taskVariableValues[i]);
            }
        }
        else
        {
            Debug.LogError("There was not a save or test save that was ready on load.");
            save = new PlayerSave();
            save.presetBlueprints = new string[5];
            save.currentHealths   = new float[] { 1000, 250, 500 };
            save.partInventory    = new List <EntityBlueprint.PartInfo>();

            player.blueprint                   = ScriptableObject.CreateInstance <EntityBlueprint>();
            player.blueprint.name              = "Player Save Blueprint";
            player.blueprint.coreSpriteID      = "core1_light";
            player.blueprint.coreShellSpriteID = "core1_shell";
            player.blueprint.baseRegen         = CoreUpgraderScript.GetRegens(player.blueprint.coreShellSpriteID);
            player.blueprint.shellHealth       = CoreUpgraderScript.defaultHealths;
            player.blueprint.parts             = new List <EntityBlueprint.PartInfo>();
            player.cursave     = save;
            player.abilityCaps = CoreUpgraderScript.minAbilityCap;
        }
    }
 //Function called Save this will allow us to save our indexes
 void Save()
 {
     PlayerSave.SaveData(this);
     SelectCharacter.chosenCharacter = Warrior;
 }
Example #22
0
    /// <summary>Saves the Player's data</summary>
    public void Save(PlayerData data)
    {
        if (!File.Exists(Application.persistentDataPath + "/playerData.dat"))
        {
            Debug.Log("Creating file at " + Application.persistentDataPath);
            BinaryFormatter bf    = new BinaryFormatter();
            FileStream      file  = File.Create(Application.persistentDataPath + "/playerData.dat");
            PlayerSave      pData = new PlayerSave();

            Debug.Log("Saving data from " + data.gameObject.name);

            /*pData.m_EnemiesKilledLifetime = pData.m_EnemiesKilledLifetime + m_PData.m_EnemiesKilled;
             * pData.m_WavesCompleted = m_PData.m_WavesCompleted;
             * pData.m_TotalScore = m_PData.m_TotalScore;
             * pData.m_Salvage = m_PData.m_Salvage;
             * pData.m_ShipTier = m_PData.m_ShipLevel;
             * pData.m_Shield = m_PData.m_Shield;
             * pData.m_HP = m_PData.m_HP;
             * pData.m_EngineLevel = m_PData.m_EngineLevel;
             * pData.m_ShieldLevel = m_PData.m_ShieldLevel;
             * pData.m_HealthLevel = m_PData.m_HealthLevel;
             * pData.m_DamageLevel = m_PData.m_DamageLevel;
             * pData.m_Items = m_PData.m_Items;
             * pData.m_Tokens = m_PData.m_Tokens;*/

            pData.m_EnemiesKilledLifetime = pData.m_EnemiesKilledLifetime + data.m_EnemiesKilled;
            pData.m_WavesCompleted        = data.m_WavesCompleted;
            pData.m_TotalScore            = data.m_TotalScore;
            Debug.Log("Saved salvage: " + pData.m_Salvage + "     Current Salvage: " + data.m_Salvage);
            pData.m_Salvage    += data.m_Salvage;
            pData.m_ShipTier    = data.m_ShipLevel;
            pData.m_Shield      = data.m_Shield;
            pData.m_HP          = data.m_HP;
            pData.m_EngineLevel = data.m_EngineLevel;
            pData.m_ShieldLevel = data.m_ShieldLevel;
            pData.m_HealthLevel = data.m_HealthLevel;
            pData.m_DamageLevel = data.m_DamageLevel;
            pData.m_Items       = data.m_Items;
            pData.m_Tokens      = data.m_Tokens;

            bf.Serialize(file, pData);
            file.Close();
        }
        else
        {
            Debug.Log("Saving to " + Application.persistentDataPath);
            BinaryFormatter bf    = new BinaryFormatter();
            FileStream      file  = File.Open(Application.persistentDataPath + "/playerData.dat", FileMode.Open);
            PlayerSave      pData = new PlayerSave();

            Debug.Log("Saving data from " + data.gameObject.name);

            /*pData.m_EnemiesKilledLifetime = pData.m_EnemiesKilledLifetime + m_PData.m_EnemiesKilled;
             * pData.m_WavesCompleted = m_PData.m_WavesCompleted;
             * pData.m_TotalScore = m_PData.m_TotalScore;
             * pData.m_Salvage = m_PData.m_Salvage;
             * pData.m_ShipTier = m_PData.m_ShipLevel;
             * pData.m_Shield = m_PData.m_Shield;
             * pData.m_HP = m_PData.m_HP;
             * pData.m_EngineLevel = m_PData.m_EngineLevel;
             * pData.m_ShieldLevel = m_PData.m_ShieldLevel;
             * pData.m_HealthLevel = m_PData.m_HealthLevel;
             * pData.m_DamageLevel = m_PData.m_DamageLevel;
             * pData.m_Items = m_PData.m_Items;
             * pData.m_Tokens = m_PData.m_Tokens;*/

            pData.m_EnemiesKilledLifetime = pData.m_EnemiesKilledLifetime + data.m_EnemiesKilled;
            pData.m_WavesCompleted        = data.m_WavesCompleted;
            pData.m_TotalScore            = data.m_TotalScore;
            Debug.Log("Saved salvage: " + pData.m_Salvage + "     Current Salvage: " + data.m_Salvage);
            pData.m_Salvage += data.m_Salvage;
            Debug.Log("After save salvage: " + pData.m_Salvage);
            pData.m_ShipTier    = data.m_ShipLevel;
            pData.m_Shield      = data.m_Shield;
            pData.m_HP          = data.m_HP;
            pData.m_EngineLevel = data.m_EngineLevel;
            pData.m_ShieldLevel = data.m_ShieldLevel;
            pData.m_HealthLevel = data.m_HealthLevel;
            pData.m_DamageLevel = data.m_DamageLevel;
            pData.m_Items       = data.m_Items;
            pData.m_Tokens      = data.m_Tokens;

            bf.Serialize(file, pData);
            file.Close();
        }
    }
 public void NewTournament()
 {
     tournament = new Tournament();
     //For now, creating a match:
     tournament.CreateMatch(PlayerSave.CreateRandomCPU());
 }
Example #24
0
 public PlayerData(PlayerSave player)
 {
     level = player.level;
 }
Example #25
0
    public void SaveState()
    {
        if(saveState != null) {
            saveState.UpdateFromState(this);
        }
        else {
            saveState = new PlayerSave();
        }

        XMLObjectLoader.SaveXMLObject<PlayerSave>(testSavefile, saveState);
    }
Example #26
0
 public void OnInputNameChanged(string eventInput)
 {
     PlayerSave.SetPlayerName(inputName.text);
 }
Example #27
0
 private void Start()
 {
     inputName.text  = PlayerSave.GetPlayerName();
     SelectHead      = PlayerSave.GetHead();
     SelectCharacter = PlayerSave.GetCharacter();
 }
Example #28
0
    static PlayerSave initFirstPlay()
    {
        PlayerSave s = new PlayerSave();
        BrickSave brick;
        int ROW = 161;
        int COLUMN = 50;
        int brkType;
        float rand;
        for (int i=0; i<ROW; i++) {
            for(int j=0; j<COLUMN; j++){
                brick = new BrickSave();
                brick.id = i*COLUMN+j;
                brkType = getBrickType(i);
                brick.brickType = (BrickType)brkType;
                brick.drilledAmount = 0;
                brick.neighbourCode = i*COLUMN+j<COLUMN ? "1011":"1111";
                //add minerals
                if(i==ROW-1 || (i == 0 && j >= 22 && j <= 27)){
                    //last row, cant be drilled
                    brick.mineralType = MineralType.NonBreakableStone;
                }else{
                    rand = UnityEngine.Random.value;
                    if(rand <0.2f){
                        brick.mineralType = (MineralType)(rand>0.18? brkType+1: (rand> 0.13? (int)MineralType.Stone:brkType));
                    }
                }
                s.bricks.Add(brick);
            }
        }
        //first commit
        s.commit ();

        return s;
    }
 public void NewSave()
 {
     state = new PlayerSave();
     Save();
     MonoBehaviour.print("Creating new save file");
 }
Example #30
0
    public void LoadState()
    {
        upgradeUnlockTable = new Dictionary<string, int>();
        equippedUpgrades = new List<UpgradePair>();

        saveState = XMLObjectLoader.LoadXMLObjectExternal<PlayerSave>(testSavefile);
        if(saveState == null) {
            Debug.Log("Player State could not load a save file from " + testSavefile);
            saveState = new PlayerSave();
        }
        else {
            Debug.Log("Player State loaded @ " + testSavefile);
        }

        upgradePoints = saveState.availablePoints;

        // Have to manually load the upgrades, TODO: tie this in with the player save better... These things are seriously sprinkled everywhere
        upgradeUnlockTable.Add("Upgrade_Health", saveState.GetSavedLevelForUpgrade("Upgrade_Health"));
        upgradeUnlockTable.Add("Upgrade_HealthRegen", saveState.GetSavedLevelForUpgrade("Upgrade_HealthRegen"));
        upgradeUnlockTable.Add("Upgrade_Energy", saveState.GetSavedLevelForUpgrade("Upgrade_Energy"));
        upgradeUnlockTable.Add("Upgrade_LifeSteal", saveState.GetSavedLevelForUpgrade("Upgrade_LifeSteal"));

        if(saveState.equippedUpgrades != null) {
            //equippedUpgrades.AddRange(saveState.equippedUpgrades);
            // update the slots in use
            for(int i = 0; i < saveState.equippedUpgrades.Length; i++) {
                EquipUpgradeType(saveState.equippedUpgrades[i].name, saveState.equippedUpgrades[i].level);
            }
        }
        else {
            saveState.equippedUpgrades = new PlayerSave.UpgradePair[0];
        }
    }
Example #31
0
    public void Initialize()
    {
        instance = this;
        string currentPath;
        var    CurrentSavePath = System.IO.Path.Combine(Application.persistentDataPath, "CurrentSavePath");

        if (!File.Exists(CurrentSavePath))
        {
            currentPath = System.IO.Path.Combine(Application.persistentDataPath, "TestSave");
        }
        else
        {
            currentPath = File.ReadAllLines(CurrentSavePath)[0];
        }

        if (File.Exists(currentPath))
        {
            // Load
            string json = File.ReadAllText(currentPath);
            save = JsonUtility.FromJson <PlayerSave>(json);
            if (save.timePlayed != 0)
            {
                player.spawnPoint = save.position;
                player.Dimension  = save.lastDimension;
            }

            if (SectorManager.testJsonPath != null)
            {
                save.resourcePath = SectorManager.testJsonPath;
            }
            else if (save.resourcePath == "")
            {
                save.resourcePath = SectorManager.jsonPath;
            }

            player.cursave = save;

            if (save.factions != null)
            {
                for (int i = 0; i < save.factions.Length; i++)
                {
                    FactionManager.SetFactionRelations(save.factions[i], save.relations[i]);
                }
            }

            SectorManager.instance.LoadSectorFile(save.resourcePath);
            save.missions.RemoveAll(m => !taskManager.questCanvasPaths.Exists(p =>
                                                                              System.IO.Path.GetFileNameWithoutExtension(p) == m.name));
            taskManager.Initialize(true); // Re-init
            DialogueSystem.InitCanvases();


            player.blueprint      = ScriptableObject.CreateInstance <EntityBlueprint>();
            player.blueprint.name = "Player Save Blueprint";
            if (!string.IsNullOrEmpty(save.currentPlayerBlueprint))
            {
                var print = SectorManager.TryGettingEntityBlueprint(save.currentPlayerBlueprint);
                player.blueprint = print;
            }
            else
            {
                Debug.LogError("Save should have been given a currentPlayerBlueprint by now.");
                player.blueprint.parts             = new List <EntityBlueprint.PartInfo>();
                player.blueprint.coreSpriteID      = "core1_light";
                player.blueprint.coreShellSpriteID = "core1_shell";
                player.blueprint.baseRegen         = CoreUpgraderScript.GetRegens(player.blueprint.coreShellSpriteID);
                player.blueprint.shellHealth       = CoreUpgraderScript.defaultHealths;
            }

            player.abilityCaps = save.abilityCaps;
            player.shards      = save.shards;
            player.SetCredits(save.credits);
            player.reputation = save.reputation;
            if (save.presetBlueprints.Length != 5)
            {
                save.presetBlueprints = new string[5];
            }

            Camera.main.GetComponent <CameraScript>().Initialize(player);

            taskManager.taskVariables.Clear();
            for (int i = 0; i < save.taskVariableNames.Length; i++)
            {
                taskManager.taskVariables.Add(save.taskVariableNames[i], save.taskVariableValues[i]);
            }
        }
        else
        {
            Debug.LogError("There was not a save or test save that was ready on load.");
            save = new PlayerSave();
            save.presetBlueprints = new string[5];
            save.currentHealths   = new float[] { 1000, 250, 500 };
            save.partInventory    = new List <EntityBlueprint.PartInfo>();

            player.blueprint                   = ScriptableObject.CreateInstance <EntityBlueprint>();
            player.blueprint.name              = "Player Save Blueprint";
            player.blueprint.coreSpriteID      = "core1_light";
            player.blueprint.coreShellSpriteID = "core1_shell";
            player.blueprint.baseRegen         = CoreUpgraderScript.GetRegens(player.blueprint.coreShellSpriteID);
            player.blueprint.shellHealth       = CoreUpgraderScript.defaultHealths;
            player.blueprint.parts             = new List <EntityBlueprint.PartInfo>();
            player.cursave     = save;
            player.abilityCaps = CoreUpgraderScript.minAbilityCap;
        }
    }
Example #32
0
 public static void UpdatePlayerSaveOnLoad(PlayerSave save)
 {
     UpdateLegacyAnimation(save.Character.LegacyAnimations);
 }
Example #33
0
 public void PlayGame()
 {
     SceneManager.LoadScene("test_Scene", LoadSceneMode.Single);
     musicVol.volume = PlayerSave.GetFloat("musicVol");
     sfxVol.volume   = PlayerSave.GetFloat("sfxVol");
 }
Example #34
0
    void Start()
    {
        indexDelete =-1;
        Save = (PlayerSave)GameObject.FindObjectOfType (typeof(PlayerSave));
        gameManage = (GameManager)GameObject.FindObjectOfType (typeof(GameManager));
        playerManage = (PlayerManager)GameObject.FindObjectOfType (typeof(PlayerManager));
        StyleManager Styles = (StyleManager)GameObject.FindObjectOfType (typeof(StyleManager));

        if (!skin && Styles)
            skin = Styles.GetSkin (0);

        Characters = Save.LoadAllCharacters ();
        indexCharacter = PlayerPrefs.GetInt ("INDEX_CRE_CHAR");
    }
Example #35
0
 private void Start()
 {
     playerSave = FindObjectOfType <PlayerSave>();
 }
Example #36
0
 // ensures that the save function carries through the levels
 void Awake()
 {
     // if this script exists already destroy it
     if (instance != null && instance != this)
     {
         Destroy(this);
         return;
     }
     instance = this;
     DontDestroyOnLoad(this);
 }
 void Start()
 {
     playerSave = GetComponent <PlayerSave>();
 }