Exemplo n.º 1
0
        void HandleCardClicked(string bundleName, int id)
        {
            Services.Get <PlaneManager>().SetCurrentPlaneId(bundleName, id);

            PlaneCard[] cards = m_grid.GetComponentsInChildren <PlaneCard>();
            for (int i = 0; i < cards.Length; ++i)
            {
                int cardId = cards[i].GetId();
                cards[i].SetSelected(cardId == id);
            }
        }
Exemplo n.º 2
0
    private void SetBagTable()
    {
        InstantiateGameCells(GameState.GetInstance().Bag.Count, Bag, BagCell);
        var bagData  = GameState.GetInstance().Bag;
        var bagCells = Bag.GetComponentsInChildren <Image>();

        for (var i = 0; i < bagData.Count; i++)
        {
            bagCells[i].GetComponent <BagCell>().SetState(Bag, bagData[i]);
        }
    }
Exemplo n.º 3
0
    void TryClear()
    {
        foreach (PlanMenuItem planMenuItem in _gridLayout.GetComponentsInChildren <PlanMenuItem>())
        {
            Destroy(planMenuItem.gameObject);
            _planPanels.Clear();
        }

        foreach (WorkoutPanel workoutPanel in _gridLayout.GetComponentsInChildren <WorkoutPanel>())
        {
            Destroy(workoutPanel.gameObject);
            _workoutPanels.Clear();
        }

        foreach (ExerciseMenuItem exerciseMenuItem in _gridLayout.GetComponentsInChildren <ExerciseMenuItem>())
        {
            Destroy(exerciseMenuItem.gameObject);
            _exerciseMenuItems.Clear();
        }
    }
Exemplo n.º 4
0
    private void SetHandsTable()
    {
        InstantiateGameCells(GameState.GetInstance().Workers.Count, Hands, HandCell);
        var workersData = GameState.GetInstance().Workers;
        var handsCells  = Hands.GetComponentsInChildren <Image>();

        for (var i = 0; i < workersData.Count; i++)
        {
            handsCells[i].GetComponent <HandCell>().SetState(Hands, workersData[i]);
        }
    }
Exemplo n.º 5
0
 void AddListenersMatColor1()
 {
     foreach (Button b in MaterialGrid1.GetComponentsInChildren <Button>())
     {
         string selectedButtonName = b.GetComponent <Image>().material.name;
         b.name = selectedButtonName;
         b.onClick.AddListener(delegate {
             SetMaterial1(selectedButtonName);
         });
     }
 }
Exemplo n.º 6
0
 private void Reset()
 {
     grid  = GetComponentInChildren <GridLayoutGroup>();
     slots = grid.GetComponentsInChildren <InventorySlot>();
     for (int i = 0; i < slots.Length; i++)
     {
         slots[i].name = $"Inv Slot {i + 1}";
         slots[i].Set();
         slots[i].Awake();
         slots[i].Update();
     }
 }
Exemplo n.º 7
0
    private void SetShopTable()
    {
        InstantiateGameCells(GameState.GetInstance().Shop.Count, Shop, ShopCell);
        var bagData   = GameState.GetInstance().Bag;
        var softMoney = Utils.FindInJsonArray(bagData, it => it["item"]["id"] == "softMoney");
        var shopData  = GameState.GetInstance().Shop;
        var shopCells = Shop.GetComponentsInChildren <Image>();

        for (var i = 0; i < shopData.Count; i++)
        {
            shopCells[i].GetComponent <ShopCell>().SetState(Shop, shopData[i], softMoney);
        }
    }
Exemplo n.º 8
0
    private void Awake()
    {
        grid = GetComponent <GridLayoutGroup>();
        var images = grid.GetComponentsInChildren <Image>();

        // Getting references to all livesIcons
        foreach (var image in images)
        {
            livesIcons.Add(image.gameObject);
        }
        // Subscribing to when lives are changed
        Events.LivesChanged += OnLivesChanged;
    }
