Пример #1
0
        /// <summary>
        /// Removes all save data related to this component.
        /// This is useful for dynamic saved objects. So they get erased
        /// from the save file permanently.
        /// </summary>
        public void WipeData(SaveGame saveGame)
        {
            int componentCount = saveableComponentIDs.Count;

            for (int i = componentCount - 1; i >= 0; i--)
            {
                saveGame.Remove(saveableComponentIDs[i]);
            }

            // Ensures it doesn't try to save upon destruction.
            manualSaveLoad = true;
            SaveMaster.RemoveListener(this, false);
        }
Пример #2
0
 public MinersData(SaveMaster mast)
 {
     numStats = 4;
     stats    = new float[mast.miners.Length * numStats];
     for (int i = 0; i < mast.miners.Length; i++)
     {
         Miner miner = mast.miners[i];
         stats[(i * numStats)]     = miner.transform.position.x;
         stats[(i * numStats) + 1] = miner.transform.position.y;
         stats[(i * numStats) + 2] = miner.transform.rotation.eulerAngles.z;
         stats[(i * numStats) + 3] = miner.launchForce;
     }
 }
Пример #3
0
        private void SyncSaveLoad()
        {
            var stopWatch = new System.Diagnostics.Stopwatch();

            stopWatch.Start();

            SaveMaster.ClearSlot();
            SaveMaster.SetSlot(0, true);

            stopWatch.Stop();
            displayText.text = stopWatch.Elapsed.TotalMilliseconds.ToString();
            lastestSpeed     = stopWatch.ElapsedMilliseconds;
        }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        var allTheNeeds = GameObject.FindObjectsOfType <Needy>();


        iTime -= Time.deltaTime;

        if (!Inman.I.HasPlayer)
        {
            iTime = maxITime;
            currentlyPlaying.text = "Nobody ";
        }

        var playtime = Inman.I.HasPlayer ? Mathf.Max(Inman.I.playTime - (Time.time - Inman.I.joinTime), 0) : 0;
        var showName = Inman.I.HasPlayer ? Inman.I.username : "******";

        currentlyPlaying.text = $"{showName} is taking care of the plant and has {playtime}s of exlusive time";
        var freeze = iTime > 0;


        var  failed    = false;
        Need faileNeed = null;

        foreach (var need in allTheNeeds)
        {
            need.Freeze = freeze;

            if (!freeze && need.balance <= 0)
            {
                failed    = true;
                faileNeed = need.need;
            }
        }
        failed &= !freeze;
        if (failed)
        {
            SaveMaster.SyncLoad();
            Newspaper.I.Report(Inman.I.username, faileNeed);
            Inman.I.RelinquishControl();
            iTime = maxITime;
        }

        if (Input.GetKeyDown(KeyCode.F5))
        {
            SaveMaster.SyncSave();
        }
        if (Input.GetKeyDown(KeyCode.F9))
        {
            SaveMaster.SyncLoad();
        }
    }
Пример #5
0
        private void Awake()
        {
            // Store the component identifiers into a dictionary for performant retrieval.
            for (int i = 0; i < cachedSaveableComponents.Count; i++)
            {
                saveableComponentIDs.Add(string.Format("{0}-{1}", saveIdentification, cachedSaveableComponents[i].identifier));
                saveableComponentObjects.Add(cachedSaveableComponents[i].monoBehaviour as ISaveable);
            }

            if (!manualSaveLoad)
            {
                SaveMaster.AddListener(this);
            }
        }
Пример #6
0
        /// <summary>
        /// Gets and adds a saveable components. This is only required when you want to
        /// create gameobjects dynamically through C#. Keep in mind that changing the component add order
        /// will change the way it gets loaded.
        /// </summary>
        public void ScanAddSaveableComponents()
        {
            ISaveable[] saveables = GetComponentsInChildren <ISaveable>();

            for (int i = 0; i < saveables.Length; i++)
            {
                string mono = (saveables[i] as MonoBehaviour).name;

                AddSaveableComponent(string.Format("Dyn-{0}-{1}", mono, i.ToString()), saveables[i]);
            }

            // Load it again, to ensure all ISaveable interfaces are updated.
            SaveMaster.ReloadListener(this);
        }
