Exemple #1
0
    IEnumerator DoT(float ammount, int time, IEffectable target, SOEffect effect)
    {
        if (ammount != 0)
        {
            bool isHeal = (effect.ID == CONSTANTS.EFFECT_REGEN || effect.ID == CONSTANTS.EFFECT_HEAL);
            for (int i = 0; i < time; i++)
            {
                if (!target.AffectedBy(effect))
                {
                    // perhaps they got cured
                    break;
                }
                if (isHeal)
                {
                    // hurting
                    target.Heal(ammount);
                }
                else
                {
                    // healing
                    target.Harm(ammount);
                }

                yield return(new WaitForSeconds(1));
            }
            target.RemoveEffect(effect);
        }
    }
 public void DoDraw(int amount, IEffectable source)
 {
     for (var i = 0; i < amount; i++)
     {
         Draw();
     }
 }
Exemple #3
0
    IEnumerator ShrinkLarge(float targetScale, float time, IEffectable target, SOEffect effect)
    {
        Vector3 tagetScaleV3 = target.GetDefaultScale() * targetScale;

        for (float i = 0; i < time; i = i + 1f)
        {
            if (!target.AffectedBy(effect))
            {
                // perhaps they got cured
                break;
            }

            Transform t2 = target.GetTransform();
            t2.localScale = tagetScaleV3;
            target.SetTransform(t2);

            yield return(new WaitForSeconds(1));
        }
        Transform t = target.GetTransform();

        t.localScale = target.GetDefaultScale();
        target.SetTransform(t);

        target.RemoveEffect(effect);
    }
Exemple #4
0
 public override void Tick(IEffectable p_target)
 {
     if (p_target is IDamageable)
     {
         ((IDamageable)p_target).OnDamage(null, m_type, m_damage, true, true);
     }
 }
Exemple #5
0
 static void ApplyEffect(BaseEffectData effect, ITargetable[] targets, IEffectable source)
 {
     for (var i = 0; i < targets.Length; i++)
     {
         var target = targets[i];
         effect.Apply(target, source);
     }
 }
Exemple #6
0
        private void CaseAttackStateAttack()
        {
            IEffectable skill  = skillFocused as IEffectable;
            Hashtable   action = new Hashtable();

            skill.Effect(action);
            SetAttackState(AttackState.delay);
        }
Exemple #7
0
 bool applyAffect(SOEffect s, IEffectable target)
 {
     if (target.AffectedBy(s))
     {
         return(false);
     }
     target.AddEffect(s);
     return(true);
 }
Exemple #8
0
 public override bool UseObject(IEffectable user)
 {
     if (!IsEmpty())
     {
         contents[0].onConsumeEffect.onEffect(user, contents[0].potency);
         EmptyContent(contents[0]);
     }
     return(true);
 }
Exemple #9
0
        public override ITargetable[] GetTargets(IEffectable source, IGame gameData)
        {
            //get the player
            var player = gameData.TurnLogic.GetPlayer(PlayerSeat);

            //add it as a target
            var targets = new ITargetable[] { player };

            return(targets);
        }
Exemple #10
0
            /// <summary>
            ///     Resolves and apply an effect caused by a source uppon on or many targets.
            /// </summary>
            /// <param name="effect"></param>
            /// <param name="source"></param>
            /// <param name="targets"></param>
            public static void Resolve(BaseEffectData effect, IEffectable source, ITargetable[] targets)
            {
                if (effect == null)
                {
                    Debug.LogError("Can't resolve a null effect.");
                    return;
                }

                //apply the effect on the targets
                ApplyEffect(effect, targets, source);
            }
Exemple #11
0
    public bool CureEntity(IEffectable toCure, float noop)
    {
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_CURE);

        if (applyAffect(thisEffect, toCure))
        {
            toCure.RemoveEffect(SOEffect.GetByID(CONSTANTS.EFFECT_POISON));
        }
        toCure.RemoveEffect(thisEffect);
        return(false);
    }
Exemple #12
0
    private void OnTriggerEnter(Collider other)
    {
        IEffectable effectable = other.GetComponent <IEffectable>();

        if (effectable != null)
        {
            if (obsType == ObstacleType.FinishLine)
            {
                effectable.Finish();
            }
        }
    }
        /// <summary>
        /// Rollback the decorating unit parameters.
        /// </summary>
        /// <param name="effectable"></param>
        /// <exception cref="ArgumentNullException">effectable</exception>
        private void UndoModifyParameters(IEffectable effectable)
        {
            if (effectable == null)
            {
                throw new ArgumentNullException(nameof(effectable));
            }

            if (effectable is Unit unit && unit.ParametersProvider is UnitParametersModifiedSpeed provider)
            {
                provider.UnpackDecorator();
            }
        }