Exemplo n.º 9
0
    public void ShowWorkoutsMenu()
    {
        addWorkoutPanelButton.transform.localScale  = Vector3.one;
        addExercisePanelButton.transform.localScale = Vector3.zero;

        workoutPanelsGridLayoutGroup.transform.localScale  = Vector3.one;
        exercisePanelsGridLayoutGroup.transform.localScale = Vector3.zero;

        foreach (ExercisePanel panel in exercisePanelsGridLayoutGroup.GetComponentsInChildren <ExercisePanel>())
        {
            Destroy(panel.gameObject);
        }
    }
Exemplo n.º 10
0
 Image getCell(int x, int y)
 {
     foreach (Image celda in grid.GetComponentsInChildren <Image>())
     {
         if (celda.transform.GetSiblingIndex() == obtainSilbing(x, y))
         {
             Debug.Log("RETORNECELDA");
             return(celda);
         }
     }
     Debug.Log("NORETORNECELDA");
     return(null);
 }
Exemplo n.º 11
0
 private void RemoveQuestion()
 {
     if (tileGridPanel.transform.childCount > 0)
     {
         Transform[] childs = tileGridPanel.GetComponentsInChildren <Transform>();
         foreach (Transform ch in childs)
         {
             if (ch.name != tileGridPanel.gameObject.name)
             {
                 Destroy(ch.gameObject);
             }
         }
     }
 }
Exemplo n.º 12
0
    public void ShowWorkoutsMenu()
    {
        workoutPanelsGridLayoutGroup.transform.localScale  = Vector3.one;
        exercisePanelsGridLayoutGroup.transform.localScale = Vector3.zero;

        foreach (ExerciseMenuItem panel in exercisePanelsGridLayoutGroup.GetComponentsInChildren <ExerciseMenuItem>())
        {
            Destroy(panel.gameObject);
        }

        foreach (WorkoutPanel panel in workoutPanelsGridLayoutGroup.GetComponentsInChildren <WorkoutPanel>())
        {
            Destroy(panel.gameObject);
        }

        foreach (WorkoutData workout in WorkoutManager.Instance.workoutData)
        {
            AddWorkoutPanel(workout, false);
        }

        FooterV2.Instance.ShowViewingPlanButtonGroup();

        currentMode = Mode.ViewingWorkouts;
    }
Exemplo n.º 13
0
        public void OpenInventory()
        {
            // Clear gridLayout of old Items
            foreach (ItemGUI item in gridLayout.GetComponentsInChildren <ItemGUI>())
            {
                Destroy(item.gameObject);
            }

            // Fill gridLayout with new Items
            foreach (Item i in selectedUnit.Unit.Inventory.Items)
            {
                GameObject itemObject = Instantiate(itemPrefab.gameObject);
                itemObject.transform.SetParent(gridLayout.transform);
                itemObject.GetComponent <ItemGUI>().SetItem(i, tooltipPanel, gameObject, selectedUnit, itemActionMenu, itemActionButtonPrefab);
            }
        }
    void Start()
    {
        // Récupérer les référentiels
        RefHellCircles = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='HellCircles' order by Id asc", "BlueStarDataWarehouse.db");
        RefAllegiance  = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Allegiance' order by Id asc", "BlueStarDataWarehouse.db");
        RefGenus       = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Genus' order by Id asc", "BlueStarDataWarehouse.db");
        RefSpecies     = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Species' order by Id asc", "BlueStarDataWarehouse.db");
        RefClass       = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Class' order by Id asc", "BlueStarDataWarehouse.db");
        RefImp         = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Imp' order by Id asc", "BlueStarDataWarehouse.db");
        RefOrigin      = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Origin' order by Id asc", "BlueStarDataWarehouse.db");
        RefTemper      = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Temper' order by Id asc", "BlueStarDataWarehouse.db");
        RefAstro       = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Astro' order by Id asc", "BlueStarDataWarehouse.db");
        RefAffinity    = dataBaseManager.getArrayData("select * from REF_CustomCharacters where ChoiceStage='Affinity' order by Id asc", "BlueStarDataWarehouse.db");
        RefQuestions   = dataBaseManager.getArrayData("select * from REF_Dialogues where Context='CharacterCreation' order by Id asc", "BlueStarDataWarehouse.db");
        RefErrors      = dataBaseManager.getArrayData("select * from REF_Dialogues where Context='Errors' order by Id asc", "BlueStarDataWarehouse.db");


        //Initialiser le cycle
        currentStep = PlayerHistoryStep.HELLCIRCLE;

        //Initialiser les choices à 0
        historyChoices.HellCircleChoice = 0;
        historyChoices.AllegianceChoice = 0;
        historyChoices.GenusChoice      = 0;
        historyChoices.SpeciesChoice    = 0;
        historyChoices.JobChoice        = 0;
        historyChoices.ImpChoice        = 0;
        historyChoices.OriginChoice     = 0;
        historyChoices.TemperChoice     = 0;
        historyChoices.AstroChoice      = 0;
        historyChoices.AffinityChoice   = 0;

        //Connection vers éléments de l'UI
        HistorySelection = GetComponent <Canvas> ();

        for (int i = 0; i < 9; i++)
        {
            Choice [i] = ChoiceDisplay.GetComponentsInChildren <Button> () [i];
        }



        GetHistoryUIButtons();

        HistorySelection.enabled = false;
    }
