//Method that adds elements to the proirity queue while maintaining order of smallest duration to biggest duration
    //  Pre: effect.getDuration > 0
    //  Post: A new effect has been added to the priority queue
    public void add(StatEffect effect)
    {
        Debug.Log("StatEffect Added!");
        effect.adjustDuration(timer);       //Adjust the duration of the stat effect to align with the current timer

        if (qStruct.Count == 0)
        {
            qStruct.AddFirst(effect);       //If it's empty, just add the element
        }
        else
        {
            //Iterate through the linked list until you find an effect whose duration is greater than or equal to the one being inserted OR reach end of list
            LinkedListNode <StatEffect> curNode = qStruct.Last;
            while (curNode != null && curNode.Value.getDuration() > effect.getDuration())
            {
                curNode = curNode.Previous;
            }

            //2 Cases: If at end of list, just add last. Else, add before curNode
            if (curNode != null)
            {
                qStruct.AddAfter(curNode, effect);
            }
            else
            {
                qStruct.AddFirst(effect);
            }
        }
    }
Esempio n. 2
0
    //Enact effects method
    public void enactEffects(Collider2D enemy)
    {
        PKMNEntity enemyFighter = enemy.GetComponent <PKMNEntity>();

        //Bounds shotgunBounds = shotgunBlast.GetComponent<Collider2D>().bounds;
        int   pwr;
        float offense;
        float defense;

        pwr     = SHOTGUN_PWR;
        offense = basis.accessStat(BaseStat.SPECIAL_ATTACK);
        defense = enemyFighter.accessStat(BaseStat.SPECIAL_DEFENSE);

        int damage = Battle.damageCalc(basis.level, pwr, offense, defense);

        enemyFighter.StartCoroutine(enemyFighter.receiveDamage(damage, basis));

        StatEffect effects = new StatEffect(STAT_DURATION, REDUCTION_FACTOR, BaseStat.SPECIAL_DEFENSE);

        effects.applyEffect(enemyFighter);

        //THIS SENSING METHOD DOES NOT WORK

        /*if(enemy.bounds.Intersects(shotgunBounds)) {
         *  pwr = SHOTGUN_PWR;
         *  offense = basis.accessStat(BaseStat.SPECIAL_ATTACK);
         *  defense = enemyFighter.accessStat(BaseStat.SPECIAL_DEFENSE);
         *  StatEffect effects = new StatEffect(STAT_DURATION, REDUCTION_FACTOR, BaseStat.SPECIAL_DEFENSE);
         *  effects.applyEffect(enemyFighter);
         * }else{
         *  pwr = DASH_PWR;
         *  offense = basis.accessStat(BaseStat.ATTACK);
         *  defense = enemyFighter.accessStat(BaseStat.DEFENSE);
         * }*/
    }
    //Method that updates timer.
    //  Pre: Called within a looping function (PKMNEntity's Update)
    //  Post: Updates timer IF there are any elements present in the queue and checks it with
    //        the front most element
    public void update()
    {
        if (qStruct.Count > 0)
        {
            float delta = Time.deltaTime;
            timer += delta;       //Update Timer

            //Poison method
            if (poisonIntensity > 0f)
            {
                pTimer += delta;

                if (pTimer > POISON_TICK)
                {
                    pTimer = 0f;
                    int damage = entity.accessBaseStat(BaseStat.HEALTH) / curPoisonDamage;
                    entity.StartCoroutine(entity.receiveDoT(damage, null));
                }
            }

            //If timer exceeds the current duration, remove and reverse the effect
            if (timer >= qStruct.First.Value.getDuration())
            {
                StatEffect finishedSE = this.remove();
                finishedSE.reverseEffect(this.entity);
            }
        }
    }
Esempio n. 4
0
 public ButtonResult(string buttonText, string unlocks, List <string> statEffectFields, List <Sprite> statImages)
 {
     this.buttonText = buttonText;
     unlockAdd       = new List <string>();
     unlockRemove    = new List <string>();
     foreach (string unlock in unlocks.Split(RLConstants.STRING_SPLIT_AND, System.StringSplitOptions.RemoveEmptyEntries))
     {
         if (unlock.StartsWith("-"))
         {
             unlockRemove.Add(unlock.Remove(0, 1));
         }
         else
         {
             unlockAdd.Add(unlock);
         }
     }
     statEffects = new List <StatEffect>();
     for (int sf = 0; sf < statEffectFields.Count; sf++)
     {
         StatEffect curSE = StatEffect.Create(statEffectFields[sf], statImages != null && sf < statImages.Count ? statImages[sf] : null);
         if (curSE != null)
         {
             statEffects.Add(curSE);
         }
     }
 }
