当前位置: 首页>>代码示例>>C#>>正文


C# ItemStack.GetAttributeF方法代码示例

本文整理汇总了C#中ItemStack.GetAttributeF方法的典型用法代码示例。如果您正苦于以下问题:C# ItemStack.GetAttributeF方法的具体用法?C# ItemStack.GetAttributeF怎么用?C# ItemStack.GetAttributeF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ItemStack的用法示例。


在下文中一共展示了ItemStack.GetAttributeF方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Click

 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is CharacterEntity))
     {
         // TODO: Non-character support?
         return;
     }
     CharacterEntity character = (CharacterEntity)entity;
     double range = RangeBase * item.GetAttributeF("range_mod", 1f);
     double strength = StrengthBase * item.GetAttributeF("strength_mod", 1f) * GetStrength();
     Location start = character.GetEyePosition(); // TODO: ItemPosition?
     Location forw = character.ForwardVector();
     Location mid = start + forw * range;
     // TODO: base the pull on extent of the entity rather than its center. IE, if the side of a big ent is targeted, it should be rotated by the force.
     List<Entity> ents = character.TheRegion.GetEntitiesInRadius(mid, range);
     foreach (Entity ent in ents)
     {
         if (ent is PhysicsEntity) // TODO: Support for primitive ents?
         {
             PhysicsEntity pent = (PhysicsEntity)ent;
             Location rel = (start - ent.GetPosition());
             double distsq = rel.LengthSquared();
             if (distsq < 1)
             {
                 distsq = 1;
             }
             pent.ApplyForce((rel / distsq) * strength);
         }
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:30,代码来源:BaseForceRayItem.cs

示例2: Click

 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is HumanoidEntity))
     {
         // TODO: non-humanoid support
         return;
     }
     HumanoidEntity character = (HumanoidEntity)entity;
     double fireRate = FireRate * item.GetAttributeF("firerate_mod", 1f);
     if (item.Datum != 0 && !character.WaitingForClickRelease && (character.TheRegion.GlobalTickTime - character.LastGunShot >= fireRate))
     {
         double spread = Spread * item.GetAttributeF("spread_mod", 1f);
         double speed = Speed * item.GetAttributeF("speed_mod", 1f);
         int shots = (int)((double)Shots * item.GetAttributeF("shots_mod", 1f));
         for (int i = 0; i < shots; i++)
         {
             BulletEntity be = new BulletEntity(character.TheRegion);
             be.SetPosition(character.GetEyePosition()); // TODO: ItemPosition?
             be.NoCollide.Add(character.EID);
             Location ang = character.Direction;
             ang.Yaw += Utilities.UtilRandom.NextDouble() * spread * 2 - spread;
             ang.Pitch += Utilities.UtilRandom.NextDouble() * spread * 2 - spread;
             be.SetVelocity(Utilities.ForwardVector_Deg(ang.Yaw, ang.Pitch) * speed);
             be.Size = RoundSize;
             be.Damage = ImpactDamage;
             be.SplashSize = SplashSize;
             be.SplashDamage = SplashMaxDamage;
             character.TheRegion.SpawnEntity(be);
         }
         if (ShotPerClick)
         {
             character.WaitingForClickRelease = true;
         }
         character.LastGunShot = character.TheRegion.GlobalTickTime;
         item.Datum -= 1;
         if (character is PlayerEntity)
         {
             ((PlayerEntity)character).Network.SendPacket(new SetItemPacketOut(character.Items.Items.IndexOf(item), item));
         }
     }
     else if (item.Datum == 0 && !character.WaitingForClickRelease)
     {
         Reload(character, item);
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:45,代码来源:BaseGunItem.cs

示例3: Reload

 public bool Reload(HumanoidEntity character, ItemStack item)
 {
     if (character.Flags.HasFlag(YourStatusFlags.RELOADING))
     {
         return false;
     }
     int clipSize = (int)((double)ClipSize * item.GetAttributeF("clipsize_mod", 1f));
     if (item.Datum < clipSize)
     {
         for (int i = 0; i < character.Items.Items.Count; i++)
         {
             ItemStack itemStack = character.Items.Items[i];
             if (itemStack.Info is BulletItem && itemStack.SecondaryName == AmmoType)
             {
                 if (itemStack.Count > 0)
                 {
                     int reloading = clipSize - item.Datum;
                     if (reloading > itemStack.Count)
                     {
                         reloading = itemStack.Count;
                     }
                     item.Datum += reloading;
                     if (character is PlayerEntity)
                     {
                         ((PlayerEntity)character).Network.SendPacket(new SetItemPacketOut(character.Items.Items.IndexOf(item), item));
                     }
                     itemStack.Count -= reloading;
                     if (itemStack.Count <= 0)
                     {
                         character.Items.RemoveItem(i + 1);
                     }
                     else
                     {
                         if (character is PlayerEntity)
                         {
                             ((PlayerEntity)character).Network.SendPacket(new SetItemPacketOut(i, itemStack));
                         }
                     }
                 }
                 character.Flags |= YourStatusFlags.RELOADING;
                 character.WaitingForClickRelease = true;
                 character.LastGunShot = character.TheRegion.GlobalTickTime + ReloadDelay;
                 UpdatePlayer(character);
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:49,代码来源:BaseGunItem.cs


注:本文中的ItemStack.GetAttributeF方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。