Exemple #1
0
 void reset()
 {
     AutoDestroy.destroyChildren(PlayPanel.Instance.Tutorial);
     PlayPanel.Instance.Tutorial.SetActive(false);
     Time.timeScale = PlayerInfo.Instance.userInfo.timeScale;
     isEnable       = false;
 }
    public void loadEnemy()
    {
        AutoDestroy.destroyChildren(selectedRegionPanel);
        infoTower.gameObject.SetActive(false);
        infoEnemy.gameObject.SetActive(true);

        guideType = UIGuideButton.ENEMY;

        target = null;

        //set grid
        UIGrid grid = selectedRegionPanel.GetComponent <UIGrid>();

        grid.maxPerLine    = PlayConfig.GridGuideEnemy.MaxPerLine;
        grid.cellWidth     = PlayConfig.GridGuideEnemy.CellWidth;
        grid.cellHeight    = PlayConfig.GridGuideEnemy.CellHeight;
        grid.enabled       = true;
        grid.repositionNow = true;

        EnemyController enemyController = Resources.Load <GameObject>("Prefab/Enemy/Enemy").GetComponent <EnemyController>();

        int length = enemies.Length;

        foreach (System.Collections.Generic.KeyValuePair <string, EnemyData> iterator in ReadDatabase.Instance.EnemyInfo)
        {
            GameSupportor.transferEnemyData(enemyController, iterator.Value);

            GameObject enemyGuide = Instantiate(PlayManager.Instance.modelPlay.EnemyGuide) as GameObject;
            enemyGuide.transform.parent = selectedRegionPanel.transform;
            enemyGuide.name             = enemyController.name;

            enemyGuide.GetComponent <UIStretch>().container = selectedRegionPanel;

            EnemyGuideController controller = enemyGuide.GetComponent <EnemyGuideController>();
            controller.ID      = enemyController.ID;
            controller.visible = PlayerInfo.Instance.listEnemy[enemyController.ID];

            //set icon
            if (controller.visible)
            {
                controller.Icon.mainTexture = Resources.Load <Texture>("Image/Enemy/00 Guide Icon/" + enemyController.ID.ToLower());
            }

            if (target == null && controller.visible)
            {
                target = enemyGuide;
            }
        }
        if (target != null)
        {
            target.GetComponent <EnemyGuideController>().setColor(true);
        }

        loadEnemyInfo();
    }
    void initAchievement()
    {
        AutoDestroy.destroyChildren(tempAchievement, "Collider Drag", "Scroll Bar");

        int i = 0;

        foreach (System.Collections.Generic.KeyValuePair <int, AchievementData> iterator in ReadDatabase.Instance.AchievementInfo)
        {
            GameObject achievement = Instantiate(LevelManager.Instance.Model.Achievement) as GameObject;
            achievement.transform.parent     = tempAchievement.transform;
            achievement.transform.localScale = Vector3.one;

            //Anchor
            UIAnchor uiAnchor = achievement.GetComponent <UIAnchor>();
            uiAnchor.container      = tempAchievement;
            uiAnchor.relativeOffset = new Vector2(LevelConfig.AnchorAchievementX,
                                                  LevelConfig.AnchorAchievementY - i * LevelConfig.AnchorAchievementDistanceY);

            //Stretch
            achievement.GetComponent <UIStretch>().container = tempAchievement;

            //Drag object
            achievement.GetComponent <UIDragScrollView>().scrollView = tempAchievement.GetComponent <UIScrollView>();

            AchievementController controller = achievement.GetComponent <AchievementController>();
            controller.spriteIcon.spriteName = iterator.Value.Icon;
            controller.labelName.text        = iterator.Value.Name;
            controller.labelSub.text         = LevelConfig.getAchievementTextValue(iterator.Key, iterator.Value,
                                                                                   PlayerInfo.Instance.listAchievement[iterator.Key]);
            controller.labelReward.text = iterator.Value.RewardAmount.ToString();
            controller.completeIcon.SetActive(false);

            checkAchievement(controller, iterator.Key, iterator.Value, PlayerInfo.Instance.listAchievement[iterator.Key]);

            i++;
        }
    }
    void initalize()
    {
        #region DRAGON ITEM
        AutoDestroy.destroyChildren(tempListDragonItem, null);
        //Debug.Log(ReadDatabase.Instance.DragonItemInfo.Count);
        int        i = 0;
        GameObject DragonItemBefore = null;
        float      rowItemBefore    = 0f;
        #region Code cũ
        foreach (System.Collections.Generic.KeyValuePair <string, DragonItemData> iterator in ReadDatabase.Instance.DragonInfo.Item)
        {
            GameObject dragonItem = Instantiate(Resources.Load <GameObject>("Prefab/Level/Dragon Item")) as GameObject;
            dragonItem.transform.parent     = tempListDragonItem.transform;
            dragonItem.transform.localScale = Vector3.one;

            //set ID
            dragonItem.GetComponent <DragonItemsController>().ID = iterator.Key;

            //lay du lieu bonus tu item
            string bonusText = "";
            //int OptionInRow = 0; // 2 se xuong dong
            float row = 0f;

            for (int j = 0; j < iterator.Value.Options.Length; j++)
            {
                if (iterator.Value.Options[j] > 0)
                {
                    bonusText += DragonItemData.nameOptions[j] + "+" + iterator.Value.Options[j].ToString();

                    bonusText += "\n";
                    row++;
                }
            }
            bonusText = bonusText.Substring(0, bonusText.Length - 1); // bo /n cuoi cung, do hon xet if trong vong lap

            //Anchor
            UIAnchor uiAnchor = dragonItem.GetComponent <UIAnchor>();

            //Stretch
            UIStretch uiStretch = dragonItem.GetComponent <UIStretch>();

            if (i == 0) // Phan tu dau neo theo cha
            {
                uiAnchor.container     = tempListDragonItem;
                uiStretch.container    = tempListDragonItem;
                uiStretch.relativeSize = new Vector2(uiStretch.relativeSize.x, row / 10);
                dragonItem.GetComponent <UIDragScrollView>().scrollView = tempListDragonItem.GetComponent <UIScrollView>();
            }
            else // cac phan tu sau noi duoi voi nhau
            {
                uiAnchor.container        = DragonItemBefore;
                uiAnchor.relativeOffset.y = -0.52f;
                uiAnchor.side             = UIAnchor.Side.Center;
                //  dragonItem.GetComponent<UIWidget>().pivot = UIWidget.Pivot.Top;


                uiStretch.container    = DragonItemBefore;
                uiStretch.relativeSize = new Vector2(uiStretch.relativeSize.x, row / rowItemBefore);
                dragonItem.GetComponent <UIDragScrollView>().scrollView = DragonItemBefore.GetComponent <UIScrollView>();
            }


            #endregion

            #region code thu nghiem
            //foreach (System.Collections.Generic.KeyValuePair<int, DragonItemData> iterator in ReadDatabase.Instance.DragonItemInfo)
            //{

            //    GameObject dragonItem = Instantiate(LevelManager.Instance.Model.DragonItem) as GameObject;
            //    dragonItem.transform.parent = tempListDragonItem.transform;
            //    dragonItem.transform.localScale = Vector3.one;

            //    //lay du lieu bonus tu item
            //    string bonusText = "";
            //    //int OptionInRow = 0; // 2 se xuong dong
            //    float row = 0f;

            //    for (int j = 0; j < iterator.Value.Options.Length; j++)
            //    {
            //        if (iterator.Value.Options[j] > 0)
            //        {
            //            bonusText += DragonItemData.nameOptions[j] + "+" + iterator.Value.Options[j].ToString();

            //            bonusText += "\n";
            //            row++;
            //        }
            //    }
            //    bonusText  = bonusText.Substring(0,bonusText.Length - 2); // bo /n cuoi cung, do hon xet if trong vong lap

            //    //Stretch
            //    UIStretch uiStretch =  dragonItem.GetComponent<UIStretch>();



            //    uiStretch.container = tempListDragonItem;
            //    uiStretch.relativeSize = new Vector2(uiStretch.relativeSize.x, row / 10);
            //    dragonItem.GetComponent<UIDragScrollView>().scrollView = tempListDragonItem.GetComponent<UIScrollView>();
            //    float currentPosY = 0f;
            //    if (i == 0)
            //        currentPosY = dragonItem.GetComponentInParent<UIPanel>().height / 2 - dragonItem.GetComponent<UIWidget>().height / 2;
            //    else
            //        currentPosY = beforePositionY - dragonItem.GetComponent<UIWidget>().height / 2;

            //    dragonItem.transform.localPosition = new Vector3(0, currentPosY, 0);
            //    Debug.Log(dragonItem.transform.localPosition);
            #endregion
            switch (iterator.Value.Name.Substring(iterator.Value.Name.LastIndexOf(' ') + 1))
            {
            case "Head":
                dragonItem.GetComponent <UIDragonItems>().dragonItemType = DragonItemType.Head;
                break;

            case "Body":
                dragonItem.GetComponent <UIDragonItems>().dragonItemType = DragonItemType.Body;
                break;

            case "Ring":
                dragonItem.GetComponent <UIDragonItems>().dragonItemType = DragonItemType.Ring;
                break;

            case "Amulet":
                dragonItem.GetComponent <UIDragonItems>().dragonItemType = DragonItemType.Amulet;
                break;

            case "Wing":
                dragonItem.GetComponent <UIDragonItems>().dragonItemType = DragonItemType.Wing;
                break;

            case "Rune":
                dragonItem.GetComponent <UIDragonItems>().dragonItemType = DragonItemType.Rune;
                break;
            }

            dragonItem.transform.GetChild(0).gameObject.GetComponent <UILabel>().text        = iterator.Value.Name;
            dragonItem.transform.GetChild(1).gameObject.GetComponent <UILabel>().text        = bonusText;
            dragonItem.transform.GetChild(2).gameObject.GetComponent <UISprite>().spriteName = iterator.Value.Icon;

            dragonItem.SetActive(true);
            DragonItemBefore = dragonItem;
            rowItemBefore    = row;

            listItems.Add(iterator.Key, dragonItem);

            i++;
        }
        #endregion

        #region LOAD DATABASE
        string dataHead   = PlayerInfo.Instance.dragonInfo.itemHead;
        string dataWing   = PlayerInfo.Instance.dragonInfo.itemWing;
        string dataRing   = PlayerInfo.Instance.dragonInfo.itemRing;
        string dataAmulet = PlayerInfo.Instance.dragonInfo.itemAmulet;
        string dataBody   = PlayerInfo.Instance.dragonInfo.itemBody;
        string dataRune   = PlayerInfo.Instance.dragonInfo.itemRune;

        if (!dataHead.Equals(""))
        {
            GameObject item = listItems[dataHead];
            item.GetComponent <UIDragonItems>().EquipItem();
        }
        if (!dataWing.Equals(""))
        {
            GameObject item = listItems[dataWing];
            item.GetComponent <UIDragonItems>().EquipItem();
        }
        if (!dataRing.Equals(""))
        {
            GameObject item = listItems[dataRing];
            item.GetComponent <UIDragonItems>().EquipItem();
        }
        if (!dataAmulet.Equals(""))
        {
            GameObject item = listItems[dataAmulet];
            item.GetComponent <UIDragonItems>().EquipItem();
        }
        if (!dataBody.Equals(""))
        {
            GameObject item = listItems[dataBody];
            item.GetComponent <UIDragonItems>().EquipItem();
        }
        if (!dataRune.Equals(""))
        {
            GameObject item = listItems[dataRune];
            item.GetComponent <UIDragonItems>().EquipItem();
        }
        #endregion
    }
