Пример #1
0
        SaveDataFilledBeercase CreateSaveDataFilledBeercase(GameObject go)
        {
            SaveDataFilledBeercase filledBeercase = new SaveDataFilledBeercase();

            filledBeercase.Name         = go.name;
            filledBeercase.Position     = go.transform.position;
            filledBeercase.RotX         = go.transform.rotation.eulerAngles.x;
            filledBeercase.RotY         = go.transform.rotation.eulerAngles.y;
            filledBeercase.RotZ         = go.transform.rotation.eulerAngles.z;
            filledBeercase.bottleAmount = go.GetComponent <BeercaseFilled>().totalBottles;
            return(filledBeercase);
        }
Пример #2
0
        public override void OnSave()
        {
            // Called once, when save and quit
            // Serialize your save file here.
            SaveData sd = new SaveData();

            sd.unredeemedBottleDeposit = bottleRecyclingManager.totalMoneyAmountFromBottles;

            // Save Empty Bottles and Beercases, if set so.
            if ((bool)saveEmptyBottles.GetValue() || (bool)saveFilledBeercases.GetValue())
            {
                foreach (GameObject go in GameObject.FindGameObjectsWithTag("PART"))
                {
                    // empty bottles
                    if (go.name == "empty bottle(Clone)" && (bool)saveEmptyBottles.GetValue())
                    {
                        if (isBoozeBottle(go.transform)) // ignore booze bottles
                        {
                            continue;
                        }
                        SaveDataEmptyBottle emptyBottle = CreateSaveDataEmptyBottle(go);
                        sd.emptyBottles.Add(emptyBottle);
                        continue;
                    }

                    // filled beercases
                    if (go.name == "empty(itemx)" && (bool)saveFilledBeercases.GetValue())
                    {
                        BeercaseFilled filled = go.GetComponent <BeercaseFilled>();
                        if (filled)
                        {
                            SaveDataFilledBeercase filledBeercase = CreateSaveDataFilledBeercase(go);
                            sd.filledBeercases.Add(filledBeercase);
                            continue;
                        }
                    }
                }
            }

            // save to file
            SaveLoad.SerializeSaveFile(this, sd, "BottleRecyclingSave.save");
        }