//展示精灵 public ErrorCodes BattleMainElf(CharacterController character, int index) { if (index <= 0) { return(ErrorCodes.Error_ElfNotBattle); } var item = character.GetItemByBagByIndex((int)eBagType.Elf, index); if (item == null || item.GetId() < 0) { return(ErrorCodes.Error_ElfNotFind); } var tbElf = Table.GetElf(item.GetId()); if (tbElf == null) { return(ErrorCodes.Error_ElfNotFind); } if (item.GetIndex() >= MaxElfFightCount) { if (character.CheckElfType(tbElf, 0) != -1) { return(ErrorCodes.Error_ElfTypeSame); } } var nowFightCount = character.GetElfFightCount(); if (item.GetIndex() >= MaxElfFightCount) //如果原来是休息的,需要重新为老的尝试找位置 { var tempItem = character.GetItemByBagByIndex((int)eBagType.Elf, 0); if (tempItem != null && tempItem.GetId() != -1) { var tbtempElf = Table.GetElf(tempItem.GetId()); if (tbtempElf != null && tbtempElf.ElfType != tbElf.ElfType) //类型冲突就不找了 直接休息吧 { for (var i = 1; i != nowFightCount; ++i) { var tempbatItem = character.GetItemByBagByIndex((int)eBagType.Elf, i); if (tempbatItem == null || tempbatItem.GetId() == -1) { character.mBag.MoveItem((int)eBagType.Elf, 0, (int)eBagType.Elf, i, 1); character.SetRankFlag(RankType.PetFight); break; } } } } } character.mBag.MoveItem((int)eBagType.Elf, index, (int)eBagType.Elf, 0, 1); //出战 //item.MarkDbDirty(); character.mBag.RefreshElfAttr(); character.BooksChange(); character.SetRankFlag(RankType.PetFight); return(ErrorCodes.OK); }
//出战精灵 public ErrorCodes BattleElf(CharacterController character, int index, int targetIndex) { var nowFightCount = character.GetElfFightCount(); if (targetIndex < 1 || targetIndex >= nowFightCount) { return(ErrorCodes.Error_DataOverflow); } if (index == 0 && targetIndex > 3) { return(ErrorCodes.Error_ElfAlreadyBattle); } if (index == targetIndex) { return(ErrorCodes.Error_ElfAlreadyBattle); } if (index > 0 && index < nowFightCount) { character.mBag.MoveItem((int)eBagType.Elf, index, (int)eBagType.Elf, targetIndex, 1); return(ErrorCodes.OK); } var elfBag = character.GetBag((int)eBagType.Elf); var item = elfBag.GetItemByIndex(index); if (item == null || item.GetId() < 0) { return(ErrorCodes.Error_ElfNotFind); } var tbElf = Table.GetElf(item.GetId()); if (tbElf == null) { return(ErrorCodes.Error_ElfNotFind); } if (item.GetIndex() >= MaxElfFightCount) { if (character.CheckElfType(tbElf, targetIndex) != -1) { return(ErrorCodes.Error_ElfTypeSame); } } character.mBag.MoveItem((int)eBagType.Elf, index, (int)eBagType.Elf, targetIndex, 1); character.mBag.RefreshElfAttr(); character.BooksChange(); return(ErrorCodes.OK); }