Exemplo n.º 1
0
    private void InitBarrier(
        int guid,
        string name,
        Vector3 center,
        Vector3 facingDir,
        float width,
        bool bidirectional,
        BlockingRules blocksVision,
        BlockingRules blocksAbilities,
        BlockingRules blocksMovement,
        BlockingRules blocksMovementOnCrossover,
        BlockingRules blocksPositionTargeting,
        bool considerAsCover,
        int maxDuration,
        ActorData owner,
        List <GameObject> barrierSequencePrefabs,
        bool playSequences,
        GameplayResponseForActor onEnemyMovedThrough,
        GameplayResponseForActor onAllyMovedThrough,
        int maxHits,
        bool endOnCasterDeath,
        SequenceSource parentSequenceSource,
        Team barrierTeam)
    {
        m_guid          = guid;
        m_name          = name;
        m_center        = center;
        m_facingDir     = facingDir;
        m_bidirectional = bidirectional;
        Vector3 a = Vector3.Cross(facingDir, Vector3.up);

        a.Normalize();
        float d = width * Board.Get().squareSize;

        m_endpoint1               = center + a * d / 2f;
        m_endpoint2               = center - a * d / 2f;
        BlocksVision              = blocksVision;
        BlocksAbilities           = blocksAbilities;
        BlocksMovement            = blocksMovement;
        BlocksMovementOnCrossover = blocksMovementOnCrossover;
        BlocksPositionTargeting   = blocksPositionTargeting;
        m_considerAsCover         = considerAsCover;
        m_owner                  = owner;
        m_team                   = m_owner?.GetTeam() ?? barrierTeam;
        m_time                   = new EffectDuration();
        m_time.duration          = maxDuration;
        m_barrierSequencePrefabs = barrierSequencePrefabs;
        m_playSequences          = playSequences && m_barrierSequencePrefabs != null;
        m_barrierSequences       = new List <Sequence>();
        if (m_playSequences)
        {
            BarrierSequenceSource = new SequenceSource(null, null, false, parentSequenceSource);
        }
        m_maxHits = maxHits;

        // added
        m_onEnemyMovedThrough = onEnemyMovedThrough;
        m_onAllyMovedThrough  = onAllyMovedThrough;
        m_endOnCasterDeath    = endOnCasterDeath;
    }
        public void RemoveAllByType(EffectType type             = EffectType.Undefined,
                                    EffectDuration durationType = EffectDuration.Undefined, bool?regenerative = null)
        {
            bool needToRemove = true;

            for (var i = 0; i < _effects.Count; i++)
            {
                // check by type (positive / negative)
                needToRemove = needToRemove && (type == EffectType.Undefined || _effects[i].EffectType == type);
                // check by type of duration
                needToRemove = needToRemove &&
                               (durationType == EffectDuration.Undefined || _effects[i].DurationType == durationType);

                if (regenerative.HasValue)
                {
                    needToRemove = needToRemove && (regenerative.Value == _effects[i] is RegenerativeStat);
                }

                if (!needToRemove)
                {
                    continue;
                }
                _effects[i].ExpireNow();
                if (_icons[_effects[i]])
                {
                    UnityEngine.Object.Destroy(_icons[_effects[i]]);
                }
                _effects.RemoveAt(i);
            }
        }
Exemplo n.º 3
0
 public EffectBase(float duration, EffectDuration durationType, EffectType effectType, Sprite effectIcon)
 {
     RemainingDuration = initialDuration = duration;
     this.durationType = durationType;
     this.effectType   = effectType;
     _effectIcon       = effectIcon;
 }
 public CollectibleBase GetEffectCollectible(EffectBase effect = null, EffectDuration duration = EffectDuration.Undefined)
 {
     if (effect == null)
     {
         effect = MasterManager.Instance.LinksHolder.GameEffectFactory.MakeRandomEffect(duration);
     }
     return(new StatChangingCollectible(effect));
 }
Exemplo n.º 5
0
        public EffectBase DeserializeEffect(byte[] buffer, ref int index)
        {
            if (buffer.Length < index)
            {
                throw new System.Exception("buffer too small to contain an Effect");
            }
            byte       b = buffer[index];
            EffectBase effectBase;

            switch (b)
            {
            case 1:
                effectBase = new EffectBase();
                break;

            case 2:
                effectBase = new EffectCreature();
                break;

            case 3:
                effectBase = new EffectDate();
                break;

            case 4:
                effectBase = new EffectDice();
                break;

            case 5:
                effectBase = new EffectDuration();
                break;

            case 6:
                effectBase = new EffectInteger();
                break;

            case 7:
                effectBase = new EffectLadder();
                break;

            case 8:
                effectBase = new EffectMinMax();
                break;

            case 9:
                effectBase = new EffectMount();
                break;

            case 10:
                effectBase = new EffectString();
                break;

            default:
                throw new System.Exception(string.Format("Incorrect identifier : {0}", b));
            }
            index++;
            effectBase.DeSerialize(buffer, ref index);
            return(effectBase);
        }
