Пример #1
0
    public void ChooseBerry(BerryInfo bi)
    {
        int index = berryInfo.IndexOf(bi);

        tileBeingPlanted.PlantBerry(seedsToPlant[index]);
        eventSystem.SetSelectedGameObject(null);
        playerControlsManager.ToggleOffGenericUI();
        berryPanel.SetActive(false);
        foreach (BerryInfo berry in berryInfo)
        {
            Destroy(berry.gameObject);
        }
        seedsToPlant.Clear();
        berryInfo.Clear();
        playerControlsManager.onCancelGenericUICallback -= CancelBerry;
    }
Пример #2
0
    public IEnumerator TeleportPlayer(Vector3 newCoords, Vector2 newDirection)
    {
        NotWalking();
        move.x                       = 0;
        move.y                       = 0;
        transform.position           = newCoords;
        currentDirection             = newDirection;
        movePoint.transform.position = newCoords;
        inFrontOfPlayerTrigger.transform.position = newCoords;
        playerControlsManager.ToggleOnGenericUI();
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        playerControlsManager.ToggleOffGenericUI();
    }
Пример #3
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);
    }