Exemplo n.º 1
0
    public static GhostbookManagerLight getInstance()
    {
        if(uniqueGBInstance == null)
        {
            UnityEngine.GameObject poRef = PersistentObjMang.getInstance();
            DatastoreScript ds = poRef.GetComponent<DatastoreScript>();

            if(ds.containsData("GBMang"))
            {
                GhostbookManagerLight extractedData = (GhostbookManagerLight) ds.getData("GBMang");
                if(extractedData != null)
                {
                    uniqueGBInstance = extractedData;
                }
                else
                {
                    uniqueGBInstance = new GhostbookManagerLight();
                    ds.insertData("GBMang",uniqueGBInstance);
                }
            }
            else
            {
                uniqueGBInstance = new GhostbookManagerLight();
                ds.insertData("GBMang",uniqueGBInstance);
            }
        }

        return uniqueGBInstance;
    }
Exemplo n.º 2
0
    public static bool loadSaveFromPlayerDownload(string para_downloadedGameState,LanguageCode language, LiteracyProfile profile)
    {
        bool successFlag = false;

        LocalisationMang.init(language);
        string gameSaveStr = para_downloadedGameState;

        try
        {
            ILearnRWSaveFilePackage savePackage = ObjectSerializerHelper.deserialiseObjFromString<ILearnRWSaveFilePackage>(gameSaveStr);
            SaveVersioningInfo saveVersionInfo =  savePackage.getGameVersionInfo();

            GameObject poRef = PersistentObjMang.getInstance();
            DatastoreScript ds = poRef.GetComponent<DatastoreScript>();

            GhostbookManagerLight gbMang;

            if((saveVersionInfo==null)||(saveVersionInfo.getYearValue()==2014)){

                ILearnRWSaveA castSave = (ILearnRWSaveA) savePackage;

                PlayerAvatarSettings tmpPASettings = castSave.getPlayerAvatarSettings();
                if(tmpPASettings == null)
                {

                    tmpPASettings = new PlayerAvatarSettings();
                    tmpPASettings.initWithDefaultState();
                }

                ds.insertData("PlayerAvatarSettings",tmpPASettings);

                PlayerGhostbookSatchel oldSatchel = castSave.getPlayerGBSatchelState();
                gbMang = new GhostbookManagerLight(oldSatchel);

            }else{
                ILearnRWSaveB castSave = (ILearnRWSaveB) savePackage;

                PlayerAvatarSettings tmpPASettings = castSave.getPlayerAvatarSettings();
                if(tmpPASettings == null)
                {

                    tmpPASettings = new PlayerAvatarSettings();
                    tmpPASettings.initWithDefaultState();
                }

                ds.insertData("PlayerAvatarSettings",tmpPASettings);

                LightSatchel satchel = castSave.getPlayerGBSatchelState();
                gbMang = new GhostbookManagerLight(satchel);

            }

            List<int[]> updates = gbMang.syncWithProfile(profile);

            foreach(int[] up in updates){
                Debug.Log("Sync: "+up[0]+" "+up[1]+" "+up[2]);
            }

            ds.insertData("IsUsingSaveFile",true);

            ds.insertData("GBMang",gbMang);

            successFlag = true;
            Debug.Log("SaveManager: Success in LOADING player file.");
        }
        catch(System.Exception ex)
        {

            Debug.Log(ex.ToString());
            Debug.Log(ex.Message);
            GameObject poRef = PersistentObjMang.getInstance();
            DatastoreScript ds = poRef.GetComponent<DatastoreScript>();
            ds.removeData("IsUsingSaveFile");
            ds.removeData("PlayerAvatarSettings");
            ds.removeData("WorldViewState");
            ds.insertData("FirstTime",true);

            Debug.LogError("SaveManager: Failed to LOAD player file.");
            successFlag = false;
        }

        return successFlag;
    }