Пример #7
0
 // Start is called before the first frame update
 public playerdatascript(SaveMaster SaveMaster)
 {
     position    = new float[3];
     position[0] = SaveMaster.position1[0];
     position[1] = SaveMaster.position1[1];
     position[2] = SaveMaster.position1[2];
     items       = new float[SaveMaster.itemlist.Count];
     for (int i = 0; i < SaveMaster.itemlist.Count; i++)
     {
         items[i] = SaveMaster.itemlist[i];
     }
     ninemilammo = SaveMaster.ninemilammo;
     rifleammo   = SaveMaster.rifleammo;
 }
Пример #8
0
        private void Start()
        {
            string checkForSave = SaveMaster.GetString("scene");


            if (string.IsNullOrEmpty(checkForSave))
            {
                return;
            }
            else
            {
                SaveMaster.SyncLoad();
            }
        }
 public void EndTrying()
 {
     if (!SaveMaster.isLevelDone(doranLevel))
     {
         tutPanel.SetActive(false);
         LocalPlayerController.isActive = false;
         decidePanel.SetActive(true);
         GameObjectiveMaster.s.isGamePlaying = false;
     }
     else
     {
         EndGame();
     }
 }
Пример #10
0
    private void Update()
    {
        /*if(Input.GetKeyDown(KeyCode.L))
         * {
         *  SaveMaster.SetSlot(0, false);
         *  SaveMaster.SetString("scene", gameObject.scene.name);
         *  SaveMaster.WriteActiveSaveToDisk();
         *  Debug.Log("Saved");
         * }*/

        if (Input.GetKeyDown(KeyCode.L))
        {
            SaveMaster.DeleteSave(0);
        }
    }
Пример #11
0
        private void OnDestroy()
        {
            if (!manualSaveLoad)
            {
                SaveMaster.RemoveListener(this);
            }

#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                Lowscope.Tools.ValidateHierarchy.Remove(this);
                saveIdentificationCache.Remove(saveIdentification);
            }
#endif
        }
Пример #12
0
 public SplitterData(SaveMaster mast)
 {
     numStats = 4; ///posx, posy, rot, force
     stats    = new float[mast.splitters.Length * numStats];
     filters  = new string[mast.splitters.Length];
     for (int i = 0; i < mast.splitters.Length; i++)
     {
         Splitter split = mast.splitters[i];
         stats[i * numStats]       = split.transform.position.x;
         stats[(i * numStats) + 1] = split.transform.position.y;
         stats[(i * numStats) + 2] = split.transform.rotation.eulerAngles.z;
         stats[(i * numStats) + 3] = split.fireForce;
         filters[i] = split.typeName;
     }
 }
Пример #13
0
    public static void SaveData(SaveMaster master, string path)
    {
        DirectoryInfo   di     = Directory.CreateDirectory(Application.dataPath + "/saves/");
        BinaryFormatter bf     = new BinaryFormatter();
        FileStream      stream = new FileStream(Application.dataPath + "/saves/" + path + ".europa", FileMode.Create);

        Debug.Log(di.FullName + "_____" + stream.Name);
        AllData data = new AllData(new RelayCannonsData(master), new FansData(master), new CrafterData(master),
                                   new ItemObjectsData(master), new MinersData(master), new OreData(master), new InventoryData(master),
                                   new UnPackagerData(master), new PackagerData(master), new EggData(master), new SplitterData(master),
                                   new PumpsData(master), new ZapTowerData(master), new RocketData(master));

        bf.Serialize(stream, data);
        //Debug.Log("The directory was created successfully at " + di.Name + path);
        stream.Close();
    }