Exemplo n.º 15
0
    /// <summary>
    /// 移除选中人员的项
    /// </summary>
    public void SetSelectPersonnelItemToggle(Personnel personnelT, bool b)
    {
        List <HistoryPersonsSearchUIItem> pList = new List <HistoryPersonsSearchUIItem>(personsGrid.GetComponentsInChildren <HistoryPersonsSearchUIItem>());
        HistoryPersonsSearchUIItem        item  = pList.Find((i) => i.personnel == personnelT);

        //HistoryPersonsSearchUIItem item = selectPersonnelList.Find((i) => i.personnel == personnelT);
        if (!b)
        {
            if (item != null)
            {
                item.SetToggle(false);
            }
            else
            {
                RemoveSelectPersonnelItem(personnelT);
            }
        }
    }
Exemplo n.º 16
0
    public void Initialize()
    {
        maxStorage = itemsGrid.transform.childCount;
        itemSlots  = new List <PlayerItemSlot>(itemsGrid.GetComponentsInChildren <PlayerItemSlot>());
        for (int i = 0; i < itemSlots.Count; i++)
        {
            itemSlots[i].Initialize(i);
        }

        this.selectedItemIndex = -1;
        this.UpdateSelected();


        //For testing
        for (int i = 0; i < ItemManager.Instance.itemData.Count - 3; i++)
        {
            AddItem(ItemManager.Instance.itemData[i].key, 1);
        }
    }
Exemplo n.º 17
0
    // Start is called before the first frame update
    void Start()
    {
        // set level backgroud: lock or unlocked
        Transform[] levelsBG     = levelsGrid.GetComponentsInChildren <Transform>(); // get array of all the children of the grid
        int         levelsPassed = 0;

        for (int i = 0; i < levelsBG.Length; i++) // go through all possible childers of grid
        {
            Transform levelLocked = levelsBG[i].Find("LevelLocked");
            if (levelLocked != null)                     // found level locked background
            {
                levelLocked.gameObject.SetActive(false); // remove the lock
                levelsPassed++;
                if (levelsPassed >= maxLevel)
                {
                    break;                           // stop when opened maxLevel levels
                }
            }
        }
    }
Exemplo n.º 18
0
 private void LoadRoomItem(List <UserData> udList)
 {
     RoomItem[] roomItems = roomLayout.GetComponentsInChildren <RoomItem>();
     foreach (RoomItem ri in roomItems)
     {
         ri.DestroySelf();
     }
     for (int i = 0; i < udList.Count; i++)
     {
         GameObject roomItem = GameObject.Instantiate(roomItemPrefab);
         roomItem.transform.SetParent(roomLayout.transform, false);
         UserData ud = udList[i];
         roomItem.GetComponent <RoomItem>().SetRoomItemInfo(ud.Id, ud.Username, ud.TotalCount, ud.WinCount, this);
     }
     roomLayout.GetComponent <RectTransform>().sizeDelta =
         new Vector2(
             roomLayout.GetComponent <RectTransform>().sizeDelta.x,
             udList.Count * (roomLayout.cellSize.y + roomLayout.spacing.y) + roomLayout.padding.top
             );
 }