Exemplo n.º 3
0
    public void init(ProgressScript c, GhostbookManagerLight gb)
    {
        unlockedCharacterFaces = new Transform[34] ;
        lockedCharacterFaces = new Transform[34] ;
        characterSmallFaces = new Transform[34] ;

        for(int i =0;i<34;i++){

            unlockedCharacterFaces[i] = ((GameObject)Resources.Load("Prefabs/Ghostbook/UnlockedProfilePics/UnlockedPortrait_"+i)).transform;
            //			unlockedCharacterFaces[i] = (Transform)Instantiate(Resources.Load("UnlockedPortrait_"+i));
            lockedCharacterFaces[i] = ((GameObject)Resources.Load("Prefabs/Ghostbook/LockedProfilePics/LockedPortrait_"+i)).transform;
            characterSmallFaces[i] = ((GameObject)Resources.Load("Prefabs/Ghostbook/SmallHeads/SmallHeads_"+i)).transform;

        }

        activitySymbols= new Transform[9];
        activitySymbols[0] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_MAIL_SORTER")).transform;
        activitySymbols[1] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_WHAK_A_MOLE")).transform;
        activitySymbols[2] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_ENDLESS_RUNNER")).transform;
        activitySymbols[3] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_HARVEST")).transform;
        activitySymbols[4] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_SERENADE_HERO")).transform;
        activitySymbols[5] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_MOVING_PATHWAYS")).transform;
        activitySymbols[6] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_EYE_EXAM")).transform;
        activitySymbols[7] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_TRAIN_DISPATCHER")).transform;
        activitySymbols[8] = ((GameObject)Resources.Load("Prefabs/Ghostbook/ActivitySymbols/SmallSymbols_DROP_CHOPS")).transform;

        photoPageCompletionStatusIcons = new Sprite[5] ;

        for(int i = 0;i<5;i++){
            photoPageCompletionStatusIcons[i] = Resources.Load<Sprite>("Prefabs/Ghostbook/PhotoIcon_V"+i);

        }

        maskShaderMaterial = (Material)Resources.Load("Prefabs/Ghostbook/ScrollMaskMat");
        maskShaderMaterialForText = (Material)Resources.Load("Prefabs/Ghostbook/ScrollMaskMatForText");

        ghostBookWordBoxPrefab = ((GameObject)Resources.Load("Prefabs/Ghostbook/GBookWordBox")).transform;

        textBannerNarrowPrefab = ((GameObject)Resources.Load("Prefabs/Ghostbook/TextBannerNarrow")).transform;
        //textBannerThickPrefab = ((GameObject)Resources.Load("Prefabs/Ghostbook/TextBannerThick")).transform;
        newsIconPrefab = ((GameObject)Resources.Load("Prefabs/Ghostbook/NewsBanner")).transform;

        this.loadTextures();
        this.prepUIBounds();

        //customTRSMat = Matrix4x4.TRS(Vector3.zero,Quaternion.identity,new Vector3(Screen.width/virtualWidth,Screen.height/virtualHeight,1.0f));

        this.gbMang = gb;
        this.control = c;

        //albumCollectionScrollPos = new Vector2();

        //smallFacesNormTexBounds = extractNormTexBoundsForMultisprites(characterSmallFaces);
        //activitySymbolsNormTexBounds = extractNormTexBoundsForMultisprites(activitySymbols);

        //constructTabbedGhostbook();
        //loadContactGridPage();
        //ghostbookGObj.SetActive(false);

        setupReady = true;
        //this.enabled = false;
    }
    public static List<PhotoDatabaseCommand> obtainNecessarySeverityUpdates(ActivitySessionMetaData acMetaData, bool para_otherData,GhostbookManagerLight gbMang,List<PackagedProfileUpdate> updateList,int[][] severities)
    {
        int usedLangArea = acMetaData.getLangAreaID();
        int usedDiffForLangArea = acMetaData.getDiffIndexForLangArea();
        bool outcome =  para_otherData;

        List<PhotoDatabaseCommand> commandQueue = null;

        //First check if the language area played had one photo already
        PhotoAlbum album = gbMang.getPhotoAlbumForCharacter(acMetaData.getQuestGiverID());
        PhotoPage reqPage = album.findSpecificPage(usedLangArea,usedDiffForLangArea);

        ApplicationID acPkey = acMetaData.getApplicationID();
        int activityOwnerID = LocalisationMang.getOwnerNpcOfActivity(acPkey);

        commandQueue = new List<PhotoDatabaseCommand>();

        if(reqPage.getNumAvailablePhotos() == 0)//The first picture is free
            {
                if(outcome == true)
                {
                    // This lang-diff combo has been played for the first time. Create the first photo automatically.
                    // (Server side starts all severities at value 3 (value 0 meaning no literacy problems) and value 3 means 1 photo).
                    // Due to this setup on the server side, the first photo in every photo page never gets removed once created.

                string[] sectionText = LocalisationMang.getBioSection(acMetaData.getQuestGiverID(),0);

                PDBCAddPhoto tmp = new PDBCAddPhoto(acMetaData.getQuestGiverID(),activityOwnerID,acPkey,usedLangArea,usedDiffForLangArea,0,sectionText);
                commandQueue.Add(tmp);
                gbMang.addPhoto(tmp);
            }

        }

        //Add more photos based on server update
        if(updateList != null)
            {
                Debug.Log(updateList.Count);
                    for(int i=0; i<updateList.Count; i++)
                    {
                        PackagedProfileUpdate tmpItem = updateList[i];

                        int tmpNPCid = -1;

                        PhotoAlbum tmpAlbum = null;
                        PhotoPage tmpPage = null;

                        if(tmpItem == null)//Provides sync of the profile and picture
                        {
                            Debug.Log("Null update");

                            tmpNPCid = gbMang.getNpcIDForLangAreaDifficulty(usedLangArea,usedDiffForLangArea);
                            tmpAlbum = gbMang.getPhotoAlbumForCharacter(tmpNPCid);
                            tmpPage = tmpAlbum.findSpecificPage(usedLangArea,usedDiffForLangArea);

                            int severityPhoto = 4-tmpPage.getNumAvailablePhotos();
                            if (severityPhoto==4)
                                severityPhoto--;

                            tmpItem = new PackagedProfileUpdate(usedLangArea, usedDiffForLangArea,severityPhoto, severities[usedLangArea][usedDiffForLangArea] , -1,-1);

                        }else{

                            tmpNPCid = gbMang.getNpcIDForLangAreaDifficulty(tmpItem.category,tmpItem.index);
                            tmpAlbum = gbMang.getPhotoAlbumForCharacter(tmpNPCid);
                            tmpPage = tmpAlbum.findSpecificPage(tmpItem.category,tmpItem.index);
                            //Update the profile
                            Debug.Log("Copy of the profile updated");
                            severities[usedLangArea][usedDiffForLangArea] = tmpItem.newSeverity;

                        }

                        int reqPhotoDiff = 4 - tmpItem.newSeverity - tmpPage.getNumAvailablePhotos();

                        /*4 -> 0 : 0
                        4 -> 1: -1
                        4 -> 2: -2
                        4 -> 3: -3

                        3 -> 0: +1
                        3 -> 3: -2

                        0 -> 3: +1
                        0 -> 0: +4
        */

                        Debug.Log("Severity:"+tmpItem.newSeverity+" NumPhotos:"+tmpPage.getNumAvailablePhotos()+" Add:"+reqPhotoDiff);

                        if(reqPhotoDiff != 0)
                        {

                                if(reqPhotoDiff < 0)
                                {
                                int numPhotosToRemove = Mathf.Abs(reqPhotoDiff);
                                    int adding = tmpPage.getNumAvailablePhotos();
                                    for(int k=0; k<numPhotosToRemove; k++)
                                    {
                                        int reqRemovePos = adding-1-k;
                                        if(reqRemovePos >= 0)
                                        {
                                            if( ! tmpPage.isPhotoStickPosVacant(reqRemovePos))
                                            {
                                                commandQueue.Add(new PDBCRemovePhoto(tmpNPCid,activityOwnerID,acPkey,tmpItem.category,tmpItem.index,reqRemovePos));
                                            // NOTE: We do not remove photos here because the popups will need the photos.
                                            // Once popups are done, they will then call tmpRemovePhotos() below.
                                        }
                                        }
                                    }
                                }
                                else if(reqPhotoDiff > 0)
                                {
                                    int numPhotosToAdd = Mathf.Abs(reqPhotoDiff);
                                    int adding = tmpPage.getNumAvailablePhotos();

                                    List<PDBCAddPhoto> gbUpdates = new List<PDBCAddPhoto>();

                                    for(int k=0; k<numPhotosToAdd; k++)
                                    {
                                        int reqStickPos = adding+k;
                                        if(reqStickPos <= 3)
                                        {
                                            if(tmpPage.isPhotoStickPosVacant(reqStickPos))
                                            {

                                                int sectionIdx = -1;
                                                for(int j=0;j<7;j++){
                                                    if(!gbMang.getContactBioSectionStatus(tmpNPCid  ,j)){
                                                        gbMang.unlockSection(tmpNPCid );
                                                        sectionIdx = j;
                                                        break;
                                                    }
                                                }

                                                if(sectionIdx == -1)
                                                    sectionIdx = UnityEngine.Random.Range(0,7);

                                                string[] sectionText = LocalisationMang.getBioSection(tmpNPCid,sectionIdx);

                                                gbUpdates.Add(new PDBCAddPhoto(tmpNPCid,activityOwnerID,acPkey,tmpItem.category,tmpItem.index,reqStickPos,sectionText));
                                                commandQueue.Add(gbUpdates[gbUpdates.Count-1]);
                                            }
                                        }
                                    }

                                    foreach(PDBCAddPhoto addCommand in gbUpdates)
                                        gbMang.addPhoto(addCommand);
                                }
                            }

                    }
            }else{

                Debug.LogError("Update list was null (quit activity)");

            }

        return commandQueue;
    }
    public static void tmpRemovePhotos(List<PhotoDatabaseCommand> para_commands,GhostbookManagerLight gbMang)
    {
        if(para_commands != null)
        {
            if(para_commands.Count > 0)
            {
                for(int i=0; i<para_commands.Count; i++)
                {
                    PhotoDatabaseCommand nxtCommand = para_commands[i];

                    if(nxtCommand is PDBCRemovePhoto)
                    {
                        PDBCRemovePhoto castRemoveCommand = (PDBCRemovePhoto) nxtCommand;
                        gbMang.removePhoto(castRemoveCommand);
                    }

                }
            }
        }
    }
