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


C# Entity.HasWeapon方法代码示例

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


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

示例1: usedRandomWeaponBox

        public void usedRandomWeaponBox(Entity box, Entity player)
        {
            if (!player.IsAlive) return;
            if (Unitily.GetPlayerTeam(player) == "axis") return;
            else
            {
                if (box.GetField<string>("state") == "using") return;
                if (box.GetField<string>("state") == "waiting" && box.GetField<string>("player") != player.GUID.ToString()) return;
                if (box.GetField<string>("state") == "waiting" && box.GetField<string>("player") == player.GUID.ToString())
                {
                    if (player.HasWeapon(box.GetField<string>("weapon")))
                    {
                        player.Call("givemaxammo", box.GetField<string>("weapon"));
                        player.SwitchToWeapon(box.GetField<string>("weapon"));
                    }
                    else
                    {
                        if (getWeaponsNum(player) > 1)
                        {
                            player.TakeWeapon(player.CurrentWeapon);
                        }
                        player.GiveWeapon(box.GetField<string>("weapon"));
                        player.Call("givemaxammo", box.GetField<string>("weapon"));
                        player.SwitchToWeapon(box.GetField<string>("weapon"));
                    }
                    weapon.Call("delete");
                    box.SetField("weapon", "");
                    box.SetField("player", "");
                    AfterDelay(2000, () => box.SetField("state", "idle"));
                    isDestroy = true;
                }
                else if (box.GetField<string>("state") == "idle")
                {
                    if (player.GetField<int>("lsd_money") >= 350)
                    {
                        weapon = Call<Entity>("spawn", "script_model", new Parameter(box.Origin));
                        weapon.SetField("angles", box.GetField<Vector3>("angles"));
                        player.SetField("lsd_money", player.GetField<int>("lsd_money") - 350);
                        int? rng = new Random().Next(weaponlist.Length);
                        Vector3 temp = box.Origin;
                        temp.Z = temp.Z + 40;
                        weapon.Call("moveto", temp, 3);
                        box.SetField("player", player.GUID.ToString());
                        box.SetField("state", "using");
                        for (int i = 0; i < 3000; i += 100)
                        {
                            AfterDelay(0 + i, () =>
                            {
                                rng = new Random().Next(weaponlist.Length);
                                int r = rng.Value;
                                string _weapon = weaponlist[r];
                                if (_weapon.StartsWith("iw5_acr"))
                                {
                                    weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 13)));
                                }
                                else
                                {
                                    weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 0)));
                                }
                            });
                        }
                        for (int i = 0; i < 1000; i += 300)
                        {
                            AfterDelay(3000 + i, () =>
                            {
                                rng = new Random().Next(weaponlist.Length);
                                int r = rng.Value;
                                string _weapon = weaponlist[r];
                                if (_weapon.StartsWith("iw5_acr"))
                                {
                                    weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 13)));
                                }
                                else
                                {
                                    weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 0)));
                                }
                            });
                        }

                        AfterDelay(4000, () =>
                        {
                            int r = rng.Value;
                            string _weapon = weaponlist[r];
                            if (_weapon.StartsWith("iw5_acr") || _weapon.StartsWith("iw5_scar"))
                            {
                                weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 13)));
                            }
                            else
                            {
                                weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 0)));
                            }
                            temp.Z = temp.Z - 40;
                            weapon.Call("moveto", temp, 8);
                            box.SetField("state", "waiting");
                            box.SetField("weapon", _weapon);
                        });
                        AfterDelay(12000, () =>
                        {
                            if (box.GetField<string>("state") == "waiting" && isDestroy == false)
                            {
//.........这里部分代码省略.........
开发者ID:China-PubX,项目名称:LSDZombie-Extreme,代码行数:101,代码来源:MapEdit.cs

示例2: GiveAmmo

 public void GiveAmmo(Entity player)
 {
     foreach (string item in weaponlist)
     {
         if (player.HasWeapon(item))
         {
             player.Call("givemaxammo", item);
         }
     }
     foreach (string item in upgradeweaponlist)
     {
         if (player.HasWeapon(item))
         {
             player.Call("givemaxammo", item);
         }
     }
 }
开发者ID:China-PubX,项目名称:LSDZombie-Extreme,代码行数:17,代码来源:MapEdit.cs

示例3: GiveAmmo

        public void GiveAmmo(Entity player)
        {
            if (!player.IsAlive || Utility.GetPlayerTeam(player) != "allies")
            {
                return;
            }
            player.Call("givemaxammo", player.GetField<string>("firstweapon"));
            player.Call("givemaxammo", player.GetField<string>("secondweapon"));

            if (!player.HasWeapon("trophy_mp"))
            {
                player.GiveWeapon("trophy_mp");
            }
            if (!player.HasWeapon("claymore_mp"))
            {
                player.GiveWeapon("claymore_mp");
            }
            player.Call("setweaponammoclip", "trophy_mp", 99);
            player.Call("givemaxammo", "trophy_mp");
            player.Call("givemaxammo", "claymore_mp");
        }
开发者ID:A2ON,项目名称:CHINA-Magic-Infect,代码行数:21,代码来源:MapEdit.cs

示例4: getWeaponsNum

 public int getWeaponsNum(Entity player)
 {
     int num = 0;
     foreach (string item in weaponlist)
     {
         if (player.HasWeapon(item))
         {
             num++;
         }
     }
     foreach (string item in upgradeweaponlist)
     {
         if (player.HasWeapon(item))
         {
             num++;
         }
     }
     return num;
 }
开发者ID:China-PubX,项目名称:LSDZombie-Extreme,代码行数:19,代码来源:MapEdit.cs

示例5: usedMysteryBox

 public void usedMysteryBox(Entity box, Entity player)
 {
     if (player.IsAlive && (Utility.GetPlayerTeam(player) != "axis"))
     {
         if (player.CurrentWeapon.Contains("killstreak") || player.CurrentWeapon.Contains("airdrop"))
         {
             return;
         }
         if (player.GetField<int>("inf2_money") < 500)
         {
             player.Call("iprintln", new Parameter[] { "^1Mystery box need $500." });
             return;
         }
         else
         {
             player.SetField("inf2_money", player.GetField<int>("inf2_money") - 500);
             Weapon weapon = Weapon.GetRandomWeapon();
             if (player.HasWeapon(weapon.Text))
             {
                 if (weapon.Text == "defaultweapon_mp")
                 {
                     player.Call("setweaponammoclip", weapon.Text, 0);
                     player.Call("setweaponammostock", weapon.Text, 0);
                 }
                 else
                 {
                     player.Call("givemaxammo", new Parameter[] { weapon.Text });
                 }
                 player.SwitchToWeapon(weapon.Text);
                 player.Call("iprintlnbold", weapon.Name);
                 Call("iprintln", player.Name + " buy weapon - " + weapon.Name);
             }
             else
             {
                 if (player.GetField<string>("secondweapon") != "none")
                 {
                     if (player.GetField<string>("firstweapon") == player.CurrentWeapon)
                     {
                         player.SetField("firstweapon", weapon.Text);
                     }
                     else if (player.GetField<string>("secondweapon") == player.CurrentWeapon)
                     {
                         player.SetField("secondweapon", weapon.Text);
                     }
                     player.TakeWeapon(player.CurrentWeapon);
                 }
                 else
                 {
                     player.SetField("secondweapon", weapon.Text);
                 }
                 player.GiveWeapon(weapon.Text);
                 if (weapon.Text == "defaultweapon_mp")
                 {
                     player.Call("setweaponammoclip", weapon.Text, 0);
                     player.Call("setweaponammostock", weapon.Text, 0);
                 }
                 else
                 {
                     player.Call("givemaxammo", new Parameter[] { weapon.Text });
                 }
                 AfterDelay(300, () => player.SwitchToWeaponImmediate(weapon.Text));
                 player.Call("iprintlnbold", weapon.Name);
                 Call("iprintln", player.Name + " buy weapon - " + weapon.Name);
             }
         }
     }
 }
开发者ID:A2ON,项目名称:CHINA-Magic-Infect,代码行数:67,代码来源:MapEdit.cs


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