Inheritance: MonoBehaviour
 public void LoadScene(int level)
 {
     persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
     persistentData.Save ();
     sceneFadeInOut = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<SceneFadeInOut>();
     sceneFadeInOut.LoadScene (level);
 }
 private static AbstractPersistentData Deserialize(string filePath, string importedBuildPath)
 {
     var deserializer = new IPersistentDataDeserializer[]
     {
         new PersistentDataDeserializerUpTo230(), new PersistentDataDeserializerCurrent()
     };
     var xmlString = File.ReadAllText(filePath);
     var version = SerializationUtils.XmlDeserializeString<XmlPersistentDataVersion>(xmlString).AppVersion;
     IPersistentDataDeserializer suitableDeserializer;
     if (version == null)
     {
         suitableDeserializer = deserializer.FirstOrDefault(c => c.MinimumDeserializableVersion == null);
     }
     else
     {
         var v = new Version(version);
         suitableDeserializer = deserializer.FirstOrDefault(c =>
             v.CompareTo(c.MinimumDeserializableVersion) >= 0
             && v.CompareTo(c.MaximumDeserializableVersion) <= 0);
     }
     if (suitableDeserializer == null)
     {
         throw new Exception(
             $"No converter available that can deserialize a PersistentData file with version {version}");
     }
     var data = new PersistentData(suitableDeserializer, importedBuildPath);
     suitableDeserializer.DeserializePersistentDataFile(xmlString);
     return data;
 }
 void Start()
 {
     playerStats = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<PlayerStats>();
     sceneFadeInOut = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<SceneFadeInOut>();
     persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
     centerMessageController = GameObject.FindGameObjectWithTag (Tags.canvas).GetComponentInChildren<CenterMessageController> ();
 }
Exemple #4
0
    /// <summary>
    /// �ⲿ�����Զ����ˮֵ
    /// </summary>
    /// <param name="coin">��ֵ</param>
    public void FreeGainCustom(int coin)
    {
        if(mBss == null)
            mBss = GameMain.Singleton.BSSetting;

        if (mBss.Dat_GainAdjustIdx.Val != 0)
        {
            Debug.LogWarning("�ڳ��ˮ״̬�µ����Զ�����ˮ,FreeGainCustom()������Ч");
            return;
        }

        mBss.Dat_GainAdjustIdx.Val = 24;
        LossProfitData[24] = coin;

        GameMain.EvtPlayerGunFired += Handle_PlayerFire;
        GameMain.Evt_PlayerGainScoreFromFish += Handle_PlayerGainScoreFromFish;

        if (GainAdjust_GainScoreRT == null) GainAdjust_GainScoreRT = new PersistentData<int, int>("GainAdjust_GainScoreRT");
        if (GainAdjust_LossScoreRT == null) GainAdjust_LossScoreRT = new PersistentData<int, int>("GainAdjust_LossScoreRT");
        mScoreGain = GainAdjust_GainScoreRT.Val = 0;
        mScoreLoss = GainAdjust_LossScoreRT.Val = 0;

        mCurLossProfitScore = LossProfitData[mBss.Dat_GainAdjustIdx.Val] * mBss.InsertCoinScoreRatio.Val;

        StopCoroutine("_Coro_SaveGainData");
        StartCoroutine("_Coro_SaveGainData");

        StopCoroutine("_Coro_LossOrProfitprocess");
        StartCoroutine("_Coro_LossOrProfitprocess");
    }
