// Use this for initialization
 void Start()
 {
     abilitiesUI    = FindObjectOfType <AbilitiesUI>();
     underAttackUI  = FindObjectOfType <UnderAttackUI>();
     playerVitalsUI = FindObjectOfType <PlayerVitalsUI>();
     dialogueUI     = FindObjectOfType <DialogueUI>();
     npcController  = FindObjectOfType <NPCs>();
     //currentAbility = CombatAbilities.passive;
     playerCharacter       = FindObjectOfType <PlayerCharacter>();
     SelectedAbilityOption = "selectedAbilityOption";
     CreateSelectionToggleGroup(SelectedAbilityOption);
     HideAbilities();
     HideUnderAttack();
     HidePlayerVitals();
 }
Exemple #2
0
    /*loads all the details of the saved game except for the scene, since loading a scene destroys saveGameManager obj*/
    public void LoadSave()
    {
        SkillsMenuUI   skillsMenuUI   = FindObjectOfType <SkillsMenuUI>();
        PlayerVitalsUI playerVitalsUI = FindObjectOfType <PlayerVitalsUI>();
        int            saveID         = PlayerPrefsManager.GetSaveGame();

        //print(DbCommands.GetConn());
        string[] playerSave = DbCommands.GetTupleFromTable("PlayerGames", " SaveIDs = " + saveID);
        print("Loading save reference: "
              + playerSave[1] + " PlayerName: "
              + playerSave[2] + " Portrait path: "
              + playerSave[3] + " Save ID: "
              + saveID);
        SetPlayerName(playerSave[2]);
        SetPlayerPortraitPath(playerSave[3]);
        player.GetComponent <PlayerCharacter>().SetMyName(playerName);
        player.GetComponent <PlayerCharacter>().SetMyPortrait(playerPortraitPath);
        playerVitalsUI.Portrait.sprite = player.GetComponent <PlayerCharacter>().GetMyPortrait();
        float playerXpos = float.Parse(playerSave[6]);
        float playerYpos = float.Parse(playerSave[7]);
        //print(playerXpos + ", " + playerYpos);
        Transform playerTransform = player.GetComponent <Transform>();

        playerTransform.localPosition  = new Vector2(playerXpos, playerYpos);
        Camera.main.transform.position = new Vector3(playerTransform.position.x, playerTransform.position.y, Camera.main.transform.position.z);
        skillsMenuUI.SetSkillPointsSpent(int.Parse(playerSave[8]));
        Time.timeScale = 1;

        //Need to update currentgame with data from player save
        CopyPlayerSaveToCurrentGame(playerSave);
        if (saveID != 0)
        {
            LoadWorldItems();
            LoadPrefabQuests();
        }

        print("game loaded");
    }