//オブジェクトの生成 新規のSpecoalでOK 親 地面かどうか public void CreateObject(Vector3 position, int objectId, int customId, SpecialObject Special, List <MapObject> mapObjects, GameObject parentObj, bool isGround) { if (objects == null) { objects = ObjectsLoad(); } GameObject obj = Instantiate(objects[objectId]); if (isGround) { position -= Vector3.up; } obj.transform.position = position; if (objectId != (int)Utility.ObjectId.Player) { obj.transform.parent = parentObj.transform; } Vector3Int pos = Utility.PositionToData(obj.transform.position); if (customId != 0) { CustomObject(obj, objectId, customId, pos, mapObjects); } else { MapObject mapObject = new MapObject(obj, objectId, pos); mapObjects.Add(mapObject); } }
// if the global version is greater than local version number, update the // local element to global version and value public SpecialObject get(int index) { SpecialObject element = array[index]; if (element.version < this.version) { element.version = this.version; element.value = this.value; } return(element); }
void Awake() { moveObjectTask = gameObject.AddComponent <MoveObjectTask>(); stageCreateTask = gameObject.AddComponent <StageCreateTask>(); uiTask = gameObject.AddComponent <GameUiTask>(); mapObjects = new List <MapObject>(); stageCreateTask.MapDataCreate(GetPath.Txt + "/" + stageName, mapObjects, ref stageData); Special = new SpecialObject(); textEvent = false; eventCount = 0; controllerTask = GetComponent <ControllerTask>(); drawFloorTask = GetComponent <DrawingFloorTask>(); }
public void DeleteObject(Vector3Int pos, int nextData, int objectId, CreateData createData) { MapObject mobj = GetMapObj(pos, objectId); mapObjects.Remove(mobj); Destroy(mobj.go); stageData[pos.x][pos.y][pos.z] = nextData; if (createData == CreateData.noCreate) { return; } //下にブロックを置くもの SpecialObject Special = new SpecialObject(); Vector3 position = Utility.DataToPosition(new Vector3Int(pos.x, pos.y, pos.z)); stageCreateTask.CreateObject(position, nextData, 0, Special, mapObjects, drawFloorTask.floorObjects[pos.x], createData == CreateData.groundCreate); }
public void MapDataToCreateStage(string str, List <MapObject> mapObjects, ref int[][][] mapData) { //下にブロックを置くもの SpecialObject Special = new SpecialObject(); //ステージの親オブジェクト GameObject stageParent = new GameObject(); stageParent.name = "StageParent"; stageParent.tag = "StageParent"; //アイテムとマップで分ける string[] str0 = str.Split(char.Parse("|"));; ItemAdd(str0[0]); //str1→階層ごとのデータ string[] str1 = str0[1].Split(char.Parse("/")); mapData = new int[str1.Length][][]; for (int y = 0; y < str1.Length; y++) { //階層ごとの親オブジェクト GameObject floor = new GameObject(); floor.transform.parent = stageParent.transform; floor.name = "Floor" + y; floor.tag = "StageFloor"; //str2→横1列ごとのデータ string[] str2 = str1[y].Split(char.Parse(";")); mapData[y] = new int[str2.Length][]; for (int z = 0; z < str2.Length; z++) { //str3→1マスのデータ string[] str3 = str2[z].Split(char.Parse(":")); mapData[y][z] = new int[str3.Length]; for (int x = 0; x < str3.Length; x++) { string[] str4 = str3[x].Split(char.Parse(".")); int mapId = Convert.ToInt32(str4[0]); int objectId = (int)Utility.GetObjectId((Utility.MapId)mapId); int customId = Convert.ToInt32(str4[1]); mapData[y][z][x] = mapId; //プレイヤーマスは地面なのでデータを変更する if (objectId == (int)Utility.ObjectId.Player) { mapData[y][z][x] = (int)Utility.MapId.Ground; } //地上に置くオブジェクトならtrue if (Array.IndexOf(Special.ThisUnder, mapId) == -1) { Vector3 pos = Utility.DataToPosition(new Vector3Int(y, z, x)); CreateObject(pos, objectId, customId, Special, mapObjects, floor, false); //オブジェクトの下にブロックを置くものならtrue if (Array.IndexOf(Special.InUnder, mapId) != -1) { CreateObject(pos, (int)Utility.ObjectId.Ground, 0, Special, mapObjects, floor, true); } } //地面に置くオブジェクト else { Vector3 pos = Utility.DataToPosition(new Vector3Int(y, z, x)); CreateObject(pos, objectId, 0, Special, mapObjects, floor, true); } } } } }