Exemplo n.º 19
0
    void Start()
    {
        grid = gameObject.GetComponent <GridLayoutGroup>();

        grid.cellSize = new Vector2(parent.rect.height / bestFillSize, parent.rect.height / bestFillSize);

        //Динамическое задание ширины для ShopList
        countElement = grid.GetComponentsInChildren <LayoutElement>().Length - 1;
        if (countElement % 2 == 0)
        {
            countElement /= 2;
        }
        else
        {
            countElement = countElement / 2 + 0.5f;
        }

        float rightOffset = countElement * (parent.rect.height / bestFillSize) + (countElement * grid.spacing.x);

        this.gameObject.GetComponent <RectTransform>().sizeDelta = new Vector2(rightOffset, parent.rect.height);
    }
    public void Init(Brick brick, int quantity)
    {
        this.brick = brick;

        imageGridLayout.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
        imageGridLayout.constraintCount = Mathf.Min(brick.width, brick.height);

        float maxSize = Mathf.Max(brick.width, brick.height);

        if (maxSize > 5)
        {
            imageGridLayout.cellSize = new Vector2(((RectTransform)imageGridLayout.transform).sizeDelta.x / maxSize, ((RectTransform)imageGridLayout.transform).sizeDelta.y / maxSize);
        }

        name = "BrickItem_" + brick.index.ToString();

        idText.text       = "ID: " + brick.index.ToString();
        nameText.text     = "Name: " + brick.name;
        quantityText.text = "Quantity: x" + quantity.ToString();
        colorText.text    = "Color: " + (brick.colorName != null && brick.colorName.Length > 0 ? brick.colorName : brick.color.ToString());

        for (int i = 0; i < brick.area; i++)
        {
            Instantiate(brickImagePrefab, imageGridLayout.transform);
        }

        foreach (var image in imageGridLayout.GetComponentsInChildren <RawImage>())
        {
            if (brick.color.r == 0 && brick.color.g == 0 && brick.color.b == 0)
            {
                image.color = new Color32(30, 30, 30, 255);
            }
            else
            {
                image.color = brick.color;
            }
        }

        onClick.AddListener(() => { Application.OpenURL(brick.GetUrl()); });
    }
Exemplo n.º 21
0
    public void UpdateDisplay()
    {
        for (int i = 0; i < CategoryCellCount; i += 1)
        {
            InventoryCategoryCell cell = CategoryGroup.GetComponentsInChildren <InventoryCategoryCell>(true)[i];
            if (i < categories.Count)
            {
                cell.gameObject.SetActive(true);
                ItemCategory category = categories[i];
                cell.Populate(category, categoryCursor == i && categoryMode);
            }
            else
            {
                cell.gameObject.SetActive(false);
            }
        }

        for (int i = 0; i < InventoryCellCount; i += 1)
        {
            int index = scrollOffset + i;
            InventoryItemCell cell = InventoryGroup.GetComponentsInChildren <InventoryItemCell>(true)[i];
            if (index < categoryItems.Count)
            {
                cell.gameObject.SetActive(true);
                InventoryEntry entry = categoryItems[index];
                cell.Populate(entry, itemCursor == i && !categoryMode);
            }
            else
            {
                cell.gameObject.SetActive(false);
            }
        }
        int selectedIndex = scrollOffset + itemCursor;

        if (selectedIndex < inventory.ItemCount())
        {
            InventoryEntry selectedEntry = inventory.ItemAtIndex(selectedIndex);
            ItemDescription.text = selectedEntry.Item.Description;
        }
    }