Пример #14
0
    //zaptowers should automatically connect to all local towers
    public ZapTowerData(SaveMaster mast)
    {
        int num = mast.zapTowers.Length;

        x = new float[num];
        y = new float[num];
        z = new float[num];

        for (int i = 0; i < num; i++)
        {
            ZapTower zap = mast.zapTowers[i];
            x[i] = zap.transform.position.x;
            y[i] = zap.transform.position.y;
            z[i] = zap.transform.position.z;
        }
    }
Пример #15
0
 public CrafterData(SaveMaster mast)
 {
     numStats = 4;
     stats    = new float[mast.crafters.Length * numStats];
     allItems = new string[mast.crafters.Length][];
     for (int i = 0; i < mast.crafters.Length; i++)
     {
         Crafting crafter = mast.crafters[i];
         stats[(i * numStats)]     = crafter.transform.position.x;
         stats[(i * numStats) + 1] = crafter.transform.position.y;
         stats[(i * numStats) + 2] = crafter.transform.rotation.eulerAngles.z;
         stats[(i * numStats) + 3] = crafter.recipe.id;
         //adds item list to the index in the parent list.
         allItems[i] = new ItemListSave(crafter.currentItems).items.ToArray();
     }
 }
Пример #16
0
 public RelayCannonsData(SaveMaster mast)
 {
     numStats = 6;
     stats    = new float[mast.cannons.Length * numStats];
     for (int i = 0; i < mast.cannons.Length; i++)
     {
         LauncherController cannon = mast.cannons[i];
         //slot 1 is x, 2 is y, 3 is z rotation
         stats[(i * numStats)]     = cannon.transform.position.x;
         stats[(i * numStats) + 1] = cannon.transform.position.y;
         stats[(i * numStats) + 2] = cannon.transform.eulerAngles.z;
         //next slot is cooldown, then comes launchforce. Currently hoping to avoid saving their stored items, b/c that sounds really hard
         stats[(i * numStats) + 3] = cannon.coolDown;
         stats[(i * numStats) + 4] = cannon.launchForce;
         stats[(i * numStats) + 5] = cannon.launchRotationVertex.rotation.eulerAngles.z;
     }
 }
Пример #17
0
        private void WipeSaveables()
        {
            var stopWatch = new System.Diagnostics.Stopwatch();

            stopWatch.Start();

            int saveableCount = saveables.Length;

            for (int i = 0; i < saveableCount; i++)
            {
                SaveMaster.WipeSaveable(saveables[i]);
            }

            stopWatch.Stop();
            displayText.text = stopWatch.Elapsed.TotalMilliseconds.ToString();
            lastestSpeed     = stopWatch.ElapsedMilliseconds;
        }
Пример #18
0
    // Start is called before the first frame update
    void Start()
    {
        if (SaveMaster.GetActiveSlot() == -1)
        {
            this.GetComponent <PlayerMovement>().LockMovement();
            stats.maxen     = 10;
            stats.maxhp     = 20;
            stats.hp        = 15;
            stats.en        = 5;
            stats.lvl       = 1;
            stats.exp       = 0;
            stats.exptonext = 20;
            stats.off       = 10;
            stats.def       = 8;
            stats.spd       = 6;
            stats.pts       = 5;
        }
        else
        {
            this.GetComponent <PlayerMovement>().UnlockMovement();
            genderMenu.SetActive(false);
            Debug.Log("Load");
        }
        //stats.maxen = 10;
        //stats.maxhp = 20;
        //stats.hp = 20;
        //stats.en = 10;
        //stats.lvl = 1;
        //stats.exp = 0;
        //stats.exptonext = 20;
        //stats.off = 10;
        //stats.def = 8;
        //stats.spd = 6;
        //stats.pts = 5;
        atks      = new Attacks();
        skillList = new List <Skill>();
        Skill armsUp = new Skill(atks.ArmsUp, 1, 2, "Arms Up", "Put your arms up in front of your much more delicate face. Defense up by 2.");
        Skill windUp = new Skill(atks.WindUp, 2, 3, "Wind Up", "Start spinning your arm around in a circle. It works in cartoons. Attack up by 2.");
        Skill heal   = new Skill(atks.GoodSide, 3, 3, "Happy Thoughts", "Guess it's not all that bad. Heal yourself by 20 HP.");
        Skill combo  = new Skill(atks.PlayerCombo, 3, 3, "Multi-Hit", "Uses a mix of elementary-level martial arts you learned at the age of 9 and primal instinct. Deals low damage to an enemy 3 times.", true);

        skillList.Add(armsUp);
        skillList.Add(windUp);
        skillList.Add(heal);
        skillList.Add(combo);
    }