Exemple #5
0
        // Use this for initialization
        void Start()
        {
            m_data = GameObject.Find("PersistentDataGO").GetComponent<PersistentData>();

            Text winTxt = GameObject.Find("Winning Player: Player Number Text").GetComponent<Text>();

            switch (m_data.m_winningPlayer)
            {
                case 1:
                    winTxt.text = "PLAYER 1";
                    break;

                case 2:
                    winTxt.text = "PLAYER 2";
                    break;

                case 3:
                    winTxt.text = "PLAYER 3";
                    break;

                case 4:
                    winTxt.text = "PLAYER 4";
                    break;

                default:
                    winTxt.text = "NOBODY";
                    break;
            }
        }
 public static void Save()
 {
     var data = new PersistentData();
     var binaryFormatter = new BinaryFormatter();
     var file = File.Create(path);
     binaryFormatter.Serialize(file, data);
     file.Close();
 }
 void Awake()
 {
     persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
     availableSpawnPoints = GetComponent<AvailableSpawnPoints> ();
     playerTransform = GameObject.FindGameObjectWithTag (Tags.player).transform;
     playerPosition = availableSpawnPoints.spawnPoints [persistentData.nextSpawnPoint].position;
     cameraTransform = GameObject.FindGameObjectWithTag (Tags.mainCamera).transform;
 }
    // Use this for initialization
    void Start()
    {
        persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();

        if (persistentData.chaptersUnlocked < chapter) {
            persistentData.chaptersUnlocked = chapter;
            persistentData.ResetDefaults();
            persistentData.Save();
        }
    }
	// Use this for initialization
	void Start ()
    {
        DOTween.Init();

        m_persistentData = GameObject.Find("SceneEssentials").GetComponent<PersistentData>();
        m_persistentData.Save();
        m_maxLevel = m_persistentData.MaxLevel;
        Debug.Log("Max level at scene start: " + m_maxLevel);

        SetCamera();
        ColorizeLevelNodes();
	}
 void populateList(GameObject newitem, PersistentData.itemInfo obj)
 {
     //		Debug.Log (newitem);
     //
     //		Debug.Log (newitem.transform.Find ("Name").GetComponent<Text>().text);
     //
     newitem.transform.Find ("Name").GetComponent<Text> ().text = obj.Name;
     newitem.transform.Find ("Information").GetComponent<Text> ().text = obj.brand;
     newitem.transform.Find ("Price").GetComponent<Text> ().text = obj.Price.ToString();
     newitem.transform.Find ("Shipping").GetComponent<Text> ().text = obj.shipping;
     //		newitem.transform.Find ("Image").GetComponent<Image> ().sprite = obj.;
 }
	void Awake()
	{
		if (mPersistentData != null && mPersistentData != this)
		{
			Destroy(gameObject);
		}
		else
		{
			DontDestroyOnLoad(gameObject);
			mPersistentData = this; 
		}		
	}
 // Update is called once per frame
 void Update()
 {
     /*if(pickUpAllowed && Input.GetKeyDown(KeyCode.E)){
      *  PersistentData.update();
      *  fc.ExecuteBlock("Ring");
      *      PickUp();
      * }*/
     if (Input.GetKeyDown(KeyCode.E))
     {
         PersistentData.update();
         PickUp();
     }
 }
Exemple #13
0
    private void LoadLayout()
    {
        mg.ClearMap();
        MapLayoutData data = SaveSystem.LoadMap(PersistentData.getLoadLevel());

        mg.height = data.height;
        mg.width  = data.width;
        mg.size   = data.size;
        mg.InitializeMap();
        mg.InitializeHills(data.hills);
        mg.InitializePortals(data.entrance, data.exit);
        mg.navSurface.BuildNavMesh();
    }
Exemple #14
0
    public void CheckNextLevel(Button button)
    {
        BaseLevel nextLevel = PersistentData.GetLevel(Level.levelNum + 1, Level.levelType);

        bool canPlayNextLevel = PersistentData.SetLevelToLoad(nextLevel);

        button.interactable = canPlayNextLevel;

        if (!canPlayNextLevel)
        {
            nextLevelStarsText.text = "Stars Needed: " + nextLevel.starsToUnlock;
        }
    }
Exemple #15
0
    void Awake()
    {
        if (Instance == null)
        {
            DontDestroyOnLoad(gameObject);
            Instance = this;
        }

        else
        {
            Destroy(gameObject);
        }
    }
