示例#1
0
        public override string Render()
        {
            var fill           = string.Empty;
            var borderColor    = string.Empty;
            var borderWidth    = string.Empty;
            var isBorderDashed = false;

            if (Effects != null)
            {
                fill           = base.Effects.Any(x => x.EffectType == VirtualEffectTypes.Fill) ? base.Effects.First(x => x.EffectType == VirtualEffectTypes.Fill).Value : string.Empty;
                borderColor    = base.Effects.Any(x => x.EffectType == VirtualEffectTypes.BorderColor) ? base.Effects.First(x => x.EffectType == VirtualEffectTypes.BorderColor).Value : string.Empty;
                borderWidth    = base.Effects.Any(x => x.EffectType == VirtualEffectTypes.BorderWidth) ? base.Effects.First(x => x.EffectType == VirtualEffectTypes.BorderWidth).Value : string.Empty;
                isBorderDashed = base.Effects.Any(x => x.EffectType == VirtualEffectTypes.Dashed);

                if (Effects.Any(x => x.EffectType == VirtualEffectTypes.Expand))
                {
                    var size = Effects.FirstOrDefault(x => x.EffectType == VirtualEffectTypes.Expand).Value;
                    this.Expand(Convert.ToInt32(size));
                }
            }

            base.Render();

            return(string.Format("addRect({0}, {1}, {2}, {3}, '{4}' ,'Circle','{5}','{6}'" + "," + "'{7}');", this.PositionX, this.PositionY, this.Radius, this.Radius, fill, borderWidth, borderColor, isBorderDashed.ToString().ToLower()));
        }
        public bool Validate(ILogger log)
        {
            if (!Effects.Any())
            {
                log.LogWarning(CompilationMessage.From($"Type {Host.FullName} has defined as an aspect, but lacks any effect.", Host));
            }

            if (Host.HasGenericParameters)
            {
                log.LogError(CompilationMessage.From($"Aspect {Host.FullName} should not have generic parameters.", Host));
                return(false);
            }

            if (Host.IsAbstract)
            {
                log.LogError(CompilationMessage.From($"Aspect {Host.FullName} cannot be static nor abstract.", Host));
                return(false);
            }

            if (GetFactoryMethod() == null)
            {
                if (Factory != null)
                {
                    log.LogError(CompilationMessage.From($"Type {Factory.FullName} should have 'public static object GetInstance(Type)' method in order to be aspect factory.", Host));
                }
                else
                {
                    log.LogError(CompilationMessage.From($"Aspect {Host.FullName} has no parameterless public constructor nor valid factory.", Host.Methods.First(m => m.IsConstructor && !m.IsStatic)));
                }
                return(false);
            }

            return(Effects.All(e => e.Validate(this, log)));
        }
示例#3
0
        public bool Validate(BaseModuleWeaver weaver)
        {
            if (!Effects.Any())
            {
                weaver.LogWarning($"Type {Host.FullName} has defined as an aspect, but lacks any effect.");
            }

            if (Host.HasGenericParameters)
            {
                weaver.LogError($"Aspect {Host.FullName} should not have generic parameters.");
                return(false);
            }

            if (Host.IsAbstract)
            {
                weaver.LogError($"Aspect {Host.FullName} cannot be static nor abstract.");
                return(false);
            }

            if (GetFactoryMethod() == null)
            {
                if (Factory != null)
                {
                    weaver.LogError($"Type {Factory.FullName} should have 'public static object GetInstance(Type)' method in order to be aspect factory.");
                }
                else
                {
                    weaver.LogError($"Aspect {Host.FullName} has no parameterless public constructor nor valid factory.");
                }
                return(false);
            }

            return(Effects.All(e => e.Validate(this, weaver)));
        }
