Ejemplo n.º 1
0
    private void ApplyEffect(CardData.CardEffectChance effect, string defaultStartText, EffectEventType type)
    {
        string message = "";

        if (effect != null)
        {
            Villagers += effect.villagerChange;
            Goats     += effect.goatChange;
            Maidens   += effect.maidenChange;
            YoungLads += effect.youngLadChange;
            deck.AddToDeck(effect.unlockedCards);
            if (defaultStartText != null && defaultStartText != "")
            {
                message += defaultStartText + System.Environment.NewLine;
            }
            message += CardData.GetEffectText(effect) + System.Environment.NewLine;
        }
        else
        {
            if (defaultStartText != null && defaultStartText != "")
            {
                message = defaultStartText;
            }
            else
            {
                message = "Nothing Happened";
            }
        }
        AddEventMessage(message, type);
    }
Ejemplo n.º 2
0
    void DayChangedHandler(int curDay, System.Action onDayComplete)
    {
        bool messageAdded = false;

        for (int i = 0; i < delayedEffects.Count; i++)
        {
            CardData.DelayedEffect dE = delayedEffects[i];
            if (dE.dayOfActivation <= CurrentDay)
            {
                CardData.CardEffectChance e = PickEffect(dE.effects);
                ApplyEffect(e, null, EffectEventType.LongTerm);
                messageAdded = true;
                delayedEffects.RemoveAt(i);
                i--;
                // Debug.Log(message);
                //show message
            }
        }
        if (messageAdded)
        {
            DisplayMessageList(delegate { onDayComplete?.Invoke(); }, UIManager.CARD_MOVE_TIME);
        }
        else
        {
            onDayComplete?.Invoke();
        }
        notificationManager.RefreshNotificaitons(CurrentDay);
    }
Ejemplo n.º 3
0
    private static string GetDescription(CardData data)
    {
        StringBuilder result = new StringBuilder();

        result.AppendLine(data.description);
        result.AppendLine();
        float totalChance = 0;

        for (int i = 0; i < data.effects.Length; i++)
        {
            CardData.CardEffectChance effect = data.effects[i];
            totalChance += effect.chance;
            if (effect.chance < 1)
            {
                result.Append("<size=140%>");
                result.Append((effect.chance * 100).ToString());
                result.Append("% ");
                result.Append("<size=100%>");
            }
            result.Append(CardData.GetEffectText(effect));
            result.AppendLine();
        }
        if (totalChance < 1.0 && data.effects.Length > 0)
        {
            Debug.LogError(data.title + "Percentages don't add up to 1: " + totalChance);
        }
        return(result.ToString());
    }
Ejemplo n.º 4
0
    private CardData.CardEffectChance PickEffect(CardData.CardEffectChance[] chances)
    {
        float effectNumber = Random.Range(0.0f, 1.0f);
        float accum        = 0;

        for (int i = 0; i < chances.Length; i++)
        {
            CardData.CardEffectChance effectChance = chances[i];
            accum += effectChance.chance;
            if (effectNumber <= accum)
            {
                return(effectChance);
            }
        }
        return(null);
    }
Ejemplo n.º 5
0
    private void CardClickedHandler(CardData data)
    {
        if (currentState == GameState.ChoosingCard)
        {
            CardData.CardEffectChance choosenEffect = PickEffect(data.effects);
            ApplyEffect(choosenEffect, data.defaultStartText, EffectEventType.Normal);
            DisplayMessageList(BeginNextTurn, 0);

            for (int i = 0; i < data.delayedEffects.Length; i++)
            {
                data.delayedEffects[i].dayOfActivation = CurrentDay + data.delayedEffects[i].duration;
                delayedEffects.Add(data.delayedEffects[i]);
                notificationManager.AddNotification(data.delayedEffects[i].notificaitonText, data.delayedEffects[i].dayOfActivation);
            }
            notificationManager.RefreshNotificaitons(CurrentDay);
            if (data.discardOnUse)
            {
                deck.RemoveFromDeck(data);
            }
        }
    }