-
Notifications
You must be signed in to change notification settings - Fork 0
ScrollMaster 2D - Sua Base Completa para Jogos Side-Scrolling na Unity #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Underewarrr
wants to merge
18
commits into
main
Choose a base branch
from
dev-scrollmaster-engine
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. **Brick**
- **Descrição:** Um jogo estilo Breakout utilizando Tilemap e Física 2D.
- **Funcionalidade:** Utiliza contatos de colisão do Physics2D para determinar qual célula no Tilemap é atingida quando há uma colisão.
- **Instruções:** Abra a cena `Brick` para começar. Execute este exemplo para iniciar o jogo.
2. **Destructible**
- **Descrição:** Demonstração de como os Tilemaps podem ser alterados em tempo de execução utilizando Tiles Scripted.
- **Funcionalidade:** Clique em uma localização para causar uma explosão e observe os efeitos subsequentes.
- **Instruções:** Abra a cena `Destructible` para começar. Execute este exemplo jogando-o.
3. **Brushes**
- **Descrição:** Seleção e uso de Brushes Scripted a partir do menu suspenso na Paleta de Tiles.
- **Funcionalidade:** Pinte com o Brush escolhido e visualize parâmetros adicionais para o Brush selecionado.
- **Instruções:** Escolha o Brush desejado na Paleta de Tiles e comece a pintar.
4. **Tiles**
- **Descrição:** Configuração de Paletas de Tiles para diferentes tipos de Tiles Scripted.
- **Funcionalidade:** Aprenda mais sobre a configuração dos assets de Tile.
- **Instruções:**
- Selecione o Tile na Paleta de Tiles.
- Clique com o botão direito na Paleta de Tiles.
- Clique em `Selecionar Asset de Tile`.
5. **Palette Swap**
- **Descrição:** Demonstração de como os Tiles em um Tilemap podem ser trocados entre diferentes Prefabs de Paleta.
- **Funcionalidade:** Use as teclas `A` e `D` para alternar entre as paletas.
- **Instruções:** Abra a cena `Palette Swap` para começar. Execute este exemplo jogando-o.
- **Compatibilidade:** Este repositório é compatível com Unity 2021.1.0f1 em diante.
- **Documentação Oficial da Engine ScrollMaster 2D :** [Acesse a documentação completa](#EmConstrucao) para informações detalhadas sobre todas as funcionalidades e ferramentas.
---
Estamos ansiosos para ver o que você vai criar com os exemplos e recursos fornecidos. Compartilhe suas experiências e projetos na nossa comunidade!
Bons estudos e boas criações!
Unity 2D Procedural Generation: Inicialmente, discutimos a criação de um script em Unity para geração procedural de terreno utilizando Tilemaps. Adicionamos árvores ao terreno com posições aleatórias e diferentes alturas de colisão. Configurando Árvores com Offsets Variados: Continuamos aprimorando o script de geração de árvores, permitindo configurar diferentes prefabs e offsets de altura para as árvores. Scriptable Object para Configuração de Árvores: Criamos um ScriptableObject para gerenciar as configurações das árvores, incluindo prefabs, offsets e saúde da árvore. Default Landscapes: Adicionamos configurações de paisagens padrão ao script de geração procedural, permitindo escolher entre diferentes paisagens predefinidas para iniciar o jogo. Erro CS0103: Resolvido um erro de compilação relacionado ao grassTile não sendo encontrado no contexto atual, ajustando a referência ao TileBase. Criação de Paisagens Complexas: Implementamos a lógica para gerar terrenos com áreas elevadas e zonas inimigas, configuráveis via ScriptableObject para testes de diferentes paisagens. Geração Procedural Avançada: Refinamos a geração de terrenos para incluir áreas randômicas com baús, que devem ser gerados em terrenos elevados. Configuração de Itens: Adicionamos configurações de itens de madeira e gravetos (stick) que seriam dropados ao interagir com as árvores. Controle de Coleta de Árvores: Criamos um TreeController que permite coletar recursos das árvores ao pressionar uma tecla. Adicionamos uma interface para mostrar um botão de coleta quando o jogador se aproxima. Inventário do Jogador: Desenvolvemos um InventoryController para gerenciar os itens coletados pelo jogador, como madeira e gravetos. UI de Coleta: Ajustamos o TreeController para exibir um botão de coleta ao jogador se aproximar da árvore, utilizando tags para identificação. Efeito de "Bounce" nas Árvores: Adicionamos um efeito visual de "bounce" nas árvores quando o jogador coleta recursos, para dar um feedback visual. Controle de Itens no Editor: Implementamos a visualização dos itens do inventário no editor do Unity, separados por categoria, utilizando CustomEditor. Registro de Itens no Jogo: Adicionamos um GameInitializer para registrar os itens no início do jogo, garantindo que todos os ItemConfig estejam disponíveis no banco de dados de itens. Verificação e Atualização do Inventário: Ajustamos o InventoryController para verificar mudanças no inventário e atualizar automaticamente a interface do editor para refletir a quantidade de itens coletados.
EnemyHealthController: Descrição: Gerencia a saúde do inimigo, aplica dano e atualiza a barra de saúde na UI. Concede experiência ao jogador ao morrer. Propriedades: int maxHealth: Saúde máxima do inimigo. int currentHealth: Saúde atual do inimigo. Slider healthBarSlider: Referência ao Slider da barra de saúde na UI. EnemyConfig enemyConfig: Configuração do inimigo. EnemyExpController expController: Controlador de experiência do inimigo. Métodos: void Start(): Inicializa a saúde e configura a barra de saúde. void TakeDamage(int damage): Aplica dano ao inimigo e verifica se deve morrer. void Die(): Concede experiência ao jogador e destrói o inimigo. void Initialize(int initialHealth): Inicializa a saúde do inimigo. void UpdateHealthBar(): Atualiza a barra de saúde na UI. EnemyController: Descrição: Gerencia o comportamento do inimigo, incluindo movimento e ataques. O inimigo segue o jogador e ataca quando está dentro do alcance. Propriedades: EnemyConfig enemyConfig: Configuração do inimigo. Transform player: Referência ao jogador. float attackRange: Alcance do ataque do inimigo. float attackCooldown: Tempo de recarga entre ataques. float currentSpeed: Velocidade atual do inimigo. string currentAnimation: Animação atual do inimigo. Parâmetros do Animator: speedParameter, isAttackingParameter. Métodos: void Start(): Inicializa o inimigo e configura as referências necessárias. void Update(): Atualiza o movimento e ataques do inimigo a cada frame. void InitializeEnemy(): Configura o inimigo com base nas configurações definidas. void HandleMovement(): Gerencia o movimento do inimigo em direção ao jogador. void Flip(): Inverte a direção do sprite do inimigo. void HandleAttacks(): Gerencia os ataques do inimigo. void DealDamage(): Aplica dano ao jogador. void LogCurrentAnimation(): Registra a animação atual para depuração. void TakeDamage(int damage): Aplica dano ao inimigo. EnemyExpController: Descrição: Gerencia a concessão de experiência ao jogador quando o inimigo morre. Propriedades: EnemyConfig enemyConfig: Configuração do inimigo. Métodos: void GiveExpToPlayer(): Concede experiência ao jogador quando o inimigo morre. EnemyConfig: Descrição: Configura as propriedades dos inimigos, incluindo saúde, dano de ataque e valor de experiência. Propriedades: string enemyName: Nome do inimigo. int maxHealth: Saúde máxima do inimigo. float moveSpeed: Velocidade de movimento do inimigo. int attackDamage: Dano de ataque do inimigo. int expValue: Valor de experiência concedido ao jogador quando o inimigo morre.
Enemy Jumping and Following System Update Feature Added: Enemy jumping logic to overcome obstacles. Details: The enemy now checks for obstacles in its path using line rendering. If an obstacle is detected, the enemy will jump over it using a configured jump force. Debugging: Line renderers were added to visualize the enemy's pathfinding and jumping logic in the Unity Editor. ChestController and Config Implementation Feature Added: ChestController to manage loot drops, experience gain, and potential monster spawns from chests. Details: The chest now has a ChestConfig that specifies items to drop, experience points to grant, and a chance to spawn a monster. The chest opens with an animation triggered by the isOpen boolean parameter in the animator. TerrainController Enemy Spawn Fix Bug Fixed: Duplicate key error in the enemy spawning system. Details: Corrected the logic for storing spawned enemies to ensure no duplicate keys are added to the dictionary. This fixed the issue of crashing due to duplicate keys. Inventory UI System Overhaul Feature Added: Inventory UI system to dynamically display items categorized by type. Details: The InventoryUIHelper script creates a button in the middle of the screen to open the inventory panel. The inventory items are displayed in categorized panels, updating dynamically when the inventory changes. Bug Fixed: Null reference exception when creating category panels and updating inventory items. Item Drop System Update for Trees Feature Added: TreeController's item drop system updated to ensure items drop correctly. Details: Corrected the logic for dropping items from trees when the player collects resources. The items now drop as expected from all trees, not just the first one spawned.
TerrainController The TerrainController is responsible for dynamically generating terrain using different tilemaps for grass, rock, dirt, and ore tiles. It also handles tree and enemy generation within the specified landscape configuration. Class TerrainController The TerrainController class manages the generation of tiles, trees, and enemies based on the LandscapeConfig settings. Inspector View: Properties: grassTilemap: Reference to the Tilemap for grass tiles. rockTilemap: Reference to the Tilemap for rock tiles. dirtTilemap: Reference to the Tilemap for dirt tiles. oreTilemap: Reference to the Tilemap for ore tiles. landscapeConfig: Reference to the LandscapeConfig used for terrain generation. treesParent: Parent Transform for tree objects. enemiesParent: Parent Transform for enemy objects. Methods: Start(): Initializes the colliders and regenerates the terrain. EnsureColliders(): Ensures that each Tilemap has a TilemapCollider2D and a Rigidbody2D. EnsureCollider(Tilemap tilemap): Adds a TilemapCollider2D and Rigidbody2D to the specified Tilemap if they don't already exist. RegenerateTerrain(): Clears existing objects and generates the terrain and trees. ClearExistingObjects(): Clears all tiles and child objects from the Tilemaps and parents. ClearChildren(Transform parent): Destroys all child objects of the specified parent Transform. GenerateTerrainAndTrees(): Iterates through the biomes in the LandscapeConfig and generates the terrain, dirt, ores, and trees. GenerateColumn(int x, int finalHeight, LandscapeConfig.Biome biome): Generates a column of tiles for the specified biome. GenerateDirt(int x, int finalHeight, LandscapeConfig.Biome biome): Generates dirt tiles based on the dirt configuration. GetTilemapToUse(TileBase tile, LandscapeConfig.Biome biome): Determines which Tilemap to use based on the tile type. GetTileToPlace(int x, int y, int finalHeight, LandscapeConfig.Biome biome): Determines which tile to place based on the position and biome settings. IsPlayerSpace(int x, int y, LandscapeConfig.Biome biome): Determines if a space should be left for the player to walk through. GenerateTrees(int x, int terrainHeight, LandscapeConfig.Biome biome): Generates trees at the specified position based on the tree configurations. GenerateEnemies(int x, int terrainHeight, LandscapeConfig.EnemyConfig enemyConfig): Generates enemies at the specified position based on the enemy configuration. GenerateOres(int x, int finalHeight, LandscapeConfig.Biome biome): Generates ore tiles based on the ore configurations. IsDirtArea(int x, LandscapeConfig.Biome biome): Determines if an area should be a dirt area based on the dirt configuration. LandscapeConfig The LandscapeConfig is a ScriptableObject that contains configuration settings for different biomes. Each biome has settings for grass, rock, dirt, ore tiles, and other environmental features. Class LandscapeConfig The LandscapeConfig class defines the structure and properties of the biomes used in terrain generation. Inspector View: Properties: biomes: An array of biomes, each containing settings for grass, rock, dirt, ores, trees, and enemies. Nested Structures: Biome: Defines the properties of a biome, including tilemaps, tiles, amplitudes, and configurations for caves, dirt, and ores. name: The name of the biome. biomeWidth: The width of the biome. biomeHeight: The height of the biome. grassTilemapName: The name of the Tilemap for grass tiles. grassTile: The TileBase for grass tiles. grassAmplitude: The amplitude for grass height variation. mountainFrequency: The frequency of the mountains. rockTilemapName: The name of the Tilemap for rock tiles. rockTile: The TileBase for rock tiles. caveConfig: Configuration for caves. dirtTilemapName: The name of the Tilemap for dirt tiles. dirtTile: The TileBase for dirt tiles. dirtConfig: Configuration for dirt areas. oreTilemapName: The name of the Tilemap for ore tiles. oreConfigs: An array of configurations for different types of ores. treeConfigs: An array of configurations for tree spawning. TreeSpawnConfig: Defines the properties for tree spawning. treeConfig: Reference to the TreeConfig. spawnFrequency: The frequency at which trees spawn. CaveConfig: Defines the properties for cave generation. caveFrequency: The frequency of the cave noise. caveThreshold: The threshold for determining cave tiles. enablePlayerSpaces: Whether to enable spaces for the player to walk. playerSpaceRange: The range for player space width. DirtConfig: Defines the properties for dirt generation. spawnChance: The chance of spawning dirt tiles. dirtFrequency: The frequency of the dirt noise. dirtDepth: The depth of dirt tiles. dirtRadius: The radius of dirt areas. enemyConfig: Configuration for enemies in dirt areas. enemySpawnFrequency: The frequency of enemy spawning. enemySpawnRange: The range for enemy spawning. OreConfig: Defines the properties for ore generation. oreTile: The TileBase for ore tiles. spawnChance: The chance of spawning ore tiles. oreFrequency: The frequency of the ore noise. oreDepth: The depth at which ores can spawn. EnemyConfig: Defines the properties for enemy generation. enemyPrefab: The prefab for the enemy. spawnChance: The chance of spawning enemies. maxQuantity: The maximum number of enemies to spawn. enemySpawnOffset: The offset for enemy spawning positions. This documentation should now clearly outline the new structure and logic for generating the terrain with grass, rock, dirt, and ore tiles, as well as tree and enemy spawning configurations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://unityking.org/threads/scrollmaster-2d-sua-base-completa-para-jogos-side-scrolling-na-unity.6/