Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            CurrentName = new Dialog().Prompt("What's your name?", "Enter below:");

            Area = new PlayingArea();
            Surface = new Surface();
            SaveSystem = new SaveSystem();

            Surface.OnUserReaction += surface_OnUserReaction;
            Surface.OnGravity += surface_OnGravity;
            Area.OnCurrentTileReachedBottom += area_OnCurrentTileReachedBottom;
            Area.OnUserScored += area_OnUserScored;
            Area.OnGameEnds += area_OnGameEnds;

            SaveSystem.ReadHighscore();

            Surface.UpdateHighscoreLabel();

            Application.Run(Surface);
        }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        SaveSystem.Load();

        BuildLevelList();
    }
Ejemplo n.º 3
0
 private void Awake()
 {
     instance = this;
 }
Ejemplo n.º 4
0
    public static string CargarNombreZona()
    {
        SaveDataInfoGloval data = SaveSystem.loadDataDatosGlovales();

        return(data.nombreZona);
    }
Ejemplo n.º 5
0
 void Save()
 {
     SaveSystem.Save(_lvlProgressList, SaveSystem.LEVEL_PROGRESS_SAVE_NAME);
 }
Ejemplo n.º 6
0
    private void OnGUI()
    {
        if (items == null)
        {
            Load();
        }
        if (window == null)
        {
            window = GetWindow <SaveSystemWindow>();
        }

        window.minSize = new Vector2(600, 200);

        EditorGUILayout.BeginHorizontal("Box");
        if (GUILayout.Button("Load"))
        {
            Load();
        }

        if (GUILayout.Button("Save"))
        {
            Save();
        }
        EditorGUILayout.EndHorizontal();

        if (list == null)
        {
            list = new ReorderableList(items.Values.ToList(), typeof(List <SaveSystem.ISaveItem>), true, true, false, false);

            //Header
            list.drawHeaderCallback = (Rect rect) =>
            {
                EditorGUI.LabelField(rect, "Items");
            };

            //List Items
            list.drawElementCallback =
                (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                var target = items.Values.ToList()[index];
                rect.y += 2;
                var rectg = new Rect(rect.x, rect.y, rect.width, rect.height);
                EditorGUI.LabelField(new Rect(rectg.x, rectg.y, 300, EditorGUIUtility.singleLineHeight), target.Key);
            };

            //View Item
            list.onSelectCallback = (ReorderableList list) =>
            {
                editItem = items.Values.ToList()[list.index];
            };
        }

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.BeginVertical(new GUIStyle()
        {
            fixedWidth = 300
        });
        itemsScroll = EditorGUILayout.BeginScrollView(itemsScroll);
        list.DoLayoutList();
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Fields");
        itemScroll = EditorGUILayout.BeginScrollView(itemScroll);

        if (editItem != null)
        {
            var type = editItem.GetType();

            DrawClass(editItem);

            void DrawClass(object item)
            {
                if (item != null)
                {
                    var fields = item.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
                    foreach (var field in fields)
                    {
                        var value = field.GetValue(item);
                        if (field.FieldType.IsArray)
                        {
                            if (value != null)
                            {
                                EditorGUILayout.BeginVertical("BOX");
                                EditorGUILayout.BeginFoldoutHeaderGroup(true, field.Name);
                                EditorGUILayout.EndFoldoutHeaderGroup();
                                foreach (var f in (Array)value)
                                {
                                    DrawClass(f);
                                }
                                EditorGUILayout.EndVertical();
                            }
                            else
                            {
                                EditorGUILayout.LabelField(field.Name, "NULL");
                            }
                        }
                        else
                        {
                            if (!field.FieldType.IsClass || field.FieldType == typeof(string))
                            {
                                Draw(field, item);
                            }
                            else
                            {
                                EditorGUILayout.BeginVertical("BOX");
                                EditorGUILayout.BeginFoldoutHeaderGroup(true, field.FieldType.Name);
                                EditorGUILayout.EndFoldoutHeaderGroup();
                                DrawClass(value);
                                EditorGUILayout.EndVertical();
                            }
                        }
                    }
                }
            }

            void Draw(FieldInfo field, object obj)
            {
                if (field.FieldType == typeof(long))
                {
                    var value = (long)field.GetValue(obj);
                    value = EditorGUILayout.LongField(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(int))
                {
                    var value = (int)field.GetValue(obj);
                    value = EditorGUILayout.IntField(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(float))
                {
                    var value = (float)field.GetValue(obj);
                    value = EditorGUILayout.FloatField(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(string))
                {
                    var value = (string)field.GetValue(obj);
                    value = EditorGUILayout.TextField(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(double))
                {
                    var value = (double)field.GetValue(obj);
                    value = EditorGUILayout.DoubleField(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(bool))
                {
                    var value = (bool)field.GetValue(obj);
                    value = EditorGUILayout.Toggle(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(Color))
                {
                    var value = (Color)field.GetValue(obj);
                    value = EditorGUILayout.ColorField(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(Vector3))
                {
                    var value = (Vector3)field.GetValue(obj);
                    value = EditorGUILayout.Vector3Field(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType == typeof(Vector2))
                {
                    var value = (Vector2)field.GetValue(obj);
                    value = EditorGUILayout.Vector2Field(field.Name, value);
                    field.SetValue(obj, value);
                }
                if (field.FieldType.IsEnum)
                {
                    var p     = Enum.Parse(field.FieldType, field.GetValue(obj).ToString());
                    var value = EditorGUILayout.EnumPopup(field.FieldType.Name, (Enum)field.GetValue(obj));
                    field.SetValue(obj, value);
                }
            }

            if (GUILayout.Button("Delete Item"))
            {
                SaveSystem.Remove(editItem.Key);
                editItem = null;
                Load();
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 7
0
 private static void Load()
 {
     SaveSystem.Load();
     list  = null;
     items = SaveSystem.GetItems();
 }
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">The index number of ths slot that was clicked</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            base.ProcessClick(_menu, _slot, _mouseState);

            eventMenu = _menu;
            eventSlot = _slot;
            ClearAllEvents();

            if (saveListType == AC_SaveListType.Save)
            {
                if (autoHandle)
                {
                    EventManager.OnFinishSaving += OnCompleteSave;
                    EventManager.OnFailSaving   += OnFailSave;

                    if (newSaveSlot && _slot == (numSlots - 1))
                    {
                        SaveSystem.SaveNewGame();

                        if (KickStarter.settingsManager.orderSavesByUpdateTime)
                        {
                            offset = 0;
                        }
                        else
                        {
                            Shift(AC_ShiftInventory.ShiftNext, 1);
                        }
                    }
                    else
                    {
                        SaveSystem.SaveGame(_slot + offset, optionToShow, fixedOption);
                    }
                }
                else
                {
                    RunActionList(_slot);
                }
            }
            else if (saveListType == AC_SaveListType.Load)
            {
                if (autoHandle)
                {
                    EventManager.OnFinishLoading += OnCompleteLoad;
                    EventManager.OnFailLoading   += OnFailLoad;

                    SaveSystem.LoadGame(_slot + offset, optionToShow, fixedOption);
                }
                else
                {
                    RunActionList(_slot);
                }
            }
            else if (saveListType == AC_SaveListType.Import)
            {
                EventManager.OnFinishImporting += OnCompleteImport;
                EventManager.OnFailImporting   += OnFailImport;

                SaveSystem.ImportGame(_slot + offset, optionToShow, fixedOption);
            }
        }
Ejemplo n.º 9
0
 public void DeleteSaveFile()
 {
     SaveSystem.DeleteData();
 }
Ejemplo n.º 10
0
        public override string RecordData()
        {
            if (data == null)
            {
                data = new Data();
            }

            // Save position:
            var currentScene = SceneManager.GetActiveScene().buildIndex;
            var found        = false;

            for (int i = 0; i < data.positions.Count; i++)
            {
                if (data.positions[i].scene == currentScene)
                {
                    found = true;
                    data.positions[i].position = transform.position;
                    data.positions[i].rotation = transform.rotation;
                    break;
                }
            }
            if (!found)
            {
                data.positions.Add(new PositionData(currentScene, transform.position, transform.rotation));
            }

            // Save perspective:
            if (savePerspective)
            {
                var camera           = UnityEngineUtility.FindCamera(null);
                var cameraController = camera.GetComponent <Opsive.UltimateCharacterController.Camera.CameraController>();
                if (cameraController != null && cameraController.CanChangePerspectives)
                {
                    data.firstPerson = (cameraController.ActiveViewType.GetType().FullName == cameraController.FirstPersonViewTypeFullName);
                }
            }

            // Save attributes:
            if (saveAttributes)
            {
                data.attributes.Clear();
                var attributeManager = GetComponent <AttributeManager>();
                if (attributeManager == null)
                {
                    if (Debug.isDebugBuild)
                    {
                        Debug.LogWarning("UCC Saver can't save attributes. " + name + " doesn't have an Attribute Manager.", this);
                    }
                }
                else
                {
                    for (int i = 0; i < attributeManager.Attributes.Length; i++)
                    {
                        data.attributes.Add(attributeManager.Attributes[i].Value);
                    }
                }
            }

            // Save inventory:
            if (saveInventory)
            {
                data.items.Clear();
                var inventory = GetComponent <InventoryBase>();
                if (inventory == null)
                {
                    if (Debug.isDebugBuild)
                    {
                        Debug.LogWarning("UCC Saver can't save inventory. " + name + " doesn't have an Inventory component.", this);
                    }
                }
                else
                {
                    // Record equipped items:
                    var equipped = new ItemType[inventory.SlotCount];
                    for (int i = 0; i < inventory.SlotCount; i++)
                    {
                        var equippedItem = inventory.GetItem(i);
                        equipped[i] = (equippedItem != null) ? equippedItem.ItemType : null;
                    }

                    // Save items:
                    var items = inventory.GetAllItems();
                    for (int i = 0; i < items.Count; i++)
                    {
                        var item = items[i];
                        if (item == null || item.ItemType == null)
                        {
                            continue;
                        }
                        var itemCount = inventory.GetItemTypeCount(item.ItemType);
                        if (itemCount <= 0)
                        {
                            continue;
                        }
                        var isDuplicateItem = data.items.Find(x => x.itemID == item.ItemType.ID) != null;
                        var itemData        = new ItemData();
                        itemData.itemID   = item.ItemType.ID;
                        itemData.slot     = item.SlotID;
                        itemData.count    = 1;
                        itemData.equipped = item.ItemType == equipped[item.SlotID];
                        for (int j = 0; j < item.ItemActions.Length; j++)
                        {
                            var usableItem = item.ItemActions[j] as UsableItem;
                            if (usableItem == null)
                            {
                                continue;
                            }
                            var itemActionData = new ItemActionData();
                            itemData.itemActionData.Add(itemActionData);
                            itemActionData.id              = usableItem.ID;
                            itemActionData.count           = isDuplicateItem ? 0 : inventory.GetItemTypeCount(usableItem.GetConsumableItemType());
                            itemActionData.consumableCount = usableItem.GetConsumableItemTypeCount();
                        }
                        data.items.Add(itemData);
                    }
                }
            }

            if (debug)
            {
                Debug.Log(JsonUtility.ToJson(data, true));        // [DEBUG]
            }
            var s = SaveSystem.Serialize(data);

            if (debug)
            {
                Debug.Log("UCC Saver on " + name + " saving: " + s, this);
            }
            return(s);
        }
Ejemplo n.º 11
0
        public override void ApplyData(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return;
            }
            var newData = SaveSystem.Deserialize <Data>(s);

            if (newData == null)
            {
                if (Debug.isDebugBuild)
                {
                    Debug.LogWarning("UCC Saver on " + name + " received invalid data. Can't apply: " + s, this);
                }
                return;
            }
            data = newData;
            var character = GetComponent <UltimateCharacterLocomotion>();

            // Restore attributes:
            if (saveAttributes)
            {
                var attributeManager = GetComponent <AttributeManager>();
                if (attributeManager == null)
                {
                    if (Debug.isDebugBuild)
                    {
                        Debug.LogWarning("UCC Saver can't load attributes. " + name + " doesn't have an Attribute Manager.", this);
                    }
                }
                else
                {
                    if (debug)
                    {
                        Debug.Log("UCC Saver on " + name + " restoring attributes", this);
                    }
                    var count = Mathf.Min(attributeManager.Attributes.Length, data.attributes.Count);
                    for (int i = 0; i < count; i++)
                    {
                        attributeManager.Attributes[i].Value = data.attributes[i];
                    }
                }
            }

            // Restore inventory:
            if (saveInventory)
            {
                var inventory = GetComponent <InventoryBase>();
                if (inventory == null)
                {
                    if (Debug.isDebugBuild)
                    {
                        Debug.LogWarning("UCC Saver can't load inventory. " + name + " doesn't have an Inventory component.", this);
                    }
                }
                else
                {
                    // Clear inventory:
                    var items = inventory.GetAllItems();
                    for (int i = 0; i < items.Count; i++)
                    {
                        var item = items[i];
                        if (item != null && item.ItemType != null)
                        {
                            for (int j = 0; j < item.ItemActions.Length; j++)
                            {
                                var usableItem = item.ItemActions[j] as UsableItem;
                                if (usableItem != null)
                                {
                                    var consumableItemType = usableItem.GetConsumableItemType();
                                    if (consumableItemType != null)
                                    {
                                        var count = (int)inventory.GetItemTypeCount(consumableItemType);
                                        if (count > 0)
                                        {
                                            inventory.RemoveItem(consumableItemType, count, false);
                                        }
                                    }
                                }
                            }
                            inventory.RemoveItem(item.ItemType, item.SlotID, false);
                        }
                    }

                    var itemCollection = UCCUtility.FindItemCollection(character.gameObject);
                    if (itemCollection == null)
                    {
                        Debug.LogError("Error: Unable to find ItemCollection.");
                        return;
                    }

                    // Add saved items: (restore equipped items last so they end up equipped)
                    HashSet <ItemType> alreadyAddedItemTypes = new HashSet <ItemType>();
                    RestoreItems(false, itemCollection, inventory, alreadyAddedItemTypes);
                    RestoreItems(true, itemCollection, inventory, alreadyAddedItemTypes);
                }
            }

            // Restore position:
            if (savePosition)
            {
                if (CompareTag("Player") && SaveSystem.playerSpawnpoint != null)
                {
                    if (debug)
                    {
                        Debug.Log("UCC Saver on " + name + " moving character to spawnpoint " + SaveSystem.playerSpawnpoint, this);
                    }
                    character.SetPositionAndRotation(SaveSystem.playerSpawnpoint.transform.position, SaveSystem.playerSpawnpoint.transform.rotation);
                }
                else
                {
                    var currentScene = SceneManager.GetActiveScene().buildIndex;
                    for (int i = 0; i < data.positions.Count; i++)
                    {
                        if (data.positions[i].scene == currentScene)
                        {
                            if (debug)
                            {
                                Debug.Log("UCC Saver on " + name + " (tag=" + tag + ") restoring saved position " + data.positions[i].position, this);
                            }
                            character.SetPositionAndRotation(data.positions[i].position, data.positions[i].rotation);
                            break;
                        }
                    }
                }
            }

            // Restore perspective:
            if (savePerspective)
            {
                var camera           = UnityEngineUtility.FindCamera(null);
                var cameraController = camera.GetComponent <Opsive.UltimateCharacterController.Camera.CameraController>();
                if (cameraController != null && cameraController.CanChangePerspectives)
                {
                    cameraController.SetPerspective(data.firstPerson, true);
                }
            }

            // Hide cursor: (In editor, UnityInput makes cursor visible when paused during scene transition.)
            var unityInput = GetComponent <UnityInput>();

            if (unityInput != null)
            {
                unityInput.DisableCursor = true;
            }
        }
Ejemplo n.º 12
0
 //It saves the information with the SaveSystem
 void EnterConfigInfo()
 {
     SaveSystem.Save(username.text, AuthToken.text, channelName.text);
 }
Ejemplo n.º 13
0
 public void SetSFXVolume(float sliderValue)
 {
     _audioMixer.SetFloat("SFXVolume", Mathf.Log10(sliderValue) * 20);
     SaveSystem.SaveSetting("SFXVolume", sliderValue);
 }
Ejemplo n.º 14
0
        /**
         * <summary>Recalculates the element's size.
         * This should be called whenever a Menu's shape is changed.</summary>
         * <param name = "source">How the parent Menu is displayed (AdventureCreator, UnityUiPrefab, UnityUiInScene)</param>
         */
        public override void RecalculateSize(MenuSource source)
        {
            newSaveSlot = false;
            if (Application.isPlaying)
            {
                if (saveListType == AC_SaveListType.Import)
                {
                    if (checkImportBool)
                    {
                        KickStarter.saveSystem.GatherImportFiles(importProductName, importSaveFilename, checkImportVar);
                    }
                    else
                    {
                        KickStarter.saveSystem.GatherImportFiles(importProductName, importSaveFilename, -1);
                    }
                }

                if (fixedOption)
                {
                    numSlots = 1;

                    if (saveListType == AC_SaveListType.Save)
                    {
                        newSaveSlot = !SaveSystem.DoesSaveExist(optionToShow);
                    }
                }
                else
                {
                    if (saveListType == AC_SaveListType.Import)
                    {
                        numSlots = SaveSystem.GetNumImportSlots();
                    }
                    else
                    {
                        numSlots = SaveSystem.GetNumSlots();

                        if (saveListType == AC_SaveListType.Save && numSlots < KickStarter.settingsManager.maxSaves && showNewSaveOption)
                        {
                            newSaveSlot = true;
                            numSlots++;
                        }
                    }

                    if (numSlots > maxSlots)
                    {
                        numSlots = maxSlots;
                    }

                    offset = Mathf.Min(offset, GetMaxOffset());
                }
            }

            if (Application.isPlaying || labels == null || labels.Length != numSlots)
            {
                labels = new string [numSlots];
            }

            if (Application.isPlaying && uiSlots != null)
            {
                ClearSpriteCache(uiSlots);
            }

            if (!isVisible)
            {
                LimitUISlotVisibility(uiSlots, 0, uiHideStyle);
            }

            base.RecalculateSize(source);
        }
Ejemplo n.º 15
0
 void Awake()
 {
     //Get State
     currentState = PlayerEnum.GAME;
     saveManager = GameObject.Find("GameManager").GetComponent<SaveSystem>();
     playerObj = GameObject.FindWithTag("Player");
 }
Ejemplo n.º 16
0
 //private PlayerPrefs save;
 void Awake()
 {
     playerStates = GameObject.FindWithTag("Player").GetComponent<PlayerStates>();
     saveManager = GameObject.Find ("GameManager").GetComponent<SaveSystem>();
 }
Ejemplo n.º 17
0
    public void LoadPlayerStep2()
    {
        PlayerData data = SaveSystem.LoadPlayer();

        currentCoins = data.coins;
    }
Ejemplo n.º 18
0
 public void SaveLifeShop()
 {
     SaveSystem.SaveLifeShop(this);
 }
Ejemplo n.º 19
0
 public void SavePlayer()
 {
     SaveSystem.SavePlayer(this);
 }
Ejemplo n.º 20
0
 private static void Save()
 {
     SaveSystem.Save();
 }
Ejemplo n.º 21
0
 public void SaveItem()
 {
     SaveSystem.SaveItems(this);
 }
Ejemplo n.º 22
0
        override public float Run()
        {
            if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad)
            {
                KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad);
            }

            string newSaveLabel = "";

            if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame))
            {
                if (selectSaveType != SelectSaveType.Autosave)
                {
                    GVar gVar = GlobalVariables.GetVariable(varID);
                    if (gVar != null)
                    {
                        //newSaveLabel = gVar.textVal;
                        newSaveLabel = gVar.GetValue(Options.GetLanguage());
                    }
                    else
                    {
                        ACDebug.LogWarning("Could not " + saveHandling.ToString() + " - no variable found.");
                        return(0f);
                    }
                }
            }

            int i = Mathf.Max(0, saveIndex);

            if (saveHandling == SaveHandling.ContinueFromLastSave)
            {
                SaveSystem.ContinueGame();
                return(0f);
            }

            if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave)
            {
                if (selectSaveType == SelectSaveType.Autosave)
                {
                    if (saveHandling == SaveHandling.LoadGame)
                    {
                        SaveSystem.LoadAutoSave();
                        return(0f);
                    }
                    else
                    {
                        if (!PlayerMenus.IsSavingLocked(this))
                        {
                            SaveSystem.SaveAutoSave();
                        }
                        else
                        {
                            ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Converation is active, or saving has been manually locked.");
                        }
                        return(0f);
                    }
                }
                else if (selectSaveType == SelectSaveType.SlotIndexFromVariable)
                {
                    GVar gVar = GlobalVariables.GetVariable(slotVarID);
                    if (gVar != null)
                    {
                        i = gVar.val;
                    }
                    else
                    {
                        ACDebug.LogWarning("Could not get save slot index - no variable found.");
                        return(0f);
                    }
                }
            }

            if (menuName != "" && elementName != "")
            {
                MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                if (menuElement != null && menuElement is MenuSavesList)
                {
                    MenuSavesList menuSavesList = (MenuSavesList)menuElement;
                    i += menuSavesList.GetOffset();
                }
                else
                {
                    ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                }
            }
            else
            {
                ACDebug.LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString());
            }

            if (saveHandling == SaveHandling.LoadGame)
            {
                SaveSystem.LoadGame(i, -1, false);
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                if (!PlayerMenus.IsSavingLocked(this))
                {
                    if (saveHandling == SaveHandling.OverwriteExistingSave)
                    {
                        SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel);
                    }
                    else if (saveHandling == SaveHandling.SaveNewGame)
                    {
                        SaveSystem.SaveNewGame(updateLabel, newSaveLabel);
                    }
                }
                else
                {
                    ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Converation is active, or saving has been manually locked.");
                }
            }
            return(0f);
        }
Ejemplo n.º 23
0
 // Start is called before the first frame update
 void Start()
 {
     playerData = SaveSystem.LoadPlayer();
     Debug.Log("Load player data: " + playerData.lastUpdateTime);
 }
Ejemplo n.º 24
0
 void SaveGame()
 {
     SaveSystem.save(this);
 }
Ejemplo n.º 25
0
 private void OnDestroy()
 {
     Debug.Log("Save player data");
     this.playerData.lastUpdateTime = System.DateTime.UtcNow;
     SaveSystem.SavePlayer(this.playerData);
 }
    public void purchaseArmour(int armourNum)
    {
        //get how much gold they have
        if (PlayerPrefs.GetInt("doubloons") == 0)
        {
            PlayerPrefs.SetInt("doubloons", 0);
            PlayerPrefs.Save();
            numberOfDoubloons = (PlayerPrefs.GetInt("doubloons"));
        }
        else
        {
            numberOfDoubloons = PlayerPrefs.GetInt("doubloons");
        }

        //variable to represent cost of armour
        int cost;

        switch (armourNum)
        {
        case 14:
            cost = 10000;
            break;

        case 13:
            cost = 8000;
            break;

        case 12:
            cost = 6000;
            break;

        case 11:
            cost = 5000;
            break;

        case 10:
            cost = 4000;
            break;

        case 9:
            cost = 3000;
            break;

        case 8:
            cost = 2000;
            break;

        case 7:
            cost = 1000;
            break;

        case 6:
            cost = 900;
            break;

        case 5:
            cost = 750;
            break;

        case 4:
            cost = 600;
            break;

        case 3:
            cost = 500;
            break;

        case 2:
            cost = 350;
            break;

        case 1:
            cost = 200;
            break;

        case 0:
            cost = 100;
            break;

        default:
            cost = -1;
            break;
        }

        alertBox.SetActive(false);

        if (cost < 0)
        {
            Debug.Log("armourNum not valid");
        }
        else if (numberOfDoubloons < cost)
        {
            StartCoroutine(InsufficientFundAlert());
        }
        else
        {
            //remove alert box saying not enough gold
            alertBox.SetActive(false);

            //decrease gold by how much armour cost
            numberOfDoubloons -= cost;
            PlayerPrefs.SetInt("doubloons", numberOfDoubloons);
            PlayerPrefs.Save();

            //add armour to their collection
            Armour armour = new Armour(armourNum, 100);
            armourList.playerArmour.Add(armour);
            SaveSystem.saveArmour(armourList);

            //Update text box for new amount of doubloons
            doubloonsTextBox.text = "Doubloons: " + numberOfDoubloons;
        }
    }
Ejemplo n.º 27
0
 public void SaveOptions()
 {
     SaveSystem.SaveOptions_Controll(MSXSlider.value, MSYSlider.value, ControllerSXSlider.value, ControllerSYSlider.value, inputType.ToString(), useAutoSave.isOn);
 }
Ejemplo n.º 28
0
    public void OpenScreen()
    {
        if (SaveSystem.GetVehicles().Count > 1)
        {
            SellPrice.text = $"Sell {SaveSystem.GetVehicles()[ids].Type} ($ {CalculatePrice(SaveSystem.GetVehicles()[ids])})";

            SellConfirmation.SetActive(true);
        }
    }
 private void Awake()
 {
     basic     = SaveSystem.LoadFile(fileIndex);
     Previewer = GetComponentInParent <UI_FilePreviewer>();
 }
Ejemplo n.º 30
0
 private void SaveInventory()
 {
     SaveSystem.SaveInventoryData(this);
 }
Ejemplo n.º 31
0
 // Start is called before the first frame update
 void Start()
 {
     saveSystem = GameObject.FindGameObjectWithTag("SaveSystem")?.GetComponent <SaveSystem>();
 }
Ejemplo n.º 32
0
 void Awake()
 {
     if (!Instance) {
         Instance = this;
         DontDestroyOnLoad(this);
     }
     else {
         Destroy(this);
     }
 }
Ejemplo n.º 33
0
 public void OnClickSaveLevel()
 {
     SaveSystem.SaveLevel(level);
 }
Ejemplo n.º 34
0
    public void LoadGame()
    {
        PlayerData data = SaveSystem.LoadPlayer();

        SceneManager.LoadScene(data.level);
    }
Ejemplo n.º 35
0
 // Use this for initialization
 void Start()
 {
     inHubWorld = IsInHubWorld();
     if (saveSystem == null)
     {
         saveSystem = this;
     }
     else if (saveSystem != this)
     {
         searchForPaintings = true;
         Destroy(gameObject);
     }
     realDali = daliObject;
     realEscher = escherObject;
     DontDestroyOnLoad(gameObject);
     if (realDali != null && readyToSave && daliPhases != null)
     {
         Debug.Log("Loading objects in dali level");
         realDali.GetComponent<DaliPhases>().LoadPhases(daliPhases, currentSave);
         readyToSave = false;
     }
     else if (realEscher != null && readyToSave && escherPhases != null)
     {
         Debug.Log("Loading objects in dali level");
         realEscher.GetComponent<EscherPhases>().LoadPhases(escherPhases, currentSave);
         readyToSave = false;
     }
 }