Exemple #16
0
 void Start()
 {
     soundMan      = GameObject.Find("Sound Manager");
     perData       = GameObject.Find("Persistent Data");
     perDataScript = perData.GetComponent <PersistentData>();
     if (soundMan != null)
     {
         soundManScript = soundMan.GetComponent <SoundManager>();
     }
     colliderA = this.GetComponent <Rigidbody2D>();
     animator  = this.gameObject.GetComponent <Animator>();
     colliderA.gravityScale = 0.0f;
 }
Exemple #17
0
        protected override void Start()
        {
            base.Start();

                        #if UNITY_EDITOR
            if (PersistentData.GetInstance() != null)
            {
                levelsList = PersistentData.GetInstance().levelsData;
            }
                        #else
            levelsList = PersistentData.GetInstance().levelsData;
                        #endif
        }
	// Get budget value from previous scene (PersistentData) and get the reference of the HUDBudget text
	void Awake () {
        hudBudget = GameObject.Find("BudgetText").GetComponent<Text>();
        try {
            persistValue = GameObject.Find("PersistentData").GetComponent<PersistentData>();
            budgetValue = persistValue.BudgetValue;

            hudBudget.text = budgetValue.ToString("#,#");
        }
        catch(NullReferenceException)
        {
            hudBudget.text = "Missing Object";
        }
    }
Exemple #19
0
    //Save data to a file
    public void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(DATA_PATH);

        p_Data              = new PersistentData();
        p_Data.shipLives    = GameManager.instance.playerLives;
        p_Data.playerScore  = GameManager.instance.playerScore;
        p_Data.cooldownLeft = GameManager.instance.recoverTimer.ToString("yyyy-MM-ddTHH:mm:sszzz");
        p_Data.pauseDate    = GameManager.instance.suspendTimestamp.ToString("yyyy-MM-ddTHH:mm:sszzz");
        bf.Serialize(file, p_Data);
        file.Close();
    }
Exemple #20
0
 private void Awake()
 {
     dedSound = GetComponent <AudioSource>();
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         DestroyImmediate(gameObject);
     }
 }
    public void SendTypedMessage()
    {
        if (!(inputField.text == ""))
        {
            AddMessage(PersistentData.GetUserName(), inputField.text);

            ChampNetManager.SendChatMessage(inputField.text);

            inputField.text = "";
        }

        ActivateInput();
    }
    // Use this for initialization
    void Awake()
    {
        DontDestroyOnLoad(gameObject);

        if (!m_Instance)
        {
            m_Instance = this;
        }
        else if (m_Instance != this)
        {
            Destroy(gameObject);
        }
    }
    //Application.persistentDataPath is an automatic path unity makes to store data.
    //It works even on mobile, it doesnt work only in webplayer (because webplayer dont have anywhere to srite files)
    public void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(completeFilePath);

        PersistentData data = new PersistentData();

        data.health     = health;
        data.experience = experience;

        bf.Serialize(file, data);
        file.Close();
    }
 void Awake()
 {
     if (current != null)
     {
         Destroy(gameObject);
     }
     else
     {
         SetLevels();
         DontDestroyOnLoad(gameObject);
         current = this;
     }
 }
Exemple #25
0
 void Start()
 {
     persistentObj    = GameObject.Find("Persistent Data");
     persistentScript = persistentObj.GetComponent <PersistentData>();
     if (this.transform.parent.gameObject.tag == "TiltBtn")
     {
         getTiltStatus();
     }
     else
     {
         getMuteStatus();
     }
 }
Exemple #26
0
    void Start()
    {
        m_pData = (PersistentData)FindObjectOfType(typeof(PersistentData));

        gameObject.name = "Player";

        m_lightPool        = m_pData.m_playerLightPool;
        m_lightConsumption = m_pData.m_playerLightConsumption;
        m_canBecomeGhost   = m_pData.m_playerCanGhost;

        m_remLight             = GameObject.Find("RemainingLightNumber");
        m_remainingLightNumber = m_remLight.GetComponent <Text>();
    }