Exemple #5
0
    public void loadInfoItem()
    {
        if (target != null)
        {
            AutoDestroy.destroyChildren(infoPanel, PlayNameHashIDs.Collider);

            //active tower name
            if (!labelTowerName.gameObject.activeSelf)
            {
                labelTowerName.gameObject.SetActive(true);
            }

            ItemShopController targetController = target.GetComponent <ItemShopController>();
            labelTowerName.text = targetController.MainName;

            //Set name color
            labelTowerName.color       = PlayConfig.ColorShopItemName;
            labelTowerName.effectColor = PlayConfig.ColorShopItemNameOutline;

            GameObject info = Instantiate(itemShopInfoModel) as GameObject;
            info.transform.parent     = infoPanel.transform;
            info.transform.localScale = Vector3.one;

            info.GetComponent <UIAnchor>().container  = infoPanel.gameObject;
            info.GetComponent <UIStretch>().container = infoPanel.gameObject;

            //Set value
            ItemShopInfoController infoController = info.GetComponent <ItemShopInfoController>();
            infoController.icon.spriteName = targetController.icon.spriteName;
            infoController.value.text      = targetController.Value.text;

            //set icon fix size
            infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
            infoController.icon.SetDimensions(infoController.icon.mainTexture.width, infoController.icon.mainTexture.height);
            infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

            //set package
            ItemData itemData = ReadDatabase.Instance.ItemInfo[targetController.ID];
            int      length   = itemData.Packages.Count;

            for (int i = 0; i < length; i++)
            {
                ItemPackage itemPackage = (ItemPackage)itemData.Packages[i];
                ItemShopPackageController packageController = infoController.packages[i].GetComponent <ItemShopPackageController>();

                packageController.labelDiamond.text = itemPackage.Diamond.ToString();
                packageController.labelGold.text    = itemPackage.Gold.ToString();

                int result = -1;
                if (int.TryParse(itemPackage.Wave, out result))
                {
                    if (result <= 1)
                    {
                        packageController.labelDuration.text = "Duration: " + result + " wave";
                    }
                    else
                    {
                        packageController.labelDuration.text = "Duration: " + result + " waves";
                    }
                }
                else
                {
                    if (itemPackage.Wave.Equals("Half"))
                    {
                        packageController.labelDuration.text = "Duration: " + WaveController.Instance.infoMap.WaveLength / 2 + " waves";
                    }
                    else if (itemPackage.Wave.Equals("Full"))
                    {
                        packageController.labelDuration.text = "Duration: all waves";
                    }
                }
            }
        }
    }