Esempio n. 5
0
 public StatEffectRecord(StatEffect e, Inventory inv, Item it, bool succ)
 {
     effect       = e;
     inventory    = inv;
     involvedItem = it;
     success      = succ;
 }
        /// <summary>
        /// Create a new physical sprite from data
        /// </summary>
        /// <param name="pd">data from which to construct unit</param>
        protected PhysicalUnit(PhysicalData pd)
        {
            _unitName = pd.Name;
            _sprite   = new Sprite(_unitName);

            if (pd.MovementParticleEffectName != null)
            {
                _movementParticleEffect = new ParticleEffect(pd.MovementParticleEffectName);
            }
            _burningParticleEffect = new ParticleEffect("Burning");

            _mass               = pd.Mass;
            _moveForce          = pd.MoveForce;
            _maxSpeed           = pd.MaxSpeed;
            _maxHealth          = pd.Health;
            _health             = _maxHealth;
            _decelerationFactor = pd.DecelerationFactor;

            _lifeState = LifeState.Dormant;     //not yet spawned
            _hitRect   = new Rectangle(0, 0, (int)_sprite.Width, (int)_sprite.Height);

            Position      = Vector2.Zero;
            MoveDirection = Vector2.Zero;
            LookDirection = Vector2.Zero;

            _statusEffects = new StatEffect(0, 0, 0);
            _statusResist  = new StatEffect(pd.FireResist, pd.CryoResist, pd.ShockResist);

            _fragments = new IceFragment[ICE_DIVISIONS, ICE_DIVISIONS];
        }
Esempio n. 7
0
    protected override void ResetActionSkill()
    {
        if (waitArrows == null)
        {
            waitArrows = Resources.LoadAssetAtPath("Assets/SRPGKit/Prefabs/Wait Arrows.prefab", typeof(GameObject)) as GameObject;
        }
        TargetSettings ts = new TargetSettings();

        targetSettings       = new TargetSettings[] { ts };
        overlayColor         = Color.clear;
        highlightColor       = Color.clear;
        ts.targetingMode     = TargetingMode.Cardinal;
        ts.targetRegion      = new Region();
        ts.targetRegion.type = RegionType.Self;
        ts.targetRegion.interveningSpaceType = InterveningSpaceType.Pick;
        ts.effectRegion      = new Region();
        ts.effectRegion.type = RegionType.Self;
        ts.effectRegion.interveningSpaceType = InterveningSpaceType.Pick;
        StatEffect facingEffect = new StatEffect();

        facingEffect.effectType = StatEffectType.ChangeFacing;
        facingEffect.target     = StatEffectTarget.Applier;
        facingEffect.triggerF   = Formula.True();
        facingEffect.value      = Formula.Lookup("arg.angle.xy", LookupType.SkillParam);
        StatEffect endTurnEffect = new StatEffect();

        endTurnEffect.effectType = StatEffectType.EndTurn;
        endTurnEffect.target     = StatEffectTarget.Applier;
        endTurnEffect.triggerF   = Formula.True();
        applicationEffects       = new StatEffectGroup {
            effects = new StatEffect[] {
                facingEffect, endTurnEffect
            }
        };
    }
        public void CheckAndApplyUnitCollision(PhysicalUnit other)
        {
            if (!Collides)
            {
                return;     //don't check collision if unit shouldn't collide
            }
            //special shattered collision detection
            if (_lifeState == LifeState.Shattered)
            {
                tempRec.Width  = _hitRect.Width / ICE_DIVISIONS;
                tempRec.Height = _hitRect.Height / ICE_DIVISIONS;
                for (int i = 0; i < ICE_DIVISIONS; i++)
                {
                    for (int j = 0; j < ICE_DIVISIONS; j++)
                    {
                        tempRec.X = (int)(_fragments[i, j].Position.X - tempRec.Width / 2);
                        tempRec.Y = (int)(_fragments[i, j].Position.Y - tempRec.Height / 2);
                        if (tempRec.Intersects(other.HitRect))
                        {
                            Vector2 fVel  = _fragments[i, j].Velocity;
                            float   fMass = (float)Mass / (ICE_DIVISIONS * ICE_DIVISIONS);
                            temp            = other.Velocity;
                            other._velocity = (other._velocity * (other.Mass - fMass) + 2 * fMass * fVel) /
                                              (fMass + other.Mass);
                            _fragments[i, j].Velocity = (fVel * (fMass - other.Mass) + 2 * other.Mass * temp) /
                                                        (fMass + other.Mass);
                        }
                    }
                }
                return; //ignore normal collision detection
            }

            //check if fire should be transferred
            float dist = XnaHelper.DistanceBetweenRects(HitRect, other.HitRect);

            if (dist < FIRE_SPREAD_DISTANCE)
            {
                if (_statusEffects.Fire > other._statusEffects.Fire)
                {
                    StatEffect transfer = new StatEffect()
                    {
                        Fire = FIRE_SPREAD_FACTOR * dist / FIRE_SPREAD_DISTANCE * _statusEffects.Fire
                    };
                    other.ApplyStatus(transfer);
                    ApplyStatus(transfer * -FIRE_SPREAD_LOSS);
                }
            }

            if (XnaHelper.RectsCollide(HitRect, other.HitRect))
            {
                temp = other._velocity; //temp is a static reusable vector

                other._velocity = (other._velocity * (other.Mass - this.Mass) + 2 * this.Mass * this._velocity) /
                                  (this.Mass + other.Mass);
                this._velocity = (this._velocity * (this.Mass - other.Mass) + 2 * other.Mass * temp) /
                                 (this.Mass + other.Mass);
            }
        }
    public void ApplyEffect(string name, float value, float duration)
    {
        StatEffect se = new StatEffect(); // Creates new effect with appropriate variables

        se.name     = name;
        se.value    = value;
        se.duration = duration;
        effects.Add(se);
    }