Exemple #14
0
        public void DoDiscard(int amount, IEffectable source)
        {
            for (var i = 0; i < amount; i++)
            {
                if (Player.Hand.Size <= 0)
                {
                    break;
                }

                var card = Player.Hand.Units.RandomItem();
                Discard(card);
            }
        }
Exemple #15
0
        public void DoSpawn(int amount, ICharacterData data, IEffectable source)
        {
            var member = RuntimeCharacterFactory.Instance.Get();

            member.SetData(data, Player);

            for (var i = 0; i < amount; i++)
            {
                Player.Team.AddMember(member);
            }

            OnSpawnCharacter(Player, member);
        }
Exemple #16
0
    public bool KillEntity(IEffectable toKill, float noop)
    {
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_DEATH);

        if (applyAffect(thisEffect, toKill))
        {
            toKill.Harm(toKill.MaxHP);
        }

        toKill.RemoveEffect(thisEffect);

        return(true);
    }
Exemple #17
0
    public bool PoisonEntity(IEffectable toPoison, float potency)
    {
        float    damage     = 1;
        int      time       = 10;
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_POISON);

        if (applyAffect(thisEffect, toPoison))
        {
            // Coroutine
            StartCoroutine(DoT(damage * potency, time, toPoison, thisEffect));
        }

        return(true);
    }
Exemple #18
0
    public bool HealOverTime(IEffectable toHeal, float potency)
    {
        float    heal       = 1;
        int      time       = 10;
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_REGEN);

        if (applyAffect(thisEffect, toHeal))
        {
            // Coroutine
            StartCoroutine(DoT(heal * potency, time, toHeal, thisEffect));
        }

        return(true);
    }
Exemple #19
0
    private void OnTriggerStay(Collider other) //addforce to player and enemies that enter the trigger in the rotation direction
    {
        IEffectable effectable = other.GetComponent <IEffectable>();

        if (effectable != null)
        {
            if (obsType == ObstacleType.RotatingPlatform)
            {
                //Vector3 forceToAdd = force * -Vector3.right * Mathf.Sign(rotationSpeed);
                Vector3 forceToAdd = -force * new Vector3(Mathf.Cos(Time.deltaTime) * 0.36f, Mathf.Sin(Time.deltaTime) * 0.36f, 0f) * Mathf.Sign(rotationSpeed);
                effectable.ApplyForce(forceToAdd, ForceMode.Force);
            }
        }
    }
Exemple #20
0
    public bool HealEntity(IEffectable toHeal, float potency)
    {
        float    value      = 20;
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_HEAL);

        if (applyAffect(thisEffect, toHeal))
        {
            toHeal.Heal(value * potency);
        }

        toHeal.RemoveEffect(thisEffect);

        return(true);
    }
Exemple #21
0
        /// <summary>
        /// Applies this effect to the specified effectable object.
        /// </summary>
        /// <param name="effectable">The effectable.</param>
        /// <param name="onEffectExpiredCallback">The expiring effect callback.</param>
        /// <exception cref="ArgumentNullException">
        /// effectable
        /// or
        /// onEffectExpiredCallback
        /// </exception>
        public void ApplyTo(IEffectable effectable, TimerCallback onEffectExpiredCallback)
        {
            if (effectable == null)
            {
                throw new ArgumentNullException(nameof(effectable));
            }

            if (onEffectExpiredCallback == null)
            {
                throw new ArgumentNullException(nameof(onEffectExpiredCallback));
            }

            data.UseOn(effectable, this);
            StartTimer(onEffectExpiredCallback);
        }
Exemple #22
0
    public bool ShrinkEntity(IEffectable target, float potency)
    {
        float scaleup = 0.5f;
        float time    = 10;

        // Conflicting
        target.RemoveEffect(SOEffect.GetByID(CONSTANTS.EFFECT_ENLARGE));
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_SHRINK);

        if (applyAffect(thisEffect, target))
        {
            StartCoroutine(ShrinkLarge(scaleup, time * potency, target, thisEffect));
        }

        return(true);
    }
Exemple #23
0
    public bool HighGravEntity(IEffectable target, float potency)
    {
        float scaleup = 5f;
        float time    = 10;

        // Conflicting
        target.RemoveEffect(SOEffect.GetByID(CONSTANTS.EFFECT_LOW_GRAV));
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_HIGH_GRAV);

        if (applyAffect(thisEffect, target))
        {
            StartCoroutine(Gravupdown(scaleup, time * potency, target, thisEffect));
        }

        return(true);
    }
