Ejemplo n.º 1
0
    //#else

    /*
     * public string fileName = "persistentdata.dat";
     * private string completeFilePath;
     */
    //#endif


    void Awake()
    {
        //DontDestroyOnLoad make the object available even when you change the scene.
        //The problem is that you must enter a scene that have the object first
        //The solution is to have one copy of the object on each scene, but when you change scenes
        //the object from previous scene is there too. So you make sure you Destroy this if there is another
        //object from the class instanced.
        //It can be verified because the variable "control" is static and is unique for every object on the class.
        //So you can verify if any object of the class is in the control static variable.
        if (control == null)
        {
            DontDestroyOnLoad(gameObject);
            control = this;
        }
        else if (control != this)
        {
            Destroy(gameObject);
        }

        //#if !UNITY_WP8

        /*
         * completeFilePath = Application.persistentDataPath + "/"+fileName;
         */
        //#endif
    }
Ejemplo n.º 2
0
 public ItemCustomFieldsEditView(string lotId)
 {
     InitializeComponent();
     m_persistence           = new PersistenceController(Scout.Core.Data.GetUnitOfWork());
     inventoryIdentText.Text = lotId;
     LoadItem();
 }
Ejemplo n.º 3
0
    /* // Activate when debugging
     * void OnGUI()
     * {
     *  if(GUI.Button(new Rect(100,100, 300,100), "GUARDAR DATOS")) {
     *      SaveDataToDisk();
     *  }
     *
     *
     *  if(GUI.Button(new Rect(100,200, 300,100), "CARGAR DATOS")) {
     *      _LoadDataFromDisk();
     *  }
     * }
     */



    public static void SaveDataToDisk( )
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/" + FileName);

        GameObject            gc               = GameObject.FindGameObjectWithTag(SuriAlFuturo.Tag.GameController);
        DialogueController    dialogCtrl       = gc.GetComponent <DialogueController>();
        PersistenceController persistenceCtrl  = gc.GetComponent <PersistenceController>();
        CollectionSystem      collectionSystem = gc.GetComponent <CollectionSystem>();
        TapController         tapCtrl          = gc.GetComponent <TapController>();
        TimeTravelController  timeTravelCtrl   = gc.GetComponent <TimeTravelController>();
        EventController       eventCtrl        = gc.GetComponent <EventController>();

        SavedGame savedGame = new SavedGame();

        savedGame.Talkables       = dialogCtrl.SavedTalkableStates;
        savedGame.GameObjects     = persistenceCtrl.SavedGameObjects;
        savedGame.Collectables    = collectionSystem.SavedCollectables;
        savedGame.Blockers        = collectionSystem.SavedBlockers;
        savedGame.Inventory       = collectionSystem.Inventory;
        savedGame.Taps            = tapCtrl.SavedTaps;
        savedGame.CurrentReality  = timeTravelCtrl.CurrentReality;
        savedGame.TouchTriggers   = eventCtrl.SavedTouchTriggers;
        savedGame.TriggeredEvents = eventCtrl.TriggeredEvents;

        bf.Serialize(file, savedGame);
        file.Close();
    }
Ejemplo n.º 4
0
        private void Init()
        {
            m_uow = Scout.Core.Data.GetUnitOfWork();

            m_persistenceController = new PersistenceController(m_uow);

            m_areaData = Scout.Core.Data.GetList <Site>(m_uow).All();

            areaGrid.DataSource = m_areaData;

            WireEvents();
            colStatus.ColumnEdit       = new AreaStatusComboObserver(m_uow);
            colDomainStatus.ColumnEdit = new AreaStatusComboObserver(m_uow);
            colSflStatus.ColumnEdit    = new AreaStatusComboObserver(m_uow);

            saveButton.Click += (s, e) =>
            {
                if (m_persistenceController.Save())
                {
                    Close();
                }
            };

            cancelButton.Click += (s, e) =>
            {
                if (m_persistenceController.Cancel())
                {
                    Close();
                }
            };
        }
Ejemplo n.º 5
0
 private void CreatePersistenceController(IUnitOfWork uow)
 {
     m_persistenceController = new PersistenceController(uow);
     m_persistenceController.CancelChanges += persistenceController_CancelChanges;
     cancelButton.Click += m_persistenceController.Cancel;
     saveButton.Click   += m_persistenceController.Save;
 }