Exemplo n.º 6
0
 static Durations()
 {
     Instant = new EffectDuration(WizardMonks.Durations.Instantaneous, 0);
     Concentration = new EffectDuration(WizardMonks.Durations.Concentration, 1);
     Diameter = new EffectDuration(WizardMonks.Durations.Diameter, 1);
     Sun = new EffectDuration(WizardMonks.Durations.Sun, 2);
     Ring = new EffectDuration(WizardMonks.Durations.Ring, 2);
     Moon = new EffectDuration(WizardMonks.Durations.Moon, 3);
     Year = new EffectDuration(WizardMonks.Durations.Year, 4, true);
 }
Exemplo n.º 7
0
 static Durations()
 {
     Instant       = new EffectDuration(WizardMonks.Durations.Instantaneous, 0);
     Concentration = new EffectDuration(WizardMonks.Durations.Concentration, 1);
     Diameter      = new EffectDuration(WizardMonks.Durations.Diameter, 1);
     Sun           = new EffectDuration(WizardMonks.Durations.Sun, 2);
     Ring          = new EffectDuration(WizardMonks.Durations.Ring, 2);
     Moon          = new EffectDuration(WizardMonks.Durations.Moon, 3);
     Year          = new EffectDuration(WizardMonks.Durations.Year, 4, true);
 }
Exemplo n.º 8
0
 public EffectData(EffectType gameEffectType, EffectDuration durationType, StatType gameStatType,
                   bool affectRegen, float amount, float duration, string iconName)
 {
     this.gameEffectType = gameEffectType;
     this.durationType   = durationType;
     this.gameStatType   = gameStatType;
     this.affectRegen    = affectRegen;
     this.amount         = amount;
     this.duration       = duration;
     this.iconName       = iconName;
     isFake = false;
 }
Exemplo n.º 9
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = EffectName != null?EffectName.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ EffectDuration.GetHashCode();
                hashCode = (hashCode * 397) ^ EffectPower.GetHashCode();
                hashCode = (hashCode * 397) ^ EffectRate.GetHashCode();
                hashCode = (hashCode * 397) ^ IsDecaying.GetHashCode();
                hashCode = (hashCode * 397) ^ StatIndex;
                hashCode = (hashCode * 397) ^ (TargetStats != null ? TargetStats.GetHashCode() : 0);
                return(hashCode);
            }
        }
Exemplo n.º 10
0
        public void InitializeEffects(Mount mount)
        {
            if (Effects.Count > 0)
            {
                Effects.Clear();
            }

            Effects.Add(m_mountEffect = new EffectMount(EffectsEnum.Effect_ViewMountCharacteristics, mount.Id, DateTime.Now, mount.Template.Id));
            if (mount.Owner != null)
            {
                Effects.Add(m_belongsToEffect = new EffectString(EffectsEnum.Effect_BelongsTo, mount.Owner.Name));
            }
            Effects.Add(m_nameEffect     = new EffectString(EffectsEnum.Effect_Name, mount.Name));
            Effects.Add(m_validityEffect = new EffectDuration(EffectsEnum.Effect_Validity, MountManager.MountStorageValidity));

            Mount             = mount;
            mount.StoredSince = DateTime.Now;
            Owner.SetOwnedMount(mount);
        }
Exemplo n.º 11
0
        private void Initialize()
        {
            if (Effects.Count > 0)
            {
                // hack to bypass initialization (see MountManager.StoreMount)
                if (Effects.Any(x => x.Id == -1))
                {
                    return;
                }

                m_mountEffect     = Effects.OfType <EffectMount>().FirstOrDefault();
                m_nameEffect      = Effects.OfType <EffectString>().FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_Name);
                m_belongsToEffect = Effects.OfType <EffectString>().FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_BelongsTo);
                m_validityEffect  = Effects.OfType <EffectDuration>().FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_Validity);

                if (m_mountEffect == null)
                {
                    logger.Error($"Invalid certificate mount effect absent");
                    CreateMount();
                    return;
                }

                // invalid certificate
                if (m_mountEffect.Date < DateTime.Now - MountManager.MountStorageValidity)
                {
                    return;
                }

                var record = MountManager.Instance.GetMount(m_mountEffect.MountId);

                if (record == null) // mount has been deleted, the certificate isn't valid anymore
                {
                    return;
                }

                Mount = new Mount(Owner, record);
            }
            else
            {
                CreateMount();
            }
        }
Exemplo n.º 12
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Effect/Duration", true, out subEle);
            subEle.Value = EffectDuration.ToString("G15");

            ele.TryPathTo("Effect/Orientation", true, out subEle);
            subEle.Value = EffectOrientation.ToString();

            ele.TryPathTo("AngleThreshold", true, out subEle);
            subEle.Value = AngleThreshold.ToString("G15");

            ele.TryPathTo("PlacementRadius", true, out subEle);
            subEle.Value = PlacementRadius.ToString("G15");

            ele.TryPathTo("SoundLevel", true, out subEle);
            subEle.Value = SoundLevel.ToString();

            ele.TryPathTo("HasDecalData", true, out subEle);
            subEle.Value = HasDecalData.ToString();
        }