Exemple #27
0
 private void Awake()
 {
     if (Instance == null)
     {
         Debug.Log("creating persistent data instance");
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemple #28
0
 void Start()
 {
     data = GameObject.FindWithTag("Data").GetComponent <PersistentData>();
     // Get container's canvas's controller script
     // That's a doozy
     if (data.loadedMenu == "Inventory")
     {
         DisplayItem = transform.parent.parent.gameObject.GetComponent <InventoryController>().DisplayItem;
     }
     else if (data.loadedMenu == "Shop")
     {
         DisplayItem = transform.parent.parent.gameObject.GetComponent <ShopController>().DisplayItem;
     }
 }
Exemple #29
0
    // Get budget value from previous scene (PersistentData) and get the reference of the HUDBudget text
    void Awake()
    {
        hudBudget = GameObject.Find("BudgetText").GetComponent <Text>();
        try {
            persistValue = GameObject.Find("PersistentData").GetComponent <PersistentData>();
            budgetValue  = persistValue.BudgetValue;

            hudBudget.text = budgetValue.ToString("#,#");
        }
        catch (NullReferenceException)
        {
            hudBudget.text = "Missing Object";
        }
    }
        public PersistentData ReadPersistent()
        {
            IntPtr persAddr = EngineAddr + persistentOffset;
            var    pers     = new PersistentData();

            pers.Gender         = (Gender)MemoryReader.ReadByte(persAddr + genderOffset);
            pers.HeroName       = ReadComString(persAddr + heroNameOffset);
            pers.Quest          = (Quest)MemoryReader.ReadByte(persAddr + questOffset);
            pers.HintsEnabled   = MemoryReader.ReadByte(persAddr + hintsAreEnabledOffset) != 0;
            pers.CurrentRoomId  = (RoomId)MemoryReader.ReadByte(persAddr + currentRoomIdOffset);
            pers.PreviousRoomId = (RoomId)MemoryReader.ReadByte(persAddr + previousRoomIdOffset);

            return(pers);
        }
Exemple #31
0
        private void Menu_DestroyPersistentData(object sender, EventArgs e)
        {
            if (PersistentDataCount == 0)
            {
                return;
            }

            RecordPersistentDataEvent("Clear selection");
            PersistentData.Clear();
            OnObjectChanged(GH_ObjectEventType.PersistentData);

            OnPingDocument()?.ClearReferenceTable();
            ExpireSolution(true);
        }
Exemple #32
0
    private void Init()
    {
        if (m_data != null)
        {
            return;
        }

        Load();

        if (m_data == null)
        {
            m_data = new PersistentData();
        }
    }
Exemple #33
0
 void Awake()
 {
     if (checkChaptersUnlocked) {
         persistentData = GameObject.FindGameObjectWithTag(Tags.mainCamera).GetComponent<PersistentData>();
         if(persistentData.chaptersUnlocked > 0){
             //enable button
             buttonIsDisabled = false;
         }
         else{
             //disable button
             buttonIsDisabled = true;
         }
     }
 }
Exemple #34
0
    void Awake()
    {
        myWand = "PearlWand";

        if (data == null)
        {
            DontDestroyOnLoad(gameObject);
            data = this;
        }
        else if (data != this)
        {
            Destroy(gameObject);
        }
    }
Exemple #35
0
        public override void ClearData()
        {
            base.ClearData();

            if (PersistentDataCount == 0)
            {
                return;
            }

            foreach (var goo in PersistentData.OfType <T>())
            {
                goo?.UnloadElement();
            }
        }
 public void PersistsAndLoads_DefaultCollection()
 {
     {
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject<Dto>("id"));
         obj.Data = TestValues.Value;
         lib.SaveChanged();
     }
     {
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject<Dto>("id"));
         Expect(obj.Data, EqualTo(TestValues.Value));
     }
 }
