Пример #1
0
 private bool SetBonusPrehurt(Player player, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
 {
     if (player.armor[0].type == ItemType <VitricHead>() && player.armor[1].type == ItemType <VitricChest>() && player.armor[2].type == ItemType <VitricLegs>())//Better way to do this?
     {
         foreach (Projectile shard in Main.projectile.Where(proj => proj.active && proj.owner == player.whoAmI && proj.modProjectile != null && proj.modProjectile is VitricArmorProjectile))
         {
             VitricArmorProjectile moddedproj = shard.modProjectile as VitricArmorProjectile;
             if (moddedproj.projectile.ai[0] < 1)
             {
                 moddedproj.Shatter();
                 damage = (int)(damage * 0.750f);
                 break;
             }
         }
     }
     return(true);
 }
        public override void ModifyDrawLayers(List <PlayerLayer> layers)
        {
            void backTarget(PlayerDrawInfo s) => DrawShards(s, false);                                   //the Action<T> of our layer. This is the delegate which will actually do the drawing of the layer.

            PlayerLayer backLayer = new PlayerLayer("VitricLayer", "Vitric Armor Effect", backTarget);   //Instantiate a new instance of PlayerLayer to insert into the list

            layers.Insert(layers.IndexOf(layers.First()), backLayer);                                    //Insert the layer at the appropriate index.

            void frontTarget(PlayerDrawInfo s) => DrawShards(s, true);                                   //the Action<T> of our layer. This is the delegate which will actually do the drawing of the layer.

            PlayerLayer frontLayer = new PlayerLayer("VitricLayer", "Vitric Armor Effect", frontTarget); //Instantiate a new instance of PlayerLayer to insert into the list

            layers.Insert(layers.IndexOf(layers.Last()), frontLayer);                                    //Insert the layer at the appropriate index.

            void DrawShards(PlayerDrawInfo info, bool back)
            {
                List <VitricArmorProjectile> allshards = new List <VitricArmorProjectile>();

                foreach (Projectile shard in Main.projectile.Where(proj => proj.active && proj.owner == player.whoAmI && proj.modProjectile != null && proj.modProjectile is VitricArmorProjectile))
                {
                    VitricArmorProjectile moddedproj = shard.modProjectile as VitricArmorProjectile;
                    allshards.Add(moddedproj);
                }

                allshards = allshards.OrderBy((x) => x.projectile.Center.Y).ToList();

                foreach (VitricArmorProjectile modshard in allshards)
                {
                    double angle = Math.Sin(-modshard.projectile.localAI[1]);
                    if (angle > 0 && !back ||
                        angle <= 0 && back)
                    {
                        Main.playerDrawData.Add(modshard.Draw());
                    }
                }
            }
        }