Ejemplo n.º 1
0
    private void Initialize()
    {
        if (m_bInitialized == false)
        {
            m_bInitialized = true;
            DontDestroyOnLoad(gameObject);
            m_dbItem          = new DBItem(Define.DB_TABLE_ASYNC_ITEM);
            m_dbItemMaster    = new DBItemMaster(Define.DB_TABLE_ASYNC_ITEM_MASTER);
            m_dbWork          = new DBWork(Define.DB_TABLE_ASYNC_WORK);
            m_dbMonster       = new DBMonster(Define.DB_TABLE_ASYNC_MONSTER);
            m_dbMonsterMaster = new DBMonsterMaster(Define.DB_TABLE_ASYNC_MONSTER_MASTER);
            m_dbKvs           = new DBKvs(Define.DB_TABLE_ASYNC_KVS);

            m_fInterval = 0.0f;
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        bool bInit = false;

        if (m_eStepPre != m_eStep)
        {
            m_eStepPre = m_eStep;
            bInit      = true;
        }

        switch (m_eStep)
        {
        case STEP.DATAMANAGER_SETUP:
            if (bInit)
            {
                /*
                 * GameObject pref = PrefabManager.Instance.PrefabLoadInstance ("test");
                 * paramtest script = pref.GetComponent<paramtest> ();
                 * Debug.Log (script.list.Count);
                 * script.list.Add (new DataItem ());
                 */
            }


            if (SpriteManager.Instance.IsIdle())
            {
                m_goRoot.SetActive(true);
                m_btnStart.gameObject.SetActive(false);
                m_eStep = STEP.SOUND_LOAD;
            }
            if (m_csLoading != null)
            {
                m_csLoading.ViewPercent(0.0f);
            }
            break;

        case STEP.SOUND_LOAD:
            if (bInit)
            {
                foreach (MasterAudioCSV data in DataManager.master_audio_list)
                {
                    if (data.audio_type != 1)
                    {
                        SoundManager.Instance.AddLoadFile(data.filename);
                    }
                }
            }
            if (m_csLoading != null)
            {
                m_csLoading.ViewPercent(0.0f);
            }
            if (SoundManager.Instance.IsIdle())
            {
                m_btnStart.gameObject.SetActive(true);
                m_eStep = STEP.IDLE;

                if (ReviewManager.Instance.IsReadyReview())
                {
                    m_eStep = STEP.REVIEW;
                }
            }
            break;

        case STEP.REVIEW:
            if (bInit)
            {
                GameObject obj = PrefabManager.Instance.MakeObject("prefab/CtrlReviewWindow", m_goRoot.transform.parent.gameObject);
                m_reviewWindow = obj.GetComponent <CtrlReviewWindow> ();
                m_reviewWindow.Initialize();

                m_goRoot.SetActive(false);
            }
            if (m_reviewWindow.IsEnd())
            {
                m_goRoot.SetActive(true);
                Destroy(m_reviewWindow.gameObject);;
                m_eStep = STEP.IDLE;
            }
            break;

        case STEP.IDLE:
            if (bInit)
            {
                m_btnStart.TriggerClear();
                m_btnBackup.TriggerClear();
            }
            if (m_btnStart.ButtonPushed)
            {
                m_eStep = STEP.DB_SETUP;
                SoundManager.Instance.PlaySE("se_cleanup");
            }
            else if (m_btnBackup.ButtonPushed)
            {
                string backupDB = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN_BK);
                if (System.IO.File.Exists(backupDB) == false)
                {
                    m_eStep = STEP.DB_BACKUP_NOEXIST;
                }
                else
                {
                    m_eStep = STEP.DB_BACKUP_CHECK;
                }
            }
            else
            {
            }

            break;

        case STEP.DB_SETUP:
            if (bInit)
            {
                m_dbItem          = new DBItem(Define.DB_TABLE_ASYNC_ITEM);
                m_dbItemMaster    = new DBItemMaster(Define.DB_TABLE_ASYNC_ITEM_MASTER);
                m_dbWork          = new DBWork(Define.DB_TABLE_ASYNC_WORK);
                m_dbMonster       = new DBMonster(Define.DB_TABLE_ASYNC_MONSTER);
                m_dbMonsterMaster = new DBMonsterMaster(Define.DB_TABLE_ASYNC_MONSTER_MASTER);
                m_dbKvs           = new DBKvs(Define.DB_TABLE_ASYNC_KVS);

                /*
                 * m_dbItem.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbItemMaster.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbWork.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbMonster.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbMonsterMaster.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_tkKvsOpen = m_dbKvs.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, ""); // DEFINE.DB_PASSWORD
                 */
            }
            if (true)
            {
                //if (m_tkKvsOpen.Completed) {

                if (m_dbKvs.ReadInt(Define.USER_SYOJIKIN) == 0)
                {
                    m_dbKvs.WriteInt(Define.USER_SYOJIKIN, 1000);
                }

                List <DataItem> data_item_list = m_dbItem.SelectAll();
                // 最初しか通らない
                if (data_item_list.Count == 0)
                {
                    Debug.LogError("here");
                    m_dbKvs.WriteInt(Define.USER_SYAKKIN, 300000000);
                    var skitMasterTable = new MasterTableMapChip();
                    skitMasterTable.Load();
                    var csvItem = new CsvItem();
                    csvItem.Load();
                    foreach (MapChipCSV csvMapChip in skitMasterTable.All)
                    {
                        DataItem data = new DataItem(csvMapChip, csvItem);
                        m_dbItem.Replace(data);
                    }
                }

                List <DataWork> data_work_list = m_dbWork.SelectAll();
                if (data_work_list.Count == 0)
                {
                    var csvWork = new CsvWork();
                    csvWork.Load();
                    foreach (CsvWorkData csv_work_data in csvWork.All)
                    {
                        DataWork data = new DataWork(csv_work_data);
                        // 最初に出現していいのはappear_work_id== 0とlevel<=1のものだけ
                        if (data.appear_work_id == 0 && data.level <= 1)
                        {
                            data.status = 1;
                        }
                        m_dbWork.Replace(data);
                    }
                }

                List <DataMonster> data_monster_list = m_dbMonster.SelectAll();
                //Debug.LogError( string.Format( "data_monster_list.Count:{0}" , data_monster_list.Count ));
                if (data_monster_list.Count == 0)
                {
                    DataMonster monster = new DataMonster();
                    monster.monster_serial = 1;
                    monster.monster_id     = 1;
                    monster.item_serial    = 12;
                    monster.condition      = (int)Define.Monster.CONDITION.FINE;
                    monster.collect_time   = TimeManager.StrNow();

                    string strHungry = TimeManager.StrGetTime(-1 * 60 * 30);
                    monster.meal_time  = strHungry;
                    monster.clean_time = strHungry;
                    m_dbMonster.Replace(monster);
                }

                List <DataMonsterMaster> data_monster_master_list = m_dbMonsterMaster.SelectAll();
                if (data_monster_master_list.Count == 0)
                {
                    var csvMonsterMaster = new CsvMonster();
                    csvMonsterMaster.Load();
                    foreach (CsvMonsterData csv_monster_master_data in csvMonsterMaster.All)
                    {
                        m_dbMonsterMaster.Replace(csv_monster_master_data);
                    }
                }

                List <DataItemMaster> data_item_master = m_dbItemMaster.SelectAll();
                //Debug.LogError (string.Format ("count:{0}", data_item_master.Count));
                if (data_item_master.Count == 0)
                {
                    var csvItem = new CsvItem();
                    csvItem.Load();
                    foreach (CsvItemData csv_item_data in csvItem.All)
                    {
                        DataItemMaster data = new DataItemMaster(csv_item_data);
                        if (data.open_item_id == 0)
                        {
                            data.status = 1;
                        }
                        m_dbItemMaster.Replace(data);
                    }
                }
                m_eStep = STEP.INPUT_WAIT;
            }
            else
            {
                //Debug.Log ("wait");
            }

            break;

        case STEP.INPUT_WAIT:
            if (bInit)
            {
                m_btnStart.TriggerClear();
            }
            if (true)
            {
                // とりあえず全部調べる
                List <DataWork> cleared_work_list = m_dbWork.Select(string.Format(" status = {0} ", (int)Define.Work.STATUS.CLEARD));
                foreach (DataWork work in cleared_work_list)
                {
                    List <DataMonsterMaster> list_monster = m_dbMonsterMaster.Select(string.Format(" status = 0 and open_work_id = {0} ", work.work_id));
                    foreach (DataMonsterMaster data_monster_master in list_monster)
                    {
                        Dictionary <string, string> monster_master_dict = new Dictionary <string, string> ();
                        monster_master_dict.Add("status", "1");
                        m_dbMonsterMaster.Update(data_monster_master.monster_id, monster_master_dict);
                    }
                }

                m_btnStart.TriggerClear();
                Application.LoadLevel("park_main");
            }
            break;

        case STEP.DB_BACKUP_NOEXIST:
            if (bInit)
            {
                GameObject objOjisan = PrefabManager.Instance.MakeObject("prefab/PrefOjisanCheck", m_posDisplay);
                m_ojisanCheck = objOjisan.GetComponent <CtrlOjisanCheck> ();
                m_ojisanCheck.Initialize("バックアップファイルが\n存在しません", true);
            }
            if (m_ojisanCheck.IsYes())
            {
                Destroy(m_ojisanCheck.gameObject);
                m_eStep = STEP.IDLE;
            }
            break;

        case STEP.DB_BACKUP_CHECK:
            if (bInit)
            {
                GameObject objOjisan = PrefabManager.Instance.MakeObject("prefab/PrefOjisanCheck", m_posDisplay);
                m_ojisanCheck = objOjisan.GetComponent <CtrlOjisanCheck> ();
                m_ojisanCheck.Initialize("自動保存されたデータ\nを利用して\nバックアップを行います\n\nよろしいですか");
            }
            if (m_ojisanCheck.IsYes())
            {
                //SoundManager.Instance.PlaySE (SoundName.BUTTON_PUSH);
                Destroy(m_ojisanCheck.gameObject);
                m_eStep = STEP.DB_BACKUP;
            }
            else if (m_ojisanCheck.IsNo())
            {
                //SoundManager.Instance.PlaySE (SoundName.BUTTON_PUSH);
                Destroy(m_ojisanCheck.gameObject);
                m_eStep = STEP.IDLE;
            }
            else
            {
            }
            break;

        case STEP.DB_BACKUP:
            if (bInit)
            {
                GameObject objOjisan = PrefabManager.Instance.MakeObject("prefab/PrefOjisanCheck", m_posDisplay);
                m_ojisanCheck = objOjisan.GetComponent <CtrlOjisanCheck> ();
                m_ojisanCheck.Initialize("完了しました\nゲームをスタートしてください", true);

                string sourceDB  = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN);
                string dummyDB   = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN + "." + TimeManager.StrGetTime());
                string backupDB  = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN_BK);
                string backup2DB = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN_BK2);
                if (System.IO.File.Exists(sourceDB))
                {
                    System.IO.File.Copy(sourceDB, dummyDB, true);
                }
                if (System.IO.File.Exists(backupDB))
                {
                    System.IO.File.Copy(backupDB, sourceDB, true);
                }
            }
            if (m_ojisanCheck.IsYes())
            {
                Destroy(m_ojisanCheck.gameObject);
                m_eStep = STEP.IDLE;
            }
            break;

        default:
            break;
        }

        if (m_btnTutorialReset.ButtonPushed)
        {
            PlayerPrefs.DeleteAll();

            string full_path = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN);
            System.IO.File.Delete(full_path);

            m_btnTutorialReset.TriggerClear();
        }
        if (m_btnCacheClear.ButtonPushed)
        {
            Caching.CleanCache();
            m_btnCacheClear.TriggerClear();
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        bool bInit = false;

        if (m_eStepPre != m_eStep)
        {
            m_eStepPre = m_eStep;
            bInit      = true;
        }

        switch (m_eStep)
        {
        case STEP.DB_SETUP:
            if (bInit)
            {
                m_dbItem          = new DBItem(Define.DB_TABLE_ASYNC_ITEM);
                m_dbItemMaster    = new DBItemMaster(Define.DB_TABLE_ASYNC_ITEM_MASTER);
                m_dbWork          = new DBWork(Define.DB_TABLE_ASYNC_WORK);
                m_dbMonster       = new DBMonster(Define.DB_TABLE_ASYNC_MONSTER);
                m_dbMonsterMaster = new DBMonsterMaster(Define.DB_TABLE_ASYNC_MONSTER_MASTER);
                m_dbStaff         = new DBStaff(Define.DB_TABLE_ASYNC_STAFF);
                if (m_dbKvs == null)
                {
                    m_dbKvs = new DBKvs(Define.DB_TABLE_ASYNC_KVS);
                }

                /*
                 * m_dbItem.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbItemMaster.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbWork.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbMonster.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbMonsterMaster.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_dbStaff.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, "");
                 * m_tkKvsOpen = m_dbKvs.Open (Define.DB_NAME_DOUBTSUEN, Define.DB_FILE_DIRECTORY, ""); // DEFINE.DB_PASSWORD
                 */
            }
            //if (m_tkKvsOpen.Completed) {
            if (true)
            {
                DataManager.itemMaster = m_dbItemMaster.SelectAll();

                m_header.Initialize();
                m_header.RefleshNum();
                m_collectGold.Initialize();
                m_fukidashiWork.Initialize();


                m_eStep = STEP.IDLE;
            }
            break;

        case STEP.IDLE:
            if (bInit)
            {
                m_fBackupInterval      = 10.0f;
                m_fBackupIntervalTimer = 0.0f;
            }

            /*
             * m_fBackupIntervalTimer += Time.deltaTime;
             * if (m_fBackupInterval < m_fBackupIntervalTimer) {
             *      m_fBackupIntervalTimer -= m_fBackupInterval;
             *
             *      m_eStep = STEP.BACKUP_CHECK;
             * }
             */
            if (TutorialManager.Instance.IsTutorial() == false && ReviewManager.Instance.IsReadyReview())
            {
                m_eStep = STEP.REVIEW;
            }
            break;

        case STEP.REVIEW:
            if (bInit)
            {
                GameObject obj = PrefabManager.Instance.MakeObject("prefab/CtrlReviewWindow", m_goPanelFront);
                m_reviewWindow = obj.GetComponent <CtrlReviewWindow> ();
                m_reviewWindow.Initialize();
            }
            if (m_reviewWindow.IsEnd())
            {
                Destroy(m_reviewWindow.gameObject);;
                m_eStep = STEP.IDLE;
            }
            break;

        case STEP.BACKUP_CHECK:
            if (bInit)
            {
                string sourceDB  = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN);
                string backup2DB = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN_BK2);
                System.IO.File.Copy(sourceDB, backup2DB, true);

                m_dbItemBackup  = new DBItem(Define.DB_NAME_DOUBTSUEN_BK2);
                m_tkBackupCheck = new ThreadQueue.TaskControl();
                m_tkBackupCheck = m_dbItemBackup.Open(Define.DB_NAME_DOUBTSUEN_BK2, Define.DB_FILE_DIRECTORY, "");
                //Debug.Log ("STEP.BACKUP_CHECK");
            }
            //Debug.Log ("frame");
            if (m_tkBackupCheck.Completed)
            {
                m_eStep = STEP.IDLE;
                try
                {
                    // DBおかしくなってたらここでThrowされる
                    List <DataItem> check = m_dbItemBackup.SelectAll();

                    //Debug.Log( "Copy" );
                    //string sourcePath = System.IO.Path.Combine (Application.streamingAssetsPath, Define.DB_FILE_DIRECTORY + Define.DB_NAME_DOUBTSUEN );
                    string backupDB  = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN_BK);
                    string backup2DB = System.IO.Path.Combine(Application.persistentDataPath, Define.DB_NAME_DOUBTSUEN_BK2);
                    if (System.IO.File.Exists(backup2DB))
                    {
                        System.IO.File.Copy(backup2DB, backupDB, true);
                    }
                }catch {
                    //Debug.LogError ("まずー");
                }
            }
            break;

        default:
            break;
        }
    }