コード例 #1
0
ファイル: STransform.cs プロジェクト: flofe104/SpackJerrow
 protected override void saveComponent(Transform component, PersistentGameDataController.SaveType saveType)
 {
     localPosition = new Serializable3DVector(component.localPosition);
     position      = new Serializable3DVector(component.position);
     rotation      = new Serializable3DVector(component.eulerAngles);
     scale         = new Serializable3DVector(component.localScale);
 }
コード例 #2
0
 public override IRestorableComponent saveComponent(GameObject gameObject,
                                                    IComponentAssigner assigner, PersistentGameDataController.SaveType saveType)
 {
     setSaveData(saveType);
     AutomatedScriptTransfer.transferScriptsSaving(this, savedDictionary, saveType);
     return(CreatedSaveableMonoBehaviour);
 }
コード例 #3
0
 protected override void setDataBeforeSaving(PersistentGameDataController.SaveType saveType)
 {
     if (targetPos != null)
     {
         target = new Serializable3DVector(targetPos.position);
     }
 }
コード例 #4
0
 protected override void setDataBeforeSaving(PersistentGameDataController.SaveType saveType)
 {
     if (leaveBoatPosition != null)
     {
         leaveBoatPos = new Serializable3DVector(leaveBoatPosition.position);
     }
     base.setDataBeforeSaving(saveType);
 }
コード例 #5
0
 public override IRestorableComponent saveComponent(GameObject gameObject,
                                                    IComponentAssigner assigner, PersistentGameDataController.SaveType saveType)
 {
     saveComponentValues(gameObject, assigner, saveType);
     AutomatedScriptTransfer.transferComponentSaving
         (this, CreatedSaveableComponent.DataContainer);
     return(CreatedSaveableComponent);
 }
コード例 #6
0
    /// <summary>
    /// saves all script values by calling the "saveComponent" method for all saveableComponents.
    /// Also calls this method rekursivly for its children
    /// </summary>
    /// <param name="saveState"></param>
    public void saveAllBehaviours(PersistentGameDataController.SaveType saveState)
    {
        foreach (ISaveableComponent b in saveableComponents)
        {
            b.saveComponent(gameObject, this, saveState);
        }

        foreach (ISaveableGameObject children in childrenWithPath.getValues())
        {
            children.saveAllBehaviours(saveState);
        }
        ResetAssigner();
    }
コード例 #7
0
 public abstract IRestorableComponent saveComponent(GameObject gameObject,
                                                    IComponentAssigner assigner, PersistentGameDataController.SaveType saveType);
コード例 #8
0
 protected override void saveComponent(CapsuleCollider component, PersistentGameDataController.SaveType saveType)
 {
     base.saveComponent(component, saveType);
 }
コード例 #9
0
 public abstract void setSaveData(PersistentGameDataController.SaveType saveType);
コード例 #10
0
 /// <summary>
 /// calls "saveScene" for the current scene
 /// </summary>
 /// <param name="saveType"></param>
 public void saveCurrentScene(PersistentGameDataController.SaveType saveType)
 {
     currentScene.saveScene(saveType);
 }
コード例 #11
0
 protected override void saveComponent(CannonShooter component, PersistentGameDataController.SaveType saveType)
 {
     b = component.boat;
 }
コード例 #12
0
 public override void saveComponentValues(GameObject gameObject,
                                          IComponentAssigner assigner, PersistentGameDataController.SaveType saveType)
 {
     Component = assigner.getComponent <T>();
     saveComponent(Component, saveType);
 }
コード例 #13
0
 protected override void saveComponent(MeshRenderer component, PersistentGameDataController.SaveType saveType)
 {
     isEnabled = component.enabled;
 }
コード例 #14
0
 public sealed override void setSaveData(PersistentGameDataController.SaveType saveType)
 {
     IsEnabled = enabled;
     setDataBeforeSaving(saveType);
 }
コード例 #15
0
 protected virtual void setDataBeforeSaving(PersistentGameDataController.SaveType saveType)
 {
 }
コード例 #16
0
 protected override void saveComponent(BoxCollider component, PersistentGameDataController.SaveType saveType)
 {
     base.saveComponent(component, saveType);
     center = new Serializable3DVector(component.center);
     size   = new Serializable3DVector(component.size);
 }
コード例 #17
0
ファイル: Palm.cs プロジェクト: flofe104/SpackJerrow
 protected override void setDataBeforeSaving(PersistentGameDataController.SaveType saveType)
 {
     palmHeigth = GetPalmHeight();
 }
コード例 #18
0
    public static void transferScriptsSaving(object source, Dictionary <string, object> target, PersistentGameDataController.SaveType transferState)
    {
        Type sourceType = source.GetType();

        Type savedAttribute = typeof(SaveAttribute);

        foreach (FieldInfo f in getFieldsFromType(sourceType, typeof(SaveableMonoBehaviour)))
        {
            if (f.IsDefined(savedAttribute, true))
            {
                SaveAttribute currentSaveAttribute = (SaveAttribute)
                                                     (f.GetCustomAttributes(savedAttribute, false)[0]);

                if ((transferState == PersistentGameDataController.SaveType.Game && currentSaveAttribute.saveForScene) ||
                    (transferState == PersistentGameDataController.SaveType.Scene && currentSaveAttribute.saveForGame))
                {
                    object value = getValue(f.GetValue(source));
                    target.Add(f.Name, value);
                }
            }
        }
    }