Exemplo n.º 22
0
    public override void OnEnter()
    {
        foreach (Card card in grid.GetComponentsInChildren <Card>())
        {
            cards.Add(card);
        }

        switch (action)
        {
        case Action.MoveFirstTime:
            StartCoroutine(MoveFirstTime());
            break;

        case Action.MoveToDeck:
            StartCoroutine(MoveToDeck());
            break;

        case Action.MoveToTable:
            StartCoroutine(MoveToTable());
            break;
        }

        Continue();
    }
Exemplo n.º 23
0
    //--------------------------------------------------------------------------------------
    //aqui le os arquivos de configuracao do time selecionado
    IEnumerator LoadExternal(String url)
    {
        string fileToAccess;

        if (Application.platform == RuntimePlatform.Android)
        {
            url = url.Replace("index.info", "");
        }
        warning.text = "***** LoadExternal url = " + url;

        LoadedPackage.packages [url].stages.Clear();

        // para o total de fases (até 8) em um mesmo time, ler as configuracoes;
        // isto precisa melhorar e virar um unico arquivo...
        for (int i = 0; i < files.Length; i++)
        {
            warning.text = url + "/" + files [i] + ".txt";
            fileToAccess = warning.text;

            WWW www = new WWW(fileToAccess);
            yield return(www);

            if ((www.error != null) && (www.error != ""))
            {
                if (warning != null)
                {
                    warning.text = "Failed to upload file " + files[i] + ".txt\n" + www.error;                   //171005generic msg
                }
            }
            else
            {
                if (www.text != null)
                {
                    LoadedPackage.packages[url].stages.Add(www.text);
                }
            }
        }

        LoadedPackage.loaded = LoadedPackage.packages[url];

        if (warning != null)
        {           //171005 translation
            warning.text = translate.getLocalizedValue("loadPckgs") + "\n" + LoadedPackage.packages[url].name;

            //packetSelected = LoadedPackage.packages[url].name.ToString();  //170310 salvar nome do pacote selecionado pelo user
            //170310 salvar nome do pacote selecionado pelo user em PlayerPrefs
            PlayerPrefs.SetString("teamSelected", LoadedPackage.packages[url].name);


            //170921 destacar o time selecionado
            //lembrar de repintar todos, por possiveis selecionados antes (o 1o escolhido programaticamente)
            buttons = g.GetComponentsInChildren <Button>();
            for (int xx = 0; xx < buttons.Length; xx++)
            {
                //buttons [xx].GetComponentInChildren<Text> ().SetNativeSize ();
                if (buttons [xx].name == LoadedPackage.packages [url].name)
                {
                    //buttons [xx].GetComponentInChildren<Text> ().fontStyle = FontStyle.Bold; ficou muito feio
                    buttons [xx].GetComponentInChildren <Text> ().color = new Color32(255, 255, 0, 255);
                    buttons[xx].GetComponent <Image>().color            = new Color32(255, 255, 255, 255);
                }
                else
                {
                    buttons [xx].GetComponentInChildren <Text> ().color = Color.white;
                    buttons[xx].GetComponent <Image>().color            = new Color32(255, 255, 255, dynamicButtonDefaultAlpha);
                }
            }
        }


        if (OnLoadPkgExternalHandler == null)
        {
            OnLoadPkgExternalHandler = null;            //StartCoroutine(MiscUtils.WaitAndLoadLevel("MainScene", 3));
        }
        else
        {
            OnLoadPkgExternalHandler(url);
        }
    }
