public static void PreLoad(int resourceId, Action cb) { ResourceConfig conf = configs[resourceId]; if (conf == null) { Debug.LogErrorFormat("RreLoad error, not conf {0}", resourceId); return; } XLoader.LoadAsync <GameObject>(conf.path, (UnityEngine.Object go) => { GameObject g = go as GameObject; if (MapResourceCenter.caches.ContainsKey(resourceId)) { return; } g.transform.localScale = new Vector3((float)Map.MAP_CELL_DEMANSION_X, (float)Map.MAP_CELL_DEMANSION_Y, (float)Map.MAP_CELL_DEMANSION_X); MapResourceCache cache = new MapResourceCache(g); Debug.LogFormat("PreLoad {0}", resourceId); caches[resourceId] = cache; cb(); }); }
public BasicClock(XLoader loader, ClockSettings clockSettings, BasicClockView basicClockView, IClockController clockController, PhysicsRaycasterWithCache physicsRaycasterWithCache) { _loader = loader; _clockSettings = clockSettings; _basicClockView = basicClockView; _clockController = clockController; _physicsRaycasterWithCache = physicsRaycasterWithCache; }
public void StartMap() { sceneCamera = sceneCameraTrans.GetComponent <Camera>(); plane = new Plane(); DontDestroyOnLoad(this); md = XLoader.Load <MapData>("Map/MapContainer/map_data.asset"); for (int ty = 0; ty < MAP_TILE_COUNT_Y; ++ty) { for (int tx = 0; tx < MAP_TILE_COUNT_X; ++tx) { int tile_id = ty * MAP_TILE_COUNT_X + tx; MapTileData td = md.tileList[tile_id]; MapTile tile = new MapTile(tile_id, td); tile.basePos.x = tx * MAP_TILE_DEMANSION_X; tile.basePos.z = ty * MAP_TILE_DEMANSION_Y; tiles[tile_id] = tile; for (int by = 0; by < MAP_BLOCK_COUNT_Y; ++by) { for (int bx = 0; bx < MAP_BLOCK_COUNT_X; ++bx) { int yy = ty * MAP_BLOCK_COUNT_Y + by; int xx = tx * MAP_BLOCK_COUNT_X + bx; int block_id = yy * MAP_BLOCK_COUNT_TOTAL_X + xx; MapBlock block = new MapBlock(tile, block_id, td.blockList[by * MAP_BLOCK_COUNT_X + bx]); block.basePos.x = tile.basePos.x + bx * MAP_BLOCK_DEMANSION_X; block.basePos.z = tile.basePos.z + by * MAP_BLOCK_DEMANSION_Y; blocks[block_id] = block; } } } } sceneCameraTrans.position = new Vector3(MAP_DEMANSION_X / 2, 10, MAP_DEMANSION_Y / 2); run = true; }
public void Construct(XLoader loader) { _loader = loader; }
// Start is called before the first frame update void Start() { GameObject.DontDestroyOnLoad(gameObject); XLoader.Initialize(true); initLua(); }