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
    public IEnumerator MonsterTile(Transform coords, Encounter encounter, Sprite background)
    {
        TileflipVisual tfv = Instantiate(tileToFlip, coords).GetComponent <TileflipVisual>();

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

        onWaitForFlipDoneCallback?.Invoke();
        tfv.onFlipAnimationDoneCallback -= WaitForAnimDone;
        StartCoroutine(LaunchCustomBattle(null, encounter.list, background));
        yield return(null);
    }
Beispiel #3
0
    public IEnumerator LaunchCustomBattle(GameObject monsterIConVisualGO, List <GameObject> enemies, Sprite background)
    {
        if (monsterIConVisualGO != null)
        {
            selectedTile = monsterIConVisualGO;
            TileflipVisual tfv = selectedTile.GetComponent <TileflipVisual>();
            tfv.onFlipAnimationDoneCallback += WaitForAnimDone;
            tfv.TriggerMonsterAnimation();
            waitForAnim = true;
            yield return(StartCoroutine(WaitForFlipAnimation()));
        }

        battleStartupInfo.enemies.Clear();
        for (int k = 0; k < enemies.Count; k++)
        {
            battleStartupInfo.enemies.Add(enemies[k]);
        }
        battleStartupInfo.battleBackground = background;
        yield return(null);

        FindObjectOfType <LevelLoader>().LoadBattleScene();
    }
Beispiel #4
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);
    }