void createLevelWidget(ILevelProvider level, int levelIndex) { var instance = InstantiateUtil.InstantiateUIAt(levelItemPrefab, levelList); var levelWidget = instance.GetComponent <LevelItemWidget>(); levelWidget.SetData(level, levelIndex); levelWidget.onSelect.AddListener(onItemSelect.Dispatch); }
public TView Show <TView>() where TView : MonoBehaviour { var uiPath = uiMap.GetPath(typeof(TView)); var prefab = (GameObject)Resources.Load(uiPath); var instance = InstantiateUtil.InstantiateUIAt(prefab, uiContainer); return(instance.GetComponent <TView>()); }
private bool ChanceToDrop(int valueSort, InstantiateUtil instantiateUtil, Vector3 position) { if (valueSort >= instantiateUtil.chanceToDrop) return false; if (instantiateUtil.prefab != null) Instantiate(instantiateUtil.prefab, position, Quaternion.identity, transform); return true; }
void CreateElement(Point position, string textureId) { var instance = InstantiateUtil.InstantiateAt(elementPrefab, elementsContainer); // TODO: если использовать пул, то здесь нужно брать объект из него var element = instance.GetComponent <ElementWidget>(); element.Init(position, textureId); element.transform.position = WorldFromCellPosition(position); element.trigger.onOver.AddListener(ItemSelectedHandler); element.trigger.onClick.AddListener(ItemClickHandler); elements.Add(element); }
public Sprint Create(SprintRequest sprintRequest) { List <ChunkFacade> chunkFacades = SpawnChunkFacades(sprintRequest); Checkpoint checkpoint = null; if (!sprintRequest.checkpointOverride) { checkpoint = SpawnCheckpoint(sprintRequest); } List <TypeValuePair> args = new List <TypeValuePair>(); args.Add(InstantiateUtil.CreateTypePair <List <ChunkFacade> >(chunkFacades)); args.Add(InstantiateUtil.CreateTypePair <Checkpoint>(checkpoint)); Sprint sprint = container.InstantiateExplicit <Sprint>(args); sprint.Initialize(); return(sprint); }
public override void Execute() { safeUnbind <ILevelProvider>(); safeUnbind <ILevelModel>(GameState.Current); safeUnbind <IChainModel>(GameState.Current); safeUnbind <int>(GameState.Current); var provider = levelList.LevelsAvailable[levelIndex]; injectionBinder.Bind <ILevelProvider>().To(provider); var level = (GameObject)Resources.Load(provider.View); InstantiateUtil.InstantiateAt(level, world); var chain = injectionBinder.GetInstance <IChainModel>() as ChainModel; injectionBinder.Bind <ILevelModel>().To(chain.level).ToName(GameState.Current); injectionBinder.Bind <IChainModel>().To(chain).ToName(GameState.Current); injectionBinder.Bind <int>().To(levelIndex).ToName(GameState.Current); ui.Show <ScreenHUDView>(); }