Exemple #1
0
        public CommandButton(GameObject _go, Sprite _symbol, string _text, PayType _payType, int _buyPrice, UnityAction _call)
        {
            go         = _go;
            Background = go.GetComponent <Image>();
            Title      = go.transform.Find("Title").GetComponent <Text>();
            Icon       = go.transform.Find("Icon").GetComponent <Image>();
            Price      = go.transform.Find("Price").GetComponent <Text>();
            PriceIcon  = go.transform.Find("PriceIcon").GetComponent <Image>();
            Symbol     = _symbol;
            Title.text = _text;
            call       = _call;
            Disabled   = false;
            Locked     = false;

            payType  = _payType;
            BuyPrice = _buyPrice;

            Icon.overrideSprite = Symbol;

            Price.text = (BuyPrice == 0) ? "" : BuyPrice.ToString("#,##0");
            PriceIcon.overrideSprite = TBDatabase.GetPayTypeIcon(_payType);
            PriceIcon.gameObject.SetActive((BuyPrice == 0) ? false : true);
            //PriceIcon.gameObject.SetActive (false);

            State(false);
        }
Exemple #2
0
        // get max count of given building type from database
        public int GetBuildingCountMax(int BuildingType)
        {
            BuildingType bt           = TBDatabase.GetBuildingType(BuildingType);
            Building     buildingTown = Buildings[0][0];

            return(bt.MaxCount[buildingTown.Level - 1]);
        }
Exemple #3
0
        public float timeLeft = 0.0f;                                   // training time left of current training unit

        public GenQueItem(Building _building, int _unitID, int _Count)
        {
            building = _building;
            unitID   = _unitID;
            at       = TBDatabase.GetArmyType(unitID);
            Count    = _Count;
            timeLeft = at.TrainingTime;
        }
Exemple #4
0
        // Sound
        public static void SoundPlay(int iType)
        {
            if (BESetting.SoundVolume == 0)
            {
                return;
            }

            AudioSource aS = instance.AudioSourcePop();

            aS.PlayOneShot(TBDatabase.GetAudio(iType));
        }
Exemple #5
0
 public void Init(UIDialogTraining _uiTraining, int _unitID)
 {
     uiTraining = _uiTraining;
     unitID     = _unitID;
     at         = TBDatabase.GetArmyType(unitID);
     ad         = (at != null) ? at.GetDefine(1) : null;
     if (ad != null)
     {
         Price.text = ad.ResearchCost.ToString("#,##0");
     }
 }
Exemple #6
0
        // incase shop item is inapp
        public void FillInApp(int id, string TabName)
        {
            toggleButtons[id].transform.Find("Label").GetComponent <Text>().text = TabName;

            for (int i = 0; i < TBDatabase.GetInAppItemCount(); ++i)
            {
                UIShopItem script = AddShopItem(prefabShopItemGem, id, i);
                script.Init(TBDatabase.GetInAppItem(i));
            }

            contents[id].GetComponent <RectTransform>().sizeDelta = new Vector3(320 * TBDatabase.GetInAppItemCount(), 440);
        }
Exemple #7
0
        void Reset()
        {
            queItems.Clear();
            bd = null;
            bt = TBDatabase.GetBuildingType(7); //building.Type);
            bd = bt.GetDefine(1);               //building.Level);

            // delete old items of each content
            for (int j = rtUnitQueList.childCount - 1; j >= 0; j--)
            {
                Destroy(rtUnitQueList.GetChild(j).gameObject);
            }
            for (int i = 0; i < building.queUnitGen.Count; ++i)
            {
                GenQueItem item = building.queUnitGen[i];

                GameObject go = (GameObject)Instantiate(prefabUnitQueItem, Vector3.zero, Quaternion.identity);
                go.transform.SetParent(rtUnitQueList);
                go.transform.localScale = Vector3.one;
                RectTransform rt = go.GetComponent <RectTransform>();
                rt.anchoredPosition = new Vector2(i * -100, 0);

                UIUnitQueItem script = go.GetComponent <UIUnitQueItem>();
                script.Init(this, item);
                queItems.Add(script);
                Debug.Log("queItems.Add " + queItems.Count.ToString() + "unitID:" + item.unitID.ToString());
            }

            // delete old items of each content
            for (int j = rtUnitList.childCount - 1; j >= 0; j--)
            {
                Destroy(rtUnitList.GetChild(j).gameObject);
            }
            int sz = TBDatabase.GetArmyTypeCount();

            for (int i = 0; i < sz; ++i)
            {
                int col = i / 2;
                int row = i % 2;

                GameObject go = (GameObject)Instantiate(prefabUnitItem, Vector3.zero, Quaternion.identity);
                go.transform.SetParent(rtUnitList);
                go.transform.localScale = Vector3.one;
                RectTransform rt = go.GetComponent <RectTransform>();
                rt.anchoredPosition = new Vector2(col * 160, row * -160);

                UIUnitItem script = go.GetComponent <UIUnitItem>();
                script.Init(this, i);
            }
            rtUnitList.sizeDelta = new Vector3(160 * ((sz + 1) / 2), 310);
        }
Exemple #8
0
        void Reset()
        {
            if (unitID == -1)
            {
                return;
            }

            at = TBDatabase.GetArmyType(unitID);
            //ad = (at != null) ? at.GetDefine(1) : null;

            if (at != null)
            {
                textTitle.text = at.Name;
                //textLevel.text = "Level "+building.Level.ToString ();
                //imgIcon.sprite = ;
            }
        }
Exemple #9
0
 // set price icon and value
 public void PriceInfoApply(Image _PriceIcon, Text _Price)
 {
     if (BuildGoldPrice != 0)
     {
         _PriceIcon.sprite = TBDatabase.GetPayTypeIcon(PayType.Gold);
         _Price.text       = BuildGoldPrice.ToString("#,##0");
     }
     else if (BuildElixirPrice != 0)
     {
         _PriceIcon.sprite = TBDatabase.GetPayTypeIcon(PayType.Elixir);
         _Price.text       = BuildElixirPrice.ToString("#,##0");
     }
     else if (BuildGemPrice != 0)
     {
         _PriceIcon.sprite = TBDatabase.GetPayTypeIcon(PayType.Gem);
         _Price.text       = BuildGemPrice.ToString("#,##0");
     }
     else
     {
     }
 }