Пример #19
0
    public InventoryData(SaveMaster mast)
    {
        numStats = 6; //because what if I add more items?
        stats    = new string[numStats];
        int i = 0;

        foreach (KeyValuePair <string, int> keyVal in mast.invent.storedVals)
        {
            stats[i] = keyVal.Key + "," + keyVal.Value.ToString(); //"Key,Value"
            if (i > numStats)
            {
                Debug.LogError("More keys in storedvals dictionary than are allowed to be saved! Increase numstats");
            }
            i++;
        }
        stats[5] = mast.invent.core.level.ToString();
    }
Пример #20
0
    public void LoadButton()
    {
        SaveMaster.SetSlot(0, false);

        string sceneName = SaveMaster.GetString("scene");

        if (string.IsNullOrEmpty(sceneName))
        {
            Debug.Log("No level set for this game.");
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
        }
        else
        {
            // Load the saved scene name
            SceneManager.LoadScene(sceneName);
        }
    }
Пример #21
0
 private void OnEnable()
 {
     if (!mast)
     {
         mast = GameObject.FindObjectOfType <SaveMaster>();
     }
     if (!wGen)
     {
         wGen = GameObject.FindObjectOfType <WorldGen>();
     }
     if (input && mast)
     {
         string p     = mast.currentPath;
         int    index = p.IndexOf("/saves/") + 1;
         string piece = p.Substring(index);
         input.text = piece.Split('/')[1];
     }
 }
    // Use this for initialization
    void Start()
    {
        DialogTree.s.myCustomTriggers[0]                   += StartElementTrial;
        DialogTree.s.myCustomTriggers[1]                   += EndGame;
        CharacterStuffController.s.buttonStateHijack       += ButtonStateHiJack;
        CharacterStuffController.s.isHijacked               = true;
        CharacterStuffController.s.powerUpDisabledCallback += PowerUpDisabledCallback;

        tutPanel.SetActive(false);
        decidePanel.SetActive(false);
        youCanExitHerePanel.SetActive(false);

        SetUpButtons();

        if (SaveMaster.isLevelDone(doranLevel))
        {
            Invoke("LateStartChangeDialog", 0.1f);
        }
    }
Пример #23
0
    public PumpsData(SaveMaster mast)
    {
        int len = mast.pumps.Length;

        numStats      = 3;
        transforms    = new float[len * 3];
        storedBarrels = new int[len];

        for (int i = 0; i < len; i++)
        {
            Pump p = mast.pumps[i];
            //x,y,rot lol
            transforms[(i * numStats)]     = p.transform.position.x;
            transforms[(i * numStats) + 1] = p.transform.position.y;
            transforms[(i * numStats) + 2] = p.transform.rotation.eulerAngles.z;

            storedBarrels[i] = p.amntContainersStored;
        }
    }