Exemple #24
0
    public bool SlowEntity(IEffectable target, float potency)
    {
        float scaleup = 0.5f;
        float time    = 10;

        // Conflicting
        target.RemoveEffect(SOEffect.GetByID(CONSTANTS.EFFECT_SPEED));
        SOEffect thisEffect = SOEffect.GetByID(CONSTANTS.EFFECT_SLOW);

        if (applyAffect(thisEffect, target))
        {
            StartCoroutine(SpeedSlow(scaleup, time * potency, target, thisEffect));
        }

        return(true);
    }
Exemple #25
0
    private void OnCollisionEnter(Collision collision)
    {
        IEffectable effectable = collision.gameObject.GetComponent <IEffectable>();

        if (effectable != null)
        {
            if (obsType == ObstacleType.Wall || obsType == ObstacleType.Moving)
            {
                effectable.Respawn();
            }
            else if (obsType == ObstacleType.RotatingStick || obsType == ObstacleType.HalfDonut)
            {
                effectable.GetStunned(force, transform.right + (transform.up / 2f), ForceMode.Impulse);
            }
        }
    }
        public override ITargetable[] GetTargets(IEffectable source, IGame gameData)
        {
            //get player team
            var team = gameData.TurnLogic.GetPlayer(PlayerSeat).Team;

            var teamSize = team.Members.Count;

            //instantiate an array with the proper size
            var targets = new ITargetable[teamSize];

            //add all members to the target list
            for (var i = 0; i < teamSize; i++)
            {
                targets[i] = team.GetMember(i);
            }
            return(targets);
        }
Exemple #27
0
    IEnumerator SpeedSlow(float factor, float time, IEffectable target, SOEffect effect)
    {
        float targetSpeed = target.GetDefaultSpeed() * factor;

        for (float i = 0; i < time; i = i + 1f)
        {
            if (!target.AffectedBy(effect))
            {
                // perhaps they got cured
                break;
            }

            target.SetSpeed(targetSpeed);

            yield return(new WaitForSeconds(1));
        }
        target.SetSpeed(target.GetDefaultSpeed());
        target.RemoveEffect(effect);
    }
        /// <summary>
        /// Applies an effect with this data to the selected effectable target.
        /// </summary>
        /// <param name="effectable">The effectable target.</param>
        /// <param name="effect">The effect.</param>
        /// /// <exception cref="ArgumentNullException">
        /// effectable
        /// or
        /// effect
        /// </exception>
        /// <returns>The effect using this effect date.</returns>
        public void UseOn(IEffectable effectable, IEffect effect)
        {
            if (effectable == null)
            {
                throw new ArgumentNullException(nameof(effectable));
            }

            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            if (effectable is Unit unit)
            {
                unit.ApplyDamage(effect.Owner, damage);
                ModifyParameters(unit, effect);
                ShowActivationEffect(unit.Position, effect);
                MakeIceCube(unit, effect);
            }
        }
Exemple #29
0
    IEnumerator Gravupdown(float factor, float time, IEffectable target, SOEffect effect)
    {
        float targetGrav = target.GetDefaultGravity() * factor;
        float jumpHeight = target.GetDefaultJumpHeight() / factor;

        for (float i = 0; i < time; i = i + 1f)
        {
            if (!target.AffectedBy(effect))
            {
                // perhaps they got cured
                break;
            }

            target.SetGravity(targetGrav);
            target.SetJumpHeight(jumpHeight);

            yield return(new WaitForSeconds(1));
        }
        target.SetGravity(target.GetDefaultGravity());
        target.SetJumpHeight(target.GetDefaultJumpHeight());
        target.RemoveEffect(effect);
    }
Exemple #30
0
    bool DevCommandAddEffect(string[] parms)
    {
        if (parms.Length != 1)
        {
            DeveloperConsole.instance.writeError("Missing Effect ID or too many parameters.");
            return(false);
        }
        if (!Int32.TryParse(parms[0].Trim(), out int id))
        {
            DeveloperConsole.instance.writeError("Effect ID must be a number.");
            return(false);
        }

        SOEffect s = SOEffect.GetByID(id);

        if (s == null)
        {
            DeveloperConsole.instance.writeError("Unknown Effect ID " + id);
            return(false);
        }
        GameObject charo = gc.GetCharacter();

        if (charo == null)
        {
            DeveloperConsole.instance.writeError("Unable to get player.(1)");
            return(false);
        }
        IEffectable toEffect = charo.GetComponent <IEffectable>();

        if (toEffect == null)
        {
            DeveloperConsole.instance.writeError("Unable to get player.(2)");
            return(false);
        }

        s.onEffect(toEffect, 1);
        DeveloperConsole.instance.writeMessage("Applied effect " + s.PrintString() + " to player");
        return(true);
    }