Map Events

You can create your own Map Events if the existing ones are not doing what you'd like to do. Or you can edit existing ones. They can be found in Scripts/Events folder. Map events will be activated

AreEventsConditionMet : Will check if the event can be done. This function can be especially useful for events that are triggered by a choice event. The choices that return a false condition will not be displayed in the list of choices for the event.

DoEvent: The code executed when the players move to that location and the event start.

Let's create an example event that gives a random card to a champion. If the championhas less than 10 cards in their deck. Since this example is not linked to any UI, it would best be used as choice when selecting from an EventChoice. Or as chain event after an EventText.

[CreateAssetMenu(fileName = "Special", menuName = "TcgEngine/MapEvent/Special", order = 10)]
public class EventSpecial : EventData
{

    public override bool AreEventsConditionMet(World world, Champion champion)
    {
        return champion.cards.Count < 10;
    }

    public override void DoEvent(WorldLogic logic, Champion champion)
    {
        int seed = logic.WorldData.GetLocationSeed(1234);                              //Use seed-based randomization, so the result is based on seed selected in menu
        System.Random rand = new System.Random(seed);
        List<CardData> cards = CardData.GetRewardCards(champion.ChampionData.team); //List of champions cards that can be unlocked
        CardData card = cards[rand.Next(0, cards.Count)];                           //Get Random card
        champion.AddCard(card);
    }

}

Then, like other scriptable objects, you would need to create the data file for this event in the Resources folder by right click - TcgEngine/MapEvent/Special.

Last updated