Exemple #10
0
        // add exp
        public void GainExp(int exp)
        {
            ExpTotal += exp;
            int NewLevel      = TBDatabase.GetLevel(ExpTotal);
            int LevelExpToGet = TBDatabase.GetLevelExp(NewLevel);
            int LevelExpStart = TBDatabase.GetLevelExpTotal(NewLevel);

            SceneTown.Exp.MaxSet(LevelExpToGet);
            int ExpLeft = ExpTotal - LevelExpStart;

            SceneTown.Exp.ChangeTo(ExpLeft);

            // if level up occured
            if ((NewLevel > Level) && (Level != 0))
            {
                // show levelup notify here
            }
            Level          = NewLevel;
            textLevel.text = NewLevel.ToString();

            // save game data
            Save();
        }
Exemple #11
0
        public void OnButtonInstant()
        {
            if (!TownLevelOk)
            {
                // upgrade not available
                return;
            }

            // checkuser has enough gem count
            if (SceneTown.Gem.Target() < GemCount)
            {
                // you need more gem
                UIDialogMessage.Show("More Gem Required", "Ok", "Error", TBDatabase.GetPayTypeIcon(PayType.Gem));

                return;
            }

            // decrease gem count and upgrade immediately
            SceneTown.Gem.ChangeDelta(-GemCount);
            building.UpgradeEnd();
            SceneTown.instance.BuildingSelect(null);

            _Hide();
        }
Exemple #12
0
        // whether upgrading is enable
        public bool IsUpgradeEnable()
        {
            BuildingType bt = TBDatabase.GetBuildingType(Type);

            // if this level is max level
            if (bt.LevelMax <= Level)
            {
                return(false);
            }
            // if no next level
            if (defNext == null)
            {
                return(false);
            }

            // if user don't have enough resources to upgrade
            if (((defNext.BuildGoldPrice != 0) && (SceneTown.Gold.Target() < defNext.BuildGoldPrice)) &&
                ((defNext.BuildElixirPrice != 0) && (SceneTown.Elixir.Target() < defNext.BuildElixirPrice)))
            {
                return(false);
            }

            return(true);
        }
