Beispiel #1
0
    IEnumerator GameStartCoroutine()
    {
        theFade.FadeOut();
        yield return(new WaitForSeconds(2f));

        Color color = thePlayer.GetComponent <SpriteRenderer>().color;

        color.a = 1f;
        thePlayer.GetComponent <SpriteRenderer>().color = color;
        thePlayer.currentMapName = "Town";

        theGM.LoadStart();
        SceneManager.LoadScene("Town");
    }
Beispiel #2
0
    public void CallLoad()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Open(Application.dataPath + "/SaveFile.dat", FileMode.Open);

        if (file != null && file.Length > 0)
        {
            data = (Data)bf.Deserialize(file);

            theDatabase   = FindObjectOfType <DataBaseManager>();
            thePlayer     = FindObjectOfType <Player_Movement>();
            thePlayerStat = FindObjectOfType <Player_Stat>();
            theEquip      = FindObjectOfType <Equipment>();
            theInven      = FindObjectOfType <Inventory>();

            thePlayer.currentMapName = data.mapName;
            //thePlayer.currentSceneName = data.sceneName;

            vector.Set(data.playerX, data.playerY, data.playerZ);
            thePlayer.transform.position = vector;

            thePlayerStat.character_Lv = data.playerLv;
            thePlayerStat.hp           = data.playerHP;
            thePlayerStat.mp           = data.playerMP;
            thePlayerStat.currentHp    = data.playerCurrentHP;
            thePlayerStat.currentMp    = data.playerCurrentMP;
            thePlayerStat.currentExp   = data.playerCurrentEXP;
            thePlayerStat.atk          = data.playerATK;
            thePlayerStat.def          = data.playerDEF;

            thePlayerStat.Gold = data.playerGlod;

            //호감도
            thePlayerStat.favorability_Letitia = data.favorLetitia;
            thePlayerStat.favorability_Seren   = data.favorSeren;

            theEquip.added_atk = data.added_atk;
            theEquip.added_def = data.added_def;

            //이벤트 기록
            theDatabase.has_event001        = data.HasEvent001;
            theDatabase.has_event002        = data.HasEvent002;
            theDatabase.has_eventLetitia001 = data.HasEventLetitia001;
            theDatabase.has_eventLetitia002 = data.HasEventLetitia002;
            theDatabase.has_eventLetitia003 = data.HasEventLetitia003;
            theDatabase.has_eventLetitia004 = data.HasEventLetitia004;
            theDatabase.has_eventSeren001   = data.HasEventSeren001;
            theDatabase.has_eventSeren002   = data.HasEventSeren002;
            theDatabase.has_eventSeren003   = data.HasEventSeren003;
            theDatabase.has_eventSeren004   = data.HasEventSeren004;

            theDatabase.var         = data.varNumberList.ToArray();
            theDatabase.var_name    = data.varNameList.ToArray();
            theDatabase.switches    = data.swList.ToArray();
            theDatabase.switch_name = data.swNameList.ToArray();

            for (int i = 0; i < theEquip.equipItemList.Length; i++)
            {
                for (int x = 0; x < theDatabase.itemList.Count; x++)
                {
                    if (data.playerEquipItem[i] == theDatabase.itemList[x].itemID)
                    {
                        theEquip.equipItemList[i] = theDatabase.itemList[x];
                        Debug.Log("장착된 아이템을 로드했습니다 : " + theEquip.equipItemList[i].itemID);
                        break;
                    }
                }
            }


            List <Item> itemList = new List <Item>();

            for (int i = 0; i < data.playerItemInventory.Count; i++)
            {
                for (int x = 0; x < theDatabase.itemList.Count; x++)
                {
                    if (data.playerItemInventory[i] == theDatabase.itemList[x].itemID)
                    {
                        itemList.Add(theDatabase.itemList[x]);
                        Debug.Log("인벤토리 아이템을 로드했습니다 : " + theDatabase.itemList[x].itemID);
                        break;
                    }
                }
            }

            for (int i = 0; i < data.playerItemInventoryCount.Count; i++)
            {
                itemList[i].itemCount = data.playerItemInventoryCount[i];
            }

            theInven.LoadItem(itemList);
            theEquip.ShowText();

            RPGGameManager theGM = FindObjectOfType <RPGGameManager>();
            theGM.LoadStart();

            SceneManager.LoadScene(data.mapName);
        }
        else
        {
            Debug.Log("저장된 세이브 파일이 없습니다");
        }


        file.Close();
    }