public InDoorElement AddSceneByType(InDoorInfo activeInfo) { var currentInDoorPrefab = InDoorPool.Instance.ResLoader.LoadSync <GameObject>(Indoorsceneprefab.BundleName, activeInfo.name); GameObject sceneObj = GameObject.Instantiate(currentInDoorPrefab); InDoorElement skuSceneElement = sceneObj.AddComponent <InDoorElement>(); skuSceneElement.ElementInDoorInfo = activeInfo; inDoorElements.Add(skuSceneElement); return(skuSceneElement); }
public InDoorElement GetSceneWithInDoor(InDoorInfo activeInfo) { if (inDoorTypesDict.ContainsKey(activeInfo.name)) { return(inDoorTypesDict[activeInfo.name].GetInDoorElement(activeInfo)); } else { //此处为处理特殊超出缓存情况,一般情况下应该不会执行到。 AddInDoor(activeInfo); } return(null); }
public InDoorElement AddInDoor(InDoorInfo activeInfo) { if (!inDoorTypesDict.ContainsKey(activeInfo.name)) { InDoorType inDoorType = new InDoorType(); inDoorType.Types = activeInfo.name; inDoorTypesDict.Add(activeInfo.name, inDoorType); return(inDoorType.AddSceneByType(activeInfo)); } else { InDoorType skuSceneType = inDoorTypesDict[activeInfo.name]; if (skuSceneType.DoorElementCount < 3) { return(skuSceneType.AddSceneByType(activeInfo)); } } return(null); }
public InDoorElement GetInDoorElement(InDoorInfo activeInfo) { bool hasFind = false; for (int i = inDoorElements.Count - 1; i >= 0; i--) { if (inDoorElements[i].ElementInDoorInfo == activeInfo) { InDoorElement sceneElement = inDoorElements[i]; inDoorElements.RemoveAt(i); hasFind = true; return(sceneElement); } } if (!hasFind) { InDoorElement sceneElement = inDoorElements[0]; sceneElement.ElementInDoorInfo = activeInfo; inDoorElements.RemoveAt(0); return(sceneElement); } return(null); }