Exemple #13
0
        void Awake()
        {
            instance = this;

            //add InApp purchase item
            InApps.Add(new InAppItem("Pile of Diamonds", 500, "$4.99"));
            InApps.Add(new InAppItem("Pouch of Diamonds", 1200, "$9.99"));
            InApps.Add(new InAppItem("Bag of Diamonds", 2500, "$19.99"));
            InApps.Add(new InAppItem("Box of Diamonds", 6500, "$49.99"));
            InApps.Add(new InAppItem("Crate of Diamonds", 14000, "$99.99"));

            // set experience values to each level
            for (int Level = 0; Level <= MAX_LEVEL; ++Level)
            {
                LevelExp[Level]      = Level * 50 + Mathf.Max(0, (Level - 199) * 450);
                LevelExpTotal[Level] = Level * (Level - 1) * 25;
                //Debug.Log ("Level "+Level.ToString ()+" - Exp:"+LevelExp[Level].ToString ()+" ExpTotal:"+LevelExpTotal[Level].ToString ());
            }

            // if set building type and definition data by coding
            // use this code

/*			//0-Town Hall
 *                      {
 *                              BuildingType bt = new BuildingType(0, "Town Hall", "", 4, 4, 5, 0, "1,1,1,1,1,1,1,1,1,1");
 *                              { BuildingDef bd = new BuildingDef (1500,      0,       0, 0,      0, 0);	bd.SetCapacity(1000,1000); bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef (1600,   1000,       0, 0,     10, 1);	bd.SetCapacity(1000,1000); bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef (1850,   4000,       0, 0,  10800, 2);	bd.SetCapacity(1000,1000); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (2100,  25000,       0, 0,  86400, 3);	bd.SetCapacity(1000,1000); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (2400, 150000,       0, 0, 172800, 4);	bd.SetCapacity(1000,1000); bt.Add(bd); }
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //1-Hut
 *                      {
 *                              BuildingType bt = new BuildingType(1, "Hut", "", 2, 2, 1, 0, "0,0,0,0,0,0,0,0,0,0");
 *                              { BuildingDef bd = new BuildingDef ( 250,        0,       0, 0,      0, 0); bt.Add(bd); }
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //2-Wall
 *                      {
 *                              BuildingType bt = new BuildingType(2, "Wall", "", 1, 1, 11, 0, "0,25,50,75,100,125,175,225,250,250");
 *                              { BuildingDef bd = new BuildingDef ( 300,     50,       0, 0,      0, 2); bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 500,   1000,       0, 0,      0, 2); bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 700,   5000,       0, 0,      0, 3); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 900,  10000,       0, 0,      0, 4); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (1400,  30000,       0, 0,      0, 5); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (2000,  75000,       0, 0,      0, 6); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (2500, 200000,       0, 0,      0, 7); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (3000, 500000,       0, 0,      0, 8); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (4000,1000000, 1000000, 0,      0, 9); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (5500,3000000, 3000000, 0,      0, 9); bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef (7000,4000000, 4000000, 0,      0,10); bt.Add(bd); }
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //3-Gold Mine
 *                      {
 *                              BuildingType bt = new BuildingType(3, "Gold Mine", "", 3, 3, 12, 0, "1,2,3,4,5,6,6,6,6,7");
 *                              { BuildingDef bd = new BuildingDef ( 400,      0,     150, 0,     10, 1);	bd.SetCapacity(   500,0);	bd.SetProduction(PayType.Gold,  200);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 440,      0,     300, 0,     60, 1);	bd.SetCapacity(  1000,0);	bd.SetProduction(PayType.Gold,  400);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 480,      0,     700, 0,    900, 2);	bd.SetCapacity(  1500,0);	bd.SetProduction(PayType.Gold,  600);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 520,      0,    1400, 0,   3600, 2);	bd.SetCapacity(  2500,0);	bd.SetProduction(PayType.Gold,  800);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 560,      0,    3000, 0,   7200, 3);	bd.SetCapacity( 10000,0);	bd.SetProduction(PayType.Gold, 1000);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 600,      0,    7000, 0,  21600, 3);	bd.SetCapacity( 20000,0);	bd.SetProduction(PayType.Gold, 1300);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 640,      0,   14000, 0,  43200, 4);	bd.SetCapacity( 30000,0);	bd.SetProduction(PayType.Gold, 1600);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 680,      0,   28000, 0,  86400, 4);	bd.SetCapacity( 50000,0);	bd.SetProduction(PayType.Gold, 1900);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 720,      0,   56000, 0, 172800, 5);	bd.SetCapacity( 75000,0);	bd.SetProduction(PayType.Gold, 2200);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 780,      0,   84000, 0, 259200, 5);	bd.SetCapacity(100000,0);	bd.SetProduction(PayType.Gold, 2500);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 860,      0,  168000, 0, 345600, 7);	bd.SetCapacity(150000,0);	bd.SetProduction(PayType.Gold, 3000);	bt.Add(bd); }
 *                              //{ BuildingDef bd = new BuildingDef ( 960,      0,  336000, 0, 432000, 8);	bd.SetCapacity(200000,0);	bd.SetProduction(PayType.Gold, 3500);	bt.Add(bd); }
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //4-Elixir Collector
 *                      {
 *                              BuildingType bt = new BuildingType(4, "Elixir Collector", "", 3, 3, 12, 0, "1,2,3,4,5,6,6,6,6,7");
 *                              { BuildingDef bd = new BuildingDef ( 400,    150, 0, 0,     10, 1);	bd.SetCapacity(0,   500);	bd.SetProduction(PayType.Elixir,  200);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 440,    300, 0, 0,     60, 1);	bd.SetCapacity(0,  1000);	bd.SetProduction(PayType.Elixir,  400);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 480,    700, 0, 0,    900, 2);	bd.SetCapacity(0,  1500);	bd.SetProduction(PayType.Elixir,  600);	bt.Add(bd); }
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //5-Gold Storage
 *                      {
 *                              BuildingType bt = new BuildingType(5, "Gold Storage", "", 3, 3, 11, 0, "1,1,2,2,2,2,2,3,4,4");
 *                              { BuildingDef bd = new BuildingDef ( 400,      0,     300, 0,     10, 1);	bd.SetCapacity(   1000,0);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 600,      0,     750, 0,   1800, 2);	bd.SetCapacity(   3000,0);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 800,      0,    1500, 0,   3600, 2);	bd.SetCapacity(  61000,0);	bt.Add(bd); }
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //6-Elixir Storage
 *                      {
 *                              BuildingType bt = new BuildingType(6, "Elixir Storage", "", 3, 3, 11, 0, "1,1,2,2,2,2,2,3,4,4");
 *                              { BuildingDef bd = new BuildingDef ( 400,    300, 0, 0,     10, 1);	bd.SetCapacity(0,   1000);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 600,    750, 0, 0,   1800, 2);	bd.SetCapacity(0,   3000);	bt.Add(bd); }
 *                              { BuildingDef bd = new BuildingDef ( 800,   1500, 0, 0,   3600, 2);	bd.SetCapacity(0,   6000);	bt.Add(bd); }
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //7-Barracks
 *                      {
 *                              BuildingType bt = new BuildingType(7, "Barrack", "", 3, 3, 10, 0, "1,2,2,3,3,3,4,4,4,4");
 *                              { BuildingDef bd = new BuildingDef ( 250, 0,     200, 0,     10, 1);	bt.Add(bd); } //20
 *                              Buildings.Add (bt);
 *                      }
 *
 *                      //8-Army Camp
 *                      {
 *                              BuildingType bt = new BuildingType(8, "Army Camp", "", 4, 4, 8, 0, "1,1,2,2,3,3,4,4,4,4");
 *                              { BuildingDef bd = new BuildingDef ( 250, 0,     250, 0,   300, 1);	bt.Add(bd); } //20
 *                              Buildings.Add (bt);
 *                      }
 *
 */
            // load building type and definition data from xml file
            Load();

            // unit definiron for training
            //0-Barbarian
            {
                ArmyType at = new ArmyType("Barbarian", "", 7);                 //None, Melee, 1, 20, 16, 1, 1, 0.4
                at.Add(new ArmyDef(8, 45, 25, 0, 0, 0));
                at.Add(new ArmyDef(11, 54, 40, 50000, 1, 21600));
                at.Add(new ArmyDef(14, 65, 60, 150000, 3, 86400));
                at.Add(new ArmyDef(18, 78, 100, 500000, 5, 259200));
                at.Add(new ArmyDef(23, 95, 150, 1500000, 6, 432000));
                at.Add(new ArmyDef(26, 110, 200, 4500000, 7, 864000));
                at.Add(new ArmyDef(30, 125, 250, 6000000, 8, 1209600));
                Armies.Add(at);
            }

            //1-Archer
            {
                ArmyType at = new ArmyType("Archer", "", 1);
                at.Add(new ArmyDef(8, 45, 25, 0, 0, 0));
                Armies.Add(at);
            }
        }
