Пример #1
0
        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);
        }
Пример #2
0
        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;
    }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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>();
        }