示例#1
0
    public static void SaveUfoData(UfoControl ufoControl)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Path.Combine(Application.persistentDataPath, "ufo.fun");
        FileStream      stream    = new FileStream(path, FileMode.Create);

        UfoData ufoData = new UfoData(ufoControl);

        formatter.Serialize(stream, ufoData);
        stream.Close();
    }
    private void LoadUfoData()
    {
        UfoData ufoData = SaveSystem.LoadUfoData();

        if (ufoData != null)
        {
            ufoSpeed       = ufoData.ufoSpeed;
            ufoDurability  = ufoData.ufoDurability;
            durEffectValue = ufoData.durEffectValue;
        }
    }
示例#3
0
    public static UfoData LoadUfoData()
    {
        string path = Path.Combine(Application.persistentDataPath, "ufo.fun");

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            UfoData ufoData = formatter.Deserialize(stream) as UfoData;
            stream.Close();
            return(ufoData);
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return(null);
        }
    }
示例#4
0
    private void OnEnable()
    {
        if (device == null)
        {
            device = GetComponent <EnergyDevice>();
        }
        if (ud == null)
        {
            ud = GetComponent <UfoData>();
        }
        if (hazardManager == null)
        {
            hazardManager = FindObjectOfType <DeviceHazardManager>();
        }
        rigid = GetComponent <Rigidbody>();

        device.forceDeactive = true;

        interactable = GetComponent <VRTK_InteractableObject>();
        interactable.InteractableObjectGrabbed   += OnGrabbed;
        interactable.InteractableObjectUngrabbed += OnUnGrabbed;
    }