Exemple #14
0
        public void _Show(Building script)
        {
            building = script;
            Reset();
            Visible = true;

            // if newly create building was selected
            if (building.OnceLanded == false)
            {
                // only show 'create','cancel' button
                AddButton(Resources.Load <Sprite>("Icons/CheckedMark"), "Ok", PayType.None, 0, CommandType.Create);
                AddButton(Resources.Load <Sprite>("Icons/Multiplication"), "Cancel", PayType.None, 0, CommandType.CreateCancel);
            }
            else
            {
                // if building is not in creation, show 'info' button
                if (building.Level != 0)
                {
                    AddButton(Resources.Load <Sprite>("Icons/Info"), "Info", PayType.None, 0, CommandType.Info);
                }

                // if building can upgrade to next level
                if (building.defNext != null)
                {
                    // if in upgrading
                    if (building.InUpgrade)
                    {
                        if (!building.UpgradeCompleted)
                        {
                            // shows 'Cancel','Finish' buttons
                            AddButton(Resources.Load <Sprite>("Icons/Multiplication"), "Cancel", PayType.None, 0, CommandType.UpgradeCancel);
                            int FinishGemCount = building.GetFinishGemCount();
                            AddButton(Resources.Load <Sprite>("Icons/Gem"), "Finish\nNow", PayType.Gem, FinishGemCount, CommandType.UpgradeFinish);
                        }
                    }
                    else
                    {
                        // get price to upgrade
                        PayType payType  = PayType.None;
                        int     BuyPrice = 0;
                        if (building.defNext.BuildGoldPrice != 0)
                        {
                            payType = PayType.Gold;       BuyPrice = building.defNext.BuildGoldPrice;
                        }
                        else if (building.defNext.BuildElixirPrice != 0)
                        {
                            payType = PayType.Elixir; BuyPrice = building.defNext.BuildElixirPrice;
                        }
                        else if (building.defNext.BuildGemPrice != 0)
                        {
                            payType = PayType.Gem;        BuyPrice = building.defNext.BuildGemPrice;
                        }
                        else
                        {
                        }

                        // add 'upgrade' button
                        AddButton(Resources.Load <Sprite>("Icons/UpArrow"), "Upgrade", payType, BuyPrice, CommandType.Upgrade);
                    }
                }

                // is building is barrack
                if ((building.Type == 7) && !building.InUpgrade)
                {
                    // add'Train' button
                    AddButton(Resources.Load <Sprite>("Icons/Bullet"), "Train\nTroops", 0, 0, CommandType.Training);
                }
            }

            ButtonReposition();

            Info.text = TBDatabase.GetBuildingName(building.Type) + "  Level " + building.Level.ToString();
            //BETween.anchoredPosition3D(gameObject, 0.2f, new Vector3(0,-250,0), new Vector3(0,0,0));//.method = BETweenMethod.easeOut;
            StartCoroutine(TweenMov(GetComponent <RectTransform>(), new Vector2(0, -250), new Vector2(0, 0), 0.2f, 0));
        }
Exemple #15
0
        // when button clicked
        public void ButtonClicked(CommandType ct)
        {
            //Debug.Log ("ButtonClicked "+ct.ToString());
            BEAudioManager.SoundPlay(6);

            // if newly created building is selected
            // only perform create and cancel
            if (building.OnceLanded == false)
            {
                // if user clicked 'create' button
                if (ct == CommandType.Create)
                {
                    // building can land
                    if (building.Landable)
                    {
                        // hide command dialog
                        Hide();
                        // land building and unselect
                        SceneTown.instance.BuildingLandUnselect();

                        // decrease build price of the building
                        BuildingDef bd = TBDatabase.GetBuildingDef(building.Type, (building.Level == 0) ? 1 : building.Level);
                        building.PayforBuild(bd);
                        // if building level is 0(need buildtime), upgrade to level 1 start
                        // if not, check resource capacity
                        if (building.Level == 0)
                        {
                            building.Upgrade();
                        }
                        else
                        {
                            SceneTown.instance.CapacityCheck();
                        }
                    }

                    // if house is created add worker
                    if (building.Type == 1)
                    {
                        BEWorkerManager.instance.AddWorker();
                    }

                    // if wall is created,automatically next wall create for convenience
                    if (building.Type == 2)
                    {
                        // check if user has enough gold and wall count is not max count
                        BuildingDef bd        = TBDatabase.GetBuildingDef(building.Type, 1);
                        bool        Available = bd.PriceInfoCheck(null);
                        int         CountMax  = BEGround.instance.GetBuildingCountMax(building.Type);
                        int         Count     = BEGround.instance.GetBuildingCount(building.Type);
                        if (Available && (Count < CountMax))
                        {
                            //Debug.Log ("wall tilePos:"+building.tilePos.ToString ());
                            // add another wall automatically
                            Building script = BEGround.instance.BuildingAdd(2, 1);
                            if (script != null)
                            {
                                // choose whicj direction
                                Building buildingNeighbor = null;
                                Vector2  tilePos          = Vector2.zero;
                                int      NeighborX        = 0;
                                int      NeighborZ        = 0;
                                bool     bFind            = false;
                                // check prev and next tile in x,z coordination
                                for (int dir = 0; dir < 2; ++dir)
                                {
                                    for (int value = 0; value < 2; ++value)
                                    {
                                        if (dir == 0)
                                        {
                                            NeighborX = 0;
                                            NeighborZ = ((value == 0) ? -1 : 1);
                                        }
                                        else
                                        {
                                            NeighborX = ((value == 0) ? -1 : 1);
                                            NeighborZ = 0;
                                        }
                                        buildingNeighbor = BEGround.instance.GetBuilding((int)building.tilePos.x + NeighborX, (int)building.tilePos.y + NeighborZ);

                                        // if wall finded
                                        if ((buildingNeighbor != null) && (buildingNeighbor.Type == 2))
                                        {
                                            bFind = true;
                                            break;
                                        }
                                    }

                                    if (bFind)
                                    {
                                        break;
                                    }
                                }
                                //Debug.Log ("wall NeighborX:"+NeighborX.ToString ()+ "NeighborZ:"+NeighborZ.ToString ());

                                // set inverse direction
                                tilePos = building.tilePos;
                                if (NeighborX == 0)
                                {
                                    tilePos.y -= (float)NeighborZ;
                                }
                                else
                                {
                                    tilePos.x -= (float)NeighborX;
                                }

                                //Debug.Log ("wall tilePos New:"+tilePos.ToString ());
                                script.Move((int)tilePos.x, (int)tilePos.y);
                                script.CheckLandable();
                                SceneTown.instance.BuildingSelect(script);
                            }
                        }
                    }

                    SceneTown.instance.Save();
                    BEWorkerManager.instance.SetWorker(building);
                }
                // if user clicked 'cancel' button
                else if (ct == CommandType.CreateCancel)
                {
                    // hide command dialog
                    Hide();
                    // delete temporary created building
                    SceneTown.instance.BuildingDelete();
                }
                else
                {
                }
            }
            else
            {
                if (ct == CommandType.Info)
                {
                    Hide();
                    UIDialogInfo.Show(building);
                }
                else if (ct == CommandType.Upgrade)
                {
                    // check if worker available
                    if (BEWorkerManager.instance.WorkerAvailable())
                    {
                        Hide();
                        UIDialogUpgradeAsk.Show(building);
                    }
                    else
                    {
                        UIDialogMessage.Show("All workers are working now", "Ok", "No Worker Available");
                    }
                }
                else if (ct == CommandType.UpgradeCancel)
                {
                    UIDialogMessage.Show("Cancel current upgrade?", "Yes,No", "Cancel Upgrade ?", null, (result) => { MessageBoxResultUpgradeCancel(result); });
                }
                else if (ct == CommandType.UpgradeFinish)
                {
                    // if instant finish button was clicked
                    int FinishGemCount = building.GetFinishGemCount();
                    // user has enough gem to finish
                    if (SceneTown.Gem.Target() >= FinishGemCount)
                    {
                        // decrease gem
                        SceneTown.Gem.ChangeDelta(-FinishGemCount);
                        // complete upgrade
                        building.UpgradeCompleted = true;
                        Hide();
                    }
                    else
                    {
                        UIDialogMessage.Show("You need more gems to finish this work immediately", "Ok", "Need More Gems");
                    }
                }
                else if (ct == CommandType.Training)
                {
                    Hide();
                    UIDialogTraining.Show(building);
                }
                else
                {
                }
            }
        }
