public override bool Enter(Func <int, int> _getRandomValueCallBack, BattleCore _t, bool _u, AiSummonData _v) { List <int> handCards = _u ? _t.mHandCards : _t.oHandCards; if (handCards.Count == 0) { return(false); } handCards = new List <int>(handCards); int index = _getRandomValueCallBack(handCards.Count); int uid = handCards[index]; int id = _t.GetCard(_u, uid); IUnitSDS sds = BattleCore.GetUnitData(id); if (sds.GetCost() > (_u ? _t.mMoney : _t.oMoney)) { return(false); } else { _v.uid = uid; return(true); } }
private BattleSummonVO AddSummon(int _time, bool _isMine, int _uid, int _pos) { int unitID = GetCard(_isMine, _uid); IUnitSDS sds = GetUnitData(unitID); if (_isMine) { if (mMoney == BattleConst.MAX_MONEY) { mMoneyTime = _time + BattleConst.RECOVER_MONEY_TIME; } mMoney -= sds.GetCost(); mHandCards.Remove(_uid); mCards.Enqueue(_uid + mCardsArr.Length); mHandCards.Add(mCards.Dequeue()); } else { if (oMoney == BattleConst.MAX_MONEY) { oMoneyTime = _time + BattleConst.RECOVER_MONEY_TIME; } oMoney -= sds.GetCost(); oHandCards.Remove(_uid); oCards.Enqueue(_uid + oCardsArr.Length); oHandCards.Add(oCards.Dequeue()); } AddUnit(_time, _isMine, sds, _pos); return(new BattleSummonVO(_isMine, _uid, _pos)); }
public int CheckAddSummon(bool _isMine, int _uid, int _pos) { List <int> handCards; int money; Turrent[] turrent; if (_isMine) { handCards = mHandCards; money = mMoney; turrent = mTurrent; } else { handCards = oHandCards; money = oMoney; turrent = oTurrent; } int handCardsIndex = handCards.IndexOf(_uid); if (handCardsIndex != -1) { int unitID = GetCard(_isMine, _uid); IUnitSDS sds = GetUnitData(unitID); if (sds.GetCost() > money) { return(1); } int row = _pos / BattleConst.MAP_WIDTH; if (Array.IndexOf(sds.GetRow(), row) != -1) { int x = _pos % BattleConst.MAP_WIDTH; for (int i = 0; i < sds.GetPos().Length; i++) { int pos = sds.GetPos()[i]; int offsetX = pos % BattleConst.MAP_WIDTH; if (x + offsetX < BattleConst.MAP_WIDTH) { if (turrent[_pos + pos] != null) { return(6); } } else { return(4); } } } else { return(3); } return(-1); } else { return(7); } }