Пример #24
0
    public ItemObjectsData(SaveMaster mast)
    {
        numStats = 6;
        stats    = new string[mast.items.Length * numStats];
        //x, y, rot, xV, yV, type.
        for (int i = 0; i < mast.items.Length; i++)
        {
            //Debug.Log(mast.items[i].name);
            Item item = mast.items[i];
            //Debug.Log(item.name);

            stats[(i * numStats)]     = item.transform.position.x.ToString();
            stats[(i * numStats) + 1] = item.transform.position.y.ToString();
            stats[(i * numStats) + 2] = item.transform.rotation.eulerAngles.z.ToString();
            Rigidbody2D rb = item.GetComponent <Rigidbody2D>();
            stats[(i * numStats) + 3] = rb.velocity.x.ToString();
            stats[(i * numStats) + 4] = rb.velocity.y.ToString();
            stats[(i * numStats) + 5] = item.typeOfItem;
        }
    }
Пример #25
0
    public PackagerData(SaveMaster mast)
    {
        int num = mast.packers.Length;

        x = new float[num];
        y = new float[num];
        z = new float[num];

        mI = new int[num];
        ft = new float[num];
        for (int i = 0; i < mast.packers.Length; i++)
        {
            Packager p = mast.packers[i];
            x[i] = p.transform.position.x;
            y[i] = p.transform.position.y;
            z[i] = p.transform.rotation.eulerAngles.z;

            mI[i] = p.maxItems;
            ft[i] = p.launchForce;
        }
    }
Пример #26
0
    public UnPackagerData(SaveMaster mast)
    {
        int num = mast.unPackers.Length;

        x = new float[num];
        y = new float[num];
        z = new float[num];

        fF       = new float[num];
        ft       = new float[num];
        allItems = new string[num][];
        for (int i = 0; i < num; i++)
        {
            UnPackager uP = mast.unPackers[i];
            Debug.Log(uP.name);
            x[i] = uP.transform.position.x;
            y[i] = uP.transform.position.y;
            z[i] = uP.transform.rotation.eulerAngles.z;

            fF[i] = uP.fireForce;
            ft[i] = uP.fireDelay;
        }
    }
Пример #27
0
    public RocketData(SaveMaster mast)
    {
        int num = mast.rockets.Length;

        transes = new float[num][];
        invents = new int[num][];

        for (int i = 0; i < num; i++)
        {
            RocketBase rocket = mast.rockets[i];
            float[]    t      = new float[3];
            t[0]       = rocket.transform.position.x;
            t[1]       = rocket.transform.position.y;
            t[2]       = rocket.transform.rotation.eulerAngles.z;
            transes[i] = t;

            int[] its = new int[3];
            its[0] = rocket.storedIron;
            its[1] = rocket.storedCopper;
            its[2] = rocket.storedFuel;

            invents[i] = its;
        }
    }
Пример #28
0
    public static bool isUnlocked(GameSettings myLevel, int questDecisionLockId, float questDecisionReqValue)
    {
        bool isLevelChecked, isLevelDone, isQuestChecked, isQuestDone;

        isLevelChecked = myLevel != null;

        if (isLevelChecked)
        {
            //check if the level is done
            isLevelDone = SaveMaster.isLevelDone(myLevel);
        }
        else
        {
            isLevelDone = true;
        }

        isQuestChecked = questDecisionLockId != -1;
        if (isQuestChecked)
        {
            if (SaveMaster.s.mySave.questDecisions.Length < questDecisionLockId)
            {
                float[] temp = SaveMaster.s.mySave.questDecisions;
                SaveMaster.s.mySave.questDecisions = new float[questDecisionLockId];
                temp.CopyTo(SaveMaster.s.mySave.questDecisions, 0);
            }

            //check if the quest requirements are met
            isQuestDone = SaveMaster.s.mySave.questDecisions[questDecisionLockId] == questDecisionReqValue;
        }
        else
        {
            isQuestDone = true;
        }

        return(isQuestDone && isLevelDone);
    }
Пример #29
0
 public void NewGameButton()
 {
     SaveMaster.DeleteSave(0);
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
 }
Пример #30
0
 private void Start()
 {
     checkforSave = SaveMaster.GetString("scene");
 }