Exemple #16
0
        void _Show(ShopType type)
        {
            // if shop dialog called while new building is in creation,
            // delete new building
            if (SceneTown.buildingSelected != null)
            {
                if (!SceneTown.buildingSelected.OnceLanded)
                {
                    SceneTown.instance.BuildingDelete();
                }
            }

            gameObject.transform.localPosition = Vector3.zero;
            gameObject.SetActive(true);
            gameObject.GetComponent <Image>().color = new Color32(0, 0, 0, 0);
            SceneTown.isModalShow = true;
            eType = type;

            // delete old items of each content
            for (int i = 0; i < contents.Length; ++i)
            {
                for (int j = contents[i].transform.childCount - 1; j >= 0; j--)
                {
                    Destroy(contents[i].transform.GetChild(j).gameObject);
                }
            }

            // create shop items of each contents
            if (eType == ShopType.Normal)
            {
                List <BuildingType> bt = new List <BuildingType>();

                // fill first tab
                bt.Clear();
                bt.Add(TBDatabase.GetBuildingType(3));
                bt.Add(TBDatabase.GetBuildingType(4));
                bt.Add(TBDatabase.GetBuildingType(5));
                bt.Add(TBDatabase.GetBuildingType(6));
                FillContents(0, "Economy", bt);

                // fill second tab
                bt.Clear();
                bt.Add(TBDatabase.GetBuildingType(2));
                bt.Add(TBDatabase.GetBuildingType(7));
                bt.Add(TBDatabase.GetBuildingType(8));
                //bt.Add (TBDatabase.GetBuildingType(9));
                //bt.Add (TBDatabase.GetBuildingType(10));
                FillContents(1, "Defense", bt);

                // fill third tab
                bt.Clear();
                bt.Add(TBDatabase.GetBuildingbyName(name: "Hut"));
                bt.Add(TBDatabase.GetBuildingbyName(name: "wangtianshu"));
                bt.Add(TBDatabase.GetBuildingbyName(name: "apartment_mess"));
                bt.Add(TBDatabase.GetBuildingbyName(name: "apartment_huge"));
                FillContents(2, "Support", bt);

                BETween.anchoredPosition(rtDialog.gameObject, 0.3f, new Vector3(0, -500), new Vector3(0, 0)).method = BETweenMethod.easeOut;
            }
            else if (eType == ShopType.InApp)
            {
                FillInApp(0, "InApp");

                // if shop has only one tab, then change position to hide tab
                BETween.anchoredPosition(rtDialog.gameObject, 0.3f, new Vector3(0, -500), new Vector3(0, -50)).method = BETweenMethod.easeOut;
            }
            else if (eType == ShopType.House)
            {
                List <BuildingType> bt = new List <BuildingType>();

                // add house building
                bt.Clear();
                bt.Add(TBDatabase.GetBuildingType(1));
                FillContents(0, "House", bt);

                // if shop has only one tab, then change position to hide tab
                BETween.anchoredPosition(rtDialog.gameObject, 0.3f, new Vector3(0, -500), new Vector3(0, -50)).method = BETweenMethod.easeOut;
            }
            else
            {
            }

            toggleButtons[0].isOn = true;
            CategorySelected(0);
            rtDialog.anchoredPosition = new Vector3(0, -500);
            BETween.alpha(gameObject, 0.3f, 0, 0.5f).method = BETweenMethod.easeOut;
        }
