internal static void AIProc(Player player) { if (player.CardNumber <= 0) return; if (MathTool.GetRandom(4) != 0) return; int row = BattleManager.Instance.MemMap.RowCount; int size = BattleManager.Instance.MemMap.CardSize; bool isLeft = player.IsLeft; var rival = (player == BattleManager.Instance.PlayerManager.LeftPlayer) ? BattleManager.Instance.PlayerManager.RightPlayer : BattleManager.Instance.PlayerManager.LeftPlayer; player.CardsDesk.SetSelectId(MathTool.GetRandom(player.CardNumber) + 1); if (player.SelectCardId != 0) { ActiveCard card = player.CardsDesk.GetSelectCard(); if (player.CheckUseCard(card, player, rival) != HSErrorTypes.OK) { return; } int tar = -1; if (card.CardType == CardTypes.Weapon) { for (int i = 0; i <BattleManager.Instance.MonsterQueue.Count; i++) { LiveMonster monster =BattleManager.Instance.MonsterQueue[i]; if (!monster.IsGhost && monster.IsLeft == isLeft && monster.Weapon == null && monster.Life > monster.RealMaxHp / 2) { if (!monster.CanAddWeapon())//建筑无法使用武器 continue; if (tar == -1 || monster.Avatar.MonsterConfig.Star >BattleManager.Instance.MonsterQueue[tar].Avatar.MonsterConfig.Star) tar = i; } } if (tar == -1) return; } else if (card.CardType == CardTypes.Spell) { SpellConfig spellConfig = ConfigData.GetSpellConfig(card.CardId); if (BattleTargetManager.IsSpellUnitTarget(spellConfig.Target)) { for (int i = 0; i <BattleManager.Instance.MonsterQueue.Count; i++) { LiveMonster monster =BattleManager.Instance.MonsterQueue[i]; if (!monster.IsGhost && ((monster.IsLeft != isLeft && spellConfig.Target[1] == 'F') || (monster.IsLeft == isLeft && spellConfig.Target[1] != 'F'))) { if (tar == -1 || monster.Avatar.MonsterConfig.Star >BattleManager.Instance.MonsterQueue[tar].Avatar.MonsterConfig.Star) tar = i; } } if (tar == -1) return; } } if (card.CardType == CardTypes.Monster) { Point monPos = GetMonsterPoint(card.CardId, false); player.UseMonster(card, monPos); } else if (card.CardType == CardTypes.Weapon) { var lm =BattleManager.Instance.MonsterQueue[tar]; player.UseWeapon(lm, card); } else if (card.CardType == CardTypes.Spell) { SpellConfig spellConfig = ConfigData.GetSpellConfig(card.CardId); Point targetPos = Point.Empty; LiveMonster targetMonster = null; if (BattleTargetManager.IsSpellNullTarget(spellConfig.Target)) { targetPos = new Point(isLeft ? MathTool.GetRandom(200, 300) : MathTool.GetRandom(600, 700), MathTool.GetRandom(size * 3 / 10, row * size - size * 3 / 10)); } else if (BattleTargetManager.IsSpellUnitTarget(spellConfig.Target)) { targetMonster = BattleManager.Instance.MonsterQueue[tar]; targetPos = targetMonster.CenterPosition; } player.DoSpell(targetMonster, card, targetPos); } } }