Exemple #37
0
    IEnumerator EndGameTransitionScreen()
    {
        transitionScreen.SetActive(true);
        //transition.GetComponent<CanvasRenderer>().SetAlpha(0.1f);
        //transition.CrossFadeAlpha(100, Time.time * transitionTime, true);
        //transitionScreen.SetActive(false);
        yield return(new WaitForSeconds(transitionTime));

        PersistentData.GetPlayerStats().SetTimeAtGameEnd(timeManager.GetCurrentGameTimeScaled());
        PersistentData.GetPlayerStats().SetBACAtGameEnd(PersistentData.GetPlayerStats().GetCurrentBAC());
        GameFlowManager GameFlowManager = GameObject.Find("GameFlowManager").GetComponent <GameFlowManager>();

        GameFlowManager.MoveFromGameToPostGameScreen();
    }
    public void Load()
    {
        if (File.Exists(completeFilePath))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(completeFilePath, FileMode.Open);

            PersistentData data = (PersistentData)bf.Deserialize(file);
            file.Close();

            health     = data.health;
            experience = data.experience;
        }
    }
    //Placeholder until we get something proper in
    private void GenerateRandomResult()
    {
        List <SlotMachineDrink> RandomDrinks = new List <SlotMachineDrink>();

        //just add 3 random drinks until we get something better
        RandomDrinks.Add(DrinksList[Random.Range(0, DrinksList.Count)]);
        RandomDrinks.Add(DrinksList[Random.Range(0, DrinksList.Count)]);
        RandomDrinks.Add(DrinksList[Random.Range(0, DrinksList.Count)]);

        //Debug.Log("Slot machine generated something");
        //Debug.Log(RandomDrinks[0].DrinkName);
        //Debug.Log(RandomDrinks[1].DrinkName);
        //Debug.Log(RandomDrinks[2].DrinkName);

        /*
         * Debug.Log(BACCalculator.CalculateEstimatedBACWidmark(2, PlayerStats.PlayerGender.MALE, 55, 1));
         * Debug.Log(BACCalculator.CalculateEstimatedBACWidmark(2, PlayerStats.PlayerGender.MALE, 55, 2));
         * Debug.Log(BACCalculator.CalculateEstimatedBACWidmark(2, PlayerStats.PlayerGender.MALE, 55, 3));
         */

        //Generate a random drinking period between 1 and 3.5 hours
        int DrinkingPeriodHours    = Random.Range(1, 3);
        int DrinkingPeriodHalfHour = Random.Range(0, 2);

        GameTime DrinkingPeriod;

        DrinkingPeriod.Hours   = DrinkingPeriodHours;
        DrinkingPeriod.Minutes = DrinkingPeriodHalfHour * 30;

        float DrinkingPeriodBAC = (float)DrinkingPeriodHours + ((float)DrinkingPeriodHalfHour * 0.5f);

        float TotalStandardDrinksConsumed = RandomDrinks[0].StandardDrinkEquivalence + RandomDrinks[1].StandardDrinkEquivalence + RandomDrinks[2].StandardDrinkEquivalence;
        float StartingBAC = BACCalculator.CalculateEstimatedBACWidmark(TotalStandardDrinksConsumed, PersistentData.GetPlayerStats().GetPlayerGender(), PersistentData.GetPlayerStats().GetPlayerWeight(), DrinkingPeriodBAC);

        PersistentData.GetPlayerStats().SetStartingBAC(StartingBAC);

        //Pass the drinking period to the player stats.
        PersistentData.GetPlayerStats().SetSlotMachineDrinkingPeriod(DrinkingPeriod);

        Debug.Log("Starting BAC: " + StartingBAC);
        //Debug.Log("Total standard drinks consumed: " + TotalStandardDrinksConsumed);
        //Debug.Log("Drinking period: " + DrinkingPeriod.Hours + "h " + DrinkingPeriod.Minutes + "m");

        GameTime MetabolismTime = BACCalculator.CalculateMetabolismTime(StartingBAC);

        Debug.Log("Time to metabolise: " + MetabolismTime.Hours + "h " + MetabolismTime.Minutes + "m");

        //Let the game manager know that the slot machine is finished, and it can advance to the main game.
        SlotMachineFinished(RandomDrinks);
    }
