public Stage(List<string> stage, MainSystem sys) { _sys = sys; _root = new GameObject("SpriteRoot"); _stage = stage; _stepCountText = GameObject.Find("StepCountText").GetComponent<Text>(); _stepCountText.text = "Step: 0"; _rows = _stage.Count; _cols = _stage[0].Length; for (int i = 0; i < _rows; i++) { _targetTable.Add(new bool[_cols]); } for (int i = 0; i < _stage.Count; i++) { for (int j = 0; j < _stage[i].Length; j++) { switch (_stage[i][j]) { case StageChar.Wall: sys.MakeSprite(SpriteType.Wall, i, j).transform.SetParent(_root.transform); break; case StageChar.Floor: sys.MakeSprite(SpriteType.Floor, i, j).transform.SetParent(_root.transform); break; case StageChar.Target: sys.MakeSprite(SpriteType.Target, i, j).transform.SetParent(_root.transform); _targetTable[i][j] = true; break; case StageChar.Box: sys.MakeSprite(SpriteType.Floor, i, j).transform.SetParent(_root.transform); var box = sys.MakeSprite(SpriteType.Box, i, j); box.transform.SetParent(_root.transform); _boxes.Add(new Box(i, j, box)); break; case StageChar.TargetAndBox: sys.MakeSprite(SpriteType.Target, i, j).transform.SetParent(_root.transform); _targetTable[i][j] = true; sys.MakeSprite(SpriteType.Floor, i, j).transform.SetParent(_root.transform); var box2 = sys.MakeSprite(SpriteType.Box, i, j); box2.transform.SetParent(_root.transform); _boxes.Add(new Box(i, j, box2)); break; case StageChar.Player: sys.MakeSprite(SpriteType.Floor, i, j).transform.SetParent(_root.transform); _player = new Player(i, j, sys, _root); break; case StageChar.None: break; default: Assert.IsTrue(false); break; } } } Assert.IsNotNull(_player); // ステージを画面中央に移動させる var pos = new Vector3(-Stage.SpriteSize * _cols / 2 + Stage.SpriteSize/2, Stage.SpriteSize * _rows / 2 - Stage.SpriteSize/2, 0); _root.transform.position = pos; }