public static EntityDataTowerPreview Create(TowerData towerData, object userData = null)
        {
            EntityDataTowerPreview entityData = ReferencePool.Acquire <EntityDataTowerPreview>();

            entityData.TowerData = towerData;
            return(entityData);
        }
        protected override void OnHide(bool isShutdown, object userData)
        {
            base.OnHide(isShutdown, userData);

            currentArea            = null;
            m_GridPosition         = IntVector2.zero;
            entityDataTowerPreview = null;
        }
        protected override void OnShow(object userData)
        {
            base.OnShow(userData);

            entityDataTowerPreview = userData as EntityDataTowerPreview;
            if (entityDataTowerPreview == null)
            {
                Log.Error("EntityDataTowerPreview param is invaild");
                return;
            }

            canPlace = false;
            validPos = false;
            moveVel  = Vector3.zero;
            SetVisiable(true);
        }
        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));
        }