Ejemplo n.º 1
0
    private void StunEnemy(Enemy e, float time)
    {
        StunStatus stun = Instantiate(StatusEffectContainer.instance.GetStatus("Stun")).GetComponent <StunStatus>();

        stun.duration = time;
        e.AddStatus(stun.gameObject);
    }
Ejemplo n.º 2
0
 private void DamageEnemy(Enemy e)
 {
     if (!e.invincible && e.health > 0)
     {
         StunStatus stun = Instantiate(StatusEffectContainer.instance.GetStatus("Stun")).GetComponent <StunStatus>();
         stun.duration = 2.0f;
         print("Stunning enemy");
         e.AddStatus(stun.gameObject);
         knight.DamageEnemy(e, knight.damage, knight.hitEffect, true, knight.hitSounds);
     }
 }
Ejemplo n.º 3
0
Archivo: Card.cs Proyecto: hmason55/B
    void ApplyToTile(int tile, Effect effect)
    {
        // Get list of valid tiles
        List <int> targetTiles;

        if (areaOfEffect)
        {
            targetTiles = Battleground.Instance.GetTilesFromShape(targetArea, tile);
        }
        else
        {
            targetTiles = new List <int> {
                tile
            }
        };

        Debug.Log("tiles number: " + targetTiles.Count);
        switch (effect.effectType)
        {
        case EffectType.Miasma:


            // Spawn miasma on tiles
            foreach (int t in targetTiles)
            {
                MiasmaFieldEffect miasma = new MiasmaFieldEffect(effect.effectValue, effect.duration, owner, t);
                Battleground.Instance.AddFieldEffect(t, miasma);
            }
            break;

        case EffectType.Damage:
            float mult = 1.00f;
            for (int i = owner.Statuses.Count - 1; i >= 0; i--)
            {
                BaseStatus status = owner.Statuses[i];
                if (status.GetType() == typeof(DamageMultiplierStatus))
                {
                    mult += status.Multiplier;

                    // Remove multiplier status
                    // TODO change if the status can have more than 1 use
                }
            }
            foreach (int t in targetTiles)
            {
                BaseUnit target = Battleground.Instance.GetUnitOnTile(t);

                if (target == null)
                {
                    continue;
                }
                if (ParseTargetType(TargetType.Enemy, target.IsPlayer()))
                {
                    int damage = (int)Math.Round(effect.effectValue * mult);
                    target.DealDamage(damage, owner);

                    owner.RemoveStatusOfType(typeof(DamageMultiplierStatus));
                    owner.UpdateUI();

                    // Add threat to player units
                    if (owner.IsPlayer())
                    {
                        PartyManager.Instance.ChangeThreat(owner, damage * 0.01f);
                    }
                }
            }
            break;
        }
    }

    void ApplyToTargets(BaseUnit[] targets, Effect effect)
    {
        Debug.Log("Applying effects");

        // Apply effects to specifically targeted units (dragged card onto or put AoE targeter on).
        switch (effect.effectType)
        {
        case EffectType.Damage:
            foreach (BaseUnit target in targets)
            {
                if (ParseTargetType(effect.targetType, target.IsPlayer()))
                {
                    float mult = 1.00f;
                    for (int i = owner.Statuses.Count - 1; i >= 0; i--)
                    {
                        BaseStatus status = owner.Statuses[i];
                        if (status.GetType() == typeof(DamageMultiplierStatus))
                        {
                            mult += status.Multiplier;

                            // Remove multiplier status
                            // TODO change if the status can have more than 1 use
                            owner.RemoveStatusOfType(status.GetType());
                            owner.UpdateUI();
                        }
                    }

                    int damage = (int)Math.Round(effect.effectValue * mult);
                    target.DealDamage(damage, owner);

                    // Add threat to player units
                    if (owner.IsPlayer())
                    {
                        PartyManager.Instance.ChangeThreat(owner, damage * 0.01f);
                    }
                }
            }
            break;

        case EffectType.Block:
            foreach (BaseUnit target in targets)
            {
                if (ParseTargetType(effect.targetType, target.IsPlayer()))
                {
                    BlockStatus blockStatus = new BlockStatus(effect.effectValue, effect.duration, owner, owner);
                    target.AddStatus(blockStatus);
                }
            }
            break;

        case EffectType.Taunt:
            foreach (BaseUnit target in targets)
            {
                if (ParseTargetType(effect.targetType, target.IsPlayer()))
                {
                    TauntStatus taunt = new TauntStatus(effect.duration, owner, target);
                    target.AddStatus(taunt);
                }
            }
            break;

        case EffectType.Stun:
            foreach (BaseUnit target in targets)
            {
                if (ParseTargetType(effect.targetType, target.IsPlayer()))
                {
                    StunStatus stun = new StunStatus(effect.duration, owner, target);
                    target.AddStatus(stun);
                }
            }
            break;

        case EffectType.Push:
            foreach (BaseUnit target in targets)
            {
                if (ParseTargetType(effect.targetType, target.IsPlayer()))
                {
                    // check if not on last col
                    List <int> pushTiles = Battleground.Instance.FindEmptyTileNear(target.GetGridPosition());
                    if (pushTiles.Count < 1)
                    {
                        return;
                    }
                    int nextPos = pushTiles[UnityEngine.Random.Range(0, pushTiles.Count)];
                    target.MoveToTile(nextPos);

                    if (owner.IsPlayer())
                    {
                        PartyManager.Instance.ChangeThreat(owner, 0.05f);
                    }
                }
            }
            break;

        case EffectType.SummonVoodoo:
            foreach (BaseUnit target in targets)
            {
                if (ParseTargetType(effect.targetType, target.IsPlayer()))
                {
                    // Create voodoo unit
                    GameObject voodooPrefab = Resources.Load <GameObject>("Prefabs/Units/Voodoo");
                    Debug.Log(voodooPrefab);
                    BaseUnit   voodoo      = Instantiate(voodooPrefab).GetComponent <BaseUnit>();
                    List <int> voodooTiles = Battleground.Instance.FindEmptyTileNear(target.GetGridPosition());
                    int        voodooPos   = voodooTiles[UnityEngine.Random.Range(0, voodooTiles.Count)];
                    Battleground.Instance.PlaceUnitAt(voodoo, voodooPos);

                    // Add status to transfer damage
                    HealthLinkStatus healthLinkstatus = new HealthLinkStatus(1.0f, owner, target);
                    voodoo.AddStatus(healthLinkstatus);
                }
            }
            break;

        case EffectType.Weakness:
            foreach (BaseUnit target in targets)
            {
                if (ParseTargetType(effect.targetType, target.IsPlayer()))
                {
                    WeaknessStatus weaknessStatus = new WeaknessStatus(0.01f * effect.effectValue, effect.duration, owner, target);
                    target.AddStatus(weaknessStatus);
                }
            }
            break;
        }
    }
Ejemplo n.º 4
0
        private void _ToStun()
        {
            var status = new StunStatus(_Binder, _Player);
            status.ExitEvent += ExitEvent;
            status.WakeEvent += _ToSurvival;

            _Machine.Push(status);
        }