public void SetTowerBuildButton(TowerData towerData, Action <TowerData> onClick)
        {
            if (towerData == null)
            {
                return;
            }

            this.towerData = towerData;

            towerLevelData = towerData.GetTowerLevelData(0);

            energyText.text = towerLevelData.BuildEnergy.ToString();
            foreach (var item in iconList)
            {
                if (towerData.Icon == item.name)
                {
                    towerIcon.sprite = item;
                }
            }

            dataPlayer = GameEntry.Data.GetData <DataPlayer>();
            UpdateEnergyState(dataPlayer.Energy);

            this.onClick = onClick;
        }
コード例 #2
0
        public void CreateTower(TowerData towerData, IPlacementArea placementArea, IntVector2 placeGrid, Vector3 position, Quaternion rotation)
        {
            if (towerData == null)
            {
                return;
            }

            TowerLevelData towerLevelData = towerData.GetTowerLevelData(0);

            if (dataPlayer.Energy < towerLevelData.BuildEnergy)
            {
                return;
            }

            dataPlayer.AddEnergy(-towerLevelData.BuildEnergy);

            Tower tower = dataTower.CreateTower(towerData.Id);

            if (tower == null)
            {
                Log.Error("Create tower fail,Tower data id is '{0}'.", towerData.Id);
                return;
            }

            entityLoader.ShowEntity(towerData.EntityId, TypeUtility.GetEntityType(tower.Type),
                                    (entity) =>
            {
                EntityTowerBase entityTowerBase = entity.Logic as EntityTowerBase;
                dicTowerInfo.Add(tower.SerialId, TowerInfo.Create(tower, entityTowerBase, placementArea, placeGrid));
            }
                                    , EntityDataTower.Create(tower, position, rotation));

            HidePreviewTower();
        }
コード例 #3
0
        public void ShowPreviewTower(TowerData towerData)
        {
            if (towerData == null)
            {
                return;
            }

            previewTowerData   = towerData;
            uiMaskFormSerialId = GameEntry.UI.OpenUIForm(EnumUIForm.UIMask);


            entityLoader.ShowEntity <EntityTowerPreview>(towerData.PreviewEntityId, (entity) =>
            {
                previewTowerEntity      = entity;
                previewTowerEntityLogic = entity.Logic as EntityTowerPreview;
                if (previewTowerEntityLogic == null)
                {
                    Log.Error("Entity '{0}' logic type invaild, need EntityTowerPreview", previewTowerEntity.Id);
                    return;
                }

                TowerLevelData towerLevelData = towerData.GetTowerLevelData(0);
                if (towerLevelData == null)
                {
                    Log.Error("Tower '{0}' Level '{1}' data is null.", towerData.Name, 0);
                }

                EntityDataRadiusVisualiser entityDataRadiusVisualiser = EntityDataRadiusVisualiser.Create(towerLevelData.Range);

                entityLoader.ShowEntity <EntityRadiusVisualizer>(EnumEntity.RadiusVisualiser, (entityRadiusVisualizer) =>
                {
                    GameEntry.Entity.AttachEntity(entityRadiusVisualizer, previewTowerEntity);
                },
                                                                 entityDataRadiusVisualiser);

                isBuilding = true;
            },
                                                         EntityDataTowerPreview.Create(towerData));
        }
コード例 #4
0
        public void ShowBuildInfo(TowerData towerData)
        {
            if (towerData == null)
            {
                return;
            }

            TowerLevelData towerLevelData = towerData.GetTowerLevelData(0);

            if (towerLevelData == null)
            {
                return;
            }

            buildInfoName.text = towerData.Name;
            buildInfoDps.text  = towerLevelData.DPS.ToString();
            BuildInfoDes.text  = towerLevelData.Des;

            GameEntry.Event.Fire(this, ShowPreviewTowerEventArgs.Create(towerData));

            showBuildInfo = true;
        }