Exemplo n.º 24
0
    public void ParseData()
    {
        string       path   = "Assets/Resources/WorldData.py";
        StreamWriter writer = new StreamWriter(path, true);

        GridLayoutGroup glg = GridLayout.GetComponentInChildren <GridLayoutGroup> ();

        Button[] glgButtons = glg.GetComponentsInChildren <Button> ();

        //int colorIndex = 0;
        int lindex = 0;

        foreach (Button bObj in glgButtons)
        {
            WorldLocation objectScript = bObj.GetComponent <WorldLocation> ();

            bool canGoNorth = objectScript.bNorth;
            bool canGoEast  = objectScript.bEast;
            bool canGoWest  = objectScript.bWest;
            bool canGoSouth = objectScript.bSouth;

            TextMeshProUGUI description         = objectScript.description;
            TextMeshProUGUI short_description   = objectScript.short_description;
            TextMeshProUGUI secrete_description = objectScript.secrete_description;

            string descrip        = description.text;
            string descripShort   = short_description.text;
            string descripSecrete = secrete_description.text;

            WorldLocation.EnviroHazardLevel hazardLevel = objectScript.hazardLevel;
            string hazard = hazardLevel.ToString();

            int area = objectScript.area;

            string northString = "Blocked";
            string eastString  = "Blocked";
            string westString  = "Blocked";
            string southString = "Blocked";

            if (canGoNorth == true)
            {
                int areaNum = area - 6;
                northString = "area" + areaNum;
            }

            if (canGoEast == true)
            {
                int areaNum = area + 1;
                eastString = "area" + areaNum;
            }

            if (canGoWest == true)
            {
                int areaNum = area - 1;
                westString = "area" + areaNum;
            }

            if (canGoSouth == true)
            {
                int areaNum = area + 6;
                southString = "area" + areaNum;
            }


            writer.WriteLine("Location" + lindex.ToString() + " = {\'north\': \'" + northString + "\'" +
                             ", \'east\': \'" + eastString + "\'" +
                             ", \'west\': \'" + westString + "\'" +
                             ", \'south\': \'" + southString + "\'" +
                             ", \'description\': \'" + descrip + "\'" +
                             ", \'short_description\': \'" + descripShort + "\'" +
                             ", \'secrete_description\': \'" + descripSecrete + "\'" +
                             ", \'hazard_level\': \'" + hazard + "\'" +
                             "}");



            lindex++;
        }

        //add two spaces
        writer.WriteLine(" ");
        writer.WriteLine(" ");


        writer.WriteLine("WorldLocations = {" +
                         "\'area0\': Location0, " +
                         "\'area1\': Location1, " +
                         "\'area2\': Location2, " +
                         "\'area3\': Location3, " +
                         "\'area4\': Location4, " +
                         "\'area5\': Location5, " +
                         "\'area6\': Location6, " +
                         "\'area7\': Location7, " +
                         "\'area8\': Location8, " +
                         "\'area9\': Location9, " +
                         "\'area10\': Location10, " +
                         "\'area11\': Location11, " +
                         "\'area12\': Location12, " +
                         "\'area13\': Location13, " +
                         "\'area14\': Location14, " +
                         "\'area15\': Location15, " +
                         "\'area16\': Location16, " +
                         "\'area17\': Location17, " +
                         "\'area18\': Location18, " +
                         "\'area19\': Location19, " +
                         "\'area20\': Location20, " +
                         "\'area21\': Location21, " +
                         "\'area22\': Location22, " +
                         "\'area23\': Location23, " +
                         "\'area24\': Location24, " +
                         "\'area25\': Location25, " +
                         "\'area26\': Location26, " +
                         "\'area27\': Location27, " +
                         "\'area28\': Location28, " +
                         "\'area29\': Location29, " +
                         "\'area30\': Location30, " +
                         "\'area31\': Location31, " +
                         "\'area32\': Location32, " +
                         "\'area33\': Location33, " +
                         "\'area34\': Location34, " +
                         "\'area35\': Location35, " +
                         "}");


        writer.Close();

        //needed?
        //AssetDatabase.ImportAsset(path);
        //TextAsset asset = (TextAsset)Resources.Load("WorldData.py");
    }
