Example #1
0
    IEnumerator SurvivalEffects()
    {
        //Declartion of Effects

        EffectData hungerEffect = new EffectData(StatType.Food, EffectType.OverTime, -hungerDropAmount, Mathf.Infinity, 1f, false, false);
        EffectData thirstEffect = new EffectData(StatType.Water, EffectType.OverTime, -WaterDropAmount, Mathf.Infinity, 1f, false, false);
        EffectData oxygenEffect = new EffectData(StatType.Air, EffectType.OverTime, -airDropAmount, Mathf.Infinity, 1f, false, false);
        EffectData sleepEffect  = new EffectData(StatType.Sleep, EffectType.OverTime, -sleepDropAmount, Mathf.Infinity, 1f, false, false);



        yield return(new WaitForSeconds(cooldownBeforeStart));



        //Applying Effects:

        EffectController worldEffect;


        worldEffect = new EffectController(playerStats.GetStat(StatType.Food), 3f);
        worldEffect.Begin(hungerEffect);

        worldEffect = new EffectController(playerStats.GetStat(StatType.Water), 3f);
        worldEffect.Begin(thirstEffect);

        worldEffect = new EffectController(playerStats.GetStat(StatType.Air), 3f);
        worldEffect.Begin(oxygenEffect);

        worldEffect = new EffectController(playerStats.GetStat(StatType.Sleep), 3f);
        worldEffect.Begin(sleepEffect);
    }
Example #2
0
    public void GatherInteraction(Vector2Int gridPosition, TileMapLayer tilemapLayer)
    {
        if (GetIsGatherable)
        {
            EffectController effectController = new EffectController(PlayerStats._instance.GetStat(StatType.EXP), 0);
            expEffect.duration = currentStage.GetExpReward / expEffect.amount;
            effectController.Begin(expEffect);

            Debug.Log("Tried gathering");
            if (currentStage.GetDestroyOnGather || currentStageIndex == 0)
            {
                Remove(gridPosition, tilemapLayer);
            }
            else
            {
                currentStageIndex--;
                if (!reachedMaxStage)
                {
                    InitEvent(gridPosition, tilemapLayer);
                }
                SetIsBeingGatheredState(false, gridPosition);
            }

            Inventory inventory = Inventory.GetInstance;
            foreach (Drop drop in currentStage.GetDrops)
            {
                if (Random.value <= drop.GetChance)
                {
                    inventory.AddToInventory(0, new ItemSlot(drop.GetItem, Random.Range(drop.GetMinAmount, drop.GetMaxAmount + 1)));
                }
            }
        }
    }