Exemple #17
0
        void Reset()
        {
            //bd = null;

            bt = TBDatabase.GetBuildingType(building.Type);
            //bd = bt.GetDefine(building.Level);
            bdNext = bt.GetDefine(building.Level + 1);
            //bdLast = bt.GetDefLast();

            textTitle.text = "Upgrade " + bt.Name + " to Level " + (building.Level + 1).ToString() + " ?";
            imgIcon.sprite = Resources.Load <Sprite>("Icons/Building/" + bt.Name);

            for (int i = 0; i < progresses.Length; ++i)
            {
                progresses[i].gameObject.SetActive(true);
            }

            // display progresses of building by building type
            if (bt.ID == 0)
            {
                // incase building si town hall, show gold capacity, elixir capacit and hitpoint
                building.UIFillProgressWithNext(progresses[0], BDInfo.CapacityGold);
                building.UIFillProgressWithNext(progresses[1], BDInfo.CapacityElixir);
                building.UIFillProgressWithNext(progresses[2], BDInfo.HitPoint);
            }
            else if (bt.ID == 1)
            {
                // incase building is house, only show hitpoint, and disable other progresses
                building.UIFillProgressWithNext(progresses[0], BDInfo.HitPoint);
                progresses[1].gameObject.SetActive(false);
                progresses[2].gameObject.SetActive(false);
            }
            else if (bt.ID == 2)
            {
                building.UIFillProgressWithNext(progresses[0], BDInfo.HitPoint);
                progresses[1].gameObject.SetActive(false);
                progresses[2].gameObject.SetActive(false);
            }
            else if ((bt.ID == 3) || (bt.ID == 4))
            {
                building.UIFillProgressWithNext(progresses[0], BDInfo.Capacity);
                building.UIFillProgressWithNext(progresses[1], BDInfo.ProductionRate);
                building.UIFillProgressWithNext(progresses[2], BDInfo.HitPoint);
            }
            else if ((bt.ID == 5) || (bt.ID == 6))
            {
                building.UIFillProgressWithNext(progresses[0], BDInfo.StorageCapacity);
                building.UIFillProgressWithNext(progresses[1], BDInfo.HitPoint);
                progresses[2].gameObject.SetActive(false);
            }
            else if (bt.ID == 7)
            {
                //"Training Capacity : 0/20";
                //"HitPoint"
            }
            else if (bt.ID == 8)
            {
                //"Total troop Capacity : 0/20";
                //"HitPoint"
                // show troops icon (click to remove unit) "Remove Troops?"
            }
            else if (bt.ID == 9)
            {
                //"Damage per second:15";
                //"HitPoint"
                //Range : 9 Tiles
                //Damage Type: Single Target
                //Targets: Ground
                //Favorite target: Any
            }
            else if (bt.ID == 10)
            {
            }
            else
            {
            }

            // get townhall to check upgrade requires next townhall
            Building buildingTown = BEGround.instance.Buildings[0][0];

            if (bdNext.TownHallLevelRequired > buildingTown.Level)
            {
                goNote.SetActive(true);
                NoteInfo.text = "To upgrade this building, you first need\n Town Hall Level " + bdNext.TownHallLevelRequired.ToString() + "!";
                TownLevelOk   = false;
                goNormal.SetActive(false);
            }
            else
            {
                goNote.SetActive(false);
                TownLevelOk = true;
                goNormal.SetActive(true);

                // set infos about upgrade
                bdNext.PriceInfoApply(PriceIcon, Price);
                textBuildTime.text = BENumber.SecToString(bdNext.BuildTime);
                GemCount           = (bdNext.BuildTime + 1) / 60;     // 1 gem per minute
                PriceGem.text      = GemCount.ToString("#,##0");
                PriceGem.color     = (SceneTown.Gem.Target() < GemCount) ? Color.red : Color.white;
            }
        }
Exemple #18
0
        void Update()
        {
            // use BETime to revise times
            float deltaTime = BETime.deltaTime;

            // if building is in selected state, keep color animation
            if (!Landed && (goCenter != null))
            {
                float fColor  = Mathf.PingPong(Time.time * 1.5f, 1) * 0.5f + 0.5f;
                Color clrTemp = new Color(fColor, fColor, fColor, 1);
                BEUtil.SetObjectColor(goCenter, clrTemp);
                BEUtil.SetObjectColor(goXInc, clrTemp);
                BEUtil.SetObjectColor(goZInc, clrTemp);
            }

            // if building can produce resources
            if (Landed && !InUpgrade && (def != null) && (def.eProductionType != PayType.None))
            {
                Production += (float)def.ProductionRate * deltaTime;

                // check maximum capacity
                if ((int)Production >= def.Capacity[(int)def.eProductionType])
                {
                    Production = def.Capacity[(int)def.eProductionType];
                }

                // is minimum resources generated, then ser collectable flagand show dialog
                if (((int)Production >= 10) && !uiInfo.groupCollect.gameObject.activeInHierarchy)
                {
                    Collectable = true;
                    uiInfo.CollectIcon.sprite = TBDatabase.GetPayTypeIcon(def.eProductionType);
                    BETween.alpha(uiInfo.groupCollect.gameObject, 0.2f, 0.0f, 1.0f);
                    uiInfo.groupCollect.gameObject.SetActive(true);
                    uiInfo.groupInfo.gameObject.SetActive(false);
                }

                if (Collectable)
                {
                    // when production count is reach to max count, then change dialog color to red
                    uiInfo.CollectDialog.color = (Production == def.Capacity[(int)def.eProductionType]) ? Color.red : Color.white;
                }
            }

            // if in upgrade
            if (InUpgrade)
            {
                // if upgrading proceed
                if (!UpgradeCompleted)
                {
                    // decrease left time
                    UpgradeTimeLeft -= deltaTime;

                    // if upgrading done
                    if (UpgradeTimeLeft < 0.0f)
                    {
                        UpgradeTimeLeft  = 0.0f;
                        UpgradeCompleted = true;

                        // if building is selected, then update command dialog
                        if (UICommand.Visible && (SceneTown.buildingSelected == this))
                        {
                            UICommand.Show(this);
                        }
                    }
                }

                // update ui info
                uiInfo.TimeLeft.text       = UpgradeCompleted ? "Completed!" : BENumber.SecToString(Mathf.CeilToInt(UpgradeTimeLeft));
                uiInfo.Progress.fillAmount = (UpgradeTimeTotal - UpgradeTimeLeft) / UpgradeTimeTotal;
                uiInfo.groupProgress.alpha = 1;
                uiInfo.groupProgress.gameObject.SetActive(true);
            }

            UnitGenUpdate(deltaTime);
        }
