public static void Loot(Unit u, LootItem loot) { if (loot.Dead != true && u.Dead != true && u.IsLootAble == true) { switch (loot.LootSettings.LootType) { case LootType.Weapon: { Weapon w = u.WeaponFromAssetName(loot.LootSettings.ObjectName); if (w != null) { if (w.AmmoNum < w.maxAmmo) { w.AmmoNum += loot.BulletNum; loot.BeginToDie(); loot.gameWorld.ShowLoot(u, loot); } } else if (loot.lootSettings.IsWeapon) { u.GetWeapon(loot.LootSettings.ObjectName, loot.bulletNum); loot.BeginToDie(); loot.gameWorld.ShowLoot(u, loot); loot.gameWorld.ShowLootWeapon(u, loot); } } break; case LootType.MissileWeapon: { MissileWeapon w = u.MissileWeaponFromAssetName(loot.LootSettings.ObjectName); if (w != null) { if (w.Num < w.missileWeaponType.maxNum) { w.Num += (int)loot.BulletNum; loot.BeginToDie(); loot.gameWorld.ShowLoot(u, loot); } } else if (loot.lootSettings.IsWeapon) { u.GetMissileWeapon(loot.LootSettings.ObjectName, loot.bulletNum); loot.BeginToDie(); loot.gameWorld.ShowLoot(u, loot); loot.gameWorld.ShowLootWeapon(u, loot); } } break; case LootType.SkillItem: { Skill s = u.SkillFromAssetName(loot.lootSettings.ObjectName); if (s == null) { if (u.skills.Count < u.maxSkillNum) { u.AddSkill(loot.LootSettings.ObjectName); loot.BeginToDie(); loot.gameWorld.ShowLoot(u, loot); } else { u.Interrupt(); if (u.CurrentSkill != null) { u.skills.Remove(u.CurrentSkill); } u.AddSkill(loot.LootSettings.ObjectName); loot.BeginToDie(); loot.gameWorld.ShowLoot(u, loot); } } } break; case LootType.QuestItem: break; default: break; } } }
/// <summary> /// 返回该物体对目标单位来说是否可以自动拾取(即拾取后不会丢掉原来的东西) /// </summary> /// <param name="u"></param> public static bool IsAutolootable(Unit u, LootItem loot) { if (loot.Dead != true && u.Dead != true && u.IsLootAble == true) { switch (loot.LootSettings.LootType) { case LootType.Weapon: { Weapon w = u.WeaponFromAssetName(loot.LootSettings.ObjectName); if (w != null) { if (w.AmmoNum < w.maxAmmo) { return(true); } } else if (loot.lootSettings.IsWeapon) { if (u.weapons.Count < u.maxWeaponNum) { return(true); } } } break; case LootType.MissileWeapon: { MissileWeapon w = u.MissileWeaponFromAssetName(loot.LootSettings.ObjectName); if (w != null) { if (w.Num < w.missileWeaponType.maxNum) { return(true); } } else if (loot.lootSettings.IsWeapon) { if (u.missiles.Count < u.maxMissileWeaponNum) { return(true); } } } break; case LootType.SkillItem: if (u.skills.Count < u.maxSkillNum) { return(true); } break; case LootType.QuestItem: return(true); break; default: break; } } return(false); }