Exemplo n.º 13
0
    public void CombineWith(EffectDuration duration)
    {
        var other = duration as DaysEffectDuration;

        if (other == null)
        {
            return;
        }

        switch (combineType)
        {
        case CombineType.Add:
            days += other.days;
            break;

        case CombineType.Highest:
            days = Mathf.Max(other.days, days);
            break;

        case CombineType.Nothing:
            break;
        }
    }
Exemplo n.º 14
0
        public EffectBase MakeEffect(EffectSet effectSet, EffectDuration durationType = EffectDuration.Undefined)
        {
            if (durationType == EffectDuration.Undefined)
            {
                durationType = Random.Range(0, 2) > 0 ? EffectDuration.Timed : EffectDuration.Permanent;
            }

            EffectBase effect;
            var        statType = effectSet.GameStatType;
            var        amount   = Random.Range(effectSet.MinAmount, effectSet.MaxAmount);

            if (effectSet.GameEffectType == EffectType.Negative)
            {
                amount *= -1;
            }
            var duration = 0f;

            if (durationType == EffectDuration.Timed)
            {
                duration = Random.Range(effectSet.MinDuration, effectSet.MaxDuration);
            }
            else
            {
                amount *= _permanentEffectsModifier;
            }

            if (effectSet.AffectRegen)
            {
                effect = new StatRegenerationChangingEffect(statType, amount, duration, durationType, effectSet.GameEffectType, effectSet.Icon);
            }
            else
            {
                effect = new StatValueChangingEffect(statType, amount, duration, durationType, effectSet.GameEffectType, effectSet.Icon);
            }

            return(effect);
        }
Exemplo n.º 15
0
 public void CombineWith(EffectDuration duration)
 {
 }
 public StatRegenerationChangingEffect(StatType affectStatType, float amount,
                                       float duration, EffectDuration durationType, EffectType effectType, Sprite icon) : base(affectStatType, amount, duration,
                                                                                                                               durationType, effectType, icon)
 {
 }
Exemplo n.º 17
0
 public StatChangingEffect(StatType affectStatType, float amount, float duration, EffectDuration durationType,
                           EffectType effectType, Sprite icon) : base(duration, durationType, effectType, icon)
 {
     this.affectStatType = affectStatType;
     _amount             = amount;
 }
Exemplo n.º 18
0
        public EffectBase ConvertExportedEffect(EffectInstance effect)
        {
            EffectBase result;

            if (effect is EffectInstanceLadder)
            {
                result = new EffectLadder(effect as EffectInstanceLadder);
            }
            else
            {
                if (effect is EffectInstanceCreature)
                {
                    result = new EffectCreature(effect as EffectInstanceCreature);
                }
                else
                {
                    if (effect is EffectInstanceDate)
                    {
                        result = new EffectDate(effect as EffectInstanceDate);
                    }
                    else
                    {
                        if (effect is EffectInstanceDice)
                        {
                            result = new EffectDice(effect as EffectInstanceDice);
                        }
                        else
                        {
                            if (effect is EffectInstanceDuration)
                            {
                                result = new EffectDuration(effect as EffectInstanceDuration);
                            }
                            else
                            {
                                if (effect is EffectInstanceMinMax)
                                {
                                    result = new EffectMinMax(effect as EffectInstanceMinMax);
                                }
                                else
                                {
                                    if (effect is EffectInstanceMount)
                                    {
                                        result = new EffectMount(effect as EffectInstanceMount);
                                    }
                                    else
                                    {
                                        if (effect is EffectInstanceString)
                                        {
                                            result = new EffectString(effect as EffectInstanceString);
                                        }
                                        else
                                        {
                                            if (effect is EffectInstanceInteger)
                                            {
                                                result = new EffectInteger(effect as EffectInstanceInteger);
                                            }
                                            else
                                            {
                                                result = new EffectBase(effect);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
 public StatValueChangingEffect(StatType affectStatType, float amount, float duration,
                                EffectDuration durationType, EffectType effectType, Sprite icon) : base(affectStatType, amount, duration, durationType,
                                                                                                        effectType, icon)
 {
     extraValue = new ExtraValue(amount);
 }
Exemplo n.º 20
0
 public override int GetHashCode()
 {
     return(EffectDuration.GetHashCode());
 }
Exemplo n.º 21
0
 /// <summary>
 /// Applies the specified effect at this location.
 /// </summary>
 /// <param name="durationType">The duration type to apply with this effect.</param>
 /// <param name="effect">The effect to apply.</param>
 /// <param name="duration">If duration type is <see cref="EffectDuration.Temporary"/>, the duration of this effect.</param>
 public void ApplyEffect(EffectDuration durationType, Effect effect, TimeSpan duration = default)
 {
     NWScript.ApplyEffectAtLocation((int)durationType, effect, this, (float)duration.TotalSeconds);
 }
Exemplo n.º 22
0
        public EffectBase MakeRandomEffect(EffectDuration durationType = EffectDuration.Undefined)
        {
            var effectSet = MasterManager.Instance.LinksHolder.EffectsSetLibrary.GetRandomEffectSet();

            return(MakeEffect(effectSet, durationType));
        }