Esempio n. 10
0
    public void ApplyStatEffect(Stat targetStat, float modifier, string sourceTag)
    {
        StatEffect effect = new StatEffect();

        effect.tag        = sourceTag;
        effect.modifier   = modifier;
        effect.targetStat = targetStat;

        activeEffects.Add(effect);
    }
Esempio n. 11
0
        /// <summary>
        /// Executes the command.
        /// TODO: Optionally allow the admin to create a new attribute if the target didn't
        /// already have the attribute available to modify.
        /// </summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender     = actionInput.Controller;
            var         originator = sender.Thing;

            // Strings to be displayed when the effect is applied/removed.
            var buffString = new ContextualString(sender.Thing, this.target)
            {
                ToOriginator = string.Format("\r\nThe '{0}' stat of {1} has changed by {2}.\r\n", this.stat.Name, this.target.Name, this.modAmount),
                ToReceiver   = string.Format("\r\nYour '{0}' stat has changed by {1}.\r\n", this.stat.Name, this.modAmount)
            };
            var unbuffString = new ContextualString(sender.Thing, this.target)
            {
                ToReceiver = string.Format("\r\nYour '{0}' stat goes back to normal.", this.stat.Abbreviation)
            };

            // Turn the above sets of strings into sensory messages.
            var sensoryMessage    = new SensoryMessage(SensoryType.Sight, 100, buffString);
            var expirationMessage = new SensoryMessage(SensoryType.Sight, 100, unbuffString);

            // Remove all existing effects on stats with the same abbreviation
            // to prevent the effects from being stacked, at least for now.
            foreach (var effect in this.target.Behaviors.OfType <StatEffect>())
            {
                if (effect.Stat.Abbreviation == this.stat.Abbreviation)
                {
                    sender.Thing.Behaviors.Remove(effect);
                }
            }

            // Create the effect, based on the type of modification.
            StatEffect statEffect = null;

            switch (this.modType)
            {
            case "value":
                statEffect = new StatEffect(sender.Thing, this.stat, this.modAmount, 0, 0, this.duration, sensoryMessage, expirationMessage);
                break;

            case "min":
                statEffect = new StatEffect(sender.Thing, this.stat, 0, this.modAmount, 0, this.duration, sensoryMessage, expirationMessage);
                break;

            case "max":
                statEffect = new StatEffect(sender.Thing, this.stat, 0, 0, this.modAmount, this.duration, sensoryMessage, expirationMessage);
                break;
            }

            // Apply the effect.
            if (statEffect != null)
            {
                this.target.Behaviors.Add(statEffect);
            }
        }
    //Reset Priority Queue and reverses all stat effects
    public void clear()
    {
        //clears and reverses everything
        while (qStruct.Count != 0)
        {
            StatEffect finishedSE = this.remove();
            finishedSE.reverseEffect(this.entity);
        }

        timer = 0.0f;
    }
Esempio n. 13
0
    //Applies effects to enemy hit
    public void enactEffects(Collider2D tgt)
    {
        PKMNEntity enemy  = tgt.GetComponent <PKMNEntity>();
        int        damage = Battle.damageCalc(basis.level, INITIAL_PWR, basis.accessStat(BaseStat.SPECIAL_ATTACK), basis.accessStat(BaseStat.SPECIAL_DEFENSE));

        enemy.StartCoroutine(enemy.receiveDamage(damage, basis));

        //Add debuff
        StatEffect debuff = new StatEffect(DEBUFF_DURATION, DEBUFF_FACTOR, DEBUFF_TYPE);

        debuff.applyEffect(enemy.GetComponent <PKMNEntity>());
    }
Esempio n. 14
0
 public StatEffectRecord(
     StatEffect e,
     float init   = 0,
     float endVal = 0,
     float v      = 0
     )
 {
     effect       = e;
     initialValue = init;
     finalValue   = endVal;
     value        = v;
 }
Esempio n. 15
0
        /// <summary>Executes the command.</summary>
        /// <remarks>
        /// TODO: Optionally allow the admin to create a new attribute if the target didn't
        /// already have the attribute available to modify.
        /// </remarks>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            // Strings to be displayed when the effect is applied/removed.
            var buffString = new ContextualString(actionInput.Actor, target)
            {
                ToOriginator = $"The '{stat.Name}' stat of {target.Name} has changed by {modAmount}.",
                ToReceiver   = $"Your '{stat.Name}' stat has changed by {modAmount}."
            };
            var unbuffString = new ContextualString(actionInput.Actor, target)
            {
                ToReceiver = $"Your '{stat.Abbreviation}' stat goes back to normal."
            };

            // Turn the above sets of strings into sensory messages.
            var sensoryMessage    = new SensoryMessage(SensoryType.Sight, 100, buffString);
            var expirationMessage = new SensoryMessage(SensoryType.Sight, 100, unbuffString);

            // Remove all existing effects on stats with the same abbreviation
            // to prevent the effects from being stacked, at least for now.
            foreach (var effect in target.Behaviors.OfType <StatEffect>())
            {
                if (effect.Stat.Abbreviation == stat.Abbreviation)
                {
                    actionInput.Actor.Behaviors.Remove(effect);
                }
            }

            // Create the effect, based on the type of modification.
            StatEffect statEffect = null;

            switch (modType)
            {
            case "value":
                statEffect = new StatEffect(actionInput.Actor, stat, modAmount, 0, 0, duration, sensoryMessage, expirationMessage);
                break;

            case "min":
                statEffect = new StatEffect(actionInput.Actor, stat, 0, modAmount, 0, duration, sensoryMessage, expirationMessage);
                break;

            case "max":
                statEffect = new StatEffect(actionInput.Actor, stat, 0, 0, modAmount, duration, sensoryMessage, expirationMessage);
                break;
            }

            // Apply the effect.
            if (statEffect != null)
            {
                target.Behaviors.Add(statEffect);
            }
        }
    //Method that removes the first element in the queue
    //  Pre: qStruct.count > 0
    //  Post: First element in the queue has been removed
    private StatEffect remove()
    {
        StatEffect result = qStruct.First.Value;

        qStruct.RemoveFirst();

        //If there are no elements in the list anymore, reset timer.
        if (qStruct.Count == 0)
        {
            timer = 0.0f;
        }

        Debug.Log("StatEffect Timed Out!");
        return(result);
    }
