Esempio n. 1
0
    public List <Sprite> GetMonsterIcons(TileflipTable tableToCheck)
    {
        List <Sprite> sprites = new List <Sprite>();

        foreach (Sprite monsterIcon in tableToCheck.monsterIcons)
        {
            sprites.Add(monsterIcon);
        }

        return(sprites);
    }
Esempio n. 2
0
    public TileflipTable SearchTile(bool isTest, string tileName)
    {
        TileflipTable tableToSend = tables.Find(x => x.name == tileName);

        if (isTest)
        {
            return(tableToSend);
        }
        else
        {
            StartCoroutine(ActivateTile(tableToSend));
            return(null);
        }
    }
Esempio n. 3
0
    private void LaunchBattle(TileflipTable matchedTable)
    {
        if (matchedTable != null)
        {
            float      totalWeight = 0;
            List <int> weightTable = new List <int>();
            foreach (Encounter enc in matchedTable.encounters)
            {
                totalWeight += enc.weight;
                weightTable.Add(enc.weight);
            }

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

            float pickedNumber = Random.Range(0, totalWeight);
            battleStartupInfo.enemies.Clear();

            for (int i = 0; i < weightTable.Count; i++)
            {
                if (pickedNumber <= weightTable[i])
                {
                    for (int k = 0; k < matchedTable.encounters[i].list.Count; k++)
                    {
                        battleStartupInfo.enemies.Add(matchedTable.encounters[i].list[k]);
                    }
                    battleStartupInfo.battleBackground = matchedTable.battleBackground;
                    FindObjectOfType <LevelLoader>().LoadBattleScene();
                    return;
                }
                else
                {
                    pickedNumber -= weightTable[i];
                }
            }
        }
    }
Esempio n. 4
0
    private void UpdateInfobox()
    {
        if (selectedTile != null && (infoBoxObject != null || infoBoxObjectMonster != null))
        {
            currentTile = groundTilemap.GetTile(new Vector3Int((int)(selectedTile.transform.position.x - 0.5f), (int)(selectedTile.transform.position.y - 0.5f), (int)selectedTile.transform.position.z)) as GroundTile;
            if (currentTile)
            {
                TileflipTable currentTileTable = encounterManager.TestGroundType(currentTile.groundType, selectedTile, true);

                if (currentTileTable != null)
                {
                    string per = "%";
                    if (infoBoxObject != null)
                    {
                        infoBoxObject.gameObject.SetActive(false);
                    }
                    if (infoBoxObjectMonster != null)
                    {
                        infoBoxObjectMonster.gameObject.SetActive(true);
                    }
                    infoBoxObjectMonster.AssignInfo(currentTileTable.monsterIcons);
                }
            }
            else
            {
                GameObject colliding = testTrigger.GetCollidingGameObject();
                if (testTrigger.GetCollidingTileableStatus())
                {
                    GroundType    tmpType          = colliding.GetComponent <TTileable>().GetTileType();
                    TileflipTable currentTileTable = encounterManager.TestGroundType(tmpType, selectedTile, true);

                    if (currentTileTable != null)
                    {
                        string per = "%";
                        if (currentTileTable.monsterChance == 0)
                        {
                            if (infoBoxObject != null)
                            {
                                infoBoxObject.gameObject.SetActive(true);
                            }
                            if (infoBoxObjectMonster != null)
                            {
                                infoBoxObjectMonster.gameObject.SetActive(false);
                            }
                            infoBoxObject.AssignInfo(currentTileTable.displayName, currentTileTable.HPChance.ToString() + per, currentTileTable.gaiaChance.ToString() + per, currentTileTable.monsterChance.ToString() + per);
                        }
                        else
                        {
                            if (infoBoxObject != null)
                            {
                                infoBoxObject.gameObject.SetActive(false);
                            }
                            if (infoBoxObjectMonster != null)
                            {
                                infoBoxObjectMonster.gameObject.SetActive(true);
                            }
                            infoBoxObjectMonster.AssignInfo(currentTileTable.monsterIcons);
                        }
                    }
                }
            }
        }
        else
        {
            if (infoBoxObject != null)
            {
                infoBoxObject.gameObject.SetActive(false);
            }
            if (infoBoxObjectMonster != null)
            {
                infoBoxObjectMonster.gameObject.SetActive(false);
            }
        }
    }
Esempio n. 5
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);
    }