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 = getSaveTarget(saveHeaderFmt);

            byte[] bytes = null;
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream))
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement(getTableName(slot_no));
                    foreach (SaveTarget item in saveTarget)
                    {
                        DataContractSerializer dataContractSerializer = (!item.IsCollection) ? new DataContractSerializer(item.ClassType) : new DataContractSerializer(item.ClassType, item.TableName + "s", string.Empty);
                        dataContractSerializer.WriteObject(xmlWriter, item.Data);
                        xmlWriter.Flush();
                    }
                    xmlWriter.WriteEndElement();
                    xmlWriter.Flush();
                    bytes = memoryStream.ToArray();
                }
            }
            File.WriteAllBytes(getMemberFilePath(slot_no), bytes);
            cacheHeader[slot_no] = saveHeaderFmt;
            return(true);
        }
Beispiel #2
0
        public bool Save()
        {
            if (operatorInstance == null || Comm_UserDatas.Instance.User_basic.Starttime == 0)
            {
                return(false);
            }
            if (SaveLoad.IsDialogOpen || IsBusy)
            {
                return(false);
            }
            SaveHeaderFmt saveHeaderFmt = new SaveHeaderFmt();

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

            byte[] data = null;
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream))
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement(getTableName());
                    foreach (SaveTarget item in saveTarget)
                    {
                        DataContractSerializer dataContractSerializer = (!item.IsCollection) ? new DataContractSerializer(item.ClassType) : new DataContractSerializer(item.ClassType, item.TableName + "s", string.Empty);
                        dataContractSerializer.WriteObject(xmlWriter, item.Data);
                    }
                    xmlWriter.WriteEndElement();
                    xmlWriter.Flush();
                    data = memoryStream.ToArray();
                }
            }
            SaveLoad.SavedGameSlotParams slotParams = default(SaveLoad.SavedGameSlotParams);
            TurnString turnString = Comm_UserDatas.Instance.User_turn.GetTurnString();
            string     text       = (Comm_UserDatas.Instance.User_plus.GetLapNum() <= 0) ? string.Empty : "★";
            string     subTitle   = $"{text}{turnString.Year}の年 {turnString.Month} {turnString.Day}日";
            string     nickname   = Comm_UserDatas.Instance.User_basic.Nickname;
            string     datail     = getDatail();

            slotParams.title    = nickname;
            slotParams.subTitle = subTitle;
            slotParams.detail   = datail;
            slotParams.iconPath = Application.streamingAssetsPath + "/SaveIcon.png";
            SaveLoad.ControlFlags controlFlags = SaveLoad.ControlFlags.NOSPACE_DIALOG_CONTINUABLE;
            return((SaveLoad.SaveGameList(data, slotParams, controlFlags) == ErrorCode.SG_OK) ? true : false);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        private SaveHeaderFmt getHeaderInfo(int slot_no)
        {
            SaveHeaderFmt saveHeaderFmt = null;
            XElement      xElement      = null;

            try
            {
                xElement = XElement.Load(this.getMemberFilePath(slot_no)).Element(SaveHeaderFmt.tableaName);
            }
            catch (Exception ex)
            {
                string message = ex.get_Message();
                xElement = null;
            }
            if (xElement != null)
            {
                saveHeaderFmt = new SaveHeaderFmt();
                if (!saveHeaderFmt.SetPropertie(xElement))
                {
                    saveHeaderFmt = null;
                }
            }
            return(saveHeaderFmt);
        }
        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);
        }