public object MarshalNativeToManaged(IntPtr pNativeData) { CGameData data = (CGameData)Marshal.PtrToStructure(pNativeData, typeof(CGameData)); GameData resData = new GameData(); resData.playerPosition = data.playerPosition; resData.calendar = new Calendar(); resData.calendar.season = ((SeasonType)data.calendar.season).ToString(); resData.calendar.time = Marshal.PtrToStringAnsi(data.calendar.time); resData.calendar.isNight = data.calendar.isNight; resData.weather = new Weather(); resData.weather.type = data.weather.type; resData.weather.temprature = data.weather.temperature; resData.weather.humidity = data.weather.humidity; resData.weather.wind = data.weather.wind; resData.weather.pressure = data.weather.pressure; resData.weather.acidic = data.weather.acidic; int width = data.map.width; int height = data.map.height; int size = width * height; Tile[] tiles = new Tile[width * height]; resData.map = new Map(width, height, tiles); for (int i = 0; i < size; i++) { IntPtr p = new IntPtr(data.map.tiles.ToInt64() + i * Marshal.SizeOf(typeof(CTile))); CTile tile = (CTile)Marshal.PtrToStructure(p, typeof(CTile)); resData.map.tiles[i] = new Tile(tile.ter, tile.loc, tile.furn, tile.seen != 0); } return(resData); }
public void CleanUpNativeData(IntPtr pNativeData) { CGameData data = (CGameData)Marshal.PtrToStructure(pNativeData, typeof(CGameData)); Marshal.FreeCoTaskMem(data.calendar.time); Marshal.FreeCoTaskMem(data.map.tiles); Marshal.FreeCoTaskMem(pNativeData); }
public override bool Open() { var filename = GetNameWithoutExtension(); if (CheckFileMagic(file, CityAreasMagic)) { CityAreaEditor editor = new CityAreaEditor(file); return(true); } else if (CheckFileMagic(file, CityShopsMagic)) { CityShopEditor editor = new CityShopEditor(file); return(true); } else if (CheckFileMagic(file, ShopMenu2Magic)) { ShopMenu2Editor editor = new ShopMenu2Editor(file); return(true); } else if (CheckFileMagic(file, SDSConfigMagic)) { SdsConfigFile SDSConfigEditor = new SdsConfigFile(); SDSConfigEditor.ReadFromFile(file); return(true); } else if (CheckFileMagic(file, TapIndicesMagic)) { TAPIndices editor = new TAPIndices(); editor.ReadFromFile(file); return(true); } else if (CheckFileMagic(file, StreamMapMagic)) { StreamEditor editor = new StreamEditor(file); return(true); } else if (CheckFileMagic(file, CGameMagic)) { CGameData data = new CGameData(file); return(true); } else { // Unsure on how we should handle this. For now we will just try and hope the loader works. SoundSectorLoader loader = new SoundSectorLoader(file); } return(false); }
public static CSoundPlayer m_soundPlayer; // サウンドプレイヤー //---------------------------------------------------------------------- // コンストラクタ //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/10/27 @Update 2014/10/27 @Author T.Kawashita // 2014/11/13 @Update 2014/11/13 @Author T.Takeuchi シーン移動しても消滅しない処理追加 //---------------------------------------------------------------------- void Awake() { m_nowStatus = eSTATUS.eWAIT; m_frame = 0; m_isGamePlay = true; CGameData.GetInstance().Init(); this.LoadData(); m_redPoint = 0; m_bluePoint = 0; m_soundPlayer = new CSoundPlayer(); m_soundPlayer.PlayBGMFadeIn("game/bgm_01", 0.05f); }
void Start() { mGameData = new CGameData(); if (mFieldViev == null) { mFieldViev = GameObject.Find("Field").GetComponent <CFieldView>(); } mFieldViev.StartGame(); input = new CInput(); input.registerObserver(this, 0); mNotificationManager.Register(EEventType.eRestartGameEvent, IsGameFinished); }
//---------------------------------------------------------------------- // CSVファイルからグローバルデータを読み込み //---------------------------------------------------------------------- // @Param none // @Return bool 成功か失敗 // @Date 2014/10/27 @Update 2014/10/27 @Author 2014/10/27 //---------------------------------------------------------------------- private bool LoadData() { // CSVファイルをロード string path = Application.dataPath + "/Resources/CSV/GlobalData.csv"; string[,] csvData = new string[1, CGameData.m_dataNum]; CCSVLoader.GetInstance().Loader(ref csvData, path, 1); // 変換用ワーク作成 string[] work = new string[CGameData.m_dataNum]; // データをセット CGameData.SetData(CUtility.ChangeArray(ref work, csvData, 0)); return(true); }
//Improve this, its bad. private void HandleFile(ListViewItem item) { if (ToolkitSettings.UseSDSToolFormat) { switch (item.SubItems[1].Text) { case "Directory": OpenDirectory((DirectoryInfo)item.Tag); return; case "SDS Archive": OpenSDS((FileInfo)item.Tag); break; default: Process.Start(((FileInfo)item.Tag).FullName); break; } return; } MaterialTool mTool; CollisionEditor cTool; ActorEditor aTool; PrefabLoader prefabs; SpeechEditor sTool; CutsceneLoader cutscene; IOFxFile iofx; EmitterFile emitterFile; TableEditor tTool; NAVData nav; ApexRenderMesh mesh; ApexClothingAssetLoader aca; CityAreaEditor caEditor; CityShopEditor csEditor; SoundSectorLoader soundSector; //DEBUG D3DForm d3dForm; //special case: if (item.SubItems[0].Text.Contains("SDSContent") && item.SubItems[1].Text == "XML") { new SDSContentEditor((FileInfo)item.Tag); return; } else if (item.SubItems[0].Text.Contains("cityareas") && item.SubItems[1].Text == "BIN") { caEditor = new CityAreaEditor((FileInfo)item.Tag); return; } else if (item.SubItems[0].Text.Contains("FrameProps") && item.SubItems[1].Text == "BIN") { FrameProps fProps = new FrameProps((FileInfo)item.Tag); return; } else if (item.SubItems[0].Text.Contains("cityshop") && item.SubItems[1].Text == "BIN") { csEditor = new CityShopEditor((FileInfo)item.Tag); return; } else if (item.SubItems[0].Text.Contains("roadmap") && item.SubItems[1].Text == "GSD") { Roadmap roadmap = new Roadmap((item.Tag as FileInfo)); return; } else if (item.SubItems[0].Text.Contains("shopmenu2") && item.SubItems[1].Text == "BIN") { ShopMenu2Editor editor = new ShopMenu2Editor((item.Tag as FileInfo)); return; } else if (item.SubItems[1].Text == "BIN" && HandleStreamMap((item.Tag as FileInfo))) { StreamEditor editor = new StreamEditor((item.Tag as FileInfo)); return; } else if (item.SubItems[1].Text == "BIN" && CGameData.CheckHeader((item.Tag as FileInfo))) { CGameData data = new CGameData((item.Tag as FileInfo)); return; } else if (item.SubItems[0].Text.Contains("sdsconfig") && item.SubItems[1].Text == "BIN") { using (BinaryReader reader = new BinaryReader(File.Open((item.Tag as FileInfo).FullName, FileMode.Open))) { SdsConfigFile sdsConfig = new SdsConfigFile(); sdsConfig.ReadFromFile(reader); } return; } switch (item.SubItems[1].Text) { case "ARM": mesh = new ApexRenderMesh((FileInfo)item.Tag); return; case "ATP": AnimalTrafficLoader loader = new AnimalTrafficLoader((FileInfo)item.Tag); return; case "ACA": aca = new ApexClothingAssetLoader((FileInfo)item.Tag); return; case "Directory": OpenDirectory((DirectoryInfo)item.Tag); return; case "Material Library": mTool = new MaterialTool((FileInfo)item.Tag); return; case "NAV": case "NOV": case "NHV": nav = new NAVData((FileInfo)item.Tag); return; case "Speech Data": sTool = new SpeechEditor((FileInfo)item.Tag); return; case "CUT": cutscene = new CutsceneLoader((FileInfo)item.Tag); return; case "SDS Archive": OpenSDS((FileInfo)item.Tag); break; case "PATCH Archive": OpenPATCH((FileInfo)item.Tag); break; case "FR": //fTool = new FrameResourceTool((FileInfo)item.Tag); d3dForm = new D3DForm((FileInfo)item.Tag); d3dForm.Dispose(); return; case "COL": cTool = new CollisionEditor((FileInfo)item.Tag); return; case "IOFX": iofx = new IOFxFile((FileInfo)item.Tag); return; case "AEA": emitterFile = new EmitterFile((FileInfo)item.Tag); return; case "Table": tTool = new TableEditor((FileInfo)item.Tag); return; case "TRA": TranslokatorEditor editor = new TranslokatorEditor((FileInfo)item.Tag); return; case "ACT": aTool = new ActorEditor((FileInfo)item.Tag); break; case "PRF": prefabs = new PrefabLoader((FileInfo)item.Tag); return; case "LUA": case "AP": case "SHP": HandleLuaFile((FileInfo)item.Tag); return; case "IFL": ResourceTypes.AnimatedTexture.AnimatedTextureLoader an = new ResourceTypes.AnimatedTexture.AnimatedTextureLoader((FileInfo)item.Tag); return; case "IDS": ResourceTypes.ItemDesc.ItemDescLoader itemDesc = new ResourceTypes.ItemDesc.ItemDescLoader((item.Tag as FileInfo).FullName); return; case "BIN": SoundSectorLoader sLoader = new SoundSectorLoader(item.Tag as FileInfo); return; default: Process.Start(((FileInfo)item.Tag).FullName); break; } }
/// <summary> /// Convert platform and game data from JSON file into the database. /// NOTE: Any existing data in the Game and Platform tables will be deleted /// </summary> /// <returns>True if in 'verify' mode or on conversion success, false on any error during verification/conversion</returns> public bool ConvertData() { bool success = true; // Open/create database and clear the Game/Platform tables if (Mode == ConvertMode.cModeApply) { success = CSqlDB.Instance.Open(true) == SQLiteErrorCode.Ok; if (!success) { CInputOutput.Log("ERROR: Could not open or create the database."); return(success); } success = CSqlDB.Instance.Execute("DELETE FROM Game; DELETE FROM Platform") == SQLiteErrorCode.Ok; // Delete existing platforms and games if (!success) { CInputOutput.Log("ERROR: Could not prepare the Platform and Game tables"); return(success); } } // Load and log all platforms and games from JSON success = CJsonWrapper.ImportFromJSON(new CPlatform(), out List <CGameData.CMatch> matches); if (!success) { CInputOutput.Log("ERROR: Could not load games from the JSON file"); return(success); } Dictionary <string, int> jsonPlatforms = CGameData.GetPlatforms(); HashSet <CGameData.CGame> jsonAllGames = CGameData.GetPlatformGameList(CGameData.GamePlatform.All); CInputOutput.LogGameData(jsonPlatforms, jsonAllGames); // Begin migration here if (Mode == ConvertMode.cModeApply) { // Add platforms to the database foreach (KeyValuePair <string, int> platform in jsonPlatforms) { if (platform.Key != "All games" && platform.Key != "Search results" && platform.Key != "Favourites" && platform.Key != "New games" && platform.Key != "Hidden games" && platform.Key != "Not installed") { CPlatform.InsertPlatform(platform.Key, ""); } } // Get the platforms from the DB (we need the PK) Dictionary <string, CPlatform.PlatformObject> dbPlatforms = CPlatform.GetPlatforms(); // Add the games to the database foreach (CGameData.CGame game in jsonAllGames) { int platformFK = (dbPlatforms.ContainsKey(game.PlatformString)) ? dbPlatforms[game.PlatformString].PlatformID : 0; GameObject tmp = new(platformFK, game.ID, game.Title, game.Alias, game.Launch, game.Uninstaller); CGame.InsertGame(tmp); } HashSet <CGame.GameObject> dbGames = CGame.GetAllGames(); success = (success && jsonAllGames.Count == dbGames.Count); if (!success) { CInputOutput.Log("ERROR: Not all games were migrated to the database"); } CInputOutput.Log((success) ? "SUCCESS" : "FAILURE"); CInputOutput.Log("Game data migration finished"); CInputOutput.Log(dbPlatforms.Count + " Platforms added"); CInputOutput.Log(dbGames.Count + " Games added"); return(success); } else { CInputOutput.Log("Mode is 'verify' - no changes have been made"); CInputOutput.Log("In order to perform conversion, run the program in 'apply' mode"); } CInputOutput.Log("**** END ****"); return(success); }