コード例 #1
0
 public string GetSaveData()
 {
     if (parameterType == ParameterType.Float)
     {
         return(floatValue.ToString());
     }
     else if (parameterType == ParameterType.String)
     {
         return(AdvGame.PrepareStringForSaving(stringValue));
     }
     else if (parameterType == ParameterType.GameObject)
     {
         if (gameObject != null)
         {
             if (gameObject.GetComponent <ConstantID>())
             {
                 return(gameObject.GetComponent <ConstantID>().constantID.ToString());
             }
             ACDebug.LogWarning("Could not save parameter data for '" + gameObject.name + "' as it has no Constant ID number.", gameObject);
         }
     }
     else if (parameterType == ParameterType.UnityObject)
     {
         if (objectValue != null)
         {
             return(objectValue.name);
         }
     }
     else
     {
         return(intValue.ToString());
     }
     return("");
 }
コード例 #2
0
ファイル: ConstantID.cs プロジェクト: ManuelAGC/StarEater
        protected string ArrayToString <T> (T[] _list)
        {
            System.Text.StringBuilder _string = new System.Text.StringBuilder();

            foreach (T state in _list)
            {
                string stateString = AdvGame.PrepareStringForSaving(state.ToString());
                _string.Append(stateString + SaveSystem.pipe);
            }
            if (_string.Length > 0)
            {
                _string.Remove(_string.Length - 1, 1);
            }
            return(_string.ToString());
        }
コード例 #3
0
        /**
         * <summary>Converts the class's data into a string that can be saved.</summary>
         * <returns>The class's data, converted to a string</returns>
         */
        public string GetSaveData()
        {
            string ID     = "";
            string convID = "";

            if (isRunning)
            {
                // Unless ActionLists can be saved mid-stream, don't save info about those currently-running
                return("");
            }

            string parameterData = "";

            if (actionListAsset != null)
            {
                ID = AdvGame.PrepareStringForSaving(actionListAsset.name);
            }
            else if (actionList != null)
            {
                if (actionList.GetComponent <ConstantID>())
                {
                    ID = actionList.GetComponent <ConstantID>().constantID.ToString();
                }
                else
                {
                    ACDebug.LogWarning("Data for the ActionList '" + actionList.gameObject.name + "' was not saved because it has no Constant ID.", actionList.gameObject);
                    return("");
                }
            }

            if (actionList != null)
            {
                parameterData = actionList.GetParameterData();
            }

            if (conversationOnEnd != null && conversationOnEnd.GetComponent <ConstantID>())
            {
                convID = conversationOnEnd.GetComponent <ConstantID>().ToString();
            }

            return(ID + SaveSystem.colon +
                   ConvertIndicesToString() + SaveSystem.colon +
                   startIndex + SaveSystem.colon +
                   ((inSkipQueue) ? 1 : 0) + SaveSystem.colon +
                   ((isRunning) ? 1 : 0) + SaveSystem.colon +
                   convID + SaveSystem.colon +
                   parameterData);
        }
コード例 #4
0
        /**
         * <summary>Generates a string that represents the parameter's saveable data</summar>
         * <returns>The data string</returns>
         */
        public string GetSaveData()
        {
            switch (parameterType)
            {
            case ParameterType.Float:
                return(floatValue.ToString());

            case ParameterType.String:
                return(AdvGame.PrepareStringForSaving(stringValue));

            case ParameterType.GameObject:
                if (gameObject != null)
                {
                    ConstantID _constantID = gameObject.GetComponent <ConstantID>();
                    if (_constantID)
                    {
                        return(_constantID.constantID.ToString());
                    }
                    ACDebug.LogWarning("Could not save parameter data for '" + gameObject.name + "' as it has no Constant ID number.", gameObject);
                }
                return(string.Empty);

            case ParameterType.UnityObject:
                if (objectValue != null)
                {
                    return(objectValue.name);
                }
                return(string.Empty);

            case ParameterType.Vector3:
                string vector3Val = vector3Value.x.ToString() + "," + vector3Value.y.ToString() + "," + vector3Value.z.ToString();
                vector3Val = AdvGame.PrepareStringForSaving(vector3Val);
                return(vector3Val);

            default:
                return(intValue.ToString());
            }
        }
コード例 #5
0
        /**
         * <summary>Converts the class's data into a string that can be saved.</summary>
         * <param name = "subScene">If set, only data for a given subscene will be saved. If null, only data for the active scene will be saved</param>
         * <returns>The class's data, converted to a string</returns>
         */
        public string GetSaveData(SubScene subScene)
        {
            string ID     = string.Empty;
            string convID = string.Empty;

            if (IsRunning())
            {
                // Unless ActionLists can be saved mid-stream, don't save info about those currently-running
                return(string.Empty);
            }

            string parameterData = string.Empty;

            if (actionListAsset != null)
            {
                ID = AdvGame.PrepareStringForSaving(actionListAsset.name);
            }
            else if (actionList != null)
            {
                if (actionList.GetComponent <ConstantID>())
                {
                    ID = actionList.GetComponent <ConstantID>().constantID.ToString();

                    if (subScene == null && UnityVersionHandler.ObjectIsInActiveScene(actionList.gameObject))
                    {
                        // OK
                    }
                    else if (subScene && UnityVersionHandler.GetSceneIndexFromGameObject(actionList.gameObject) == subScene.SceneIndex)
                    {
                        // OK
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                {
                    ACDebug.LogWarning("Data for the ActionList '" + actionList.gameObject.name + "' was not saved because it has no Constant ID.", actionList.gameObject);
                    return("");
                }
            }

            if (actionList != null)
            {
                parameterData = actionList.GetParameterData();
            }

            if (conversationOnEnd && conversationOnEnd.GetComponent <ConstantID>())
            {
                convID = conversationOnEnd.GetComponent <ConstantID>().ToString();
            }

            return(ID + SaveSystem.colon +
                   ConvertIndicesToString() + SaveSystem.colon +
                   startIndex + SaveSystem.colon +
                   ((inSkipQueue) ? 1 : 0) + SaveSystem.colon +
                   ((isRunning) ? 1 : 0) + SaveSystem.colon +
                   convID + SaveSystem.colon +
                   parameterData);
        }
コード例 #6
0
ファイル: SaveFile.cs プロジェクト: cvkumar/out-of-body
 /**
  * <summary>Gets the save file's label.  Pipes and colons are converted back so that they can be read as expected.</summary>
  * <returns>The file's label</returns>
  */
 public string GetSafeLabel()
 {
     return(AdvGame.PrepareStringForSaving(label));
 }
コード例 #7
0
 /**
  * <summary>Converts the replacementText into a temporary one that has no colon or pipe characters, so that it is safe for saving.</summary>
  * <returns>The converted replacementText that is safe for saving.</returns>
  */
 public string GetSafeReplacementText()
 {
     return(AdvGame.PrepareStringForSaving(replacementText));
 }