Exemplo n.º 1
0
 public void AddModifier(IModifier modifier, double movesCount)
 {
     if (Modifiers.Contains(modifier))
     {
         Modifiers[modifier] = (double)movesCount;
     }
     else
     {
         Modifiers.Add(modifier, (double)movesCount);
         if (modifier is IDamageModifier)
         {
             _metaUnit.damage = ((IDamageModifier)modifier).ModifyDamage(_metaUnit.damage);
         }
         if (modifier is IAttackModifier)
         {
             _metaUnit.attack = ((IAttackModifier)modifier).ModifyAttack(_metaUnit.attack);
         }
         if (modifier is IDefenseModifier)
         {
             _metaUnit.defence = ((IDefenseModifier)modifier).ModifyDefense(_metaUnit.defence);
         }
         if (modifier is IHitPointsModifier)
         {
             uint newHitPoints = ((IHitPointsModifier)modifier).ModifyHitPoints(_metaUnit.hitPoints);
             initHitPoints       = newHitPoints * unitsCount;
             totalHitPoints      = (uint)(Math.Floor((double)totalHitPoints / (double)_metaUnit.hitPoints) * newHitPoints + totalHitPoints % _metaUnit.hitPoints);
             _metaUnit.hitPoints = newHitPoints;
         }
         if (modifier is IInitiativeModifier)
         {
             _metaUnit.initiative = ((IInitiativeModifier)modifier).ModifyInitiative(_metaUnit.initiative);
         }
     }
 }
Exemplo n.º 2
0
 void IPlayerHelper.RemoveModifier(FarmerModifier modifier)
 {
     if (Modifiers.Contains(modifier))
     {
         Modifiers.Remove(modifier);
     }
     UpdateCompound();
 }
Exemplo n.º 3
0
        public void UseAbility(Player player, Vector2 target)
        {
            bool    vanish    = Modifiers.Contains(GlyphModifier.Vanish);
            Vector2 oldCenter = player.Center;

            if (vanish)
            {
                //Main.PlaySound(new LegacySoundStyle(2, 14).WithVolume(0.5f), oldCenter);
                SoundManager.PlaySound(Sounds.LegacySoundStyle_Item14, oldCenter, .5f);


                Projectile.NewProjectile(oldCenter - new Vector2(24, 48), Vector2.Zero, ModContent.ProjectileType <SmokePellets>(), 2, 0f, player.whoAmI);
                Vector2 vector32;
                vector32.X = Main.mouseX + Main.screenPosition.X;
                if (Math.Abs(player.gravDir - 1f) < .01)
                {
                    vector32.Y = Main.mouseY + Main.screenPosition.Y - player.height;
                }
                else
                {
                    vector32.Y = Main.screenPosition.Y + Main.screenHeight - Main.mouseY;
                }
                vector32.X -= (float)(player.width / 2.0);
                if (vector32.X > 50f && vector32.X < Main.maxTilesX * 16 - 50 && vector32.Y > 50f && vector32.Y < Main.maxTilesY * 16 - 50)
                {
                    int num276 = (int)(vector32.X / 16f);
                    int num277 = (int)(vector32.Y / 16f);
                    if ((Main.tile[num276, num277].wall != 87 || num277 <= Main.worldSurface || NPC.downedPlantBoss) &&
                        !Collision.SolidCollision(vector32, player.width, player.height))
                    {
                        player.Teleport(vector32, 1);
                        NetMessage.SendData((int)PacketTypes.Teleport, -1, -1, null, 0, player.whoAmI, vector32.X, vector32.Y, 1);
                        if (player.chaosState)
                        {
                            player.statLife -= player.statLifeMax2 / 7;
                            PlayerDeathReason damageSource = PlayerDeathReason.ByOther(13);
                            if (Main.rand.Next(2) == 0)
                            {
                                damageSource = PlayerDeathReason.ByOther(player.Male ? 14 : 15);
                            }
                            if (player.statLife <= 0)
                            {
                                player.KillMe(damageSource, 1.0, 0);
                            }
                            player.lifeRegenCount = 0;
                            player.lifeRegenTime  = 0;
                        }

                        player.AddBuff(BuffID.ChaosState, 360);
                    }
                }
            }

            UseAction(this, player, vanish ? oldCenter : target);
        }