Esempio n. 17
0
    //Responsible for grab knockback
    IEnumerator grabKnockback(Transform enemy)
    {
        //Sets up knockback variable and needed reference variables
        Vector2     kVect        = Battle.dirKnockbackCalc(enemy.position, basis.transform.position, KNOCKBACK_VAL);
        Rigidbody2D rb           = enemy.GetComponent <Rigidbody2D>();
        Rigidbody2D basisRB      = basis.GetComponent <Rigidbody2D>();
        PKMNEntity  enemyFighter = enemy.GetComponent <PKMNEntity>();
        Controller  control      = enemyFighter.getController();

        //Disable movement until grab movement done
        if (!enemyFighter.getAssist())
        {
            control.canMove = false;
        }

        yield return(new WaitForSeconds(STUN_DELAY));        //Overrides default knockback canceller (receiveDamage)

        rb.AddForce(kVect);
        float kbTimer = 0;

        while (kbTimer < KNOCKBACK_DURATION)
        {
            yield return(new WaitForFixedUpdate());

            kbTimer += Time.deltaTime;
        }

        rb.velocity      = Vector2.zero;
        basisRB.velocity = Vector2.zero;

        if (basis.tag == "Player" || basis.tag == "PlayerAttack" || basis.tag == "PlayerRecovery")
        {
            PlayerMovement mainControl = (PlayerMovement)(basis.getController());
            mainControl.selectedFighter.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
        }

        if (!enemyFighter.isStunned() && !enemy.GetComponent <DashChargeHitBox>().isDashing() && !enemy.GetComponent <Animator>().GetBool("Dashing"))
        {
            control.canMove = true;
        }

        //Add debuff
        StatEffect debuff = new StatEffect(DEBUFF_DURATION, DEBUFF_FACTOR, STAT_TYPE);

        debuff.applyEffect(enemy.GetComponent <PKMNEntity>());
    }
Esempio n. 18
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender = actionInput.Controller;
            //StatEffect effect;

            var statEffect = sender.Thing.Behaviors.FindFirst <StatEffect>();

            if (statEffect != null)
            {
                // @@@ ??
            }
            else
            {
                statEffect = new StatEffect();
                //{
                //    Modifier = 15,
                //    Name = "strength",
                //};
            }
        }
Esempio n. 19
0
        public GameplayController()
        {
            GameConsole.Init(Fonts.Font, 96, 32);

            GameConsole.Camera.BackgroundColor = GameConsole.BaseBackgroundColor;

            RasterizerState rasterizerState = new RasterizerState();

            rasterizerState.CullMode          = CullMode.None;
            rasterizerState.ScissorTestEnable = false;
            rasterizerState.FillMode          = FillMode.Solid;
            DrawCntrl.Rasterizer = rasterizerState;
            DrawCntrl.Sampler    = SamplerState.PointClamp;

            //new Terrain(96, 32);
            //new MapEditor();
            new MainMenu();

            Inventory.LoadItemPool();
            StatEffect.InitStatEffects();
        }