Exemple #19
0
        void Reset()
        {
            //bd = null;
            bt = TBDatabase.GetBuildingType(building.Type);
            //bd = bt.GetDefine(building.Level);
            //bdNext = bt.GetDefine(building.Level+1);
            //bdLast = bt.GetDefLast();

            textTitle.text = bt.Name;
            textLevel.text = "Level " + building.Level.ToString();
            imgIcon.sprite = Resources.Load <Sprite>("Icons/Building/" + bt.Name);


            for (int i = 0; i < progresses.Length; ++i)
            {
                progresses[i].gameObject.SetActive(true);
            }


            // display progresses of building by building type
            if (bt.ID == 0)
            {
                // incase building si town hall, show gold capacity, elixir capacit and hitpoint
                textInfo.text = "This is the heart of your village. Upgrading your Town Hall unlocks new defenses, buildings, traps and much more.";
                building.UIFillProgress(progresses[0], BDInfo.CapacityGold);
                building.UIFillProgress(progresses[1], BDInfo.CapacityElixir);
                building.UIFillProgress(progresses[2], BDInfo.HitPoint);
            }
            else if (bt.ID == 1)
            {
                // incase building is house, only show hitpoint, and disable other progresses
                textInfo.text = "Nothing gets done around here without Builders! You can hire more Builders to start multiple construction projects, or speed up their work by using green gems.";
                building.UIFillProgress(progresses[0], BDInfo.HitPoint);
                progresses[1].gameObject.SetActive(false);
                progresses[2].gameObject.SetActive(false);
            }
            else if (bt.ID == 2)
            {
                textInfo.text = "Walls are great for keeping your village safe and your enemies in the line of fire.";
                building.UIFillProgress(progresses[0], BDInfo.HitPoint);
                progresses[1].gameObject.SetActive(false);
                progresses[2].gameObject.SetActive(false);
            }
            else if ((bt.ID == 3) || (bt.ID == 4))
            {
                if (bt.ID == 3)
                {
                    textInfo.text = "The Gold Mine produces gold. Upgrade it to boost its production and gold storage capacity.";
                }
                else
                {
                    textInfo.text = "Elixir is pumped from the Ley Lines coursing underneath your village. Upgrade your Elixir Collectors to maximize elixir production.";
                }
                building.UIFillProgress(progresses[0], BDInfo.Capacity);
                building.UIFillProgress(progresses[1], BDInfo.ProductionRate);
                building.UIFillProgress(progresses[2], BDInfo.HitPoint);
            }
            else if ((bt.ID == 5) || (bt.ID == 6))
            {
                if (bt.ID == 5)
                {
                    textInfo.text = "All your precious gold is stored here. Don't let sneaky goblins anywhere near! Upgrade the storage to increase its capacity and durability against attack.";
                }
                else
                {
                    textInfo.text = "These storages contain the elixir pumped from underground. Upgrade them to increase the maximum amount of elixir you can store.";
                }
                building.UIFillProgress(progresses[0], BDInfo.StorageCapacity);
                building.UIFillProgress(progresses[1], BDInfo.HitPoint);
                progresses[2].gameObject.SetActive(false);
            }
            else if (bt.ID == 7)
            {
                textInfo.text = "The Barracks allow you to train troops to attack your enemies. Upgrade the Barracks to unlock advanced units that can win epic battles.";
                //"Training Capacity : 0/20";
                //"HitPoint"
            }
            else if (bt.ID == 8)
            {
                textInfo.text = "Your troops are stationed in Army Camps. Build more camps and upgrade them to muster a powerful army.";
                //"Total troop Capacity : 0/20";
                //"HitPoint"
                // show troops icon (click to remove unit) "Remove Troops?"
            }
            else if (bt.ID == 9)
            {
                textInfo.text = "Cannons are great for point defense. Upgrade cannons to increase their firepower, but beware that your defensive turrets cannot shoot while being upgraded!";
                //"Damage per second:15";
                //"HitPoint"
                //Range : 9 Tiles
                //Damage Type: Single Target
                //Targets: Ground
                //Favorite target: Any
            }
            else if (bt.ID == 10)
            {
                textInfo.text = "Archer Towers have longer range than cannons, and unlike cannons they can attack flying enemies.";
            }
            else
            {
            }
        }
Exemple #20
0
        // fill building upgrading info in building upgrade ask dialog
        public void UIFillProgressWithNext(ProgressInfo progress, BDInfo type)
        {
            if (type == BDInfo.CapacityGold)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(PayType.Gold);
                progress.textInfo.text          = "Capacity : " + def.Capacity[(int)PayType.Gold].ToString("#,##0") + "+" + (defNext.Capacity[(int)PayType.Gold] - def.Capacity[(int)PayType.Gold]).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.Capacity[(int)PayType.Gold] / (float)defLast.Capacity[(int)PayType.Gold];
                progress.imageFront.fillAmount  = (float)def.Capacity[(int)PayType.Gold] / (float)defLast.Capacity[(int)PayType.Gold];
            }
            else if (type == BDInfo.CapacityElixir)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(PayType.Elixir);
                progress.textInfo.text          = "Capacity : " + def.Capacity[(int)PayType.Elixir].ToString("#,##0") + "+" + (defNext.Capacity[(int)PayType.Elixir] - def.Capacity[(int)PayType.Elixir]).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.Capacity[(int)PayType.Elixir] / (float)defLast.Capacity[(int)PayType.Elixir];
                progress.imageFront.fillAmount  = (float)def.Capacity[(int)PayType.Elixir] / (float)defLast.Capacity[(int)PayType.Elixir];
            }
            else if (type == BDInfo.Capacity)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(def.eProductionType);
                progress.textInfo.text          = "Capacity : " + def.Capacity[(int)def.eProductionType].ToString("#,##0") + "+" + (defNext.Capacity[(int)defNext.eProductionType] - def.Capacity[(int)def.eProductionType]).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.Capacity[(int)defNext.eProductionType] / (float)defLast.Capacity[(int)defLast.eProductionType];
                progress.imageFront.fillAmount  = (float)def.Capacity[(int)def.eProductionType] / (float)defLast.Capacity[(int)defLast.eProductionType];
            }
            else if (type == BDInfo.ProductionRate)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(def.eProductionType);
                progress.textInfo.text          = "ProductionRate : " + ((int)(def.ProductionRate * 3600.0f)).ToString("#,##0") + "+" + ((int)((defNext.ProductionRate - def.ProductionRate) * 3600.0f)).ToString("#,##0") + " per Hour";
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : defNext.ProductionRate / defLast.ProductionRate;
                progress.imageFront.fillAmount  = def.ProductionRate / defLast.ProductionRate;
            }
            else if (type == BDInfo.HitPoint)
            {
                progress.imageIcon.sprite       = Resources.Load <Sprite>("Icons/Heart");
                progress.textInfo.text          = "HitPoints : " + def.HitPoint.ToString("#,##0") + "+" + (defNext.HitPoint - def.HitPoint).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.HitPoint / (float)defLast.HitPoint;
                progress.imageFront.fillAmount  = (float)def.HitPoint / (float)defLast.HitPoint;
            }
            else if (type == BDInfo.StorageCapacity)
            {
                PayType payType = PayType.None;
                for (int i = 0; i < (int)PayType.Max; ++i)
                {
                    if (def.Capacity[i] != 0)
                    {
                        payType = (PayType)i;
                        break;
                    }
                }
                if (payType == PayType.None)
                {
                    return;
                }

                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(payType);
                progress.textInfo.text          = "Storage Capacity : " + def.Capacity[(int)payType].ToString("#,##0") + "+" + (defNext.Capacity[(int)payType] - def.Capacity[(int)payType]).ToString("#,##0");
                progress.imageMiddle.fillAmount = defNext.Capacity[(int)payType] / (float)defLast.Capacity[(int)payType];
                progress.imageFront.fillAmount  = def.Capacity[(int)payType] / (float)defLast.Capacity[(int)payType];
            }
            else
            {
            }
        }
