Example #1
0
        protected int ShowEntity(EnumEntity enumEntity, Type entityLogicType, Action <Entity> onShowSuccess, object userData = null)
        {
            if (entityLoader == null)
            {
                entityLoader = EntityLoader.Create(this);
            }

            return(entityLoader.ShowEntity(enumEntity, entityLogicType, onShowSuccess, userData));
        }
        public void OnEnter()
        {
            entityLoader = EntityLoader.Create(this);
            dataLevel    = GameEntry.Data.GetData <DataLevel>();
            dataPlayer   = GameEntry.Data.GetData <DataPlayer>();
            dataTower    = GameEntry.Data.GetData <DataTower>();
            dataEnemy    = GameEntry.Data.GetData <DataEnemy>();

            GameEntry.UI.OpenUIForm(EnumUIForm.UILevelMainInfoForm);
            GameEntry.UI.OpenUIForm(EnumUIForm.UITowerListForm);

            entityLoader.ShowEntity <EntityPlayer>(EnumEntity.Player, null, EntityData.Create(level.PlayerPosition, level.PlayerQuaternion));
        }
        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));
        }