Exemple #1
0
    public static GameEffect CreateGameEffect(GameEffect.EffectType type, float delay = 3f)
    {
        GameEffect newEffect = new GameEffect(type, delay);

        switch (type)
        {
        case GameEffect.EffectType.KillPlayer:
            newEffect.onActivate = KillPlayer;
            break;

        case GameEffect.EffectType.VentAir:
            newEffect.onActivate = VentAir;
            break;

        case GameEffect.EffectType.HoldBreath:
            newEffect.onActivate = HoldBreath;
            break;

        case GameEffect.EffectType.Cry:
            newEffect.onActivate = Cry;
            break;

        case GameEffect.EffectType.Explode:
            newEffect.onActivate = Explode;
            break;

        case GameEffect.EffectType.Flail:
            newEffect.onActivate = Flail;
            break;
        }



        return(newEffect);
    }
    Sprite IconSpriteFromType(GameEffect.EffectType type)
    {
        switch (type)
        {
        case GameEffect.EffectType.Wood:
            return(woodIcon);

        case GameEffect.EffectType.Food:
            return(foodIcon);

        case GameEffect.EffectType.Villager:
            return(villagerIcon);

        case GameEffect.EffectType.Dice:
            return(diceIcon);

        case GameEffect.EffectType.Stone:
            return(stoneIcon);

        case GameEffect.EffectType.Shield:
            return(shieldIcon);

        default:
            return(woodIcon);
        }
    }
Exemple #3
0
    public void Play(GameEffect.EffectType effectType)
    {
        speaker.Stop();

        switch (effectType)
        {
        case GameEffect.EffectType.Dice:
            speaker.clip = resources.dice;
            break;

        case GameEffect.EffectType.Villager:
            speaker.clip = resources.villager;
            break;

        case GameEffect.EffectType.Wood:
            speaker.clip = resources.wood;
            break;

        case GameEffect.EffectType.Food:
            speaker.clip = resources.food;
            break;

        case GameEffect.EffectType.Stone:
            speaker.clip = resources.stone;
            break;

        case GameEffect.EffectType.Shield:
            speaker.clip = resources.shield;
            break;
        }

        speaker.Play();
    }
Exemple #4
0
    public void AddEffect(GameEffect.EffectType type, int value, object target = null)
    {
        GameEffect eff = GameEffect.CreateInstance <GameEffect>();

        eff.type  = type;
        eff.value = value;
        AddEffect(eff, target);
        Destroy(eff);
    }
    public void Reset(GameEffect effect, object target = null)
    {
        this.effectType   = effect.type;
        this.effectValue  = effect.value;
        this.effectTarget = target;

        icon.sprite = IconSpriteFromType(effect.type);
        text.text   = (effect.value > 0 ? "+" : "") + effect.value + " " + effect.type;
    }
Exemple #6
0
    public void ApplyEffect(GameEffect.EffectType effectType, int effectValue, object target = null)
    {
        Action <int> updateDices = (value) =>
        {
            dicesCount += value;
            if (dicesCount < 0)
            {
                dicesCount = 0;
            }
        };

        Action <int> updateShield = (value) =>
        {
            shield += value;
            if (shield < 0)
            {
                shield = 0;
            }

            gameCanvas.resourceTexts.shield.text = shield.ToString();
            gameCanvas.PopFloatingText(gameCanvas.resourceTexts.shield.transform, value);
        };

        switch (effectType)
        {
        case GameEffect.EffectType.Wood:
            wood += effectValue;
            if (wood < 0)
            {
                wood = 0;
            }
            gameCanvas.resourceTexts.wood.text = wood.ToString();
            gameCanvas.PopFloatingText(gameCanvas.resourceTexts.wood.transform, effectValue);
            break;

        case GameEffect.EffectType.Stone:
            stone += effectValue;
            if (stone < 0)
            {
                stone = 0;
            }
            gameCanvas.resourceTexts.stone.text = stone.ToString();
            gameCanvas.PopFloatingText(gameCanvas.resourceTexts.stone.transform, effectValue);
            break;

        case GameEffect.EffectType.Food:
            meals += effectValue;
            if (meals < 0)
            {
                meals = 0;
            }
            gameCanvas.resourceTexts.food.text = meals.ToString();
            gameCanvas.PopFloatingText(gameCanvas.resourceTexts.food.transform, effectValue);
            break;

        case GameEffect.EffectType.Dice:
            updateDices(effectValue);

            break;

        case GameEffect.EffectType.Villager:
            int value = effectValue;

            // Shield points take for the villager.
            if (shield > 0 && value < 0)
            {
                value = effectValue + shield;

                if (value > 0)
                {
                    value = 0;
                }

                updateShield(effectValue);
            }

            villagersCount += value;

            if (villagersCount < 0)
            {
                villagersCount = 0;
            }

            gameCanvas.resourceTexts.villager.text = villagersCount.ToString();
            gameCanvas.PopFloatingText(gameCanvas.resourceTexts.villager.transform, value);

            while (villagers.villagers.Count > villagersCount)
            {
                Villager targetVillager = (Villager)target;
                villagers.RemoveVillager(targetVillager != null ? targetVillager : villagers.villagers[0]);
            }

            while (villagers.villagers.Count < villagersCount)
            {
                villagers.AddVillager();
            }

            CheckForDefeat();

            updateDices(effectValue);
            break;

        case GameEffect.EffectType.Shield:
            updateShield(effectValue);
            break;
        }
    }