Exemple #6
0
    public void loadItem()
    {
        if (shopType == EShopType.ITEM)
        {
            return;
        }

        shopType = EShopType.ITEM;
        target   = null;

        AutoDestroy.destroyChildren(towerPanel, PlayNameHashIDs.Collider);
        towerPanel.transform.localPosition = Vector3.zero;
        towerPanel.GetComponent <UIPanel> ().clipOffset = Vector2.zero;

        setSpriteButton(EShopType.ITEM);

        int i = 0;

        foreach (System.Collections.Generic.KeyValuePair <string, ItemData> item in ReadDatabase.Instance.ItemInfo)
        {
            GameObject _itemShop = Instantiate(itemShopModel) as GameObject;
            _itemShop.transform.parent     = towerPanel.transform;
            _itemShop.transform.localScale = Vector3.one;

            UIAnchor anchor = _itemShop.GetComponent <UIAnchor>();
            anchor.container      = towerPanel.gameObject;
            anchor.relativeOffset = new Vector2(PlayConfig.TowerShopAnchor.PanelAnchorStart + i * PlayConfig.TowerShopAnchor.PanelAnchorDistance, 0);

            ItemShopController itemShopController = _itemShop.GetComponent <ItemShopController>();
            itemShopController.ID        = item.Key;
            itemShopController.ItemState = ItemManager.getItemState(item.Key);

            //set name
            string[] arr      = item.Value.Name.Split('-');
            string   text     = "";
            string   mainName = "";
            for (int k = 0; k < arr.Length; k++)
            {
                text     += arr[k];
                mainName += arr[k] + " ";
                if (k + 1 < arr.Length)
                {
                    text += "\n";
                }
            }
            text     = text.Trim();
            mainName = mainName.Trim();

            itemShopController.Name.text = text;
            itemShopController.MainName  = mainName;

            //set text value
            itemShopController.Value.text = item.Value.ValueText;

            //set background stretch
            foreach (Transform child in _itemShop.transform)
            {
                if (child.name == "Background")
                {
                    child.GetComponent <UIStretch>().container = towerPanel;
                    break;
                }
            }

            //set icon
            itemShopController.icon.spriteName = "item-" + item.Key.ToLower();
            itemShopController.setColor(false);

            itemShopController.icon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
            itemShopController.icon.SetDimensions(itemShopController.icon.mainTexture.width, itemShopController.icon.mainTexture.height);
            itemShopController.icon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

            UIStretch uiStretch = itemShopController.icon.GetComponent <UIStretch>();
            uiStretch.enabled = true;

            if (target == null)
            {
                target = _itemShop;
            }

            i++;
        }
        if (target != null)
        {
            target.GetComponentInChildren <ItemShopController>().setColor(true);
        }

        loadInfoItem();
    }