Exemple #40
0
        public void PersistantInitTest()
        {
            PersistentData data = new PersistentData();

            Assert.IsNotNull(data);
            Assert.IsNotNull(data.imageData);
            Assert.AreEqual(data.timeZone, "");
            Assert.AreEqual(data.plz, "");
            Assert.AreEqual(data.maxImageCount, 0);
            Assert.IsNull(data.startWithWindows);
            Assert.IsNull(data.changeInBackground);
            Assert.IsNull(data.autoImageSearch);
            Assert.AreEqual(data.openWeatherMapAPIKey, "");
        }
Exemple #41
0
 public void PersistsAndLoads_DefaultCollection()
 {
     {
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject <Dto>("id"));
         obj.Data = TestValues.Value;
         lib.SaveChanged();
     }
     {
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject <Dto>("id"));
         Expect(obj.Data, EqualTo(TestValues.Value));
     }
 }
Exemple #42
0
        private async Task Reload()
        {
            if (GetDirtyBuilds().Any())
            {
                var result = await _dialogCoordinator.ShowQuestionAsync(this,
                                                                        L10n.Message("Any unsaved changes will be lost.\nAre you sure?"));

                if (result != MessageBoxResult.Yes)
                {
                    return;
                }
            }
            await PersistentData.ReloadBuildsAsync();
        }
Exemple #43
0
 public void AllDataSaved_WhenSaveIsForced()
 {
     {
         var lib = CreateLibrary();
         var obj = lib.DefaultCollection.GetObject <Dto>("id");
         obj.Entity.Data = TestValues.Value;
         lib.SaveAll();
     }
     {
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject <Dto>("id"));
         Expect(obj.Data, EqualTo(TestValues.Value));
     }
 }
Exemple #44
0
 public void UnflaggedDataChangesNotSaved_WhenSaveOnlyChanged()
 {
     {
         var lib = CreateLibrary();
         var obj = lib.DefaultCollection.GetObject <Dto>("id");
         obj.Entity.Data = TestValues.Value;
         lib.SaveChanged();
     }
     {
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject <Dto>("id"));
         Expect(obj.Data, Not.EqualTo(TestValues.Value));
     }
 }
 public void AllDataSaved_WhenSaveIsForced()
 {
     {
         var lib = CreateLibrary();
         var obj = lib.DefaultCollection.GetObject<Dto>("id");
         obj.Entity.Data = TestValues.Value;
         lib.SaveAll();
     }
     {
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject<Dto>("id"));
         Expect(obj.Data, EqualTo(TestValues.Value));
     }
 }
    void Awake()
    {
        persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();

        //This tests to see if a LocalScenePersistentGameObject already exists within the persistent data for this scene.
        if(persistentData.localScenePersistentContainers.Count > 0){
            for(int i = 0; i < persistentData.localScenePersistentContainers.Count; i ++){
                GameObject go = persistentData.localScenePersistentContainers[i];
                if(go.GetComponent<LocalScenePersistentGameObjects>()){
                    localScenePersistentGameObjects = go.GetComponent<LocalScenePersistentGameObjects>();
                    if(localScenePersistentGameObjects.localScene == localScene){
                        if(localScenePersistentGameObjects.isCopy){
                            go.SetActive(false);
                            copyExists = true;
                        }
                        else {
                            go.SetActive(true);
                            exists = true;
                        }
                    }
                    else{
                        go.SetActive(false);
                    }
                }
            }
            if(exists && copyExists){
                //If it already exists and a copy already exists, then destroy this...
                Destroy (gameObject);
            }
            else if (exists && !copyExists){
                //If it already exists, but a copy does not exist, then make this the copy and save it to the persistent list...
                isCopy = true;
                persistentData.localScenePersistentContainers.Add (gameObject);
            }
            else if(!exists && !copyExists){
                //It does not exist, or this is a Copy; add this copy to the persistent list...
                persistentData.localScenePersistentContainers.Add (gameObject);
            }
            else{
            }
        }
        else{
            //It does not exist, add this to the persistent list...
            persistentData.localScenePersistentContainers.Add (gameObject);

        }
        //persistentData.gameObjectsDoNotDestroyList.Add (gameObject);
        DontDestroyOnLoad (gameObject);
    }
 // Use this for initialization
 void Awake()
 {
     persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
     //Disable planet Xes and enable chapterGeometry...
     for (int i = 0; i < planetXes.Count; i++) {
         if(i< persistentData.chaptersUnlocked){
             //unlock chapter...
             planetXes[i].SetActive (false);
         }
         else{
             //lock chapter...
             chapterGeometry[i].SetActive (false);
         }
     }
 }
    void Start()
    {
        renderer = transform.GetComponent<LineRenderer>();

        persistentData = GameObject.Find("PersistentData").GetComponent<PersistentData>();

        if (persistentData.levelUnlockedStatus[levelID - 1] == 0)
        {
            renderer.material = locked;
        }
        else
        {
            renderer.material = unlocked;
        }
    }
    void Awake()
    {
        //On awake, check to see if the gate is active or inactive and setup gate...
        if(isActive){
            ActivateGate();
        }
        else{
            DeactivateGate ();
        }

        //shakeCam = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<SmoothCamera2D> ();
        player = GameObject.FindGameObjectWithTag (Tags.player);
        sceneFadeInOut = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<SceneFadeInOut> ();
        persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
    }