示例#4
0
    protected override void UpdateSpeed()
    {
        var normalSpeed = 0.0f;

        if (Visible)
        {
            normalSpeed = (enemyData as Declarations.RogueData).RunSpeed;
        }
        else
        {
            normalSpeed = enemyData.Speed;
        }

        if (Effects.Any(x => x.Type == Declarations.EffectType.Stun))
        {
            CurrentSpeed = 0;
        }
        else
        {
            var enemyInFront = GameManager.instance.SpawnManager.GetEnemyInFront(this);
            if (enemyInFront != null)
            {
                if (Vector3.Distance(transform.position, enemyInFront.transform.position) <= distanceFromFrontEnemy)
                {
                    if (enemyInFront.CurrentSpeed < CurrentSpeed)
                    {
                        CurrentSpeed = enemyInFront.CurrentSpeed;
                    }
                }
                else
                {
                    if (CurrentSpeed != normalSpeed)
                    {
                        CurrentSpeed = normalSpeed;
                    }
                }
            }
            else
            {
                if (CurrentSpeed != normalSpeed)
                {
                    CurrentSpeed = normalSpeed;
                }
            }
            var slow    = Effects.FirstOrDefault(x => x.Type == Declarations.EffectType.Slow);
            var speedUp = Effects.FirstOrDefault(x => x.Type == Declarations.EffectType.Speed);
            if (speedUp != null)
            {
                CurrentSpeed *= speedUp.Value;
            }
            else if (slow != null)
            {
                CurrentSpeed -= CurrentSpeed * (slow.Value / 100);
            }
        }
        if (Moving)
        {
            anim.speed = CurrentSpeed / normalSpeed;//keep the leg movement consistent
        }
    }
        public bool Validate(ILogger log)
        {
            var result = true;

            if (Scope != Scope.Global && Scope != Scope.PerInstance)
            {
                log.Log(GeneralRules.UnknownCompilationOption, Host, GeneralRules.Literals.UnknownAspectScope(Scope.ToString()));
            }

            if (!Effects.Any())
            {
                log.Log(AspectRules.AspectShouldContainEffect, Host, Host.Name);
            }

            if (Host.HasGenericParameters)
            {
                log.Log(AspectRules.AspectMustHaveValidSignature, Host, Host.Name, AspectRules.Literals.HasGenericParams);
                result = false;
            }

            if (!Host.IsPublic && !Host.IsNestedPublic)
            {
                log.Log(AspectRules.AspectMustHaveValidSignature, Host, Host.Name, AspectRules.Literals.IsNotPublic);
                result = false;
            }

            if (Host.IsAbstract)
            {
                if (Host.IsSealed)
                {
                    log.Log(AspectRules.AspectMustHaveValidSignature, Host, Host.Name, AspectRules.Literals.IsStatic);
                }
                else
                {
                    log.Log(AspectRules.AspectMustHaveValidSignature, Host, Host.Name, AspectRules.Literals.IsAbstract);
                }

                result = false;
            }

            if (GetFactoryMethod() == null)
            {
                if (Factory != null)
                {
                    log.Log(AspectRules.AspectFactoryMustContainFactoryMethod, Host, Factory.Name);
                }
                else
                {
                    log.Log(AspectRules.AspectMustHaveContructorOrFactory, Host, Host.Name);
                }

                result = false;
            }

            var effectsValid = Effects.All(e => e.Validate(this, log));

            return(result && effectsValid);
        }
示例#6
0
 public TokenScroll(Character owner, PlayerItemRecord record)
     : base(owner, record)
 {
     if (!Effects.Any(x => x.EffectId == EffectsEnum.Effect_AddOgrines))
     {
         Effects.Add(new EffectInteger(EffectsEnum.Effect_AddOgrines, (short)Stack));
         Stack = 1;
     }
 }
示例#7
0
        public virtual bool IsLinkedToPlayer()
        {
            if (Template.IsLinkedToOwner)
                return true;

            if (Template.Type.SuperType == ItemSuperTypeEnum.SUPERTYPE_QUEST)
                return true;

            if (IsTokenItem())
                return true;

            return Effects.Any(x => x.EffectId == EffectsEnum.Effect_NonExchangeable_981);
        }