コード例 #19
0
ファイル: SRigidBody.cs プロジェクト: flofe104/HouseGenerator
 protected override void saveComponent(Rigidbody component, PersistentGameDataController.SaveType saveType)
 {
     isKinematic = component.isKinematic;
     vel         = new Serializable3DVector(component.velocity);
     angVel      = new Serializable3DVector(component.angularVelocity);
 }
コード例 #20
0
 protected abstract void saveComponent(T component, PersistentGameDataController.SaveType saveType);
コード例 #21
0
    /// <summary>
    /// will iterate the list of registered inGameISaveableGameObject and have them create a
    /// SaveableObject which are saved within this list or referenced by other SaveableObjects.
    /// However this function just stores the data temporary and does not write it into the scene file!
    /// "DirtyData" is set to true, so this scene will be saved to fíle upon next game save.
    /// </summary>
    /// <param name="saveState"></param>
    /// <param name="ignoreForSave">hand any gameobject over that shall not be saved.
    /// instead their theirs trees of restoreableGameobejcts are returned
    /// usefull to take gameobject to the next scene</param>
    /// <returns>this functions returns the unsaved objects, since its very
    /// likely that they shall be transfered to another scene</returns>
    public List <IRestorableGameObject> saveScene(PersistentGameDataController.SaveType saveState,
                                                  List <ISaveableGameObject> ignoreForSave)
    {
        List <IRestorableGameObject> result = new List <IRestorableGameObject>();

        ///clear current list, and fill it with current objects
        RestoreableObjectTree.clear();

        HirachyTree <ISaveableGameObject> saveableObjectTree = new HirachyTree <ISaveableGameObject>();

        Stack <int> currentHirachy;

        ///reset the hirachy tree before saving again
        foreach (ISaveableGameObject gameObject in AllInGameObjects)
        {
            gameObject.ResetChildNodes();
        }

        ///set parent and children of all objects
        ///also adds all objects with no saveable parent to root list
        foreach (ISaveableGameObject gameObject in AllInGameObjects)
        {
            ///if the objects should not be saved in the current scene they
            ///are just ignored for now. since the objects dont use this tree to find
            ///their parent, the hirachy of the non saved objects are not lost
            if (!ignoreForSave.Contains(gameObject))
            {
                if (!gameObject.findAndSetParent(out currentHirachy))
                {
                    saveableObjectTree.add(gameObject, currentHirachy);
                }
            }
        }

        ///all the gameObjects with no saveableParent are returning their saveable object,
        ///which are added to the list. childrens are recursivly added aswell
        foreach (ITreeNode <ISaveableGameObject> gameObject in saveableObjectTree.getAllNodesWithValues())
        {
            RestoreableObjectTree.add
                (gameObject.Value.saveObjectAndPrepareScripts(), gameObject.getFullTreePath());
        }

        ///even though the object is not saved in this scene the restoreable objects are
        ///still created and returned as result so they can be used in other scenes
        foreach (ISaveableGameObject gameObject in ignoreForSave)
        {
            result.Add(gameObject.saveObjectAndPrepareScripts());
        }

        IList <ISaveableGameObject> savedObjects = saveableObjectTree.getValues();

        ///after all object with their scripts were initiated the scripts values are saved
        foreach (ISaveableGameObject gameObject in savedObjects)
        {
            gameObject.saveAllBehaviours(saveState);
        }

        ///all not saved objects are saved aswell. however their restoreable references
        ///will not be associated with the current scene. Instead they are returned
        ///so they can be used in other scenes
        foreach (ISaveableGameObject gameObject in ignoreForSave)
        {
            gameObject.saveAllBehaviours(saveState);
        }

        ///deleting all children for next save
        saveableObjectTree.clear();

        ///since the scene is saved, it needs to be stored to file on the
        ///next game save
        DirtyData = true;

        return(result);
    }
コード例 #22
0
 protected override void saveComponent(T component, PersistentGameDataController.SaveType saveType)
 {
     isTrigger = component.isTrigger;
     isEnabled = component.enabled;
 }
コード例 #23
0
    /// <summary>
    /// will iterate the list of registered inGameISaveableGameObject and have them create a
    /// SaveableObject which are saved within this list or referenced by other SaveableObjects.
    /// However this function just stores the data temporary and does not write it into the scene file!
    /// "DirtyData" is set to true, so this scene will be saved to fíle upon next game save.
    /// </summary>
    /// <param name="saveState"></param>
    public void saveScene(PersistentGameDataController.SaveType saveState)
    {
        List <ISaveableGameObject> empty = new List <ISaveableGameObject>();

        saveScene(saveState, empty);
    }
コード例 #24
0
 /// <summary>
 /// calls "saveScene" for the current scene
 /// </summary>
 /// <param name="saveType"></param>
 public List <IRestorableGameObject> saveCurrentScene(
     PersistentGameDataController.SaveType saveType, List <ISaveableGameObject> ignoreForSave)
 {
     return(currentScene.saveScene(saveType, ignoreForSave));
 }
コード例 #25
0
 public abstract void saveComponentValues(GameObject gameObject, IComponentAssigner assigner, PersistentGameDataController.SaveType saveType);