コード例 #1
0
        public override bool Enter(Func <int, int> _getRandomValueCallBack, BattleCore _t, bool _u, AiSummonData _v)
        {
            Turrent[] turrentArr = _u ? _t.mTurrent : _t.oTurrent;

            int id = _t.GetCard(_u, _v.uid);

            IUnitSDS unitSDS = BattleCore.GetUnitData(id);

            for (int i = 0; i < BattleConst.MAP_HEIGHT; i++)
            {
                if (Array.IndexOf(unitSDS.GetRow(), i) != -1)
                {
                    for (int m = 0; m < BattleConst.MAP_WIDTH; m++)
                    {
                        int unitPos = i * BattleConst.MAP_WIDTH + m;

                        bool canSet = true;

                        for (int n = 0; n < unitSDS.GetPos().Length; n++)
                        {
                            int posFix = unitSDS.GetPos()[n];

                            int x = posFix % BattleConst.MAP_WIDTH;

                            if (m + x < BattleConst.MAP_WIDTH)
                            {
                                int pos = unitPos + posFix;

                                if (turrentArr[pos] != null)
                                {
                                    canSet = false;

                                    break;
                                }
                            }
                            else
                            {
                                canSet = false;

                                break;
                            }
                        }

                        if (canSet)
                        {
                            int score = BattlePublicTools.GetUnitAttackTargetScore(_t, _u, id, unitPos, turrentTargetScore, baseTargetScore);

                            if (score > 0)
                            {
                                _v.summonPosList.Add(new KeyValuePair <int, int>(unitPos, score));
                            }
                        }
                    }
                }
            }

            return(_v.summonPosList.Count > 0);
        }
コード例 #2
0
ファイル: BattleCore.cs プロジェクト: ludidilu/Turrent
        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);
            }
        }