Пример #1
0
        public void showBuildButton()
        {
            if (StaticVar.currentSelectedTile == null)
            {
                return;
            }
            if (preBuildTypeList != null)
            {
                foreach (BuildType type in preBuildTypeList)
                {
                    BuildButtonCtrl buildButtonCtrl = buildButtonCtrlDic[type];
                    buildButtonCtrl.transform.localPosition = new Vector3(1000, 0, 0);
                }
            }
            List <BuildType> buildTypelist = Tool.getBuildTypeList(StaticVar.currentSelectedTile);

            preBuildTypeList = buildTypelist;
            int i = 1;

            foreach (BuildType type in buildTypelist)
            {
                BuildButtonCtrl buildButtonCtrl = buildButtonCtrlDic[type];
                buildButtonCtrl.transform.localPosition = new Vector3(i * 100 - Screen.width / 2, -Screen.height / 2 + 50, 0);
                i++;
            }
        }
Пример #2
0
        public void init()
        {
            gameObject = GameObject.Find("BuildPanel").gameObject;
            foreach (Builder builder in GameConfigure.instance.buildLibrary.builderList)
            {
                BuildButtonCtrl buildButtonCtrl = Object.Instantiate(GameConfigure.instance.buildButtonCtrlPrefab, gameObject.transform);
                buildButtonCtrl.transform.localPosition = new Vector3(1000, 0, 0);
                buildButtonCtrl.text.text = builder.buildName;

                BuildButton buildButton = new BuildButton();
                buildButton.name            = builder.buildType.ToString();
                buildButton.builder         = builder;
                buildButtonCtrl.buildButton = buildButton;

                buildButtonCtrlList.Add(buildButtonCtrl);
            }
            buildButtonCtrlDic = buildButtonCtrlList.ToDictionary(t => t.buildButton.builder.buildType);
        }