Пример #1
0
        public bool Save(int slot_no)
        {
            if (Comm_UserDatas.Instance.User_basic.Starttime == 0)
            {
                return(false);
            }
            SaveHeaderFmt saveHeaderFmt = new SaveHeaderFmt();

            saveHeaderFmt.SetPropertie();
            List <SaveTarget> saveTarget = this.getSaveTarget(saveHeaderFmt);

            byte[] array = null;
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream))
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement(this.getTableName(slot_no));
                    using (List <SaveTarget> .Enumerator enumerator = saveTarget.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            SaveTarget             current = enumerator.get_Current();
                            DataContractSerializer dataContractSerializer;
                            if (current.IsCollection)
                            {
                                dataContractSerializer = new DataContractSerializer(current.ClassType, current.TableName + "s", string.Empty);
                            }
                            else
                            {
                                dataContractSerializer = new DataContractSerializer(current.ClassType);
                            }
                            dataContractSerializer.WriteObject(xmlWriter, current.Data);
                            xmlWriter.Flush();
                        }
                    }
                    xmlWriter.WriteEndElement();
                    xmlWriter.Flush();
                    array = memoryStream.ToArray();
                }
            }
            File.WriteAllBytes(this.getMemberFilePath(slot_no), array);
            this.cacheHeader.set_Item(slot_no, saveHeaderFmt);
            return(true);
        }
        public bool Save()
        {
            if (this.operatorInstance == null || Comm_UserDatas.Instance.User_basic.Starttime == 0)
            {
                return(false);
            }
            if (SaveLoad.get_IsDialogOpen() || this.IsBusy)
            {
                return(false);
            }
            SaveHeaderFmt saveHeaderFmt = new SaveHeaderFmt();

            saveHeaderFmt.SetPropertie();
            List <SaveTarget> saveTarget = this.getSaveTarget(saveHeaderFmt);

            byte[] array = null;
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream))
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement(this.getTableName());
                    using (List <SaveTarget> .Enumerator enumerator = saveTarget.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            SaveTarget             current = enumerator.get_Current();
                            DataContractSerializer dataContractSerializer;
                            if (current.IsCollection)
                            {
                                dataContractSerializer = new DataContractSerializer(current.ClassType, current.TableName + "s", string.Empty);
                            }
                            else
                            {
                                dataContractSerializer = new DataContractSerializer(current.ClassType);
                            }
                            dataContractSerializer.WriteObject(xmlWriter, current.Data);
                        }
                    }
                    xmlWriter.WriteEndElement();
                    xmlWriter.Flush();
                    array = memoryStream.ToArray();
                }
            }
            SaveLoad.SavedGameSlotParams savedGameSlotParams = default(SaveLoad.SavedGameSlotParams);
            TurnString turnString = Comm_UserDatas.Instance.User_turn.GetTurnString();
            string     text       = (Comm_UserDatas.Instance.User_plus.GetLapNum() <= 0) ? string.Empty : "★";
            string     subTitle   = string.Format("{0}{1}の年 {2} {3}日", new object[]
            {
                text,
                turnString.Year,
                turnString.Month,
                turnString.Day
            });
            string nickname = Comm_UserDatas.Instance.User_basic.Nickname;
            string datail   = this.getDatail();

            savedGameSlotParams.title    = nickname;
            savedGameSlotParams.subTitle = subTitle;
            savedGameSlotParams.detail   = datail;
            savedGameSlotParams.iconPath = Application.get_streamingAssetsPath() + "/SaveIcon.png";
            SaveLoad.ControlFlags controlFlags = 0;
            ErrorCode             errorCode    = SaveLoad.SaveGameList(array, savedGameSlotParams, controlFlags);

            return(errorCode == null);
        }