示例#1
0
        public SimpleBomb(int id,BombType type, Player owner,BaseGame game,BallInfo info, Tile shape,bool controled)
            :base(id,info.Mass,info.Weight,info.Wind,info.DragIndex)
        {
            m_owner = owner;
            m_game = game;
            m_info = info;

            m_shape = shape;
            m_type = type;
            m_power = info.Power;
            m_radius = info.Radii;
            m_controled = controled;

            m_lifeTime = 0;
        }
示例#2
0
        public Map(MapInfo info, Tile layer1, Tile layer2)
        {
            _info = info;

            _objects = new HashSet<Physics>();

            _layer1 = layer1;
            _layer2 = layer2;

            if (_layer1 != null)
            {
                _bound = new Rectangle(0, 0, _layer1.Width, _layer1.Height);
            }
            else
            {
                _bound = new Rectangle(0, 0, _layer2.Width, _layer2.Height);
            }
        }
示例#3
0
        public BombObject(int id,BombType type, Player owner, Tile shape, int radius, bool controled, float mass, float gravityFactor, float windFactor, float airResitFactor,double power)
            : base(id)
        {
            _power = power;
            _owner = owner;
            _controled = controled;
            _mass = mass;
            _gravityFactor = gravityFactor;
            _windFactor = windFactor;
            _airResitFactor = airResitFactor;
            _type = type;
            _isHole = true;

            _radius = radius;

            _vx = new EulerVector(0, 0, 0);
            _vy = new EulerVector(0, 0, 0);

            _shape = shape;
            _rect = new Rectangle(-3,-3,6,6);
        }
示例#4
0
 public void Dig(int cx, int cy, Tile surface, Tile border)
 {
     _layer1.Dig(cx, cy, surface, border);
     if (_layer2 != null)
     {
         _layer2.Dig(cx, cy, surface, border);
     }
 }
示例#5
0
        protected void Remove(int x, int y, Tile tile)
        {
            byte[] addData = tile._data;

            Rectangle rect = tile.Bound;

            rect.Offset(x, y);
            rect.Intersect(_rect);
            if (rect.Width != 0 && rect.Height != 0)
            {
                rect.Offset(-x, -y);

                int cx = rect.X / 8;
                int cx2 = (rect.X + x) / 8;

                int cy = rect.Y;

                //Tile中n列可以对src中n+1列产生影响,所以cw+1,防止溢出,过滤一下.
                int cw = rect.Width / 8 + 1;
                int ch = rect.Height;

                if (rect.X == 0)
                {
                    if (cw + cx2 < _bw)
                    {
                        cw++;
                        cw = cw > tile._bw ? tile._bw : cw;
                    }
                    int b_offset = (rect.X + x) % 8;

                    int self_offset = 0;
                    int tile_offset = 0;

                    Int32 r_bits = 0;
                    Int32 l_bits = 0;

                    int src = 0;
                    int target = 0;
                    for (int j = 0; j < ch; j++)
                    {
                        r_bits = 0;
                        l_bits = 0;
                        for (int i = 0; i < cw; i++)
                        {
                            self_offset = (j + y + cy) * _bw + i + cx2;
                            tile_offset = (j + cy) * tile._bw + i + cx;

                            src = addData[tile_offset];

                            r_bits = src >> b_offset;

                            target = _data[self_offset];
                            //把target中src为1的位设置位0.
                            target &= ~(target & r_bits);
                            if (l_bits != 0)
                            {
                                target &= ~(target & l_bits);
                            }
                            _data[self_offset] = (byte)target;
                            l_bits = src << 8 - b_offset;
                        }
                    }
                }
                else
                {
                    int b_offset = rect.X % 8;

                    int self_offset = 0;
                    int tile_offset = 0;

                    Int32 r_bits = 0;
                    Int32 l_bits = 0;

                    int src = 0;
                    int target = 0;
                    for (int j = 0; j < ch; j++)
                    {
                        r_bits = 0;
                        l_bits = 0;
                        for (int i = 0; i < cw; i++)
                        {
                            self_offset = (j + y + cy) * _bw + i + cx2;
                            tile_offset = (j + cy) * tile._bw + i + cx;

                            src = addData[tile_offset];
                            l_bits = src << b_offset;
                            if (i < cw - 1)
                            {
                                src = addData[tile_offset +1];
                                r_bits = src >> (8 - b_offset);
                            }
                            else
                            {
                                r_bits = 0;
                            }
                            target = _data[self_offset];
                            target &= ~(target & l_bits);
                            if (r_bits != 0)
                            {
                                target &= ~(target & r_bits);
                            }
                            _data[self_offset] = (byte)target;
                        }
                    }
                }
            }
        }
示例#6
0
        protected void Add(int x, int y, Tile tile)
        {
            //需要重写,原来的逻辑不对,参照Remove

            //
            //byte[] addData = tile._data;

            //Rectangle rect = tile.Bound;

            //rect.Offset(x, y);
            //rect.Intersect(_rect);
            //if (rect.Width != 0 && rect.Height != 0)
            //{
            //    rect.Offset(-x, -y);

            //    int cx = rect.X / 8;
            //    int cx2 = (rect.X + x) / 8;

            //    int cy = rect.Y;
            //    int cw = (int)Math.Floor((double)rect.Width / 8);
            //    int ch = rect.Height;

            //    int b_offset = rect.X % 8;

            //    int self_offset = 0;
            //    int tile_offset = 0;

            //    Int32 r_bits = 0;
            //    Int32 l_bits = 0;

            //    int src = 0;
            //    int target = 0;
            //    for (int j = 0; j < ch; j++)
            //    {
            //        r_bits = 0;
            //        l_bits = 0;
            //        for (int i = 0; i < cw; i++)
            //        {
            //            self_offset = (j + y + cy) * _bw + i + cx2;
            //            tile_offset = (j + cy) * tile._bw + i + cx;

            //            src = addData[tile_offset];

            //            r_bits = src >> b_offset;

            //            _data[self_offset] |= (byte)r_bits;
            //            _data[self_offset] |= (byte)l_bits;

            //            l_bits = src << 8 - b_offset;
            //        }
            //    }
            //}
        }
示例#7
0
        public void Dig(int cx, int cy, Tile surface, Tile border)
        {
            if (_digable && surface != null)
            {
                int x1 = (int)(cx - surface.Width / 2);
                int y1 = (int)(cy - surface.Height / 2);

                Remove(x1, y1, surface);

                if (border != null)
                {
                    x1 = (int)(cx - border.Width / 2);
                    y1 = (int)(cy - border.Height / 2);

                    Add(x1, y1, surface);
                }
            }
        }
示例#8
0
 public BombObject(int id,BombType type, Player owner, Tile shape, int radius, bool controled,double power)
     :this(id,type,owner,shape,radius,controled,10,100,1,1,power)
 {
 }