Exemple #50
0
    void Start()
    {
        if (GameObject.Find("PersistentData") != null)
            persistentData = GameObject.Find("PersistentData").GetComponent<PersistentData>();

        if (persistentData.levelUnlockedStatus[levelID - 1] == 0)
        {
            unlocked = false;
            renderer.material = lockedMat;
        }
        else
        {
            unlocked = true;
            renderer.material = unlockedMat;
        }
    }
Exemple #51
0
 void Awake()
 {
     if (deleteAll)
         PlayerPrefs.DeleteAll ();
     instance = this;
     if (PlayerPrefs.HasKey (PREFS_record)) {
         record = PlayerPrefs.GetInt (PREFS_record);
     } else {
         PlayerPrefs.SetInt(PREFS_record, record);
     }
     if (PlayerPrefs.HasKey (PREFS_record)) {
         record = PlayerPrefs.GetInt (PREFS_record);
     } else {
         PlayerPrefs.SetInt(PREFS_record, record);
     }
 }
 // Use this for initialization
 void Start()
 {
     chapterController = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<ChapterController> ();
     persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
     if (hotSpotIndex < persistentData.chaptersUnlocked) {
         if(hotSpotIndex != -1){
             //-1 is the prologue and is already set...
             chapterGeometry = chapterController.chapterGeometry[hotSpotIndex];
         }
         chapterGeometryController = chapterGeometry.GetComponent<ChapterGeometryController>();
         isClickable = true;
     }
     else{
         chapterGeometry = chapterController.planetXes[hotSpotIndex];
         chapterGeometryController = chapterGeometry.GetComponent<ChapterGeometryController>();
         //GetComponent<EventTrigger>().enabled = false;
     }
 }
 public void LoadHighscore()
 {
     try
     {
         using (FileStream stream = File.OpenRead(filePath))
         {
             persistentData = formatter.Deserialize(stream) as PersistentData;
         }
     }
     catch (FileNotFoundException)
     {
         Debug.Log("No persistent data to load");
     }
     catch (InvalidCastException)
     {
         Debug.LogWarning("Persistent data class has changed");
     }
 }
	void Start () {
        persistentData = GameObject.Find("SceneEssentials").GetComponent<PersistentData>();

        if (AudioListener.volume == 0) {
			soundOnText.text = "Sound: off";
		} else {
			soundOnText.text = "Sound: on";
		}

		Scene currentScene = SceneManager.GetActiveScene ();
		if (currentScene == SceneManager.GetSceneByName ("levelselect")) {
			levelsButton.gameObject.SetActive (false);
		} else if (currentScene == SceneManager.GetSceneByName ("menu")) {
			levelsButton.gameObject.SetActive (false);
			menuButton.gameObject.SetActive (false);
		} else if (currentScene == SceneManager.GetSceneByName ("main")){
			LevelLogic.Instance.paused = true;
		}
	}
