Beispiel #1
0
    public IEnumerator GaiaTile(Transform coords)
    {
        TileflipVisual tfv = Instantiate(tileToFlip, coords).GetComponent <TileflipVisual>();

        waitForAnim = true;
        tfv.onFlipAnimationDoneCallback += WaitForAnimDone;
        tfv.TriggerGaiaAnimation();
        yield return(StartCoroutine(WaitForFlipAnimation()));

        onWaitForFlipDoneCallback?.Invoke();
        tfv.onFlipAnimationDoneCallback -= WaitForAnimDone;
        yield return(null);
    }
Beispiel #2
0
    IEnumerator ActivateTile(TileflipTable matchedTable)
    {
        if (matchedTable == null)
        {
            yield return(null);
        }

        float totalWeight  = 0;
        int   pickedOption = 0;

        totalWeight += matchedTable.gaiaChance;
        totalWeight += matchedTable.HPChance;
        totalWeight += matchedTable.monsterChance;

        if (totalWeight > 100)
        {
            Debug.LogError("Sum of chances for flipped tile is over 100");
        }

        float          pickedNumber = Random.Range(0, totalWeight);
        TileflipVisual tfv          = selectedTile.GetComponent <TileflipVisual>();

        tfv.onFlipAnimationDoneCallback += WaitForAnimDone;

        if (pickedNumber < matchedTable.HPChance)
        {
            if (playerValues.healthPoints >= playerValues.maxHealthPoints) //HP was max, choose monster
            {
                pickedNumber = matchedTable.gaiaChance + matchedTable.HPChance;
            }
            else
            {
                pickedOption = 2;
                pickedNumber = 999;
                tfv.TriggerHPAnimation();
            }
        }

        pickedNumber -= matchedTable.HPChance;

        if ((pickedNumber < matchedTable.gaiaChance && playerValues.gaia < playerValues.maxGaia) || matchedTable.gaiaChance == 100)
        {
            pickedOption = 1;
            pickedNumber = 999;
            tfv.TriggerGaiaAnimation();
        }

        pickedNumber -= matchedTable.gaiaChance;

        if (pickedNumber < matchedTable.monsterChance)
        {
            pickedOption = 3;
            tfv.TriggerMonsterAnimation();
        }

        waitForAnim = true;
        FindObjectOfType <TileflipManager>().RemoveFlipSquares();

        yield return(StartCoroutine(WaitForFlipAnimation()));

        if (onWaitForFlipDoneCallback != null)
        {
            onWaitForFlipDoneCallback?.Invoke();
        }

        playerControlsManager.ToggleOffGenericUI();
        tfv.onFlipAnimationDoneCallback -= WaitForAnimDone;

        if (pickedOption == 1)
        {
            FindObjectOfType <LaunchRewards>().LanuchGaiaRewardbox(matchedTable.gaiaRewardAmount);
        }
        else if (pickedOption == 2)
        {
            FindObjectOfType <LaunchRewards>().LanuchHPRewardbox(matchedTable.HPRewardAmount);
        }
        else if (pickedOption == 3)
        {
            LaunchBattle(matchedTable);
        }

        yield return(null);
    }