Ejemplo n.º 1
0
    private void PromptSave()
    {
        var comparer         = new WarehouseManager.Data.Comparer();
        var isDataSame       = comparer.Equals(this.Context.data.activeWarehouseData, this.warehouseManager.ActiveData);
        var isLevelCompleted = isDataSame && this.Context.data.activeWarehouseLevelMeta.firstCompletionDate.HasValue;

        this.alert.SetDefault();
        this.alert.TitleText       = isLevelCompleted ? "Upload" : "Completion Required";
        this.alert.DescriptionText = isLevelCompleted ? "Would you like to upload this level so others may play?" : "You must complete this level before uploading.";
        this.alert.AcceptText      = isLevelCompleted ? "Upload & Save" : "Play Now";
        this.alert.DeclineText     = "Nevermind";
        this.alert.Prompt(result =>
        {
            switch (result.result)
            {
            case Alert.ResultType.Accepted:
                if (isLevelCompleted)
                {
                    this.SaveActive();
                    this.UploadActive();
                }
                else
                {
                    this.PlayActiveLevel();
                }
                return;
            }
        });
    }
Ejemplo n.º 2
0
        public void SetActiveData(GameContext context, WarehouseManager.Data warehouseData, string relativePath = null)
        {
            var previousData = this._activeWarehouseData;

            WarehouseManager.MetaData.LevelMetaData levelMetaData = null;

            //var previousItems = (previousData?.buildItems ?? new List<WarehouseBuildItemRequest>())
            //    .OrderBy(x => x.column).ThenBy(x => x.row)
            //    .Select(x => x.Name)
            //    .ToList();
            //var newItems = (warehouseData?.buildItems ?? new List<WarehouseBuildItemRequest>())
            //    .OrderBy(x => x.column).ThenBy(x => x.row)
            //    .Select(x => x.Name)
            //    .ToList();

            // rotate data guid if there's a change (probably from editor)
            if (previousData?.Identifier == warehouseData.Identifier)
            {
                var comparer = new WarehouseManager.Data.Comparer();
                if (!comparer.Equals(previousData, warehouseData))
                {
                    warehouseData.RotateGuid();
                }
                else
                {
                    levelMetaData = this._activeWarehouseLevelMeta;
                }
            }

            // fallback to  existing meta
            if (levelMetaData == null)
            {
                var metaData = context.file.Get <WarehouseManager.MetaData>();
                levelMetaData = metaData.levelData.FirstOrDefault(x => x.Identifier == warehouseData.Identifier);
            }

            // finally fallback to new
            if (levelMetaData == null)
            {
                levelMetaData = new WarehouseManager.MetaData.LevelMetaData(warehouseData);
            }
            levelMetaData.relativePath = relativePath;

            this._activeWarehouseData      = warehouseData;
            this._activeWarehouseLevelMeta = levelMetaData;
            this._recentMovementHistory    = new List <BaseItem.MovementHistory>();
            Debug.Log($"Active data set to level localIdentifier: {this._activeWarehouseData?.localIdentifier}");
        }