protected override void OnUpdate() { for (int i = 0; i < group.Length; i++) { if (MapDataManager.GetInstance().isCreated) { PostUpdateCommands.DestroyEntity(group.entity[i]); continue; } } }
public float Cost() { var info_id = MapDataManager.GetInstance().map[x][y]; var passCost = MapDataManager.GetInstance().cellInfo[info_id].PassEfficiency; if (passCost <= 0) { return(99); } return(passCost); }
public BacktrackingAlg.Node[] GetAllAdjacentNodes() { Node[] nodes = new Node[4]; int count = 0; if (x + 1 <= MapDataManager.GetInstance().width - 1) { nodes[count] = new Node { x = x + 1, y = y }; count++; } if (x - 1 >= 0) { nodes[count] = new Node { x = x - 1, y = y }; count++; } if (y + 1 <= MapDataManager.GetInstance().height - 1) { nodes[count] = new Node { x = x, y = y + 1 }; count++; } if (y - 1 >= 0) { nodes[count] = new Node { x = x, y = y - 1 }; count++; } if (0 == count) { return(null); } BacktrackingAlg.Node[] ret = new BacktrackingAlg.Node[count]; for (int i = 0; i < count; ++i) { ret[i] = nodes[i]; } return(ret); }
protected override void OnUpdate() { while (group.Length != 0) { var sourceEntity = group.Entity[0]; string mapPath = group.file[0].path; string cellAttPath = Application.dataPath + "/Config/cellAtt.xml"; if (group.file[0].use_defalt_path == true) { mapPath = Application.dataPath + "/Config/DemoMap.xml"; } var cells = XML.Paraser.XmlParaser <ItemCollection <XML.Data.Cell> > .Paraser(Application.dataPath + "/Config/cellAtt.xml"); Dictionary <int, Cell> cellMap = new Dictionary <int, Cell>(); foreach (var cell in cells.Items) { MapDataManager.GetInstance().cellInfo.Add(cell.ID, cell); } var terrains = XML.Paraser.XmlParaser <ItemCollection <XML.Data.Terrain> > .Paraser(Application.dataPath + "/Config/DemoMap.xml"); foreach (var terr in terrains.Items) { MapDataManager.GetInstance().map[terr.X - 1][terr.Y - 1] = terr.CellID; string resource_path = "Terrain_" + terr.CellID; var prefab = Resources.Load <GameObject>(resource_path); GameObject terr_go = GameObject.Instantiate(prefab); var e = terr_go.GetComponent <GameObjectEntity>(); EntityManager.SetComponentData(e.Entity, new Position { Value = new float3(terr.X, 0, terr.Y) }); } MapDataManager.GetInstance().width = 23; MapDataManager.GetInstance().height = 20; MapDataManager.GetInstance().isCreated = true; EntityManager.RemoveComponent <FileCreateMap>(sourceEntity); UpdateInjectedComponentGroups(); } }