Exemple #7
0
    public void loadInfoTower()
    {
        if (target != null)
        {
            AutoDestroy.destroyChildren(infoPanel, PlayNameHashIDs.Collider);

            //active tower name
            if (!labelTowerName.gameObject.activeSelf)
            {
                labelTowerName.gameObject.SetActive(true);
            }

            TowerShopController targetController = target.GetComponent <TowerShopController>();
            labelTowerName.text = targetController.Name.text.ToUpper() + " TOWER";

            //Set towe name color
            Color[] nameColor = PlayConfig.getColorTowerName(targetController.ID);
            labelTowerName.color       = nameColor[0];
            labelTowerName.effectColor = nameColor[1];

            STowerID towerID = targetController.ID;

            GameObject[] towers = ObjectManager.Instance.Towers;
            int          length = towers.Length;
            int          count  = 0;

            for (int i = 0; i < length; i++)
            {
                TowerController towerController = towers[i].GetComponent <TowerController>();

                if (towerController.ID.Type == towerID.Type && towerController.ID.Level == towerID.Level)
                {
                    while (true)
                    {
                        GameObject info = Instantiate(towerInfoModel) as GameObject;
                        info.transform.parent     = infoPanel.transform;
                        info.transform.localScale = Vector3.one;
                        info.name = towerController.name;

                        UIAnchor anchor = info.GetComponent <UIAnchor>();
                        anchor.container      = infoPanel.gameObject;
                        anchor.relativeOffset = new Vector2(0, PlayConfig.InfoShopAnchor.PanelAnchorStart - count * PlayConfig.InfoShopAnchor.PanelAnchorDistance);

                        #region TOWER
                        TowerShopInfoController infoController = info.GetComponent <TowerShopInfoController>();
                        infoController.icon.mainTexture = Resources.Load <Texture>(PlayConfig.getTowerIcon(towerID));
                        infoController.level.text       = "Level " + ((int)towerID.Level).ToString();
                        infoController.atk.text         = towerController.attribute.MinATK.ToString() + " - " + towerController.attribute.MaxATK.ToString();
                        infoController.spawnShoot.text  = towerController.attribute.SpawnShoot.ToString();
                        infoController.timeBuild.text   = towerController.attribute.TimeBuild.ToString();

                        //Bullet label
                        string[] str = PlayConfig.getBulletType(towerController.attackType.ToString());
                        infoController.bulletAbility.text = str[0] + " TARGET";
                        infoController.bulletRegion.text  = str[1];

                        //set icon fix size
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        Vector2 localSize = new Vector2(infoController.icon.mainTexture.width, infoController.icon.mainTexture.height);
                        infoController.icon.SetDimensions((int)localSize.x, (int)localSize.y);
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch uiStretch = infoController.icon.GetComponent <UIStretch>();
                        uiStretch.enabled = true;
                        #endregion

                        #region BULLET
                        object[] bulletData = PlayConfig.getBulletShop(towerID);
                        infoController.bulletIcon.mainTexture = Resources.Load <Texture>("Image/Bullet/Bullet Icon/" + bulletData[0].ToString());

                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        infoController.bulletIcon.SetDimensions(infoController.bulletIcon.mainTexture.width, infoController.bulletIcon.mainTexture.height);
                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch stretch = infoController.bulletIcon.GetComponent <UIStretch>();
                        stretch.relativeSize.y = (float)bulletData[1];
                        stretch.enabled        = true;

                        //Add effect
                        infoController.bullet = towerController.bullet;
                        #endregion

                        count++;

                        //get Next Tower
                        if (towerController.nextLevel != null)
                        {
                            towerID         = towerController.nextLevel.GetComponent <TowerController>().ID;
                            towerController = towerController.nextLevel;
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
Exemple #8
0
    public void loadTower()
    {
        if (shopType == EShopType.TOWER)
        {
            return;
        }

        shopType = EShopType.TOWER;
        target   = null;

        AutoDestroy.destroyChildren(towerPanel, PlayNameHashIDs.Collider);
        towerPanel.transform.localPosition = Vector3.zero;
        towerPanel.GetComponent <UIPanel> ().clipOffset = Vector2.zero;

        setSpriteButton(EShopType.TOWER);

        int length = ObjectManager.Instance.Towers.Length;

        for (int i = 0; i < length; i++)
        {
            TowerController currentTower = ObjectManager.Instance.Towers[i].GetComponent <TowerController>();

            GameObject _towerShop = Instantiate(towerShopModel) as GameObject;
            _towerShop.transform.parent     = towerPanel.transform;
            _towerShop.transform.localScale = Vector3.one;
            _towerShop.name = currentTower.name;

            UIAnchor anchor = _towerShop.GetComponent <UIAnchor>();
            anchor.container      = towerPanel.gameObject;
            anchor.relativeOffset = new Vector2(PlayConfig.TowerShopAnchor.PanelAnchorStart + i * PlayConfig.TowerShopAnchor.PanelAnchorDistance, 0);

            TowerShopController towerShopController = _towerShop.GetComponent <TowerShopController>();
            towerShopController.Index     = i;
            towerShopController.ID        = currentTower.ID;
            towerShopController.Name.text = currentTower.attribute.Name.Split()[0];

            //set background stretch
            foreach (Transform child in _towerShop.transform)
            {
                if (child.name == "Background")
                {
                    child.GetComponent <UIStretch>().container = towerPanel;
                    break;
                }
            }

            //set diamond and gold
            STowerCost cost = ReadDatabase.Instance.TowerCostInfo[towerShopController.ID.Type.ToString()];
            towerShopController.Money   = cost.Gold;
            towerShopController.Diamond = cost.Diamond;

            string s = GameConfig.PathTowerIcon + currentTower.ID.Type.ToString() + "-" + currentTower.ID.Level;

            towerShopController.icon.mainTexture = Resources.Load <Texture>(s);
            towerShopController.setColor(false);

            towerShopController.icon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
            Vector2 localSize = new Vector2(towerShopController.icon.mainTexture.width, towerShopController.icon.mainTexture.height);
            towerShopController.icon.SetDimensions((int)localSize.x, (int)localSize.y);
            towerShopController.icon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

            UIStretch uiStretch = towerShopController.icon.GetComponent <UIStretch>();
            uiStretch.enabled = true;

            if (target == null)
            {
                target = _towerShop;
            }

            if (!initWhenStart)
            {
                towerShopType[i] = WaveController.Instance.infoMap.TowerUsed.ToUpper().Contains(currentTower.ID.Type.ToString()) ? ETowerShopState.TOWER_BUY_DEFAULT : ETowerShopState.TOWER_BUY_ENABLE;
            }

            _towerShop.GetComponentInChildren <UITowerShop>().type = towerShopType[i];
        }
        if (target != null)
        {
            target.GetComponentInChildren <TowerShopController>().setColor(true);
        }

        loadInfoTower();

        if (!initWhenStart)
        {
            initWhenStart = true;
        }
    }
    void initalize()
    {
        #region Enemy
        AutoDestroy.destroyChildren(tempListEnemyShop, null);
        //Debug.Log(ReadDatabase.Instance.DragonItemInfo.Count);
        int i = 0;

        GameObject EnemyBefore   = null;
        float      rowItemBefore = 0f;

        #region Code cũ
        foreach (System.Collections.Generic.KeyValuePair <string, EnemyData> iterator in ReadDatabase.Instance.EnemyInfo)
        {
            GameObject enemyObj = Instantiate(Resources.Load <GameObject>("Prefab/Bluetooth/Enemy Bluetooth")) as GameObject;
            enemyObj.transform.parent     = tempListEnemyShop.transform;
            enemyObj.transform.localScale = Vector3.one;

            //set ID
            enemyObj.GetComponent <EnemyBluetoothController>().ID = iterator.Key;



            //Anchor
            UIAnchor uiAnchor = enemyObj.GetComponent <UIAnchor>();

            //Stretch
            UIStretch uiStretch = enemyObj.GetComponent <UIStretch>();

            if (i == 0)             // Phan tu dau neo theo cha
            {
                uiAnchor.container  = tempListEnemyShop;
                uiStretch.container = tempListEnemyShop;

                enemyObj.GetComponent <UIDragScrollView>().scrollView = tempListEnemyShop.GetComponent <UIScrollView>();
            }
            else             // cac phan tu sau noi duoi voi nhau
            {
                uiAnchor.container        = EnemyBefore;
                uiAnchor.relativeOffset.y = -0.52f;
                uiAnchor.side             = UIAnchor.Side.Center;
                //  dragonItem.GetComponent<UIWidget>().pivot = UIWidget.Pivot.Top;


                uiStretch.container    = EnemyBefore;
                uiStretch.relativeSize = Vector2.one;
                enemyObj.GetComponent <UIDragScrollView>().scrollView = tempListEnemyShop.GetComponent <UIScrollView>();
            }


            #endregion



            enemyObj.transform.GetChild(0).gameObject.GetComponent <UILabel>().text = iterator.Value.Name;
            //	enemyObj.transform.GetChild(1).gameObject.GetComponent<UILabel>().text = bonusText;

            enemyObj.transform.GetChild(1).gameObject.GetComponent <UITexture>().mainTexture = Resources.Load <Texture>("Image/Enemy/00 Guide Icon/" + iterator.Value.Name.ToLower());
            Transform info = enemyObj.transform.GetChild(2).gameObject.transform;
            info.GetChild(0).gameObject.GetComponentInChildren <UILabel>().text = iterator.Value.HP.ToString();
            info.GetChild(1).gameObject.GetComponentInChildren <UILabel>().text = iterator.Value.DEF.ToString();
            info.GetChild(2).gameObject.GetComponentInChildren <UILabel>().text = iterator.Value.Coin.ToString();
            info.GetChild(3).gameObject.GetComponentInChildren <UILabel>().text = iterator.Value.Region.ToString();
            info.GetChild(4).gameObject.GetComponentInChildren <UILabel>().text = iterator.Value.Speed.ToString();

            enemyObj.SetActive(true);
            EnemyBefore = enemyObj;
            //	rowItemBefore = row;

            listItems.Add(iterator.Key, enemyObj);

            i++;
        }

        tempListEnemyShop.GetComponent <UIPanel>().clipOffset = Vector2.one;
        #endregion
    }
    public void loadTower()
    {
        AutoDestroy.destroyChildren(selectedRegionPanel);

        infoTower.gameObject.SetActive(true);
        infoEnemy.gameObject.SetActive(false);

        target    = null;
        guideType = UIGuideButton.TOWER;

        //set grid
        UIGrid grid = selectedRegionPanel.GetComponent <UIGrid>();

        grid.maxPerLine    = PlayConfig.GridGuideTower.MaxPerLine;
        grid.cellWidth     = PlayConfig.GridGuideTower.CellWidth;
        grid.cellHeight    = PlayConfig.GridGuideTower.CellHeight;
        grid.enabled       = true;
        grid.repositionNow = true;

        int length = ObjectManager.Instance.Towers.Length;

        for (int i = 0; i < length; i++)
        {
            TowerController towerController = ObjectManager.Instance.Towers[i].GetComponent <TowerController>();

            GameObject towerGuide = Instantiate(PlayManager.Instance.modelPlay.TowerGuide) as GameObject;
            towerGuide.transform.parent = selectedRegionPanel.transform;

            towerGuide.GetComponent <UIStretch>().container = selectedRegionPanel;
            towerGuide.GetComponentInChildren <TowerGuideController>().ID = towerController.ID;

            //Set icon
            towerGuide.GetComponent <UISprite>().spriteName = "tower-info-" + towerController.ID.Type.ToString().ToLower();
            towerGuide.name = towerController.ID.Type.ToString();

            //Set name

            string name = towerController.ID.Type.ToString();

            UILabel label = towerGuide.GetComponentInChildren <UILabel>();
            label.text = name[0] + name.Substring(1, name.Length - 1).ToLower();

            //Set color
            Color[] colors = PlayConfig.getColorTowerName(towerController.ID);
            label.color       = colors[0];
            label.effectColor = colors[1];

            if (target == null)
            {
                target = towerGuide;
            }
        }
        if (target != null)
        {
            target.GetComponentInChildren <TowerGuideController>().setColor(true);
        }

        loadTowerInfo();



        length = ObjectManager.Instance.TowersPassive.Length;
        for (int i = 0; i < length; i++)
        {
            TowerPassiveController towerController = ObjectManager.Instance.TowersPassive[i].GetComponent <TowerPassiveController>();

            GameObject towerGuide = Instantiate(PlayManager.Instance.modelPlay.TowerGuide) as GameObject;
            towerGuide.transform.parent = selectedRegionPanel.transform;

            towerGuide.GetComponent <UIStretch>().container = selectedRegionPanel;
            towerGuide.GetComponentInChildren <TowerGuideController>().ID = towerController.ID;


            //Set icon
            towerGuide.GetComponent <UISprite>().spriteName = "tower-info-" + towerController.ID.Type.ToString().ToLower();
            towerGuide.name = towerController.ID.Type.ToString();

            //Set name

            string name = towerController.ID.Type.ToString();

            UILabel label = towerGuide.GetComponentInChildren <UILabel>();
            label.text = name[0] + name.Substring(1, name.Length - 1).ToLower();

            //Set color
            Color[] colors = PlayConfig.getColorTowerName(towerController.ID);
            label.color       = colors[0];
            label.effectColor = colors[1];

            if (target == null)
            {
                target = towerGuide;
            }
        }
        if (target != null)
        {
            target.GetComponentInChildren <TowerGuideController>().setColor(true);
        }

        loadTowerPassiveInfo();
    }
    public void loadTowerInfo()
    {
        ;
        if (target != null)
        {
            AutoDestroy.destroyChildren(infoTower, "Level");

            //clear array
            listTower.Clear();

            //active tower name
            if (!infoName.gameObject.activeSelf)
            {
                infoName.gameObject.SetActive(true);
            }

            TowerGuideController targetController = target.GetComponentInChildren <TowerGuideController>();
            string name = targetController.ID.Type.ToString();
            infoName.text = name[0] + name.Substring(1, name.Length - 1).ToLower() + " LV " + targetController.ID.Level;

            //Set towe name color
            Color[] nameColor = PlayConfig.getColorTowerName(targetController.ID);
            infoName.color       = nameColor[0];
            infoName.effectColor = nameColor[1];

            STowerID towerID = targetController.ID;

            GameObject[] towers = ObjectManager.Instance.Towers;
            int          length = towers.Length;
            int          count  = 0;
            for (int i = 0; i < length; i++)
            {
                TowerController towerController = towers[i].GetComponent <TowerController>();
                if (towerController.ID.Type == towerID.Type && towerController.ID.Level == towerID.Level)
                {
                    while (true)
                    {
                        GameObject info = Instantiate(PlayManager.Instance.modelPlay.TowerGuideInfo) as GameObject;
                        info.transform.parent     = infoTower.transform;
                        info.transform.localScale = Vector3.one;
                        info.name = towerController.name;

                        UIAnchor anchor = info.GetComponent <UIAnchor>();
                        anchor.container      = InfoPanel.gameObject;
                        anchor.relativeOffset = new Vector2(PlayConfig.AnchorTowerGuideInfoStartX + count * PlayConfig.AnchorTowerGuideInfoDistance, PlayConfig.AnchorTowerGuideInfoStartY);

                        #region TOWER
                        TowerShopInfoController infoController = info.GetComponent <TowerShopInfoController>();
                        infoController.icon.mainTexture = Resources.Load <Texture>(PlayConfig.getTowerIcon(towerID));
                        infoController.level.text       = "Level " + ((int)towerID.Level).ToString();

                        infoController.atk.parent.transform.GetComponentInChildren <UISprite> ().spriteName = "icon-atk";
                        infoController.atk.text        = towerController.attribute.MinATK.ToString() + " - " + towerController.attribute.MaxATK.ToString();
                        infoController.spawnShoot.text = towerController.attribute.SpawnShoot.ToString();
                        infoController.timeBuild.text  = towerController.attribute.TimeBuild.ToString();

                        //Bullet label
                        string[] str = PlayConfig.getBulletType(towerController.attackType.ToString());
                        infoController.bulletAbility.text = str[0] + " TARGET";
                        infoController.bulletRegion.text  = str[1];

                        //set icon fix size
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        infoController.icon.SetDimensions(infoController.icon.mainTexture.width, infoController.icon.mainTexture.height);
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch uiStretch = infoController.icon.GetComponent <UIStretch>();
                        uiStretch.enabled = true;
                        #endregion

                        #region BULLET
                        object[] bulletData = PlayConfig.getBulletShop(towerID);
                        infoController.bulletIcon.mainTexture     = Resources.Load <Texture>("Image/Bullet/Bullet Icon/" + bulletData[0].ToString());
                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        infoController.bulletIcon.SetDimensions(infoController.bulletIcon.mainTexture.width, infoController.bulletIcon.mainTexture.height);
                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch stretch = infoController.bulletIcon.GetComponent <UIStretch>();
                        stretch.relativeSize.y = (float)bulletData[1];
                        stretch.enabled        = true;

                        //Add effect
                        infoController.bullet = towerController.bullet;
                        #endregion

                        count++;
                        listTower.Add(info);

                        //get Next Tower
                        if (towerController.nextLevel != null)
                        {
                            towerID         = towerController.nextLevel.GetComponent <TowerController>().ID;
                            towerController = towerController.nextLevel;
                        }
                        else
                        {
                            maxLevel     = count;
                            currentLevel = 1;
                            towerLevelSelected.transform.position = levels[currentLevel - 1].transform.position;
                            break;
                        }
                    }
                    break;
                }
            }

            towers = ObjectManager.Instance.TowersPassive;
            length = towers.Length;
            for (int i = 0; i < length; i++)
            {
                TowerPassiveController towerController = towers[i].GetComponent <TowerPassiveController>();
                if (towerController.ID.Type == towerID.Type && towerController.ID.Level == towerID.Level)
                {
                    while (true)
                    {
                        GameObject info = Instantiate(PlayManager.Instance.modelPlay.TowerGuideInfo) as GameObject;
                        info.transform.parent     = infoTower.transform;
                        info.transform.localScale = Vector3.one;
                        info.name = towerController.name;

                        UIAnchor anchor = info.GetComponent <UIAnchor>();
                        anchor.container      = InfoPanel.gameObject;
                        anchor.relativeOffset = new Vector2(PlayConfig.AnchorTowerGuideInfoStartX + count * PlayConfig.AnchorTowerGuideInfoDistance, PlayConfig.AnchorTowerGuideInfoStartY);

                        #region TOWER
                        TowerShopInfoController infoController = info.GetComponent <TowerShopInfoController>();
                        infoController.icon.mainTexture = Resources.Load <Texture>(PlayConfig.getTowerIcon(towerID));
                        infoController.level.text       = "Level " + ((int)towerID.Level).ToString();

                        infoController.atk.parent.transform.GetComponentInChildren <UISprite> ().spriteName = "icon-gold";
                        infoController.atk.text        = towerController.passiveAttribute.Value.ToString();
                        infoController.spawnShoot.text = towerController.passiveAttribute.UpdateTime.ToString();
                        infoController.timeBuild.text  = towerController.passiveAttribute.TimeBuild.ToString();

                        //Bullet label
                        //string[] str = PlayConfig.getBulletType(towerController.attackType.ToString());
                        infoController.bulletAbility.text = towerController.passiveAttribute.Describe.ToString();
                        infoController.bulletRegion.text  = towerController.passiveAttribute.Type.ToString();;

                        //set icon fix size
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        infoController.icon.SetDimensions(infoController.icon.mainTexture.width, infoController.icon.mainTexture.height);
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch uiStretch = infoController.icon.GetComponent <UIStretch>();
                        uiStretch.enabled = true;
                        #endregion

                        #region BULLET
                        object[] bulletData = PlayConfig.getBulletShop(towerID);
                        infoController.bulletIcon.mainTexture     = Resources.Load <Texture>("Image/Bullet/Bullet Icon/" + bulletData[0].ToString());
                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        infoController.bulletIcon.SetDimensions(infoController.bulletIcon.mainTexture.width, infoController.bulletIcon.mainTexture.height);
                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch stretch = infoController.bulletIcon.GetComponent <UIStretch>();
                        stretch.relativeSize.y = (float)bulletData[1];
                        stretch.enabled        = true;

                        //Add effect

                        infoController.bullet = towerController.bullet;
                        #endregion

                        count++;
                        listTower.Add(info);

                        //get Next Tower
                        if (towerController.nextLevel != null)
                        {
                            towerID         = towerController.nextLevel.GetComponent <TowerPassiveController>().ID;
                            towerController = (TowerPassiveController)towerController.nextLevel;
                        }
                        else
                        {
                            maxLevel     = count;
                            currentLevel = 1;
                            towerLevelSelected.transform.position = levels[currentLevel - 1].transform.position;
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
    public void initDailyQuest()
    {
        currentPage = 1;

        //set maxPage
        int questLength = ReadDatabase.Instance.QuestInfo.Count;

        if (questLength % LevelConfig.ValueDailyQuestPerPage == 0)
        {
            maxPage = questLength / LevelConfig.ValueDailyQuestPerPage;
        }
        else
        {
            maxPage = (questLength / LevelConfig.ValueDailyQuestPerPage) + 1;
        }

        labelPage.text = currentPage + "/" + maxPage;

        AutoDestroy.destroyChildren(questTemp);

        int i = 0;
        int x = 0;

        foreach (System.Collections.Generic.KeyValuePair <int, QuestData> iterator in ReadDatabase.Instance.QuestInfo)
        {
            GameObject quest = Instantiate(LevelManager.Instance.Model.Quest) as GameObject;
            quest.transform.parent     = questTemp.transform;
            quest.transform.localScale = Vector3.one;

            //anchor
            UIAnchor anchor = quest.GetComponent <UIAnchor>();
            anchor.container      = mainBoard;
            anchor.relativeOffset = new Vector2(LevelConfig.AnchorDailyQuestStartX + x * LevelConfig.AnchorDailyQuestDistanceX,
                                                LevelConfig.AnchorDailyQuestStartY - i * LevelConfig.AnchorDailyQuestDistanceY);

            //stretch
            quest.GetComponent <UIStretch>().container = mainBoard;

            QuestController controller = quest.GetComponent <QuestController>();
            controller.labelName.text = iterator.Value.Name;
            controller.labelText.text = iterator.Value.Text;

            controller.labelTime.text = ((PlayerInfo.Instance.listDailyQuest[iterator.Key] <= iterator.Value.Time) ?
                                         PlayerInfo.Instance.listDailyQuest[iterator.Key] : iterator.Value.Time)
                                        + " / " + iterator.Value.Time;
            controller.ID        = iterator.Key;
            controller.SceneName = iterator.Value.SceneName;

            string[] rewards   = iterator.Value.Reward.Split(',');
            string   result    = "";
            int      strLength = rewards.Length;
            for (int k = 0; k < strLength; k++)
            {
                result += " (" + rewards[k].ToLower() + ")";
            }
            result = result.Trim();
            controller.labelReward.text = result;

            i++;
            if (i == LevelConfig.ValueDailyQuestPerPage)
            {
                i = 0;
                x++;
            }
        }
    }