// for marking the parameters that will be afftected - when swiping to each direction
    public int [] MarkPossibleEffects(int currentCardId, bool isRight)
    {
        bibiCard currBibiCard = bibiCards.UnitySheet.Find(x => x.id == currentCardId);

        int[] vals = GetEffectVals(currBibiCard, isRight);

        Debug.Log("MarkPossibleEffects cardId: " + currBibiCard.Id + " " + vals[0] + " " + vals[1] + " " + vals[2] + " " + vals[3]);


        int [] possibleEffects = new int[] { 0, 0, 0, 0 };
        for (int i = 0; i < 4; i++)
        {
            if (vals[i] == midParamEffect)// no effect
            {
                possibleEffects[i] = 0;
            }
            else if (vals[i] == midParamEffect * 2 || vals[i] == 0)// extreme effect
            {
                possibleEffects[i] = 2;
            }
            else
            {
                possibleEffects[i] = 1;
            }
        }

        Debug.Log("MarkPossibleEffects cardId: " + currBibiCard.Id + " " + possibleEffects[0] + " " + possibleEffects[1] + " " + possibleEffects[2] + " " + possibleEffects[3]);


        return(possibleEffects);
    }
    public int SwipeEffectOnParams(bibiCard currBibiCard, bool isRight)
    {
        // on swipe left - the text is shown on the right
        // therefore swipe left chooses the right option
        int[] vals = GetEffectVals(currBibiCard, !isRight);
        Debug.Log("SwipeEffectOnParams cardId: " + currBibiCard.Id + " " + vals[0] + " " + vals[1] + " " + vals[2] + " " + vals[3]);

        for (int i = 0; i < 4; i++)
        {
            float rowEffect = vals[i] - midParamEffect;
            float effect    = rowEffect * unitEffect;
            valParams[i] += effect;
            if (valParams[i] <= thresholdEmpty)
            {
                valParams[i] = 0;
            }
            else if (valParams[i] >= thresholdFull)
            {
                valParams[i] = 1;
            }
            Debug.Log("val:" + vals[i] + " rowEffect:" + rowEffect + " unitEffect:" + unitEffect + " effect:" + effect + " valParam:" + valParams[i]);

            gameParams[i].fillAmount += effect;

            CheckThreshold(i);
        }

        int wishCardId = CheckEndGame();

        StartCoroutine(SignalUpDown(vals));

        return(wishCardId);
    }
示例#3
0
 string DescribeItemEntity(bibiCard entity)
 {
     return(string.Format(
                "{0} : {1}, {2}, {3}, {4}, {5}",
                entity.id,
                entity.character,
                entity.text,
                entity.right,
                entity.left,
                entity.category
                ));
 }
    void CreateCard(bibiCard c)
    {
        Card tmp = ScriptableObject.CreateInstance <Card>();

        tmp.name   = c.id.ToString();// "id" field added to cards using empty field "name"
        tmp.title  = c.Character;
        tmp.myText = c.Text;
        tmp.opt01  = c.Left;
        tmp.opt02  = c.Right;
        Debug.Log("next allCards: " + tmp.title + " " + tmp.myText);
        tmp.image = GetCardImage(tmp.title);

        allCards.Add(tmp);
    }
    void SwipeEffect(int currentCardIndex, bool isRight)
    {
        if (allCards[currentCardIndex].name == null)
        {
            return;
        }

        int      id           = int.Parse(allCards[currentCardIndex].name);
        bibiCard currBibiCard = bibiCards.UnitySheet.Find(x => x.id == id);

        int wishCardId = paramsManager.SwipeEffectOnParams(currBibiCard, isRight);

        if (wishCardId >= 1000)
        {
            EndGameDueParam(wishCardId);
        }
    }
    int[] GetEffectVals(bibiCard currBibiCard, bool isRight)
    {
        int [] vals = new int [] { -1, -1, -1, -1 };
        if (isRight)
        {
            vals[0] = currBibiCard.affectOnPR1;
            vals[1] = currBibiCard.affectOnPR2;
            vals[2] = currBibiCard.affectOnPR3;
            vals[3] = currBibiCard.affectOnPR4;
        }
        else
        {
            vals[0] = currBibiCard.affectOnPL1;
            vals[1] = currBibiCard.affectOnPL2;
            vals[2] = currBibiCard.affectOnPL3;
            vals[3] = currBibiCard.affectOnPL4;
        }

        return(vals);
    }
    void Start()
    {
        Debug.Log("SwipeManager.Start()");
        bool     isLastExists = false;
        bibiCard tmpLastCard  = new bibiCard();

        // reading the excel structure (dina)
        Debug.Log(bibiCards.UnitySheet.Count);
        foreach (bibiCard c in bibiCards.UnitySheet)
        {
            if (c.weight == 10)
            {
                // this card should be last in the game - adding it after the shuffle
                tmpLastCard  = c;
                isLastExists = true;
            }
            else
            {
                CreateCard(c);
            }
        }

        for (int i = 0; i < allCards.Count; i++)
        {
            Card temp        = allCards[i];
            int  randomIndex = Random.Range(i, allCards.Count);
            allCards[i]           = allCards[randomIndex];
            allCards[randomIndex] = temp;
        }

        if (isLastExists)
        {
            CreateCard(tmpLastCard);
        }

        // currentCard.SetCardIcon(allCards[currentCardIndex].image);
        Debug.Log("CARD TITLE " + allCards[currentCardIndex].title);
        currentCard.SetCardData(allCards[currentCardIndex]);

        currentCard.CardSwipedDelegate += CardSwiped;
    }