Ejemplo n.º 6
0
    private void Awake()
    {
        QualitySettings.vSyncCount  = 0;
        Application.targetFrameRate = -1;

        if (Instance == null)
        {
            Instance        = this;
            soundAudible    = true;
            timeFrozen      = false;
            elevatorMoving  = false;
            inGame          = true;
            bullets         = new ArrayList();
            isDead          = false;
            soundAudible    = true;
            timeFreezes     = 0;
            currentLevel    = -2;
            levelFreshStart = true;
            powerUps        = new ArrayList();

            DontDestroyOnLoad(gameObject); // gameObject = the game object this script lives on
        }

        else //Gives singleton property. stops unity from trying to duplicate and create more instances
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 7
0
    void Start()
    {
        PersistenceKey = transform.position;

        _controller = GameObject.FindGameObjectWithTag(Tag.GameController)
                      .GetComponent <PersistenceController>();

        if (_controller.HasSavedData(this))
        {
            if ((ResetsOnGameStart &&
                 _controller.HasBeenLoaded.ContainsKey(this.PersistenceKey)) ||
                !ResetsOnGameStart)
            {
                _controller.Load(this);
            }
            else
            {
                _controller.NotifyLoad(this);
            }
        }

        gameObject.SetActive(Enabled);

        _isInitialized = true;
    }
Ejemplo n.º 8
0
 /** Initializes variables and loads buttons. */
 private void Awake()
 {
     persistenceController = GameObject.Find("PersistenceController").GetComponent <PersistenceController>();
     buttons        = new List <RectTransform>();
     currentPage    = 0;
     totalPageCount = (persistenceController.Levels.Count - 1) / 10 + 1;
     LoadButtons();
 }
Ejemplo n.º 9
0
 void Start()
 {
     anim          = transform.GetComponent <Animator>();
     pc            = GameObject.Find("PersistenceController").GetComponent <PersistenceController>();;
     ui            = GameObject.Find("UIController").GetComponent <UIController>();
     shootingSound = GetComponents <AudioSource>()[0];
     reloadSound   = GetComponents <AudioSource>()[1];
 }
Ejemplo n.º 10
0
 public void SetUnitOfWork(IUnitOfWork uow)
 {
     m_persistenceController = new PersistenceController(uow);
     saveButton.Click       += m_persistenceController.Save;
     cancelButton.Click     += m_persistenceController.Cancel;
     m_persistenceController.CancelChanges += (o, t) => this.CancelChanges(o, t);
     m_persistenceController.SaveChanges   += (o, t) => this.SaveChanges(o, t);
 }
Ejemplo n.º 11
0
 void Start()
 {
     StartCoroutine("WaitDamage");
     transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0);
     bounces = 0;
     pc      = GameObject.Find("PersistenceController").GetComponent <PersistenceController>();;
     ui      = GameObject.Find("UIController").GetComponent <UIController>();
 }
Ejemplo n.º 12
0
 public void SaveAndExitGame()
 {
     PersistenceController.SaveGame();
     #if UNITY_EDITOR
     UnityEditor.EditorApplication.isPlaying = false;
     #else
     Application.Quit();
     #endif
 }
Ejemplo n.º 13
0
    public void testStoreAndRetrieve()
    {
        // Reset with instantiate instance
        PersistenceController.instance.inventoryState.currentLine = 3;
        Assert.AreEqual(3, PersistenceController.instance.inventoryState.currentLine);

        PersistenceController.ResetState();
        Assert.AreEqual(0, PersistenceController.instance.inventoryState.currentLine);
    }
Ejemplo n.º 14
0
    void Start()
    {
        ui = GameObject.Find("UIController").GetComponent <UIController>();
        pc = GameObject.Find("PersistenceController").GetComponent <PersistenceController>();;

        if (isMoney)
        {
            pc.moneyLeft++;
        }
    }
Ejemplo n.º 15
0
    public void OnTimeTravel()
    {
        string lastReality = CurrentReality;

        // going present, or going to future according to water taps
        CurrentReality = (CurrentReality != "Present") ? "Present" : RealitySceneName[GetFutureRealityIndex()];

        SceneManager.LoadSceneAsync(CurrentReality, LoadSceneMode.Additive);
        SceneManager.UnloadScene(lastReality);

        PersistenceController.SaveDataToDisk();
    }
Ejemplo n.º 16
0
    void Awake()
    {
        contr = PersistenceController.Instance;

        foreach (Sound s in sounds)
        {
            s.source      = gameObject.AddComponent <AudioSource>();
            s.source.clip = s.clip;

            s.source.volume = s.volume;
        }
    }