Esempio n. 20
0
        public static StatEffect Create(string fieldText, Sprite image)
        {
            if (string.IsNullOrEmpty(fieldText))
            {
                return(null);
            }
            StatEffect retval     = new StatEffect();
            int        splitIndex = fieldText.IndexOf('\n');

            foreach (string scText in fieldText.Substring(0, splitIndex).Split(RLConstants.STRING_SPLIT_AND))
            {
                retval.statChanges.Add(new StatChange(scText.Trim()));
            }

            retval.effectTexts = new List <string>(fieldText.Substring(splitIndex + 1).Split(RLConstants.STRING_SPLIT_OR, System.StringSplitOptions.RemoveEmptyEntries));
            for (int e = 0; e < retval.effectTexts.Count; e++)
            {
                retval.effectTexts[e] = RLUtilities.ApplyBoldItalic(retval.effectTexts[e]);
            }

            retval.EffectImage = image;
            return(retval);
        }
        public virtual void Update(GameTime gameTime, Rectangle levelBounds)
        {
            switch (_lifeState)
            {
            case LifeState.Living:
            case LifeState.Ghost:
            {
                if (Panicked)
                {
                    _panicTimer -= gameTime.ElapsedGameTime;
                    if (_panicTimer <= TimeSpan.Zero)
                    {
                        _panicTimer = TimeSpan.FromSeconds(PANIC_DIRECTION_CHANGE_FREQUENCY);
                        XnaHelper.RandomizeVector(ref _moveDirection, -1, 1, -1, 1);
                        _lookDirection = _moveDirection;
                    }
                }
                lookThisWay(LookDirection);
                if (MoveDirection.Length() > 0)
                {
                    moveThisWay(MoveDirection, gameTime);
                }

                //handle burning
                ApplyDamage(_statusEffects.Fire * (float)gameTime.ElapsedGameTime.TotalSeconds * FIRE_DPS);

                break;
            }

            case LifeState.Disabled:
            case LifeState.Frozen:
            {
                if (_statusEffects.Cryo <= 0)
                {
                    _lifeState = LifeState.Living;
                    //still cold after defrosting
                    _statusEffects.Cryo = MAX_STAT_EFFECT / 2;
                }
                break;
            }

            case LifeState.Shattered:
            {
                for (int y = 0; y < ICE_DIVISIONS; y++)
                {
                    for (int x = 0; x < ICE_DIVISIONS; x++)
                    {
                        _fragments[x, y].Angle       += _fragments[x, y].AngularVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        _fragments[x, y].Position    += _fragments[x, y].Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        _fragments[x, y].Velocity    += _fragments[x, y].Acceleration * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        _fragments[x, y].Acceleration = Vector2.Zero;
                        _fragments[x, y].Health      -= FRAGMENT_MELT_RATE * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        _fragments[x, y].ScaleFactor  = _fragments[x, y].Health / FRAGMENT_HEALTH * FRAGMENT_SCALE_FACTOR;
                        XnaHelper.ClampVector(ref _fragments[x, y].Velocity, FRAGMENT_MAX_VELOCITY, out _fragments[x, y].Velocity);
                        if (_fragments[x, y].BeingEaten)
                        {
                            _fragments[x, y].Health -= FRAGMENT_EAT_RATE * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        }
                    }
                }
                return;
            }

            case LifeState.BeingEaten:
            {
                _sprite.ScaleFactor -= BLACK_HOLE_EAT_SCALE_FACTOR * (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (_sprite.ScaleFactor <= 0)
                {
                    _lifeState = LifeState.Destroyed;
                }
                break;
            }

            case LifeState.Destroyed:
            default:
            {
                return;             //don't update anything
            }
            }

            stayInBounds(levelBounds.Width, levelBounds.Height);
            _velocity += _acceleration * (float)gameTime.ElapsedGameTime.TotalSeconds;
            Position  += _velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
            controlVelocity(_maxSpeed, gameTime.ElapsedGameTime);
            _sprite.Angle += _angularVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds;

            LookDirection = Vector2.Zero;
            MoveDirection = Vector2.Zero;
            _acceleration = Vector2.Zero;

            if (_movementParticleEffect != null)
            {
                _movementParticleEffect.Update(gameTime);
            }

            //burning visual effect
            _burningParticleEffect.Spawn(Position, 0.0f, gameTime.ElapsedGameTime, _velocity);
            _burningParticleEffect.IntensityFactor = _statusEffects.Fire / MAX_STAT_EFFECT;
            _burningParticleEffect.Update(gameTime);

            //cryo visual effect
            if (_statusEffects.Cryo > 0 && _lifeState != LifeState.Disabled)
            {
                _sprite.Shade = Color.Lerp(Color.White, Color.Blue, _statusEffects.Cryo / MAX_STAT_EFFECT);
            }

            _hitRect.X = (int)Position.X - _hitRect.Width / 2;
            _hitRect.Y = (int)Position.Y - _hitRect.Height / 2;

            //manage stat effects
            if (_statusEffects.Cryo >= MAX_STAT_EFFECT && _lifeState != LifeState.Frozen)
            {
                _lifeState          = LifeState.Frozen;
                _iceIntegrity       = maxHealth * ICE_INTEGRITY_FACTOR;
                _statusEffects.Fire = 0;    //stop burning if frozen
            }

            //decrement every stat effect based on status resist
            _statusEffects -= _statusResist * (float)gameTime.ElapsedGameTime.TotalSeconds;
            _statusEffects.Clamp(0, MAX_STAT_EFFECT);

            _sprite.Update(gameTime);
        }
 public void ApplyStatus(StatEffect effects)
 {
     _statusEffects += effects;
 }
Esempio n. 23
0
 public StatEffectRecord(StatEffect e, StatusEffect sfx)
 {
     effect       = e;
     statusEffect = sfx;
 }
Esempio n. 24
0
 protected override void ResetActionSkill()
 {
     if(waitArrows == null) {
         waitArrows = Resources.LoadAssetAtPath("Assets/SRPGKit/Prefabs/Wait Arrows.prefab", typeof(GameObject)) as GameObject;
     }
     TargetSettings ts = new TargetSettings();
     targetSettings = new TargetSettings[]{ts};
     overlayColor = Color.clear;
     highlightColor = Color.clear;
     ts.targetingMode = TargetingMode.Cardinal;
     ts.targetRegion = new Region();
     ts.targetRegion.type = RegionType.Self;
     ts.targetRegion.interveningSpaceType = InterveningSpaceType.Pick;
     ts.effectRegion = new Region();
     ts.effectRegion.type = RegionType.Self;
     ts.effectRegion.interveningSpaceType = InterveningSpaceType.Pick;
     StatEffect facingEffect = new StatEffect();
     facingEffect.effectType = StatEffectType.ChangeFacing;
     facingEffect.target = StatEffectTarget.Applier;
     facingEffect.triggerF = Formula.True();
     facingEffect.value = Formula.Lookup("arg.angle.xy", LookupType.SkillParam);
     StatEffect endTurnEffect = new StatEffect();
     endTurnEffect.effectType = StatEffectType.EndTurn;
     endTurnEffect.target = StatEffectTarget.Applier;
     endTurnEffect.triggerF = Formula.True();
     applicationEffects = new StatEffectGroup{effects=new StatEffect[]{
         facingEffect, endTurnEffect
     }};
 }
Esempio n. 25
0
    public static Multiplier TranslateStatToMultiplyer(StatEffect stat)
    {
        Multiplier multi = Multiplier.NONE;

        if (stat == StatEffect.Defense) { multi = Multiplier.Defense; }
        else if (stat == StatEffect.Offense) { multi = Multiplier.Offense; }
        else if (stat == StatEffect.Sense) { multi = Multiplier.Sense; }
        else if (stat == StatEffect.Sneak) { multi = Multiplier.Sneak; }
        else if (stat == StatEffect.Speed) { multi = Multiplier.Speed; }

        return multi;
    }
Esempio n. 26
0
 public StatEffectRecord(StatEffect e, StatusEffect[] removedSfx)
 {
     effect = e;
     removedStatusEffects = removedSfx;
 }
Esempio n. 27
0
 public StatEffectRecord(StatEffect e, Vector3 start)
 {
     effect = e;
     specialMoveStart = start;
 }
Esempio n. 28
0
 //Adds stat effect to the queue
 //  Pre: effect != null and effect.StatFactor != 0
 //  Post: effect is added to stat queue
 public void addStatQ(StatEffect effect)
 {
     statChangeQ.add(effect);
 }
Esempio n. 29
0
        public static bool ApplyEffectsToStats(StatEffect effect, bool forward)
        {
            Type            typeFromHandle = typeof(PlayerStats);
            PlayerStats     stats          = LocalPlayer.Stats;
            PlayerInventory inventory      = LocalPlayer.Inventory;
            int             num            = (!forward) ? -1 : 1;

            StatEffect.Types type = effect._type;
            switch (type)
            {
            case StatEffect.Types.BatteryCharge:
                stats.BatteryCharge = Mathf.Clamp(stats.BatteryCharge + effect._amount * (float)num, 0f, 100f);
                break;

            case StatEffect.Types.VisibleLizardSkinArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.LizardSkin);
                inventory.PendingSendMessage = "CheckArmor";
                break;

            default:
                switch (type)
                {
                case StatEffect.Types.Stamina:
                    stats.Stamina += effect._amount * (float)num;
                    break;

                case StatEffect.Types.Health:
                    stats.HealthChange(effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio);
                    LocalPlayer.Stats.CheckStats();
                    break;

                case StatEffect.Types.Energy:
                    stats.Energy += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio;
                    break;

                case StatEffect.Types.Armor:
                    stats.Armor = Mathf.Clamp(stats.Armor + (int)effect._amount * num, 0, 2000);
                    break;

                default:
                    if (type != StatEffect.Types.MaxAmountBonus)
                    {
                        FieldInfo field = typeFromHandle.GetField(effect._type.ToString(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (field.FieldType == typeof(float))
                        {
                            field.SetValue(stats, (float)field.GetValue(stats) + effect._amount * (float)num);
                        }
                        else if (field.FieldType == typeof(int))
                        {
                            field.SetValue(stats, (int)((float)((int)field.GetValue(stats)) + effect._amount * (float)num));
                        }
                        LocalPlayer.Stats.CheckStats();
                    }
                    else
                    {
                        LocalPlayer.Inventory.AddMaxAmountBonus(effect._itemId, (int)(effect._amount * (float)num));
                    }
                    break;

                case StatEffect.Types.Fullness:
                    stats.Fullness += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio;
                    break;
                }
                break;

            case StatEffect.Types.Method_PoisonMe:
                if (effect._amount == 0f)
                {
                    stats.PoisonMe();
                }
                else
                {
                    stats.Invoke("PoisonMe", effect._amount);
                }
                break;

            case StatEffect.Types.Method_HitFood:
                if (effect._amount == 0f)
                {
                    stats.HitFood();
                }
                else
                {
                    stats.Invoke("HitFood", effect._amount);
                }
                break;

            case StatEffect.Types.VisibleDeerSkinArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.DeerSkin);
                inventory.PendingSendMessage = "CheckArmor";
                break;

            case StatEffect.Types.ColdArmor:
                stats.ColdArmor = Mathf.Clamp(stats.ColdArmor + effect._amount * (float)num, 0f, 2f);
                break;

            case StatEffect.Types.VisibleStealthArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.Leaves);
                inventory.PendingSendMessage = "CheckArmor";
                break;

            case StatEffect.Types.Stealth:
                LocalPlayer.Stats.Stealth += effect._amount * (float)num;
                break;

            case StatEffect.Types.Thirst:
                if (num > 0)
                {
                    stats.Thirst += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio * GameSettings.Survival.ItemUsedThirstGainRatio;
                }
                else
                {
                    stats.Thirst += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio * GameSettings.Survival.ItemUsedThirstLossRatio;
                }
                break;

            case StatEffect.Types.AirRecharge:
                if (stats.AirBreathing.CurrentRebreatherAir >= stats.AirBreathing.MaxRebreatherAirCapacity)
                {
                    return(false);
                }
                stats.AirBreathing.CurrentRebreatherAir = stats.AirBreathing.MaxRebreatherAirCapacity;
                break;

            case StatEffect.Types.Method_UseRebreather:
                stats.UseRebreather(forward);
                break;

            case StatEffect.Types.CureFoodPoisoning:
                LocalPlayer.Stats.FoodPoisoning.Cure();
                break;

            case StatEffect.Types.CureBloodInfection:
                LocalPlayer.Stats.BloodInfection.Cure();
                break;

            case StatEffect.Types.OvereatingPoints:
                Debug.LogError("Use of deprecated option please report");
                break;

            case StatEffect.Types.UndereatingPoints:
                Debug.LogError("Use of deprecated option please report");
                break;

            case StatEffect.Types.SnowFlotation:
                LocalPlayer.FpCharacter.snowFlotation = (num > 0);
                break;

            case StatEffect.Types.SoundRangeDampFactor:
                if (LocalPlayer.Stats.SoundRangeDampFactor < 0.69f)
                {
                    LocalPlayer.Stats.SoundRangeDampFactor = 0.7f;
                }
                LocalPlayer.Stats.SoundRangeDampFactor += effect._amount * (float)num;
                break;

            case StatEffect.Types.VisibleBoneArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.Bone);
                inventory.PendingSendMessage = "CheckArmor";
                break;

            case StatEffect.Types.ResetFrost:
                LocalPlayer.Stats.ResetFrost();
                break;

            case StatEffect.Types.FuelRecharge:
                if (stats.Fuel.CurrentFuel >= stats.Fuel.MaxFuelCapacity)
                {
                    return(false);
                }
                stats.Fuel.CurrentFuel = stats.Fuel.MaxFuelCapacity;
                break;

            case StatEffect.Types.EatenCalories:
                LocalPlayer.Stats.Calories.OnAteFood(Mathf.RoundToInt(effect._amount * (float)num));
                break;

            case StatEffect.Types.VisibleWarmsuit:
                if (forward)
                {
                    stats.AddArmorVisible(PlayerStats.ArmorTypes.Warmsuit);
                }
                else
                {
                    stats.AddArmorVisible(PlayerStats.ArmorTypes.None);
                }
                inventory.PendingSendMessage = "CheckArmor";
                break;

            case StatEffect.Types.hairSprayFuelRecharge:
                if (stats.hairSprayFuel.CurrentFuel >= stats.hairSprayFuel.MaxFuelCapacity)
                {
                    return(false);
                }
                stats.hairSprayFuel.CurrentFuel = stats.hairSprayFuel.MaxFuelCapacity;
                break;

            case StatEffect.Types.VisibleCreepyArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.Creepy);
                inventory.PendingSendMessage = "CheckArmor";
                break;
            }
            return(true);
        }
