示例#1
0
    bool LoadNext()
    {
        if (levelLoadingComplete)
        {
            return(false);
        }
        var            integralParent     = GameObject.Find("Integral").transform;
        var            decoratationParent = GameObject.Find("Decoration").transform;
        LevelDataBlock block   = CurrentWorld.GetBlockAt(CurrentLoadingLayer, X, Y);
        var            GObject = CurrentLoadingLayer == BlockLayers.Integral ? GetObject(block) : GetDecoration(block);

        if (GObject != null)
        {
            var transform = GObject.transform;
            transform.position = new Vector3(-X * Grid_Size.x, transform.position.y, Y * Grid_Size.y);
            transform.rotation = Quaternion.identity;
            transform.parent   = CurrentLoadingLayer == BlockLayers.Integral ? integralParent : decoratationParent;
            float angle = 0;
            switch (block.Rotation)
            {
            case SRotation.NORTH: angle = 0;   break;

            case SRotation.EAST: angle = 90;   break;

            case SRotation.WEST: angle = -90;  break;

            case SRotation.SOUTH: angle = 180; break;
            }
            transform.RotateAround(transform.position, Vector3.up, angle);
        }
        LoadingPercentage = (((Y * Level.Columns) + X) / ((float)Level.Total * 2)) + (CurrentLoadingLayer == BlockLayers.Decoration ? .5f : 0.0f);
        return(true);
    }
示例#2
0
 private void Populate(string searchTerm = "")
 {
     GalleryWrapper.Children.Clear();
     foreach (var block in LevelDataBlock.LoadAllFromDB())
     {
         if (searchTerm == "" || block.Name.ToLower().Contains(searchTerm.ToLower()))
         {
             var stack = new StackPanel();
             stack.Children.Add(new Image()
             {
             });
             stack.Children.Add(new TextBlock()
             {
                 Text         = block.Name,
                 TextWrapping = TextWrapping.Wrap,
                 //Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF343434"))
             });
             var button = new Button()
             {
                 Content    = stack,
                 Tag        = block,
                 Padding    = new Thickness(10),
                 Margin     = new Thickness(5, 5, 0, 0),
                 Background = new SolidColorBrush(AppResources.S_ColorConvert(block.Color))
             };
             button.Click += delegate
             {
                 OnDataSelected?.Invoke(this, button.Tag as LevelDataBlock);
             };
             GalleryWrapper.Children.Add(button);
         }
     }
 }