Exemplo n.º 25
0
    void Show(InventoryTabType tab = InventoryTabType.Battle, HeroSlotState state = HeroSlotState.Inventory)
    {
        currentHeroSlotState = state;
        sortToggle.isOn      = false;
        SortingTypeButtonPanel.SetActive(sortToggle.isOn);

        //slotBG.offsetMin = new Vector2(slotBG.offsetMin.x, -0.25f);
        //slotBG.offsetMax = new Vector2(slotBG.offsetMax.x, 0);

        if (!sortToggle.gameObject.activeSelf)
        {
            sortToggle.gameObject.SetActive(true);
        }

        if (coroutineShow != null)
        {
            return;
        }

        if (state == HeroSlotState.Territory || state == HeroSlotState.Training)
        {
            sortBehavior.SortHeroList(HeroSortingType.Auto, state);
        }
        else
        {
            sortBehavior.SortHeroList(currentSortType, HeroSlotState.Inventory);
        }

        if (tab == InventoryTabType.Battle)
        {
            toggleTown.isOn   = false;
            toggleBattle.isOn = true;// Select();
            heroInventoryScrollViewContent.gameObject.SetActive(true);
            territoryheroInventoryScrollViewContent.gameObject.SetActive(false);
            UIHeroSlotContainer[] temp = heroInventoryScrollViewContent.GetComponentsInChildren <UIHeroSlotContainer>();

            if (temp.Length > 0)
            {
                notHeroText.gameObject.SetActive(false);
            }
            else
            {
                notHeroText.gameObject.SetActive(true);
            }
        }
        else
        {
            toggleTown.isOn   = true;//Select();
            toggleBattle.isOn = false;
            heroInventoryScrollViewContent.gameObject.SetActive(false);
            territoryheroInventoryScrollViewContent.gameObject.SetActive(true);
            UIHeroSlotContainer[] temp = territoryheroInventoryScrollViewContent.GetComponentsInChildren <UIHeroSlotContainer>();

            if (temp.Length > 0)
            {
                notHeroText.gameObject.SetActive(false);
            }
            else
            {
                notHeroText.gameObject.SetActive(true);
            }
        }

        coroutineShow = StartCoroutine(ShowA(tab, state));
    }
Exemplo n.º 26
0
    private void Awake()
    {
        next.onClick.AddListener(Next);
        previous.onClick.AddListener(Previous);
        EventListener.Get(gameObject).onExit  += e => { StartCoroutine(CarouselImage()); };
        EventListener.Get(gameObject).onEnter += e => { isCarouseling = false; };

        #region 初始化轮播
        if (isCarousel)
        {
            wait = new WaitForSeconds(carouselSpeed);
            StartCoroutine(CarouselImage());
        }
        #endregion

        #region 初始化索引按钮
        if (selectIndex != null)
        {
            for (int i = 0; i < selectIndex.Length; i++)
            {
                var Index = i;
                selectIndex[i].onClick.AddListener(() => { SetIndex(Index); });
            }
        }
        #endregion

        #region 初始化grid
        gridTransform       = (RectTransform)grid.transform;
        gridTransform.pivot = new Vector2(0, 1);
        size          = ((RectTransform)transform).sizeDelta;
        grid.cellSize = size;
        #endregion

        #region 初始化图片事件
        images   = grid.GetComponentsInChildren <Image>();
        maxIndex = images.Length;

        for (int i = 0; i < images.Length; i++)
        {
            var index = i;
            EventListener.Get(images[i].gameObject).onClick += e => {
                IndexClick.Invoke(index);
            };
        }
        #endregion
        #region  制最后一个和第一个
        var go = Instantiate(images[images.Length - 1]).transform;
        go.SetParent(gridTransform);
        go.SetAsFirstSibling();
        EventListener.Get(go.gameObject).onClick += e => {
            IndexClick.Invoke(images.Length - 1);
        };

        go = Instantiate(images[0]).transform;
        go.SetParent(gridTransform);
        EventListener.Get(go.gameObject).onClick += e => {
            IndexClick.Invoke(0);
        };
        #endregion

        #region 设置图片
        if (isHorizontal)
        {
            gridTransform.sizeDelta = new Vector2(size.x * (images.Length + 2), size.y);
            size = gridTransform.anchoredPosition = new Vector2(-size.x, 0);
        }
        else
        {
            gridTransform.sizeDelta = new Vector2(size.x, size.y * (images.Length + 2));
            size = gridTransform.anchoredPosition = new Vector2(0, size.y);
        }
        #endregion
    }