示例#8
0
        protected override Validation Validate(ColossoFighter user)
        {
            var log = new List <string>();
            var t   = base.Validate(user);

            if (!t.IsValid)
            {
                return(t);
            }

            log.AddRange(t.Log);

            //Psy Seal:
            //PPCost > 1 is, because Items are right now implemented as Psynergy with PPCost 1
            if (PpCost > 1 && user.HasCondition(Condition.Seal))
            {
                log.Add($"{user.Name}'s Psynergy is sealed!");
                return(new Validation(false, log));
            }

            if (user.Stats.PP < PpCost)
            {
                log.Add($"{user.Name} has not enough PP to cast {Name}.");
                return(new Validation(false, log));
            }

            var targets = GetTarget(user);

            if (!Effects.Any(i => i is ReviveEffect || i is MysticCallEffect) && targets.TrueForAll(i => !i.IsAlive))
            {
                log.Add(
                    $"{user.Name} wants to {(PpCost == 1 ? "use" : "cast")} {Name}, but {(targets.Count == 1 ? "the target is" : "all the targets are")} down.");
                if (user.Moves.FirstOrDefault(m => m is Defend) != null)
                {
                    log.AddRange(user.Moves.FirstOrDefault(m => m is Defend).Use(user));
                }
                return(new Validation(false, log));
            }

            user.Stats.PP -= (int)PpCost;
            log.Add($"{Emote} {user.Name} {(PpCost == 1 ? "uses" : "casts")} {Name}!");
            return(new Validation(true, log));
        }
示例#9
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();
            }
        }
示例#10
0
 public void UseSkill()
 {
     if (!Effects.Any(item => item == "Заворожение"))
     {
         if (!Effects.Any(item => item == "Огненные стрелы"))
         {
             UsingSkill.UseSkill(this);
         }
         else
         {
             Hp -= 2;
             Logger.LogMessage($"({Class}) {Name} получает урон 2 от (Огненные стрелы).");
             UsingSkill.UseSkill(this);
         }
     }
     else
     {
         Logger.LogMessage($"({Class}) {Name} пропускает ход.");
         Effects.Remove("Заворожение");
     }
 }
示例#11
0
文件: HotDot.cs 项目: tuita520/Tera
        public void Update(int id, string type, double hp, double mp, double amount, DotType method, uint time, int tick,
                           string name, string itemName, string tooltip, string iconName)
        {
            Types rType;

            rType = Enum.TryParse(type, out rType) ? rType : Types.Unknown;
            if (Effects.Any(x => x.Type == rType))
            {
                return;                                    // already added - duplicate strings with the same id and type in tsv (different item names - will be deleted soon)
            }
            Hp   = rType == Types.HPChange ? hp : Hp;
            Mp   = rType == Types.MPChange ? mp : Mp;
            Tick = rType == Types.MPChange || rType == Types.HPChange ? tick : Tick; //assume that hp and mp tick times should be the same for one abnormality id
            Effects.Add(new Effect
            {
                Type   = rType,
                Amount = amount,
                Method = method
            });
            Debuff     = Debuff || (rType == Types.Endurance || rType == Types.CritResist) && amount < 1 || rType == Types.Mark || (rType == Types.DefPotion && amount > 1);
            HPMPChange = HPMPChange || rType == Types.HPChange || rType == Types.MPChange;
            Buff       = Buff || (rType != Types.HPChange); // && rType != Types.MPChange);//try to show MPChange abnormals
        }
示例#12
0
        public ResultType PickFromTable(Dictionary <ResultType, double> table, double rand)
        {
            Dictionary <ResultType, double> pickTable = new Dictionary <ResultType, double>(table);

            bool reckless = Effects.Any(e => e is RecklessnessBuff);

            if (Effects.Any(e => e is RecklessnessBuff))
            {
                pickTable[ResultType.Hit]  = 0;
                pickTable[ResultType.Crit] = 1;
            }

            /*
             * string debug = "rand " + rand;
             * foreach (ResultType type in pickTable.Keys)
             * {
             *  debug += " | " + type + " - " + table[type];
             * }
             * if(Program.logFight)
             * {
             *  Program.Log(debug);
             * }
             */

            double i = 0;

            foreach (ResultType type in pickTable.Keys)
            {
                i += pickTable[type];
                if (rand <= i)
                {
                    return(type);
                }
            }

            throw new Exception("Hit Table Failed");
        }