示例#3
0
 private GameObject GetDecoration(LevelDataBlock block)
 {
     textures = block.GetReferences(AssetType.Texture);
     if (TryGetByParameter(block, out var byParameter))
     {
         return(byParameter); // try getting by parameter
     }
     return(default);
 public void Load(LevelDataBlock subject)
 {
     if (Subject != subject)
     {
         Source  = subject.Parameters.Values.ToList();
         Subject = subject;
     }
     ParameterStack.Children.Clear();
     foreach (var param in Source)
     {
         var dock = new Grid()
         {
             Margin = new Thickness(0, 0, 0, 5)
         };
         dock.ColumnDefinitions.Add(new ColumnDefinition()
         {
             Width = new GridLength(1, GridUnitType.Star),
         });
         dock.ColumnDefinitions.Add(new ColumnDefinition()
         {
             Width = new GridLength(1, GridUnitType.Star)
         });
         var deleteButton = new Button()
         {
             Content = "x", Background = Brushes.DarkRed, BorderBrush = Brushes.Red, Margin = new Thickness(0, 0, 10, 0)
         };
         deleteButton.Click += DeleteButton_Click;
         deleteButton.Tag    = param;
         var stack = new DockPanel();
         stack.Children.Add(deleteButton);
         Grid.SetColumn(stack, 0);
         dock.Children.Add(stack);
         var textbox = new TextBox()
         {
             Text = param.Value
         };
         dock.Children.Add(textbox);
         Grid.SetColumn(textbox, 1);
         textbox.KeyDown += Textbox_KeyDown;
         textbox.Tag      = param;
         var nameBox = new TextBlock()
         {
             Margin = new Thickness(0, 0, 10, 0), Text = param.Name + ":"
         };
         DockPanel.SetDock(nameBox, Dock.Right);
         stack.Children.Add(nameBox);
         ParameterStack.Children.Add(dock);
     }
     AddNewButton.IsEnabled = true;
     BlockParameter.LoadParameterDB();
     namebox.AutoSuggestionList.Clear();
     foreach (var name in BlockParameter.ParameterDBDescriptions.Keys)
     {
         namebox.AutoSuggestionList.Add(name);
     }
 }
示例#5
0
 /// <summary>
 /// Gets the <see cref="LevelDataBlock"/> at the specified TilePosition in the World, if <see cref="VerifyTilePosition(int, int)"/> returns true
 /// </summary>
 /// <param name="Layer">The layer to get blocks from</param>
 /// <param name="X">The X Position</param>
 /// <param name="Y">The Y Position</param>
 /// <param name="BlockInfo">The Block data if found</param>
 /// <returns></returns>
 public bool TryGetBlockAt(BlockLayers Layer, int X, int Y, out LevelDataBlock BlockInfo)
 {
     BlockInfo = null;
     if (VerifyTilePosition(X, Y))
     {
         BlockInfo = GetBlockAt(Layer, X, Y);
         return(true);
     }
     return(false);
 }
    private void Load()
    {
        if (loaded)
        {
            return;
        }
        GameInitialization.Initialize();
        LevelDataBlock block = default;

        switch (Mode)
        {
        case KQLoaderMode.GUID:
            block = LevelDataBlock.LoadFromDatabase(BlockGUID, out bool success);
            break;

        case KQLoaderMode.Name:
            block = LevelDataBlock.LoadFromDatabase(BlockName);
            break;
        }
        if (block != null)
        {
            var newObject = CreateKrabbyQuestObject(block, 0, 0, ApplyMaterial);
            newObject.SetActive(true);
            var lTransform = newObject.transform;
            var scale      = newObject.transform.localScale;
            lTransform.parent        = transform;
            lTransform.localPosition = new Vector3(0, 0, 0);
            lTransform.localRotation = new Quaternion();
            lTransform.localScale    = scale;
            if (RemoveAnimation)
            {
                var anim = newObject.GetComponentInChildren <Animator>();
                if (anim != null)
                {
                    if (Application.isPlaying)
                    {
                        Destroy(anim);
                    }
                }
            }
            newObject.name = block.Name;
            Debug.Log(block.Name + " loaded");
        }
        loaded = true;
    }
示例#7
0
        public async Task FindDifferences()
        {
            if (Path1 == null || Path2 == null)
            {
                throw new Exception("None of the paths submitted can be null.");
            }
            var oldDBPath = LevelDataBlock.BlockDatabasePath;

            LevelDataBlock.BlockDatabasePath = Path1;
            DB1_BlockData = LevelDataBlock.LoadAllFromDB();
            LevelDataBlock.BlockDatabasePath = Path2;
            DB2_BlockData = LevelDataBlock.LoadAllFromDB();
            AddedBlocks   = new Dictionary <string, LevelDataBlock>();
            RemovedBlocks = new Dictionary <string, LevelDataBlock>();
            double total = DB1_BlockData.Length + DB2_BlockData.Length, current = 0;
            await Task.Run(delegate
            {
                foreach (var entry in DB1_BlockData)
                {
                    current++;
                    PercentUpdated?.Invoke(this, current / total);
                    if (!RemovedBlocks.ContainsKey(entry.GUID))
                    {
                        if (!DB2_BlockData.Where(x => x.GUID == entry.GUID).Any())
                        {
                            RemovedBlocks.Add(entry.GUID, entry);
                            continue;
                        }
                    }
                }
                foreach (var entry in DB2_BlockData)
                {
                    current++;
                    PercentUpdated?.Invoke(this, current / total);
                    if (!AddedBlocks.ContainsKey(entry.GUID))
                    {
                        if (!DB1_BlockData.Where(x => x.GUID == entry.GUID).Any())
                        {
                            AddedBlocks.Add(entry.GUID, entry);
                            continue;
                        }
                    }
                }
            });
        }
示例#8
0
    /// <summary>
    /// Loads all referenced sound effects into the Sound Cache
    /// </summary>
    /// <param name="DataBlock"></param>
    public void LoadAll(LevelDataBlock DataBlock)
    {
        List <string> references = new List <string>();

        foreach (var reference in DataBlock.GetReferences(AssetType.Sound))
        {
            references.Add(reference.DBName);
            if (SoundEffects.ContainsKey(reference.DBName))
            {
                continue;
            }
            var audio = LoadFromFile(reference.FileName);
            audio.name = reference.DBName;
            SoundEffects.Add(reference.DBName, audio);
        }
        SoundReferences = references.ToArray();
        Loaded          = true;
    }
示例#9
0
 private void Awake()
 {
     if (!TryGetComponent(out TileComponent) && InheritParent && !ForceTemplate)
     {
         TileComponent = GetComponentInParent <DataBlockComponent>();
     }
     // if (TileComponent?.TextureLoaded ?? false && !ForceTemplate)
     //   return;
     Data = TileComponent?.DataBlock;
     if (DefaultMaterial == null)
     {
         DefaultMaterial = (Material)Instantiate(Resources.Load("Materials/Object Material"));
     }
     if (Data == null || ForceTemplate)
     {
         Data = ApplyTileData(); // try to apply templated data
     }
     if (Data == null)
     {
         return;                                       // outright failure
     }
     textures = Data.GetReferences(AssetType.Texture); // get referenced textures
     if (Data.GetParameterByName("FLOOR", out _))      // floors
     {
         CreateFloor();
     }
     else if (Data.GetParameterByName("WALL", out _)) // walls
     {
         CreateWall();
     }
     else if (Data.GetParameterByName("FillTexture", out var parameter)) // generic fill texture parameter info
     {
         ApplyTextureMaterial(GetComponent <Renderer>(), int.Parse(parameter.Value));
     }
     else
     {
         ApplyTextureMaterial(GetComponentInChildren <Renderer>(), 0);
     }
     if (TileComponent != null)
     {
         TileComponent.TextureLoaded = true;
     }
     Loaded = true;
 }
 private void PopulateInfo(LevelDataBlock block)
 {
     AssetInfoStack.Children.Clear();
     AssetInfoStack.Children.Add(assetInfoLabel);
     foreach (var assetRef in block.AssetReferences)
     {
         Button border = new Button()
         {
             Background = Brushes.DarkCyan,
             Content    = $"Asset GUID: {assetRef.guid} \n" +
                          $"Asset Type: {assetRef.type}",
             Margin      = new Thickness(0, 0, 0, 5),
             Padding     = new Thickness(10, 5, 10, 5),
             BorderBrush = Brushes.Turquoise
         };
         border.Click += delegate
         {
             MainWindow.PushTab(new TextureToolPage(Properties.Settings.Default.DestinationDir, assetRef.guid));
         };
         AssetInfoStack.Children.Add(border);
     }
 }
 public ParameterDialog(LevelDataBlock subject) : this()
 {
     Load(subject);
 }
    /// <summary>
    /// Creates the object without any additional scripts from the given block info
    /// </summary>
    /// <param name="block"></param>
    /// <returns></returns>
    public static GameObject CreateKrabbyQuestObject(LevelDataBlock block, int X = 0, int Y = 0, Material ApplyMaterial = default)
    {
        Debug.Log("Creating object " + block.Name);
        void applyLevelBlock(GameObject obj)
        {
            var blockComponent = obj.AddComponent <DataBlockComponent>();

            blockComponent.DataBlock  = block;
            blockComponent.WorldTileX = X;
            blockComponent.WorldTileY = Y;
            blockComponent.Parent     = obj;
        }

        GameObject     returnVal = default;
        BlockParameter parameter = default;

        if (block.GetParameterByName("FLOOR", out parameter))
        {
            returnVal = Instantiate(ResourceLoad("Objects/GroundTileObject")); // create a floor
        }
        else if (block.GetParameterByName("WALL", out parameter))
        {
            switch (parameter.Value)
            {
            case "Low":
                returnVal = Instantiate(ResourceLoad("Objects/LowWallObject"));
                break;

            case "Medium":
                returnVal = Instantiate(ResourceLoad("Objects/MidWallObject"));
                break;

            case "High":
                returnVal = Instantiate(ResourceLoad("Objects/HighWallObject"));
                break;
            }
        }
        else if (block.GetParameterByName("Prefab", out parameter))
        {
            var prefab = ResourceLoad("Objects/" + parameter.Value);
            if (prefab != null)
            {
                returnVal = Instantiate(prefab);
                var loader = returnVal.GetComponentInChildren <ModelLoader>();
                if (loader != null)
                {
                    loader.ApplyMaterial = ApplyMaterial;
                }
            }
        }
        else if (block.GetParameterByName("ServiceObject", out _))
        {
            switch (block.BlockLayer)
            {
            case BlockLayers.Decoration:
                returnVal = Instantiate(ResourceLoad("Objects/AnonymousObject"));
                break;

            case BlockLayers.Integral:
                returnVal = Instantiate(ResourceLoad("Objects/AnonymousIntegralObject"));
                break;
            }
        }
        else if (block.Name?.Contains("THROWER") ?? false)
        {
            returnVal = Instantiate(ResourceLoad("Objects/TentacleCannon"));
        }
        else if (block.Name?.StartsWith("SPROUT") ?? false)
        {
            returnVal = Instantiate(ResourceLoad("Objects/TentacleSpike"));
        }
        else if (block.HasModel || block.GetParameterByName("ApplyTemplater", out _))
        {
            returnVal = Instantiate(ResourceLoad("Objects/EmptyObject"));
            var loader = returnVal.AddComponent <ModelLoader>();
            loader.ApplyMaterial = ApplyMaterial;
        }
        if (returnVal == null)
        {
            return(null);
        }
        returnVal.name = block.Name;
        applyLevelBlock(returnVal);
        return(returnVal);
    }
示例#13
0
 private bool TryGetByParameter(LevelDataBlock blockData, out GameObject byParameter)
 {
     byParameter = GetObjectByParameter(blockData);
     return(byParameter != default);
 }