public SummonSpellEffect(Game gameCore, Player player, Skill skill, UnitBase unitBase, ChessboardCell cbCell)
 {
     this._gameCore = gameCore;
     this._player = player;
     this._skill = skill;
     this._unitBase = unitBase;
     this._cbCell = cbCell;
 }
        /// <summary>
        /// 直接生成地图不注册区域
        /// </summary>
        /// <param name="mapType"></param>
        /// <returns></returns>
        private ChessboardCell[,] MakeMap(MapType mapType = MapType.Common)
        {
            var idList = new IDList("");
            var temp = new ChessboardCell[8, 12];
            for (int x = 0; x < temp.GetLength(0); x++)//初始化区块
            {
                for (int y = 0; y < temp.GetLength(1); y++)
                {
                    Position a = new Position(x, y);
                    temp[x, y] = new ChessboardCell(idList, a);
                }
            }
            for (int x = 0; x < temp.GetLength(0); x++)//设定召唤区块
            {
                for (int y = 0; y < 2; y++)
                {
                    temp[x, y].CellType = ChessboardCellType.Birth;
                    temp[x, y].Owner = GameCore.Teams[0];
                }
                for (int y = temp.GetLength(1) - 2; y < temp.GetLength(1); y++)
                {
                    temp[x, y].CellType = ChessboardCellType.Birth;
                    temp[x, y].Owner = GameCore.Teams[1];
                }
            }
            if (temp.GetLength(0) % 2 == 0) //设定基地,自动基地判断大小
            {
                for (int x = temp.GetLength(0) / 2 - 1; x <= temp.GetLength(0) / 2; x++) //偶数
                {
                    for (int y = 0; y <= 0; y++)
                    {
                        temp[x, y].CellType = ChessboardCellType.Base;
                    }
                    for (int y = temp.GetLength(1) - 1; y <= temp.GetLength(1) - 1; y++)
                    {
                        temp[x, y].CellType = ChessboardCellType.Base;
                    }
                }
            }
            else
            {
                for (int x = temp.GetLength(0) / 2 - 1; x <= temp.GetLength(0) / 2 + 1; x++) //奇数
                {
                    for (int y = 0; y <= 0; y++)
                    {
                        temp[x, y].CellType = ChessboardCellType.Base;
                    }
                    for (int y = temp.GetLength(1) - 1; y <= temp.GetLength(1) - 1; y++)
                    {
                        temp[x, y].CellType = ChessboardCellType.Base;
                    }
                }
            }

            return temp;
        }
 /// <summary>
 /// 自动读取一张地图,并将区块注册至区域表
 /// </summary>
 /// <param name="core"></param>
 /// <param name="map"></param>
 public Chessboard(Game core, ChessboardCell[,] map)
 {
     GameCore = core;
     CellList = map;
     for (int x = 0; x < map.GetLength(0); x++)//注册区块
     {
         for (int y = 0; y < map.GetLength(1); y++)
         {
             GameCore.IDP.RID.SetID(CellList[x, y]);
         }
     }
 }
示例#4
0
        public void SummonToLocation(ChessboardCell cbCell)
        {
            if (Unit_Summoning != null)
            {
                Unit_Summoning(this);
            }

            bool result = cbCell.PlaceUnit(this);
            if (!result)
            {
                throw new Exception("Summon failed. Location is not avaliable for this unit.");
            }

            if (Unit_Summoned != null)
            {
                Unit_Summoned(this);
            }
        }
示例#5
0
        /// <summary>
        /// 移动到某个位置,不能移动返回假
        /// </summary>
        /// <param name="region"></param>
        /// <returns></returns>
        public bool MoveTo(ChessboardCell region)
        {
            if (CanMove(region) == false)
            {
                return false;
            }

            if (ActionState.IsAction == false)//如果没有激活,自动激活
            {
                if (Activate() == false)
                {
                    return false;
                }
            }

            Owner.bDot--;
            return region.PlaceUnit(this);
        }
示例#6
0
 /// <summary>
 /// 计算该单位到某格子的距离,无法计算返回-1
 /// </summary>
 /// <param name="r"></param>
 /// <returns></returns>
 public int GetDistance(ChessboardCell r)
 {
     if (this.Position == null) return -1;
     int distanceX = this.Position.Location.X - r.Location.X;
     int distanceY = this.Position.Location.Y - r.Location.Y;
     if (distanceX < 0) distanceX = -distanceX;
     if (distanceY < 0) distanceY = -distanceY;
     return distanceX + distanceY;
 }
示例#7
0
 /// <summary>
 /// 检测是否可以移动到某位置,重写这个方法可更改移动判断规则
 /// </summary>
 /// <param name="region"></param>
 /// <returns></returns>
 public virtual bool CanMove(ChessboardCell region)
 {
     if (Owner.bDot <= 1) return false;
     if (ActionState.HaveAction == true) return false;
     if (ActionState.HaveMove == true) return false;
     if (region.Unit != null) return false;
     Owner.bDot--;
     return GetDistance(region) <= Mobility.Current;
 }
示例#8
0
 /// <summary>
 /// 检测是否可以攻击某位置,重写这个方法可更改射程判断规则
 /// </summary>
 /// <param name="region"></param>
 /// <returns></returns>
 public virtual bool CanAttack(ChessboardCell region)
 {
     if (Owner.bDot <= 1) return false;
     if (ActionState.HaveAction == true) return false;
     if (ActionState.HaveAttack == true) return false;
     return GetDistance(region) <= AttackRange.Current;
 }