Exemple #21
0
        // initialize building
        public void Init(int type, int level)
        {
            Type  = type;
            Level = level;

            // delete old meshes
            if (goCenter != null)
            {
                Destroy(goCenter); goCenter = null;
            }
            if (goXInc != null)
            {
                Destroy(goXInc); goXInc = null;
            }
            if (goZInc != null)
            {
                Destroy(goZInc); goZInc = null;
            }

            bt = TBDatabase.GetBuildingType(type);

            // get mesh path type and level
            int    displayLevel = (level == 0) ? 1 : level;
            string meshPath     = "Prefabs/Building/" + bt.Name + "_" + displayLevel.ToString();
            //Debug.Log ("Loading Mesh "+meshPath);

            // instantiate mesh and set to goCenter
            GameObject prefabMesh = Resources.Load(meshPath) as GameObject;

            goCenter = (GameObject)Instantiate(prefabMesh, Vector3.zero, Quaternion.identity);
            goCenter.transform.SetParent(gameObject.transform);
            goCenter.transform.localPosition = Vector3.zero;
            goCenter.transform.localRotation = Quaternion.Euler(0, -90, 0);

            // if wall
            if (type == 2)
            {
                // create x,z side mesh
                string     meshSidePath   = meshPath + "Side";
                GameObject prefabMeshSide = Resources.Load(meshSidePath) as GameObject;

                goXInc = (GameObject)Instantiate(prefabMeshSide, Vector3.zero, Quaternion.identity);
                goXInc.transform.SetParent(gameObject.transform);
                goXInc.transform.localPosition = Vector3.zero;
                goXInc.transform.localRotation = Quaternion.Euler(0, 180, 0);               // rotate to x direction

                goZInc = (GameObject)Instantiate(prefabMeshSide, Vector3.zero, Quaternion.identity);
                goZInc.transform.SetParent(gameObject.transform);
                goZInc.transform.localPosition = Vector3.zero;
                goZInc.transform.localRotation = Quaternion.Euler(0, 90, 0);               // rotate to z direction
            }

            // set tile size
            tileSize = new Vector2(bt.TileX, bt.TileZ);
            // set proper material to gogrid
            goGrid.GetComponent <Renderer>().material = Resources.Load("Materials/Tile" + bt.TileX.ToString() + "x" + bt.TileZ.ToString()) as Material;
            goGrid.transform.localScale           = new Vector3(bt.TileX, 1, bt.TileZ);
            goArrowXMinus.transform.localPosition = new Vector3(-(0.4f + (float)bt.TileX * 0.5f), 0.01f, 0);
            goArrowXPlus.transform.localPosition  = new Vector3((0.4f + (float)bt.TileX * 0.5f), 0.01f, 0);
            goArrowZMinus.transform.localPosition = new Vector3(0, 0.01f, -(0.4f + (float)bt.TileX * 0.5f));
            goArrowZPlus.transform.localPosition  = new Vector3(0, 0.01f, (0.4f + (float)bt.TileX * 0.5f));

            goArea.transform.localScale = new Vector3(bt.TileX, 1, bt.TileZ);

            // get ui
            if (transform.Find("UIBuilding"))
            {
                uiInfo = transform.Find("UIBuilding").transform.Find("UIInfo").GetComponent <UIInfo>();
            }
            else
            {
                uiInfo = UIInGame.instance.AddInGameUI(prefUIInfo, transform, new Vector3(0, 1.5f, 0)).GetComponent <UIInfo>();
            }
            uiInfo.groupInfo.gameObject.SetActive(false);
            uiInfo.groupProgress.gameObject.SetActive(false);
            uiInfo.groupCollect.gameObject.SetActive(false);
            uiInfo.Name.text  = TBDatabase.GetBuildingName(Type);
            uiInfo.Level.text = "Level " + displayLevel.ToString();
            uiInfo.building   = this;

            // currently not used
            goRangeIn.SetActive(false);
            goRangeOut.SetActive(false);

            // initialize values
            tilePosOld = tilePos;
            CheckLandable();
            CheckNeighbor();
            def              = TBDatabase.GetBuildingDef(Type, Level);
            defNext          = bt.GetDefine(Level + 1);
            defLast          = bt.GetDefLast();
            UpgradeTimeTotal = (defNext != null) ? defNext.BuildTime : 0;
        }