示例#13
0
        public SnpEffAnnotation(string annotation)
        {
            bool isSnpEffAnnotation = annotation.StartsWith("ANN=") || annotation.StartsWith("EFF=");

            Annotation = isSnpEffAnnotation ? annotation.Substring(4) : annotation;
            if (!isSnpEffAnnotation)
            {
                return;
            }
            string[] a = Annotation.Split('|');
            Allele            = a[0];
            Effects           = a[1].Split('&');
            PutativeImpact    = a[2];
            GeneName          = a[3];
            GeneID            = a[4];
            FeatureType       = a[5];
            FeatureID         = a[6];
            TranscriptBiotype = a[7];
            if (a[8].Split('/').Length > 0 && int.TryParse(a[8].Split('/')[0], out int x))
            {
                ExonIntronRank = x;
            }
            if (a[8].Split('/').Length > 1 && int.TryParse(a[8].Split('/')[1], out int y))
            {
                ExonIntronTotal = y;
            }
            HGVSNotationDnaLevel     = a[9];
            HGVSNotationProteinLevel = a[10];
            if (a[11].Split('/').Length > 0 && int.TryParse(a[11].Split('/')[0], out x))
            {
                OneBasedTranscriptCDNAPosition = x;
            }
            if (a[11].Split('/').Length > 1 && int.TryParse(a[11].Split('/')[1], out y))
            {
                TranscriptCDNALength = y;
            }
            if (a[12].Split('/').Length > 0 && int.TryParse(a[12].Split('/')[0], out x))
            {
                OneBasedCodingDomainSequencePosition = x;
            }
            if (a[12].Split('/').Length > 1 && int.TryParse(a[12].Split('/')[1], out y))
            {
                CodingDomainSequenceLengthIncludingStopCodon = y;
            }
            if (a[13].Split('/').Length > 0 && int.TryParse(a[13].Split('/')[0], out x))
            {
                OneBasedProteinPosition = x;
            }
            if (a[13].Split('/').Length > 1 && int.TryParse(a[13].Split('/')[1], out y))
            {
                ProteinLength = y;
            }
            if (int.TryParse(a[14], out y))
            {
                DistanceToFeature = y;
            }
            Warnings = a[15].Split('&');

            Missense          = Effects.Any(eff => eff == "missense_variant");
            Synonymous        = !Effects.Any(eff => NonSynonymousVariations.Contains(eff));
            FrameshiftVariant = Effects.Contains("frameshift_variant");
            BadTranscript     = Warnings.Any(w => BadTranscriptWarnings.Contains(w));
        }
示例#14
0
        public override bool Drop(BasePlayerItem dropOnItem)
        {
            var allowedItemType = new[] {
                ItemTypeEnum.AMULETTE,
                ItemTypeEnum.ARC,
                ItemTypeEnum.BAGUETTE,
                ItemTypeEnum.BÂTON,
                ItemTypeEnum.DAGUE,
                ItemTypeEnum.ÉPÉE,
                ItemTypeEnum.MARTEAU,
                ItemTypeEnum.PELLE,
                ItemTypeEnum.ANNEAU,
                ItemTypeEnum.CEINTURE,
                ItemTypeEnum.BOTTES,
                ItemTypeEnum.CHAPEAU,
                ItemTypeEnum.CAPE,
                ItemTypeEnum.HACHE,
                ItemTypeEnum.PIOCHE,
                ItemTypeEnum.FAUX,
                ItemTypeEnum.SAC_À_DOS
            };

            if (!allowedItemType.Contains((ItemTypeEnum)dropOnItem.Template.TypeId))
            {
                Owner.SendServerMessage("L'amélioration a échouée : Vous ne pouvez pas améliorer ce type d'objet.");
                return(false);
            }

            if (Effects.Any(x => x.EffectId == EffectsEnum.Effect_AddRange || x.EffectId == EffectsEnum.Effect_AddRange_136))
            {
                if (dropOnItem.Effects.Exists(x => x.EffectId == EffectsEnum.Effect_AddRange || x.EffectId == EffectsEnum.Effect_AddRange_136))
                {
                    Owner.SendServerMessage("L'amélioration a échouée : L'objet possède déjà un PO.");
                    return(false);
                }
            }
            else
            {
                if (dropOnItem.Effects.Exists(x => x.EffectId == EffectsEnum.Effect_AddMP ||
                                              x.EffectId == EffectsEnum.Effect_AddMP_128 ||
                                              x.EffectId == EffectsEnum.Effect_AddAP_111))
                {
                    Owner.SendServerMessage("L'amélioration a échouée : L'objet possède déjà un PA, ou un PM.");
                    return(false);
                }
            }

            ApplyEffects(dropOnItem, ItemEffectHandler.HandlerOperation.UNAPPLY);

            dropOnItem.Effects.AddRange(Effects);

            dropOnItem.Invalidate();
            Owner.Inventory.RefreshItem(dropOnItem);
            dropOnItem.OnObjectModified();

            ApplyEffects(dropOnItem, ItemEffectHandler.HandlerOperation.APPLY);
            Owner.RefreshStats();

            Owner.SendServerMessage("Votre objet a été amélioré avec succès !");

            return(true);
        }