Esempio n. 30
0
        public static void ApplyEffectsToStats(StatEffect effect, bool forward)
        {
            Type            typeFromHandle = typeof(PlayerStats);
            PlayerStats     stats          = LocalPlayer.Stats;
            PlayerInventory inventory      = LocalPlayer.Inventory;
            int             num            = (!forward) ? -1 : 1;

            switch (effect._type)
            {
            case StatEffect.Types.Stamina:
                stats.Stamina += effect._amount * (float)num;
                goto IL_412;

            case StatEffect.Types.Health:
                stats.Health += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio;
                goto IL_412;

            case StatEffect.Types.Energy:
                stats.Energy += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio;
                goto IL_412;

            case StatEffect.Types.Armor:
                stats.Armor += (int)effect._amount * num;
                goto IL_412;

            case StatEffect.Types.Fullness:
                stats.Fullness += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio;
                goto IL_412;

            case StatEffect.Types.BatteryCharge:
                stats.BatteryCharge = Mathf.Clamp(stats.BatteryCharge + effect._amount * (float)num, 0f, 100f);
                goto IL_412;

            case StatEffect.Types.VisibleLizardSkinArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.LizardSkin);
                inventory.PendingSendMessage = "CheckArmor";
                goto IL_412;

            case StatEffect.Types.Method_PoisonMe:
                if (effect._amount == 0f)
                {
                    stats.PoisonMe();
                }
                else
                {
                    stats.Invoke("PoisonMe", effect._amount);
                }
                goto IL_412;

            case StatEffect.Types.Method_HitFood:
                if (effect._amount == 0f)
                {
                    stats.HitFood();
                }
                else
                {
                    stats.Invoke("HitFood", effect._amount);
                }
                goto IL_412;

            case StatEffect.Types.VisibleDeerSkinArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.DeerSkin);
                inventory.PendingSendMessage = "CheckArmor";
                goto IL_412;

            case StatEffect.Types.VisibleStealthArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.Leaves);
                inventory.PendingSendMessage = "CheckArmor";
                goto IL_412;

            case StatEffect.Types.Stealth:
                LocalPlayer.Stats.Stealth += effect._amount * (float)num;
                goto IL_412;

            case StatEffect.Types.Thirst:
                stats.Thirst += effect._amount * (float)num * LocalPlayer.Stats.FoodPoisoning.EffectRatio;
                goto IL_412;

            case StatEffect.Types.AirRecharge:
                stats.AirBreathing.CurrentRebreatherAir = stats.AirBreathing.MaxRebreatherAirCapacity;
                goto IL_412;

            case StatEffect.Types.Method_UseRebreather:
                stats.UseRebreather(forward);
                goto IL_412;

            case StatEffect.Types.CureFoodPoisoning:
                LocalPlayer.Stats.FoodPoisoning.Cure();
                goto IL_412;

            case StatEffect.Types.CureBloodInfection:
                LocalPlayer.Stats.BloodInfection.Cure();
                goto IL_412;

            case StatEffect.Types.OvereatingPoints:
                stats.PhysicalStrength.OvereatingPointsChange(effect._amount * (float)num);
                goto IL_412;

            case StatEffect.Types.UndereatingPoints:
                stats.PhysicalStrength.UndereatingPointsChange(effect._amount * (float)num);
                goto IL_412;

            case StatEffect.Types.SnowFlotation:
                LocalPlayer.FpCharacter.snowFlotation = (num > 0);
                goto IL_412;

            case StatEffect.Types.SoundRangeDampFactor:
                if (LocalPlayer.Stats.SoundRangeDampFactor < 0.69f)
                {
                    LocalPlayer.Stats.SoundRangeDampFactor = 0.7f;
                }
                LocalPlayer.Stats.SoundRangeDampFactor += effect._amount * (float)num;
                goto IL_412;

            case StatEffect.Types.VisibleBoneArmor:
                stats.AddArmorVisible(PlayerStats.ArmorTypes.Bone);
                inventory.PendingSendMessage = "CheckArmor";
                goto IL_412;
            }
            FieldInfo field = typeFromHandle.GetField(effect._type.ToString(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (field.FieldType == typeof(float))
            {
                field.SetValue(stats, (float)field.GetValue(stats) + effect._amount * (float)num);
            }
            else if (field.FieldType == typeof(int))
            {
                field.SetValue(stats, (int)((float)((int)field.GetValue(stats)) + effect._amount * (float)num));
            }
IL_412:
            LocalPlayer.Stats.CheckStats();
        }
Esempio n. 31
0
 public StatEffectRecord(StatEffect e, Inventory inv, Item it, bool succ)
 {
     effect = e;
     inventory = inv;
     involvedItem = it;
     success = succ;
 }
Esempio n. 32
0
 public StatEffectRecord(StatEffect e, StatusEffect[] removedSfx)
 {
     effect = e;
     removedStatusEffects = removedSfx;
 }
Esempio n. 33
0
 public StatEffectRecord(StatEffect e, StatusEffect sfx)
 {
     effect = e;
     statusEffect = sfx;
 }
Esempio n. 34
0
 protected void ApplyActionEffects(StatEffect[] fx)
 {
     foreach(StatEffect se in fx) {
         se.Apply(
             applyingSkill,
             applyingSkill != null ? applyingSkill.character : null,
             character
         );
     }
 }
    private string getEffectDescription(StatEffect stat)
    {
        string rtn = "";

        return(rtn);
    }
Esempio n. 36
0
    public StatEffectRecord(
		StatEffect e, 
		float init=0, 
		float endVal=0, 
		float v=0
	)
    {
        effect = e;
        initialValue = init;
        finalValue = endVal;
        value = v;
    }
 public ViewModelSkillEffectStat(StatEffect statEffect, byte maxLevel) : base(statEffect, maxLevel)
 {
     this.statEffect = statEffect;
 }
Esempio n. 38
0
    //EnactEffects method. Apply self-buff on unit and add buff to the PriorityQueue
    public void enactEffects(Collider2D self)
    {
        StatEffect effects = new StatEffect(DURATION, CHANGE_FACTOR, BaseStat.SPEED);

        effects.applyEffect(unit);
    }
Esempio n. 39
0
    protected virtual void ApplyPerApplicationEffectsTo(
		StatEffect[] effects,
		List<Character> targs
	)
    {
        Character targ = (targs == null || targs.Count == 0) ? null : targs[0];
        if(targ == null) {
            foreach(StatEffect se in effects) {
                if(se.target == StatEffectTarget.Applied) {
                    Debug.LogError("Applied-facing ability used without target");
                    return;
                }
            }
        }
        foreach(StatEffect se in effects) {
            //Debug.Log("apply "+se.effectType);
            var rec = se.Apply(
                this,
                character,
                targ
            );
            if(rec != null) {
                lastEffects.Add(rec);
            }
        }
    }