Ejemplo n.º 17
0
 // Start is called before the first frame update
 void Start()
 {
     enemyDeathSound = GetComponent <AudioSource>();
     pc                          = PersistenceController.Instance;
     ui                          = GameObject.Find("UIController").GetComponent <UIController>();
     isShooting                  = false;
     player                      = pc.player;
     healthBar.value             = health;
     navMeshAgent                = GetComponent <NavMeshAgent>();
     navMeshAgent.updatePosition = false;
     pc.enemiesLeft++;
 }
Ejemplo n.º 18
0
    void Start()
    {
        PersistenceController options = GameObject.Find("Options").GetComponent <PersistenceController>();

        touchButton.GetComponent <Button>().onClick.AddListener(() => options.SetControls(0));
        joystickButton.GetComponent <Button>().onClick.AddListener(() => options.SetControls(1));
        accelButton.GetComponent <Button>().onClick.AddListener(() => options.SetControls(2));

        nextSkin.GetComponent <Button>().onClick.AddListener(() => options.SetSkin(true));
        prevSkin.GetComponent <Button>().onClick.AddListener(() => options.SetSkin(false));

        adsToggle.GetComponent <Toggle>().onValueChanged.AddListener(val => options.SetAds(val));
    }
Ejemplo n.º 19
0
 // check PersistenceController existence
 void Awake()
 {
     if (persistence == null)
     {
         DontDestroyOnLoad(gameObject);
         persistence = this;
     }
     else if (persistence != this)
     {
         Destroy(gameObject);
     }
     Load();
 }
Ejemplo n.º 20
0
    public void UpdateUI()
    {
        UnityEngine.Debug.Log("Called");
        pc = PersistenceController.Instance;

        if (pc.enemiesLeft == 0 && pc.moneyLeft == 0 && !pc.isDead)
        {
            destroyEnemies.color = Color.green;
            objectiveText.color  = Color.green;
            //Level complete!
            nextLevel.SetActive(true);
            pc.isDead        = true;
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
        }

        if (pc.enemiesLeft == 0)
        {
            destroyEnemies.color = Color.green;
        }

        else
        {
            destroyEnemies.color = Color.red;
        }

        if (pc.moneyLeft == 0)
        {
            objectiveText.color = Color.green;
        }

        else
        {
            objectiveText.color = Color.red;
        }

        if (pc.timeFrozen)
        {
            timeFreezeText.SetActive(true);
        }

        else
        {
            timeFreezeText.SetActive(false);
        }

        ammo.text = pc.ammoInClip.ToString() + "/" + pc.ammoLeft.ToString();

        CheckDoorOpen();
    }
Ejemplo n.º 21
0
        public void TogglePersistence(string tag, bool state)
        {
            if (!soundObject.tag.Equals(tag))
            {
                //Debug.Log($"Can Play FX ?: {state}");
                PersistenceController.playerData.soundConfig.canPlayFX = state; //? Pq não funciona ?
            }
            else
            {
                //Debug.Log($"Can Play Music ?: {state}");
                PersistenceController.playerData.soundConfig.canPlayMusic = state;
            }

            PersistenceController.SavePlayerData();
        }
Ejemplo n.º 22
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            persistenceController = new PersistenceController();

            settingsController = new SettingsController(persistenceController);
            modelController    = new MonthModelController(persistenceController, settingsController);

            task = new TelegramTask(new TelegramController(settingsController, modelController));
            task.OnFetchComplete = OnFetchComplete;
            task.Start();

            expenseEditor.NewExpense();

            RefreshView();
        }
