예제 #1
0
파일: BoxShadow.cs 프로젝트: zpw987/Teteris
        public void Reflect(Object sender, BoxEventArgs e)
        {
            Box box = e.box;
            if (box == null)
                return;
            List<Square> temp = entity;
            //entity = new List<Square>(box.Entity);
            entity = new List<Square>();
            for (int i = 0; i < 4; i++)
            {
                Square s = new Square(new Position(box.Entity[i].pos.x, box.Entity[i].pos.y), BoxShape.SHADOW);
                entity.Add(s);
            }

            int tx, ty;
            int k = 0;
            bool b = true, over = false;
            while (b)
            {
                for (int i = 0; i < 4; i++)
                {
                    tx = entity[i].pos.x + 1;
                    if (tx >= gFrame.Row)
                    {
                        over = true;
                        break;
                    }
                    ty = entity[i].pos.y;
                    if (!gFrame.UnitAvilible(tx, ty))
                    {
                        b = false; break;
                    }
                }
                if (over)
                    break;
                if (b)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        entity[i].pos.x++;
                    }
                    k++;
                }
            }
            if (k > 4)
            {
                if (reflect != null)
                {
                    for (int i = 0; i < entity.Count; i++)
                    {
                        while (i < entity.Count && box.UnitInBox(entity[i].pos.x, entity[i].pos.y))
                            entity.Remove(entity[i]);
                    }
                    if (temp != null)
                        for (int i = 0; i < temp.Count; i++)
                        {
                            while (i < temp.Count && !gFrame.UnitAvilible(temp[i].pos.x,temp[i].pos.y))
                                temp.Remove(temp[i]);
                        }
                    reflect(this, new MoveEventArgs(temp, entity));
                }
            }
            else
            {
                if (reflect != null)
                {
                    if (temp != null)
                        for (int i = 0; i < temp.Count; i++)
                        {
                            while (i < temp.Count && (box.UnitInBox(temp[i].pos.x, temp[i].pos.y) || !gFrame.UnitAvilible(temp[i].pos.x,temp[i].pos.y) ))
                                temp.Remove(temp[i]);
                        }
                    reflect(this, new MoveEventArgs(temp, null));
                    entity = null;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 当前方块下落到底部的响应方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ActiveBoxCrush(Object sender, BoxEventArgs e)
        {
            if (ActiveBoxCrushEvent != null)
            {
                ActiveBoxCrushEvent(this, new MoveEventArgs(null, e.box.Entity));
            }
            //绘制当前活动方块
            int tx, ty;
            for (int i = 0; i < 4; i++)
            {
                tx = e.box.Entity[i].pos.x;
                ty = e.box.Entity[i].pos.y;
                container.map[tx, ty].Value = e.box.shape;
            }

            //当前方块掉落到底部
            //消行
            int l = CheckFullLines();

            //停用当前活动方块
            activeBox.Stop();

            GenerateActiveBox();

        }