Exemplo n.º 6
0
    /**
     *
     * Function that is called after an activity has been played (or the game just started)
     *
     *
     */
    public void attemptActivityDebrief(WorldViewScript wv)
    {
        worldView = wv;
        worldView.setLoadingIconVisibility(true);

        if(WorldViewServerCommunication.tts!=null)
            WorldViewServerCommunication.tts.clearCache();

        gbMang = GhostbookManagerLight.getInstance();

        ghostbookIcon = Camera.main.transform.FindChild("GUI_Ghostbook");
        ghostbookIcon.GetComponent<Animator>().enabled = true;
        ghostbookIcon.GetComponent<Animator>().Play("GB_ButtonShine");
        closeGB = Resources.Load<Texture2D>("Textures/Ghostbook/UI/ghostbookiconclose");

        GBIconUIBounds = WorldSpawnHelper.getWorldToGUIBounds(ghostbookIcon.FindChild("ButtonMain").renderer.bounds,upAxisArr);
        PauseIconUIBounds = WorldSpawnHelper.getWorldToGUIBounds(ghostbookIcon.FindChild("GUI_Pause").FindChild("ButtonMain").renderer.bounds,upAxisArr);

        ghostbookIcon.gameObject.SetActive(showGBIcon);
        GBOpen = false;

        worldView.displayWorldCharacters(gbMang.visibleCharacters());

        questBar = Camera.main.transform.FindChild("QuestBar");
        questBarUiBounds = WorldSpawnHelper.getWorldToGUIBounds(questBar.gameObject.renderer.bounds,upAxisArr);
        questBarAbortBtnUiBounds = WorldSpawnHelper.getWorldToGUIBounds(questBar.FindChild("AbortQuestBtn").renderer.bounds,upAxisArr);
        showQuestBar = false;

        GameObject tmp = new GameObject();
        gbDisp = tmp.AddComponent<GhostBookDisplay>();
        gbDisp.init(this,gbMang);

        deactivateWVInterface();

        GameObject poRef = PersistentObjMang.getInstance();
        DatastoreScript ds = poRef.GetComponent<DatastoreScript>();

        if(ds.containsData("ActivityOutcome"))//An activity was played before
        {

            IServerServices server = (IServerServices)getServerObject().GetComponent(typeof(IServerServices));

            List<PackagedProfileUpdate> update = server.getProfileUpdate();

            loading = 0;//Wait for the pop-ups

            ActivityExternalDebriefer aed = transform.gameObject.AddComponent<ActivityExternalDebriefer>();
            aed.debrief(
                (ApplicationID) ((System.Object[])ds.getData("ActivityOutcome"))[0],
                (bool) ((System.Object[])ds.getData("ActivityOutcome"))[1],
                    (bool)((System.Object[]) ds.getData("ActivityOutcome"))[2],
                (ActivitySessionMetaData) ds.getData("AcMetaData"),
                gbMang,
                update,
                WorldViewServerCommunication.userProfile.getLiteracyProfile().getUserSeveritites().getSeverities(),
                this);

            ds.removeData("ActivityOutcome");
            ds.removeData("AcMetaData");

        }else{
            loading = 1;

        }

        if(!gbMang.getAvailableActivities().Contains(ApplicationID.TRAIN_DISPATCHER)){

                Debug.Log("Unlock Train");

                int newMainCharacter = LocalisationMang.getOwnerNpcOfActivity(ApplicationID.TRAIN_DISPATCHER);
                gbMang.unlockCharacterForLocation(newMainCharacter);
                worldView.displayWorldCharacters(new List<int>{newMainCharacter});
        }

        if(!gbMang.getAvailableActivities().Contains(ApplicationID.MOVING_PATHWAYS)){
                Debug.Log("Unlock Moving Pathways");

                int newMainCharacter = LocalisationMang.getOwnerNpcOfActivity(ApplicationID.MOVING_PATHWAYS);
                gbMang.unlockCharacterForLocation(newMainCharacter);
                worldView.displayWorldCharacters(new List<int>{newMainCharacter});
        }

        if(!gbMang.getAvailableActivities().Contains(ApplicationID.WHAK_A_MOLE)){
                Debug.Log("Unlock Whack");

                int newMainCharacter = LocalisationMang.getOwnerNpcOfActivity(ApplicationID.WHAK_A_MOLE);
                gbMang.unlockCharacterForLocation(newMainCharacter);
                worldView.displayWorldCharacters(new List<int>{newMainCharacter});
        }

        this.enabled = true;
    }