Exemplo n.º 4
0
 public DeclaredValuePointer <G> Clone(bool includeModifiers)
 {
     return(new DeclaredValuePointer <G>(Location)
     {
         Value = Modifiers.Contains(Modifiers.Component) ? base.Value : null,
         IsDeclared = IsDeclared,
         IsDynamic = IsDynamic,
         Identifier = Identifier,
         Modifiers = includeModifiers ? Modifiers : Modifiers.None
     });
 }
Exemplo n.º 5
0
 public GlyphModifier(int id, string tooltip, Func <Glyph, bool> match, Func <bool> odds, float damageModifier = 1f, float manaModifier = 1f)
 {
     Id             = id;
     Tooltip        = tooltip;
     Match          = match;
     Odds           = odds;
     DamageModifier = damageModifier;
     ManaModifier   = manaModifier;
     if (!Modifiers.Contains(this))
     {
         Modifiers.Insert(id, this);
     }
 }
Exemplo n.º 6
0
        private string GetInspectorName()
        {
            if (Modifiers.Contains("OverrideInspectorName"))
            {
                string containedName = ModifierValues["OverrideInspectorName"];
                containedName = containedName.Replace("(", "");
                containedName = containedName.Replace(")", "");
                containedName = containedName.Replace("\"", "");
                return(containedName);
            }
            else
            {
                string adjustedName = Name;
                // Strip out leading b if this was a boolean value. Carryover from Unreal Engine habits.
                if (Name.StartsWith("b"))
                {
                    if (Name.Length > 1)
                    {
                        if (char.IsUpper(Name[1]))
                        {
                            adjustedName = Name.Substring(1);
                        }
                    }
                }

                string splitString  = "";
                bool   prevWasLower = false;
                for (int i = 0; i < adjustedName.Length; i++)
                {
                    if (char.IsUpper(adjustedName[i]) && prevWasLower)
                    {
                        splitString += " ";
                        splitString += adjustedName[i];
                        prevWasLower = false;
                    }
                    else
                    {
                        prevWasLower = true;
                        splitString += adjustedName[i];
                    }
                }

                return(splitString);
            }
        }
Exemplo n.º 7
0
        public MethodHeader(string data, string className = "")
        {
            var splittedByBracket = data.Split('(');
            var splitted          = splittedByBracket[0].Split(' ');
            int i = 0;

            while (i < splitted.Length)
            {
                Modifiers.Add(splitted[i]);
                ++i;
            }
            Name = Modifiers[Modifiers.Count - 1];
            Modifiers.RemoveAt(Modifiers.Count - 1);
            var tmp = Modifiers[Modifiers.Count - 1];

            if (PossibleModifiers.Contains(tmp))
            {
                Type = MethodTypes.Constructor;
            }
            else
            {
                ReturnType = tmp;
                Modifiers.RemoveAt(Modifiers.Count - 1);
            }
            splitted = splittedByBracket[1].Replace(")", "").Split(',');
            i        = 0;
            while (i < splitted.Length)
            {
                Arguments.Add(splitted[i]);
                ++i;
            }
            if (Modifiers.Contains("static"))
            {
                FullName = $"{className}.{Name}";
                Type     = MethodTypes.Static;
            }
            else
            {
                FullName = Name;
            }
        }
Exemplo n.º 8
0
Arquivo: AKey.cs Projeto: Nucs/nlib
 /// <summary>
 /// Compares the given mods to the current mods list
 /// </summary>
 /// <param name="mods"></param>
 /// <returns></returns>
 public bool CompareModifiers(params KeyCodeModifiers[] mods)
 {
     return(mods.All(m => Modifiers.Contains((KeyCode)m)));
 }
 public bool HasModifier(T modifier)
 {
     return(Modifiers.Contains(modifier));
 }
Exemplo n.º 10
0
 virtual public bool Is(string mod)
 {
     return(Modifiers.Contains(mod));
 }
Exemplo n.º 11
0
 public bool Exists(string modifier)
 {
     return(Modifiers.Contains(modifier));
 }
Exemplo n.º 12
0
 bool IPlayerHelper.HasModifier(FarmerModifier modifier)
 {
     return(Modifiers.Contains(modifier));
 }
Exemplo n.º 13
0
 private string HideInInspector()
 {
     return(Modifiers.Contains("InspectorHidden").ToString().ToLower());
 }