Skip to content

Instantly share code, notes, and snippets.

View LuizMoratelli's full-sized avatar

Luiz Augusto Moratelli LuizMoratelli

View GitHub Profile
@LuizMoratelli
LuizMoratelli / AILogic.cs
Last active February 17, 2025 16:39
[TcgEngine] Custom Mana System
private void CalculateNode(Game data, NodeState node)
{
//...
bool is_full_mana = HasAction(action_list, GameAction.PlayCard) && player.ManaMax() >= player.Mana();
//...
}
@LuizMoratelli
LuizMoratelli / readme.md
Last active September 9, 2024 00:49
[TCG Engine] 🤝 [mopsicus/uis]

0. Explanation

Mopsicus/UIs will be used to avoid a lot of instanciate of cards, that could cause some lags when you have a TON of cards. With this implementation, the Scroller will only spawn some rows, like ~7 and replace the values when the user scroll down and up.

1. Install mopsicus/uis (https://github.com/mopsicus/uis)

2. Edit CardData.cs

public static CardData GetCard(int index)
{
    if (index >= card_list.Count)
        return null;
@LuizMoratelli
LuizMoratelli / card-preview.md
Created August 12, 2024 13:56
[Odin] Card preview

Creating a Card Preview with Odin

1. Creating a PreviewCardScene

using UnityEditor.SceneManagement;
using UnityEngine;

public class PreviewCardScene : PreviewSceneStage
{

The Problem

When you have sprites/images overlapping and you apply alpha (via CanvasGroup or direct) it allows the color/image behind to mix with the transparent one, displaying this annoying stuff when you have borders, lines, etc.

image

The Solution

1. Create a new Shader

@LuizMoratelli
LuizMoratelli / readme.md
Last active October 11, 2024 13:43
[TCG Engine] Response Turn, interaction in opponent's turns.

First of all, this is a poc (proof of concept) be prepared to adapt, fix or encounter bugs for your specific game, I would be happy trying to help you.

Response Idea

The idea here is to allow some interaction between players in same turn. You can expand, adapt and change to fit your game, adding response on stack, or attack as response, is up to you.

What could be interacted following the steps below:

  • Selectors (Card, Target and Choice);
  • Play Cards with specific trait (similar to flash);
  • Activate Abilities;
@LuizMoratelli
LuizMoratelli / AILogic.cs
Last active October 15, 2024 10:47
[TCGEngine] Stack Response
//replace(2x) Player player = data.GetPlayer(data.current_player); ->
Player player = data.response_phase == ResponsePhase.Response ? data.GetPlayer(data.response_player) : data.GetPlayer(data.current_player);
//replace(1x) Player player = data.GetPlayer(player_id); ->
Player player = data.response_phase == ResponsePhase.Response ? data.GetPlayer(data.response_player) : data.GetPlayer(data.current_player);