Exemple #55
0
 public void MigratesData_WhenNoFilter()
 {
     {
         // create persistent entity without any migration
         var lib = CreateLibrary();
         var obj = new PersistentData(lib.DefaultCollection.GetObject<Dto>("id"));
         obj.Data = TestValues.Value;
         lib.SaveChanged();
     }
     {
         // use new type, that has a migration defined,
         // verify that value has been migrated
         var lib = CreateLibrary();
         var persistent = lib.DefaultCollection.GetObject<Dto>("id");
         var obj = new PersistentDataWithMigrationNoFilter(persistent);
         Expect(obj.Data, EqualTo(TestValues.ValueAfterMigration));
         Expect(persistent.Entity.Version, EqualTo(1));
     }
 }
Exemple #56
0
    // Use this for initialization
    void Start()
    {
        // Use editor PersistentData if available, otherwise create one
        Transform t;
        if ((t = transform.FindChild("PersistentData")) == null)
        {
            persistentData = gameObject.AddComponent<PersistentData>();
        }
        else
            persistentData = t.GetComponent<PersistentData>();
        Debug.Log (persistentData);

        // Ensure camera as assumed by FastGUI
        Camera.main.transform.position = new Vector3 (0, 0, -10);
        Camera.main.transform.rotation = Quaternion.identity;
        Camera.main.transform.localScale = new Vector3 (1, 1, 1);
        Camera.main.orthographic = true;
        Camera.main.orthographicSize = 768;
        Camera.main.nearClipPlane = .3f;
        Camera.main.farClipPlane = 11;
    }
    void Start()
    {
        //initialize persistentData...
        persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
        //initialize player head animator...
        playerHeadAnimator = GetComponent<Animator> ();
        currentValue = playerHeadAnimator.GetBool ("helmetEquipped");

        switch (persistentData.playerHelmetEquipped){

        //if persistentData helmet state is set to 0 ("default")
        case 0:
            //then set the helmet state based on the starting scene state...
            if(startSceneWithHelmetEquipped && !currentValue){
                playerHeadAnimator.SetTrigger ("equipHelmetNoEffects");
            }
            else if(!startSceneWithHelmetEquipped && currentValue){
                playerHeadAnimator.SetTrigger ("removeHelmet");
            }
            break;

        //if persistentData helmet state is set to 1 ("not equipped");
        case 1:
            if(currentValue){
                playerHeadAnimator.SetTrigger ("removeHelmet");
            }
            break;

        //if persistentData helmet state is set to 2 ("equipped");
        case 2:
            if(!currentValue){
                playerHeadAnimator.SetTrigger ("equipHelmetNoEffects");
            }
            break;
        default:
            break;
        }
    }
Exemple #58
0
 public void DoesNotMigrate_WhenVersionDoesNotMatch()
 {
     const int currentObjVersion = 3;
     {
         // create persistent entity without any migration
         var lib = CreateLibrary();
         var persistent = lib.DefaultCollection.GetObject<Dto>("id");
         // we are modifying version manually for test purposes,
         // this is normally not possible, as the field is internal.
         persistent.Entity.Version = currentObjVersion;
         var obj = new PersistentData(lib.DefaultCollection.GetObject<Dto>("id"));
         obj.Data = TestValues.Value;
         lib.SaveChanged();
     }
     {
         // use new type, that has a migration defined,
         // verify that value has NOT been migrated
         var lib = CreateLibrary();
         var persistent = lib.DefaultCollection.GetObject<Dto>("id");
         var obj = new PersistentDataWithMigration(persistent);
         Expect(obj.Data, EqualTo(TestValues.Value));
         Expect(persistent.Entity.Version, EqualTo(currentObjVersion));
     }
 }
 public void QuitGame()
 {
     persistentData = GameObject.FindGameObjectWithTag (Tags.mainCamera).GetComponent<PersistentData> ();
     persistentData.Save ();
     Application.Quit();
 }
 void Awake()
 {
     GlobalData = this;
     DontDestroyOnLoad (gameObject);
 }