Ejemplo n.º 23
0
    //Awake for singleton pattern
    private void Awake()
    {
        if (instance == null)
        {
            Debug.Log($" {this.name} - Creating new Singleton instance");
            instance = this;
        }
        else if (instance != this)
        {
            Debug.Log($" {this.name} - Destroying instances other than the original.");
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 24
0
 void Awake()
 {
     if (controller == null)
     {
         DontDestroyOnLoad(gameObject);
         controller = this;
     }
     else if (controller != this)
     {
         Destroy(gameObject);
     }
     persistenceController = new PersistenceController();
     maps = new string[] { "IntroMap", "DebugMap" };
     persistenceController.loadGame();
     unlocksController             = GameObject.Find("Unlocks").transform.GetChild(0).GetChild(0).GetChild(0).gameObject.GetComponent <UnlocksController>();
     unlocksController.weaponsList = persistenceController.saveData.weapons;
 }
Ejemplo n.º 25
0
    // Start is called before the first frame update
    void Start()
    {
        awards = new Dictionary <string, int>();

        PurchasePanel.SetActive(false);
        PurchaseOpen  = false;
        PlacementMode = false;
        SelectTowerText.gameObject.SetActive(false);

        //Persistent data
        contr             = PersistenceController.Instance;
        MoneyText.text    = "$" + contr.money;
        CurrentLevel.text = contr.level.ToString();
        HealthBar.value   = contr.health;

        if (contr.BasicCannonsPlaced == 4)
        {
            NoMoreBasic.SetActive(true);
            PurchasePanel.transform.GetChild(3).gameObject.SetActive(false);
        }

        if (contr.AdvancedCannonsPlaced == 3)
        {
            NoMoreAdvanced.SetActive(true);
            PurchasePanel.transform.GetChild(4).gameObject.SetActive(false);
        }

        if (contr.GameOver)
        {
            GameOverText.gameObject.SetActive(true);
        }

        foreach (KeyValuePair <string, int> item in contr.Inventory)
        {
            for (int i = 1; i <= item.Value; i++)
            {
                UpdateItem(item.Key);
            }
        }

        ChangeSound(contr.SoundAudible);
    }
    // Start is called before the first frame update
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        blackScreen.gameObject.SetActive(true);
        blackScreen.enabled = true;
        blackScreen.color   = Color.black;

        if (SceneManager.GetActiveScene().name == "MainLoad")
        {
            StartCoroutine(LoadShipAfterSceneLoad());
        }
        else
        {
            StartCoroutine(FadeIntoScene());
        }
    }
Ejemplo n.º 27
0
        private void Initialize()
        {
            m_orderModule = Scout.Core.Modules.Orders;
            m_areaService = Scout.Core.Service <IAreaService>();
            m_uow         = Scout.Core.Data.GetUnitOfWork();

            m_persistence = new PersistenceController(m_uow);

            m_shopfloorlines = m_areaService.GetAllShopfloorlines(m_uow);
            m_organizations  = Organization.GetActiveOrganizations();
            m_shipMethods    = OrderService.GetAllShipMethods();

            m_detailControls = new List <IBindableComponent>();

            CurrentShopfloorline = null;

            detailsTab.Visibility = LayoutVisibility.Never;

            LoadDetailsControls(m_detailControls);
        }
Ejemplo n.º 28
0
    // Start is called before the first frame update
    void Start()
    {
        contr     = PersistenceController.Instance;
        baseLayer = GameObject.Find("/Grid/BaseMap").GetComponent <Tilemap>();

        if (contr.TopTowersActive.Count != 0)
        {
            foreach (KeyValuePair <string, int> tower in contr.TopTowersActive)
            {
                SpawnTower(tower.Key.Split('.')[0], contr.TopSpots[tower.Value]);
            }
        }

        if (contr.BottomTowersActive.Count != 0)
        {
            foreach (KeyValuePair <string, int> tower in contr.BottomTowersActive)
            {
                SpawnTower(tower.Key.Split('.')[0], contr.BottomSpots[tower.Value]); // Splits off the ending tower number to have unique keys
            }
        }
    }
Ejemplo n.º 29
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                                                                 ///
    ///                                     MÉTODOS PRIVADOS                                            ///
    ///                                                                                                 ///
    ///////////////////////////////////////////////////////////////////////////////////////////////////////

    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        for (int i = 0; i < GameManager.Instance._categoryLevelFiles.Count; i++)
        {
            levelsCompleted.Add(0);
        }

        persistenceController = new PersistenceController();
        persistenceController.LoadFile();
    }
    public void StartGame()
    {
        Instance              = this; // Set to the instance that is being created
        BuyPhase              = true;
        PlayPhase             = false;
        GameOver              = false;
        RandomEnemies         = 20;
        TopTurretsPlaced      = 0;
        BottomTurretsPlaced   = 0;
        BasicCannonsPlaced    = 0;
        AdvancedCannonsPlaced = 0;
        level              = 1;
        money              = 2000;
        health             = 1.0f;
        TopTowersActive    = new Dictionary <string, int>();
        BottomTowersActive = new Dictionary <string, int>();
        TopSpotsTaken      = new bool[TopSpots.Length];
        BottomSpotsTaken   = new bool[BottomSpots.Length];
        SoundAudible       = true;
        Inventory          = new Dictionary <string, int>()
        {
            { "TownFull", 0 },
            { "TownHalf", 0 },
            { "TownQuarter", 0 },
            { "DestroyEnemies", 0 }
        };

        Towers     = new GameObject[37];
        TowerCount = 0;

        for (int i = 0; i < TopSpotsTaken.Length; i++)
        {
            TopSpotsTaken[i] = false;
        }

        for (int i = 0; i < BottomSpotsTaken.Length; i++)
        {
            BottomSpotsTaken[i] = false;
        }
    }