示例#15
0
 public bool HasEffect(SpellEffects effect)
 {
     return(Effects.Any(eff => eff != null && eff.Effect == (uint)effect));
 }
示例#16
0
 public bool HasAura(AuraType aura)
 {
     return(Effects.Any(eff => eff != null && eff.EffectAura == (uint)aura));
 }
示例#17
0
 public bool HasTargetB(Targets target)
 {
     return(Effects.Any(eff => eff != null && eff.ImplicitTarget[1] == (uint)target));
 }
        public SnpEffAnnotation(Variant variant, string annotation)
        {
            Variant    = variant;
            Annotation = annotation;
            string[] a = annotation.Split('|');
            Allele            = a[0];
            Effects           = a[1].Split('&');
            PutativeImpact    = a[2];
            GeneName          = a[3];
            GeneID            = a[4];
            FeatureType       = a[5];
            FeatureID         = a[6];
            TranscriptBiotype = a[7];
            if (a[8].Split('/').Length > 0 && int.TryParse(a[8].Split('/')[0], out int x))
            {
                ExonIntronRank = x;
            }
            if (a[8].Split('/').Length > 1 && int.TryParse(a[8].Split('/')[1], out int y))
            {
                ExonIntronTotal = y;
            }
            HGVSNotationDnaLevel     = a[9];
            HGVSNotationProteinLevel = a[10];
            if (a[11].Split('/').Length > 0 && int.TryParse(a[11].Split('/')[0], out x))
            {
                OneBasedTranscriptCDNAPosition = x;
            }
            if (a[11].Split('/').Length > 1 && int.TryParse(a[11].Split('/')[1], out y))
            {
                TranscriptCDNALength = y;
            }
            if (a[12].Split('/').Length > 0 && int.TryParse(a[12].Split('/')[0], out x))
            {
                OneBasedCodingDomainSequencePosition = x;
            }
            if (a[12].Split('/').Length > 1 && int.TryParse(a[12].Split('/')[1], out y))
            {
                CodingDomainSequenceLengthIncludingStopCodon = y;
            }
            if (a[13].Split('/').Length > 0 && int.TryParse(a[13].Split('/')[0], out x))
            {
                OneBasedProteinPosition = x;
            }
            if (a[13].Split('/').Length > 1 && int.TryParse(a[13].Split('/')[1], out y))
            {
                ProteinLength = y;
            }
            if (int.TryParse(a[14], out y))
            {
                DistanceToFeature = y;
            }
            Warnings = a[15].Split('&');

            if (HGVSNotationProteinLevel != null)
            {
                GroupCollection hgvsProteinMatch = HGVSProteinRegex.Match(HGVSNotationProteinLevel).Groups;
                if (hgvsProteinMatch.Count > 2)
                {
                    ReferenceAminoAcid = ProteogenomicsUtility.amino_acids_3to1[hgvsProteinMatch[2].Value];
                }
                if (hgvsProteinMatch.Count > 3 && int.TryParse(hgvsProteinMatch[3].Value, out int location))
                {
                    AminoAcidLocation = location;
                }
                if (hgvsProteinMatch.Count > 4)
                {
                    AlternateAminoAcid = ProteogenomicsUtility.amino_acids_3to1[hgvsProteinMatch[4].Value];
                }
            }

            Missense          = Effects.Any(eff => eff == "missense_variant");
            Synonymous        = !Effects.Any(eff => NonSynonymousVariations.Contains(eff));
            FrameshiftVariant = Effects.Contains("frameshift_variant");
            BadTranscript     = Warnings.Any(w => BadTranscriptWarnings.Contains(w));
        }