本文整理汇总了C#中Item.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Where方法的具体用法?C# Item.Where怎么用?C# Item.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item.Where方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateAvailableSpells
public void UpdateAvailableSpells(Item[] items)
{
string[] newSpells = gameController.GetSpellsFromItems (items.Where (i => i != null).ToArray ());
spells = new Spell[newSpells.Length];
for (int i = 0; i < newSpells.Length; i++) {
try {
GameObject temp = Resources.Load ("Spells/" + newSpells [i]) as GameObject;
spells [i] = temp.GetComponent<Spell> ();
} catch {
Debug.Log("Error: Could not load spell " + newSpells [i]);
}
}
spells = spells.Where (i => i != null).ToArray ();
for (int i = 0; i < spells.Length; i++) {
spellCooldowns [i].GetComponent<Image> ().sprite = spells [i].icon;
if (!nextCasts.ContainsKey (spells [i].name))
nextCasts.Add (spells [i].name, 0f);
}
UpdateSpellCooldowns ();
}
示例2: GetSpellsFromItems
public string[] GetSpellsFromItems(Item[] items)
{
items = items.Where (s => s != null).ToArray ();
string[] classes = new string [items.Length];
for (int i = 0; i < items.Length; i++) {
if (items [i] == null)
continue;
classes [i] = items [i].wizardClass;
}
classes = classes.Where (s => s != null).ToArray ();
Array.Sort (classes);
List<string> availableSpells = new List<string>();
string key = "";
// 1x
for (int i = 0; i < classes.Length; i++) {
key = classes [i];
try {
availableSpells.Add (spells [key]);
} catch {
// Debug.Log ("There is no spell defined for " + key);
}
}
// 2x
for (int i = 0; i < classes.Length; i++) {
for (int j = 0; j < i; j++) {
key = classes [j] + classes [i];
try {
availableSpells.Add (spells [key]);
} catch {
// Debug.Log ("There is no spell defined for " + key);
}
}
}
// 3x
if (classes.Length == 3) {
key = string.Join ("", classes);
try {
availableSpells.Add (spells [key]);
} catch {
// Debug.Log ("There is no spell defined for " + key);
}
}
// Debug.Log ("Available spells: " + string.Join(", ", availableSpells.ToArray()));
return availableSpells.Distinct ().ToArray ();
}
示例3: GetSubTaxSumm
static List<TaxSumm> GetSubTaxSumm(Item[] itemcodes, List<InvoiceDtls> invs)
{
List<TaxSumm> summ = new List<TaxSumm>();
var grp = from p in invs
group p by p.taxgrp into g
select new { taxgrp = g.Key, ttltax = g.Sum(x => x.tax), ttlAmt = g.Sum(v => v.netamount) };
foreach (var g in grp)
{
TaxSumm tsumm = new TaxSumm();
var list3 = itemcodes.Where(x => x.taxgrp == g.taxgrp).ToList();
if (list3.Count > 0)
{
tsumm.TaxDesc = g.taxgrp.Trim() + " @ " + list3[0].tax.ToString() + "%";
}
else tsumm.TaxDesc= g.taxgrp.Trim();
tsumm.TaxAmt = g.ttltax;
tsumm.Amount = g.ttlAmt;
tsumm.TaxGrp = g.taxgrp;
summ.Add(tsumm);
}
return summ;
}
示例4: GenerateHonestyItems
private static void GenerateHonestyItems()
{
try
{
var count = MaxGeneration - _Items.Count;
var spawned = new Item[count];
for (var i = 0; i < spawned.Length; i++)
{
var item = spawned[i] = Loot.RandomArmorOrShieldOrWeapon();
if (item == null || item.Deleted)
{
--i;
continue;
}
item.HonestyItem = true;
lock (_ItemsLock)
{
if (!_Items.Contains(item))
{
_Items.Add(item);
}
}
}
var locs = new Dictionary<Map, Point3D?[]>();
if (TrammelGeneration)
{
locs[Map.Trammel] = new Point3D?[spawned.Length];
}
locs[Map.Felucca] = new Point3D?[spawned.Length];
Parallel.For(
0,
spawned.Length,
i =>
{
var map = TrammelGeneration && Utility.RandomBool() ? Map.Trammel : Map.Felucca;
locs[map][i] = GetValidLocation(map);
});
foreach (var kv in locs)
{
var map = kv.Key;
var points = kv.Value;
for (var i = 0; i < spawned.Length;)
{
var loc = points[i];
if (loc == null || loc == Point3D.Zero)
{
continue;
}
var item = spawned[i];
if (item == null || item.Deleted)
{
continue;
}
item.HonestyRegion = _Regions[Utility.Random(_Regions.Length)];
if (!String.IsNullOrWhiteSpace(item.HonestyRegion))
{
var attempts = BaseVendor.AllVendors.Count / 10;
BaseVendor m;
do
{
m = BaseVendor.AllVendors[Utility.Random(BaseVendor.AllVendors.Count)];
}
while ((m == null || m.Map != map || !m.Region.IsPartOf(item.HonestyRegion)) && --attempts >= 0);
item.HonestyOwner = m;
}
ItemFlags.SetTaken(item, false);
item.MoveToWorld(loc.Value, map);
spawned[i] = null;
}
}
foreach (var item in spawned.Where(item => item != null && !item.Deleted))
{
item.Delete();
}
}
//.........这里部分代码省略.........