void InitializeData() { heroDatabase = HeroDatabase.Instance; heroDatabase.InitializeHeroDatabase(); itemDatabase = ItemDatabase.Instance; itemDatabase.InitializeItemDatabase(); buildingDatabase = BuildingDatabase.Instance; buildingDatabase.InitializeBuildingDatabase(); unitDatabase = UnitDatabase.Instance; unitDatabase.InitializeUnitDatabase(); Id = ""; heroData = new HeroBaseData(); resource = 0; heroState = 0; castleState = 0; equipment = new int[equipNum]; inventoryId = new int[invenNum]; inventoryNum = new int[invenNum]; skill = new int[skillNum]; unit = new Unit[unitNum]; createUnit = new Unit(); attackUnit = new Unit[unitNum]; building = new int[buildingNum]; upgrade = new int[unitNum]; buildBuilding = buildingNum; }
public Game() { Coins = 0; Level = 1; ExperiencePoints = 0; CurrentLevel = "Suburb"; Bag = new Bag(); InventoryWeapons = new List <InventoryWeapon> (); InventoryWeapon inventoryWeapon = new InventoryWeapon(WeaponDatabase.GetWeapon(0), true); InventoryWeapons.Add(inventoryWeapon); Bag.AddWeapon(InventoryWeapons [0].Weapon.ID); Heroes = new List <HeroParty> (); HeroParty heroParty = new HeroParty(HeroDatabase.GetHero(0), true); Heroes.Add(heroParty); CurrentHero = Heroes [0].Hero; Paused = false; AutoAimTarget = true; savedTimeScale = 1; achievementManager = new AchievementManager(); }
public static HeroDatabase InitSetting() { string path = Application.persistentDataPath + "/Xml/Heros.Xml"; if (!System.IO.File.Exists(path)) { string folderPath; folderPath = Application.persistentDataPath + "/Xml"; DirectoryInfo di = new DirectoryInfo(folderPath); if (di.Exists == false) { di.Create(); } TextAsset _xml = Resources.Load <TextAsset>("XmlData/Heros"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(_xml.text); if (_xml != null) { XmlSerializer serializer = new XmlSerializer(typeof(HeroDatabase)); var reader = new StringReader(_xml.text); HeroDatabase heroDB = serializer.Deserialize(reader) as HeroDatabase; reader.Close(); CreateXml(heroDB.heros[0], path); Debugging.Log("HeroDatabase 최초 생성 성공"); return(heroDB); } } Debugging.Log("HeroDatabase 최초 생성 실패"); return(null); }
public static HeroDatabase LoadUser() { string path = Application.persistentDataPath + "/Xml/Heros.Xml"; if (System.IO.File.Exists(path)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(System.IO.File.ReadAllText(path)); //복호화//// XmlElement elmRoot = xmlDoc.DocumentElement; var decrpytData = DataSecurityManager.DecryptData(elmRoot.InnerText); elmRoot.InnerXml = decrpytData; ////////// string _xml; using (var stringWriter = new StringWriter()) using (var xmlTextWriter = XmlWriter.Create(stringWriter)) { xmlDoc.WriteTo(xmlTextWriter); xmlTextWriter.Flush(); _xml = stringWriter.GetStringBuilder().ToString(); } if (_xml != null) { XmlSerializer serializer = new XmlSerializer(typeof(HeroDatabase)); var reader = new StringReader(_xml); HeroDatabase heroDB = serializer.Deserialize(reader) as HeroDatabase; reader.Close(); Debugging.Log("HeroDatabase 유저 파일 로드"); return(heroDB); } } Debugging.LogSystemWarning("HeroDatabase wasn't loaded. >> " + path + " is null. >>"); return(null); }
void CheckHeroForUpdate() { for (int i = 0; i < HeroDatabase.GetHeroesLength(); i++) { Hero hero = HeroDatabase.GetHero(i); Game.current.AddHeroToParty(hero); } }
// private string prefabPath = "Images/hero"; // Start is called before the first frame update void Start() { instance = this; heroDataFile = new HeroDataFile(); heroDataFile.heroDatas = new List <EntityData>(); //SaveHeroData(); LoadHeroData(); }
public static void SaveHeros(List <GameObject> heros) { if (heros != null) { HeroDatabase.SaveAllUser(GetHerosData(heros)); } else { Debugging.LogError("저장할 영웅들을 찾지못함"); } }
private static void InitUserData(string localId, string name) { SaveSystem.InitPlayer(localId, name); ItemDatabase.InitSetting(); HeroDatabase.InitSetting(); AbilityDatabase.InitSetting(); SkillDatabase.InitSetting(); MissionDatabase.InitSetting(); MapDatabase.InitSetting(); SaveData(); }
public static void EquipHeroEquimentItem(int index, int id, Item item) { HeroData data = userHeros.Find(x => x.id == id || x.id.Equals(id)); if (data != null && item != null) { int dismountItemId = GetHeroEquipmentItems(id)[index]; SetHeroEquipmentItems(index, id, item); HeroDatabase.SaveUser(id); ItemSystem.EquipItem(dismountItemId, item.customId, ref data); } }
public static void DismountHeroEquimentItem(int index, int id) { HeroData data = userHeros.Find(x => x.id == id || x.id.Equals(id)); if (data != null) { int dismountItemId = GetHeroEquipmentItems(id)[index]; SetHeroDismountItems(index, id); HeroDatabase.SaveUser(id); ItemSystem.DismountItem(dismountItemId); } }
public void SetDataToCloud(string socialUserId, string socialName, string saveTime) { localId = socialUserId; name = socialName; lastSavedTime = saveTime; UserData = SaveSystem.GetUserDataToCloud(); ItemData = ItemDatabase.GetItemDataToCloud(); HeroData = HeroDatabase.GetHeroDataToCloud(); AbilityData = AbilityDatabase.GetAbilityDataToCloud(); SkillData = SkillDatabase.GetSkillDataToCloud(); MissionData = MissionDatabase.GetMissionDataToCloud(); MapData = MapDatabase.GetMapDataToCloud(); }
public static void SaveHero(Hero heroPrefab) { HeroData heroData = userHeros.Find(hero => hero.id == heroPrefab.id || hero.id.Equals(heroPrefab.id)); if (heroData != null) { heroData.level = heroPrefab.status.level; heroData.exp = heroPrefab.status.exp; HeroDatabase.SaveUser(heroPrefab.id); } else { Debugging.LogError("세팅할 영웅을 찾지못함 >> " + heroPrefab.id); } }
public static void SetObtainHero(int id) { HeroData obtainHero = heros.Find(h => h.id == id || h.id.Equals(id)); if (obtainHero != null) { HeroDatabase.AddUser(id); userHeros.Add(obtainHero); SkillSystem.SetObtainSkill(obtainHero.skill); MissionSystem.AddClearPoint(MissionSystem.ClearType.CollectHero); Debugging.Log(id + " 영웅 획득 성공!"); } else { Debugging.LogError("획득할 영웅을 찾지못함 >> " + id); } }
private static void SetCloudDataToLocal() { if (gameInfo != null) { SaveSystem.SetCloudDataToUser(gameInfo); ItemDatabase.SetCloudDataToItem(gameInfo); HeroDatabase.SetCloudDataToHero(gameInfo); AbilityDatabase.SetCloudDataToAbility(gameInfo); SkillDatabase.SetCloudDataToSkill(gameInfo); MissionDatabase.SetCloudDataToMission(gameInfo); MapDatabase.SetCloudDataToMap(gameInfo); } else { Debug.LogWarning("클라우드 데이터 로컬저장중 오류 발생"); } }
public static HeroDatabase Load() { TextAsset _xml = Resources.Load <TextAsset>("XmlData/Heros"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(_xml.text); if (_xml != null) { XmlSerializer serializer = new XmlSerializer(typeof(HeroDatabase)); var reader = new StringReader(_xml.text); HeroDatabase heroDB = serializer.Deserialize(reader) as HeroDatabase; reader.Close(); Debugging.Log("HeroDatabase 로드 성공"); return(heroDB); } return(null); }
public static void LoadHero() { heros.Clear(); userHeros.Clear(); string path = Application.persistentDataPath + "/Xml/Heros.Xml"; HeroDatabase hd = null; HeroDatabase userHd = null; // 유저 데이터가 있을경우 로드 if (System.IO.File.Exists(path)) { hd = HeroDatabase.Load(); userHd = HeroDatabase.LoadUser(); } // 최초생성 else { hd = HeroDatabase.InitSetting(); userHd = HeroDatabase.LoadUser(); } if (hd != null) { foreach (HeroData hero in hd.heros) { heros.Add(hero); } } if (userHd != null) { foreach (HeroData hero in userHd.heros) { userHeros.Add(hero); } } if (heros != null & userHeros != null) { Debugging.LogSystem("HeroDatabase is loaded Succesfully."); } }
public HeroesController(HeroDatabase db) { this.db = db; }