public void Save(int index) { var data = new BattleSave() { currentBattle = index }; _battleResource.Save(data); }
public void Save(BattleSave data) { base.Save(BATTLE_SAVE, data); }
// Use this for initialization void Update() { if (BattleVal.status == STATUS.DRAW_STAGE) { maporiginy = (float)(BattleVal.mapdata[(int)MapdataList.MAPORIGINAL].Count / 2); maporiginx = (float)(-BattleVal.mapdata[(int)MapdataList.MAPORIGINAL][0].Count / 2); mapxnum = BattleVal.mapdata[(int)MapdataList.MAPORIGINAL][0].Count; mapynum = BattleVal.mapdata[(int)MapdataList.MAPORIGINAL].Count; BattleVal.mapgobj = new Dictionary <string, GameObject>(); //読み込んだmapdataに基づいて、Mapを描画する for (int y = 0; y < mapynum; y++) { for (int x = 0; x < mapxnum; x++) { GameObject tmpbox; if (BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][y][x] == 0) { Vector3 mappos = new Vector3(maporiginx + x, 0, maporiginy - y); tmpbox = Instantiate(MapBox[0], mappos, Quaternion.identity); tmpbox.transform.localScale = new Vector3(1.0f, MapBoxHeight, 1.0f); BattleVal.mapgobj.Add(string.Format("{0},{1}", x, y), tmpbox); } else { Vector3 mappos = new Vector3(maporiginx + x, (float)(BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][y][x] - 1) * MapBoxHeight / 2.0f, maporiginy - y); tmpbox = Instantiate(MapBox[BattleVal.mapdata[(int)MapdataList.MAPTEXTURE][y][x]], mappos, Quaternion.identity); tmpbox.transform.localScale = new Vector3(1.0f, (float)BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][y][x] * MapBoxHeight, 1.0f); BattleVal.mapgobj.Add(string.Format("{0},{1}", x, y), tmpbox); } //tmpbox.GetComponent<Renderer>().material = MapTexture[mapdata[(int)MapdataList.MAPTEXTURE][y][x]]; } } DrawUnitInit(); //初期描画終了 BattleVal.status = STATUS.DRAW_TITLE; //BattleVal.status = STATUS.TURNCHANGE; } //ロード時の画面描写 if (BattleVal.status == STATUS.DRAW_STAGE_FROM_LOADDATA) { //セーブデータの呼び出し FileStream fs = new FileStream(Application.streamingAssetsPath + Operation.loadtemp, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); BattleSave sd = JsonUtility.FromJson <BattleSave>(sr.ReadLine()); sd.Load(); //読み込んだmapdataに基づいて、Mapを描画する BattleVal.mapgobj = new Dictionary <string, GameObject>(); for (int y = 0; y < mapynum; y++) { for (int x = 0; x < mapxnum; x++) { GameObject tmpbox; if (BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][y][x] == 0) { Vector3 mappos = new Vector3(maporiginx + x, 0, maporiginy - y); tmpbox = Instantiate(MapBox[0], mappos, Quaternion.identity); tmpbox.transform.localScale = new Vector3(1.0f, MapBoxHeight, 1.0f); BattleVal.mapgobj.Add(string.Format("{0},{1}", x, y), tmpbox); } else { Vector3 mappos = new Vector3(maporiginx + x, (float)(BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][y][x] - 1) * MapBoxHeight / 2.0f, maporiginy - y); tmpbox = Instantiate(MapBox[BattleVal.mapdata[(int)MapdataList.MAPTEXTURE][y][x]], mappos, Quaternion.identity); tmpbox.transform.localScale = new Vector3(1.0f, (float)BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][y][x] * MapBoxHeight, 1.0f); BattleVal.mapgobj.Add(string.Format("{0},{1}", x, y), tmpbox); } //tmpbox.GetComponent<Renderer>().material = MapTexture[mapdata[(int)MapdataList.MAPTEXTURE][y][x]]; } } //キャラの配置 foreach (Unitdata unit in BattleVal.unitlist) { unit.gobj = Instantiate(unit.gobj_prefab, new Vector3(), Quaternion.identity); DrawCharacter(unit.gobj, unit.x, unit.y); unit.gobj.transform.forward = sd.keyValuePairsUnitdirection[unit]; //足元にチーム識別タイルを GameObject unittile; if (unit.team == 0) { unittile = Instantiate(prefabPlayerTile, unit.gobj.transform); unittile.transform.localScale = new Vector3(unittile.transform.localScale.x / unittile.transform.lossyScale.x, 0.01f, unittile.transform.localScale.z / unittile.transform.lossyScale.z); DrawCharacter(unittile, unit.x, unit.y); } else if (unit.team == 1) { unittile = Instantiate(prefabEnemyTile, unit.gobj.transform); unittile.transform.localScale = new Vector3(unittile.transform.localScale.x / unittile.transform.lossyScale.x, 0.01f, unittile.transform.localScale.z / unittile.transform.lossyScale.z); DrawCharacter(unittile, unit.x, unit.y); } unit.gobj.layer = 8; } //tmpファイルの削除 sr.Close(); fs.Close(); System.IO.File.Delete(Application.streamingAssetsPath + Operation.loadtemp); //セーブデータからの再描画終了 BattleVal.status = STATUS.TAKE_SCREENSHOT_FROM_LOADDATA; } //TODO //マップの透過度設定 //選択マスよりも10以上高さが高いマスは透過度を高くする。(裏にいるキャラが見れるようになる。) //この機能を使用する場合、床のMapBoxはRendering Mode をOpaqueに、壁のMapBoxはFadeにするとよいです。 if ((BattleVal.status == STATUS.PLAYER_UNIT_SELECT || BattleVal.status == STATUS.ENEMY_UNIT_SELECT) && BattleVal.selectX != -1 && is_fade_highermap) { //選択マスの高さ int selectheight = BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][BattleVal.selectY][BattleVal.selectX]; foreach (KeyValuePair <string, GameObject> mapbox in BattleVal.mapgobj) { string[] tmp = mapbox.Key.Split(','); int x = int.Parse(tmp[0]); int y = int.Parse(tmp[1]); int mapboxheight = BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][y][x]; //透明マスは飛ばす if (mapboxheight == 0) { continue; } //高さ判定 if (Mathf.Abs(mapboxheight - selectheight) >= hight_highermap) { Color tmpcolor = mapbox.Value.GetComponent <Renderer>().material.color; tmpcolor.a = highermap_alpha; mapbox.Value.GetComponent <Renderer>().material.color = tmpcolor; } else { Color tmpcolor = mapbox.Value.GetComponent <Renderer>().material.color; tmpcolor.a = 1.0f; mapbox.Value.GetComponent <Renderer>().material.color = tmpcolor; } } } }