Exemple #1
0
 public override void UpdateDirection(IBasePlayer player, IBaseMap gameMap)
 {
     if (wasHit)
     {
         Direction    = new Vector2(0, 1);
         PixelsPerSec = 10;
     }
     else
     {
         if (isDescending)
         {
             Direction    = new Vector2(0, 1);
             PixelsPerSec = 1;
         }
         else
         {
             if (Position.X <= GameSettings.Instance.WindowTilesSize.X / 4)
             {
                 Direction = new Vector2(1, 0);
             }
             else if (Position.X >= (GameSettings.Instance.WindowTilesSize.X - GameSettings.Instance.WindowTilesSize.X / 4))
             {
                 Direction = new Vector2(-1, 0);
             }
         }
     }
 }
 public override EnemyBullet GetBullet(IBasePlayer player, IBaseMap gameMap)
 {
     bullet           = GetBulletByEnemyNumber();
     bullet.Direction = this.Direction;
     bullet.Owner     = this;
     this.Reloaded    = true;
     return(bullet);
 }
        public virtual EnemyBullet GetBullet(IBasePlayer player, IBaseMap gameMap)
        {
            var bullet = new EnemyBullet(this.Position, 0);

            bullet.direction = this.Direction;
            bullet.Owner     = this;
            //this.Reloaded = false;
            return(bullet);
        }
Exemple #4
0
        public virtual EnemyBullet GetBullet(IBasePlayer player, IBaseMap gameMap)
        {
            var bullet       = new EnemyBullet2(this.Position + this.Size / 2, 0);
            var newDirection = new Vector2(player.Position.X - bullet.Position.X, (player.Position.Y + gameMap.ScrollRows) - bullet.Position.Y) + player.Size / 2;

            newDirection.Normalize();
            bullet.Direction = newDirection;
            reloaded         = false;
            return(bullet);
        }
        public CollisionType CheckMapCollision(IBaseMap gameMap, Vector2?candidateWindowPosition)
        {
            CollisionResult mapCollisionResult = new CollisionResult {
                CollisionType = CollisionType.None
            };
            var candidatePosition = (candidateWindowPosition.Value / scrollRowHeight);

            mapCollisionResult = gameMap.TestCollision(this, candidatePosition, gameMap.ScrollRows);
            return(mapCollisionResult.CollisionType);
        }
Exemple #6
0
        public override EnemyBullet GetBullet(IBasePlayer player, IBaseMap gameMap)
        {
            var bullet       = new EnemyBullet2(this.Position, 0);
            var newDirection = new Vector2(player.Position.X - this.Position.X, (player.Position.Y + gameMap.ScrollRows) - this.Position.Y) + player.Size / 2;

            newDirection.Normalize();
            bullet.Direction = newDirection;
            bullet.Owner     = this;
            this.Reloaded    = false;
            return(bullet);
        }
Exemple #7
0
 public static bool ValidateNewPlayerPosition(PlayerData playerData, IBaseMap map, bool emulateCheat = false)
 {
     if (playerData.IsMoving)
     {
         int traveled = CalculatePlayerTraveledDistance(playerData);
         if (emulateCheat) traveled += 5;
         Point newPos = CalculateNewPlayerPos(playerData.Player, traveled);
         PlayerPosProcessCollision(playerData.Player, map, ref newPos);
         if (playerData.Player.Position != newPos)
         {
             playerData.Player.Position = newPos;
             return true;
         }
     }
     return false;
 }
Exemple #8
0
 public static bool ValidateNewPlayerPosition(PlayerData playerData, IBaseMap map, bool emulateCheat = false)
 {
     if (playerData.IsMoving)
     {
         int traveled = CalculatePlayerTraveledDistance(playerData);
         if (emulateCheat)
         {
             traveled += 5;
         }
         Point newPos = CalculateNewPlayerPos(playerData.Player, traveled);
         PlayerPosProcessCollision(playerData.Player, map, ref newPos);
         if (playerData.Player.Position != newPos)
         {
             playerData.Player.Position = newPos;
             return(true);
         }
     }
     return(false);
 }
Exemple #9
0
        public override void UpdateDirection(IBasePlayer player, IBaseMap gameMap)
        {
            if ((this.Position.X / 2) == (int)(this.Position.X / 2) ||
                (this.Position.Y / 2) == (int)(this.Position.Y / 2))
            {
                var newDirection = new Vector2(player.Position.X - this.Position.X, (player.Position.Y + gameMap.ScrollRows) - this.Position.Y) + player.Size / 2;
                if (onWindowTicks / (changeDirectionInMS / tickInMS) % 2 == 0)
                {
                    newDirection = new Vector2(newDirection.X, 0);
                }
                else
                {
                    newDirection = new Vector2(0, newDirection.Y);
                }

                newDirection.Normalize();
                this.Direction = newDirection;
            }
        }
Exemple #10
0
        public BaseDB(string connectionstring, IBaseMap map)
        {
            if (m_connection == null)
            {
                m_connection = new SqlConnection();
            }
            if (m_count == 0)
            {
                m_connection.ConnectionString = connectionstring;
            }
            if (m_command == null)
            {
                m_command = new SqlCommand();
            }

            DetachParams();
            m_command.CommandType = CommandType.StoredProcedure;
            m_command.Connection  = m_connection;
            m_count++;
            m_map = map;
        }
Exemple #11
0
        private Hashtable GetFields(IBaseMap mapinstance, bool isswap)
        {
            if (mapinstance == null)
            {
                throw new Exception(ErrorConstants.NoDetailNoMap);
            }
            FieldInfo[] mapflds = mapinstance.GetType().GetFields(EnumConstants.GetField);
            Hashtable   ht      = new Hashtable();

            foreach (FieldInfo fld in mapflds)
            {
                if (isswap)
                {
                    ht.Add(fld.GetValue(mapinstance), fld.Name);
                }
                else
                {
                    ht.Add(fld.Name, fld.GetValue(mapinstance));
                }
            }
            return(ht);
        }
Exemple #12
0
        public override void UpdateDirection(IBasePlayer player, IBaseMap gameMap)
        {
            if (State == CharacterState.Alive &&
                gameMap.State == MapState.Scrolling &&
                ((this.Position.X / 2) == (int)(this.Position.X / 2) ||
                 (this.Position.Y / 2) == (int)(this.Position.Y / 2)))
            {
                var target = new Vector2(player.Position.X >= GameSettings.Instance.WindowTilesSize.X / 2 ? 0 : GameSettings.Instance.WindowTilesSize.X, (player.Position.Y + gameMap.ScrollRows));

                var newDirection = new Vector2(target.X - this.Position.X, target.Y - this.Position.Y) + this.Size / 2;
                if (onWindowTicks / (changeDirectionInMS / tickInMS) % 2 == 0)
                {
                    newDirection = new Vector2(newDirection.X, 0);
                }
                else
                {
                    newDirection = new Vector2(0, newDirection.Y);
                }

                newDirection.Normalize();
                this.Direction = newDirection;
            }
        }
Exemple #13
0
 public void FillValues(IDataReader reader, IBaseMap mapinstance)
 {
     if (reader.Read())
     {
         Hashtable    htmap = GetFields(mapinstance, true);
         int          lv, count = reader.FieldCount;
         Type         type = this.GetType();
         PropertyInfo pi;
         string       colname = string.Empty;
         for (lv = 0; lv < count; lv++)
         {
             colname = reader.GetName(lv);
             if (htmap.ContainsKey(colname))
             {
                 pi = type.GetProperty(htmap[colname].ToString());
                 if (pi != null && !reader.IsDBNull(lv))
                 {
                     pi.SetValue(this, reader.GetValue(lv), null);
                 }
             }
         }
         reader.Close();
     }
 }
Exemple #14
0
        public override void Update(GameTime gameTime, int tickCount, float scrollRows, List <IEnemy> onScreenEnemies, IBaseMap gameMap)
        {
            base.Update(gameTime, tickCount, scrollRows, onScreenEnemies, gameMap);

            if (onWindowPosition.HasValue)
            {
                if (!isDescending != onWindowPosition.Value.Y >= this.Size.Y * 2)
                {
                    isDescending = false;
                    Direction    = new Vector2(1, 0);
                }
            }
        }
Exemple #15
0
        private static void PlayerPosProcessCollision(Player player, IBaseMap map, ref Point newPos)
        {
            Point    pos = player.Position;
            TinySize size = player.Size;
            bool     stop = false, xStop = false, yStop = false;

            int mapWidth = map.Width, mapHeight = map.Height;

            int cellTs = (int)Math.Floor((float)pos.Y / ConstMap.PIXEL_SIZE);
            int cellTe = (int)Math.Floor((float)newPos.Y / ConstMap.PIXEL_SIZE);
            int cellLs = (int)Math.Floor((float)pos.X / ConstMap.PIXEL_SIZE);
            int cellLe = (int)Math.Floor((float)newPos.X / ConstMap.PIXEL_SIZE);

            int cellBs = (int)Math.Floor((float)(pos.Y + size.Height - 1) / ConstMap.PIXEL_SIZE);
            int cellBe = (int)Math.Floor((float)(newPos.Y + size.Height - 1) / ConstMap.PIXEL_SIZE);
            int cellRs = (int)Math.Floor((float)(pos.X + size.Width - 1) / ConstMap.PIXEL_SIZE);
            int cellRe = (int)Math.Floor((float)(newPos.X + size.Width - 1) / ConstMap.PIXEL_SIZE);

            int cellT = (int)Math.Floor((float)pos.Y / ConstMap.PIXEL_SIZE);
            int cellB = (int)Math.Floor((float)(pos.Y + size.Height - 1) / ConstMap.PIXEL_SIZE);

            int cellL = (int)Math.Floor((float)pos.X / ConstMap.PIXEL_SIZE);
            int cellR = (int)Math.Floor((float)(pos.X + size.Width - 1) / ConstMap.PIXEL_SIZE);

            switch (player.Direction)
            {
            case Direction.N:
            {
                for (int y = cellTs; y >= cellTe; y--)
                {
                    if (y < 0 || y >= mapHeight || stop)
                    {
                        break;
                    }
                    for (int x = cellL; x <= cellR; x++)
                    {
                        if (x < 0 || x >= mapWidth)
                        {
                            continue;
                        }
                        if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                        {
                            newPos.Y = y * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                            stop     = true;
                            break;
                        }
                    }
                }
                break;
            }

            case Direction.NW:
            {
                int tTotalDist   = cellTs - cellTe;
                int lTotalDist   = cellLs - cellLe;
                int maxTotalDist = Math.Max(tTotalDist, lTotalDist);

                for (int i = 1; i <= maxTotalDist; i++)
                {
                    if (xStop && yStop)
                    {
                        break;
                    }

                    cellT--; cellB--; cellL--; cellR--;

                    for (int y = cellT; y <= cellB; y++)
                    {
                        if (y < 0 || y >= mapHeight)
                        {
                            continue;
                        }

                        //Y
                        if (y == cellT && i <= tTotalDist)
                        {
                            for (int x = cellL; x <= cellR; x++)
                            {
                                if (x < 0 || x >= mapWidth)
                                {
                                    continue;
                                }
                                if (!yStop && (*map[(ushort)(x + 1), (ushort)cellT]).Type != TileType.Nothing)
                                {
                                    newPos.Y = cellT * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                    yStop    = true;
                                    break;
                                }
                            }
                        }

                        //X
                        if (!xStop && i <= lTotalDist &&
                            (*map[(ushort)cellL, (ushort)(y + 1)]).Type != TileType.Nothing)
                        {
                            newPos.X = cellL * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                            xStop    = true;
                            break;
                        }

                        if (xStop && yStop)
                        {
                            break;
                        }
                    }
                }
                break;
            }

            case Direction.NE:
            {
                int tTotalDist   = cellTs - cellTe;
                int rTotalDist   = cellRe - cellRs;
                int maxTotalDist = Math.Max(tTotalDist, rTotalDist);

                for (int i = 1; i <= maxTotalDist; i++)
                {
                    if (xStop && yStop)
                    {
                        break;
                    }

                    cellT--; cellB--; cellL++; cellR++;

                    for (int y = cellT; y <= cellB; y++)
                    {
                        if (y < 0 || y >= mapHeight)
                        {
                            continue;
                        }

                        //Y
                        if (y == cellT && i <= tTotalDist)
                        {
                            for (int x = cellL; x <= cellR; x++)
                            {
                                if (x < 0 || x >= mapWidth)
                                {
                                    continue;
                                }
                                if (!yStop && (*map[(ushort)(x - 1), (ushort)cellT]).Type != TileType.Nothing)
                                {
                                    newPos.Y = cellT * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                    yStop    = true;
                                    break;
                                }
                            }
                        }

                        //X
                        if (!xStop && i <= rTotalDist &&
                            (*map[(ushort)cellR, (ushort)(y + 1)]).Type != TileType.Nothing)
                        {
                            newPos.X = cellR * ConstMap.PIXEL_SIZE - size.Width;
                            xStop    = true;
                            break;
                        }

                        if (xStop && yStop)
                        {
                            break;
                        }
                    }
                }
                break;
            }

            case Direction.S:
            {
                for (int y = cellBs; y <= cellBe; y++)
                {
                    if (y < 0 || y >= mapHeight || stop)
                    {
                        break;
                    }
                    for (int x = cellL; x <= cellR; x++)
                    {
                        if (x < 0 || x >= mapWidth)
                        {
                            continue;
                        }
                        if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                        {
                            newPos.Y = y * ConstMap.PIXEL_SIZE - size.Height;
                            stop     = true;
                            break;
                        }
                    }
                }
                break;
            }

            case Direction.SW:
            {
                int bTotalDist   = cellBe - cellBs;
                int lTotalDist   = cellLs - cellLe;
                int maxTotalDist = Math.Max(bTotalDist, lTotalDist);

                for (int i = 1; i <= maxTotalDist; i++)
                {
                    if (xStop && yStop)
                    {
                        break;
                    }

                    cellT++; cellB++; cellL--; cellR--;

                    for (int y = cellT; y <= cellB; y++)
                    {
                        if (y < 0 || y >= mapHeight)
                        {
                            continue;
                        }

                        //Y
                        if (y == cellT && i <= bTotalDist)
                        {
                            for (int x = cellL; x <= cellR; x++)
                            {
                                if (x < 0 || x >= mapWidth)
                                {
                                    continue;
                                }
                                if (!yStop && (*map[(ushort)(x + 1), (ushort)cellB]).Type != TileType.Nothing)
                                {
                                    newPos.Y = cellB * ConstMap.PIXEL_SIZE - size.Height;
                                    yStop    = true;
                                    break;
                                }
                            }
                        }

                        //X
                        if (!xStop && i <= lTotalDist &&
                            (*map[(ushort)cellL, (ushort)(y - 1)]).Type != TileType.Nothing)
                        {
                            newPos.X = cellL * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                            xStop    = true;
                            break;
                        }

                        if (xStop && yStop)
                        {
                            break;
                        }
                    }
                }
                break;
            }

            case Direction.SE:
            {
                int bTotalDist   = cellBe - cellBs;
                int rTotalDist   = cellRe - cellRs;
                int maxTotalDist = Math.Max(bTotalDist, rTotalDist);

                for (int i = 1; i <= maxTotalDist; i++)
                {
                    if (xStop && yStop)
                    {
                        break;
                    }

                    cellT++; cellB++; cellL++; cellR++;

                    for (int y = cellT; y <= cellB; y++)
                    {
                        if (y < 0 || y >= mapHeight)
                        {
                            continue;
                        }

                        //Y
                        if (y == cellT && i <= bTotalDist)
                        {
                            for (int x = cellL; x <= cellR; x++)
                            {
                                if (x < 0 || x >= mapWidth)
                                {
                                    continue;
                                }
                                if (!yStop && (*map[(ushort)(x - 1), (ushort)cellB]).Type != TileType.Nothing)
                                {
                                    newPos.Y = cellB * ConstMap.PIXEL_SIZE - size.Height;
                                    yStop    = true;
                                    break;
                                }
                            }
                        }

                        //X
                        if (!xStop && i <= rTotalDist &&
                            (*map[(ushort)cellR, (ushort)(y - 1)]).Type != TileType.Nothing)
                        {
                            newPos.X = cellR * ConstMap.PIXEL_SIZE - size.Width;
                            xStop    = true;
                            break;
                        }

                        if (xStop && yStop)
                        {
                            break;
                        }
                    }
                }
                break;
            }

            case Direction.W:
            {
                for (int x = cellLs; x >= cellLe; x--)
                {
                    if (x < 0 || x >= mapWidth || stop)
                    {
                        break;
                    }
                    for (int y = cellT; y <= cellB; y++)
                    {
                        if (y < 0 || y >= mapHeight)
                        {
                            continue;
                        }
                        if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                        {
                            newPos.X = x * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                            stop     = true;
                            break;
                        }
                    }
                }
                break;
            }

            case Direction.E:
            {
                for (int x = cellRs; x <= cellRe; x++)
                {
                    if (x < 0 || x >= mapWidth || stop)
                    {
                        break;
                    }
                    for (int y = cellT; y <= cellB; y++)
                    {
                        if (y < 0 || y >= mapHeight)
                        {
                            continue;
                        }
                        if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                        {
                            newPos.X = x * ConstMap.PIXEL_SIZE - size.Width;
                            stop     = true;
                            break;
                        }
                    }
                }
                break;
            }
            }
        }
Exemple #16
0
        private void GenerateContourMap()
        {
            Surfer.Application app    = new Surfer.Application();
            IDocuments         docs   = app.Documents;
            IPlotDocument      Doc    = (IPlotDocument)docs.Add(SrfDocTypes.srfDocPlot); //創建一個空白繪圖文檔
            IShapes            Shapes = Doc.Shapes;

            #region 添加等值面
            IMapFrame contourMapFrame = Shapes.AddContourMap(path + "temp.grd");        //加載網格文件
            for (int i = 1; i <= contourMapFrame.Axes.Count; i++)
            {
                contourMapFrame.Axes.Item(i).Visible       = false;
                contourMapFrame.Axes.Item(i).MajorTickType = SrfTickType.srfTickNone;
                contourMapFrame.Axes.Item(i).ShowLabels    = false;
            }
            contourMapFrame.SetLimits(xMin: 140000,     //x最小值
                                      xMax: 370000,     //x最大者
                                      yMin: 2400000,    //y最小值
                                      yMax: 2800000     //y最大值
                                      );
            contourMapFrame.xMapPerPU = 23000;          //設置比例
            contourMapFrame.yMapPerPU = 20000;          //設置比例


            IContourMap contourMap = (IContourMap)contourMapFrame.Overlays.Item(1);

            /*
             * contourMap.ShowColorScale = true;										// 顯示對應色柱
             * contourMap.ColorScale.Top = 10;										//色柱y方向位置
             * contourMap.ColorScale.Left = contourMap.Left + contourMap.Width + 0.8;//色柱x方向位置
             * contourMap.ColorScale.Width = 1;									//色柱寬度
             * contourMap.ColorScale.Height = 10;										//色柱高度
             * contourMap.ColorScale.LabelFont.Size = 10;
             * contourMap.ColorScale.LabelFont.Face = "Time New Roman";
             * contourMap.ColorScale.LabelFrequency = 1;
             * contourMap.ColorScale.Name = "PM2.5 (μg/m3)";
             */

            contourMap.FillContours = true;    //添加顏色填充
            //通過文件加載顏色
            ILevels levels = contourMap.Levels;
            levels.LoadFile(path + "PM25.lvl");

            //加載系統顏色
            //contourMap.FillForegroundColorMap.LoadFile(path + "Rainbow.clr");
            //contourMap.ApplyFillToLevels(1, 1, 0);

            //使用灰色
            //contourMap.Levels.AutoGenerate(contourMap.Grid.zMin,contourMap.Grid.zMax,10);

            for (int i = 0; i < contourMap.Levels.Count; i++)
            {
                contourMap.Levels.Item(i + 1).ShowLabel  = false;                               //顯示等值線上的數值
                contourMap.Levels.Item(i + 1).ShowHach   = false;                               //
                contourMap.Levels.Item(i + 1).Line.Style = "Invisible";                         //不顯示線
            }

            contourMap.SmoothContours = SrfConSmoothType.srfConSmoothNone;       //平滑等值線邊界當前設置不平滑
            #endregion


            #region 添加邊界
            //後添加的會覆蓋在先前添加的圖片之上
            IMapFrame boundryMapFrame = Shapes.AddBaseMap(path + "city.shp", "Defaults=1");
            for (int i = 1; i <= boundryMapFrame.Axes.Count; i++)
            {
                boundryMapFrame.Axes.Item(i).Visible       = false;                   //隱藏軸線
                boundryMapFrame.Axes.Item(i).MajorTickType = SrfTickType.srfTickNone; //隱藏邊線
                boundryMapFrame.Axes.Item(i).ShowLabels    = false;                   //隱藏軸線上的坐標
            }
            boundryMapFrame.SetLimits(xMin: 140000,                                   //x最小值
                                      xMax: 370000,                                   //x最大者
                                      yMin: 2400000,                                  //y最小值
                                      yMax: 2800000                                   //y最大值
                                      );
            boundryMapFrame.xMapPerPU = 23000;
            boundryMapFrame.yMapPerPU = 20000;

            IBaseMap boundryBaseMap = (IBaseMap)boundryMapFrame.Overlays.Item(1);
            boundryBaseMap.Line.Width = 0.001;                          //設置邊線寬度
            #endregion

            string strWH = string.Format("width = {0:f0}, height = {1:f0}, KeepAspect = 1, ColorDepth = 32", 680, 1280); //設置輸出圖片的高度和寬度
            Doc.Export2(path + "Image.png", SelectionOnly: false, Options: strWH, FilterId: "png");                      //設置輸出圖片格式名
            Doc.Close(SrfSaveTypes.srfSaveChangesNo);                                                                    //不生成srf文件
            app.Quit();
            System.GC.Collect(System.GC.GetGeneration(app));
        }
Exemple #17
0
 protected BaseDetail(IDataReader reader, IBaseMap mapinstance)
 {
     FillValues(reader, mapinstance);
 }
 public virtual void UpdateDirection(IBasePlayer player, IBaseMap gameMap)
 {
     this.player = player;
 }
        public virtual void Update(Microsoft.Xna.Framework.GameTime gameTime, int tickCount, float scrollRows, List <IEnemy> onScreenEnemies, IBaseMap gameMap)
        {
            CheckFirstAppearance(scrollRows);

            this.scrollRows = scrollRows;

            var action = movementStrategy.GetTimedAction(this, player, gameMap);

            ExecuteTimedAction(gameTime, player, action);

            Position = GetPositionFromWindowPosition(scrollRows);

            accumShotTime = accumShotTime.Add(gameTime.ElapsedGameTime);

            UpdateBlink(tickCount);

            //if ((State == CharacterState.Alive || State == CharacterState.Combo) && onWindowPosition != null)
            //{
            //    CheckReload();
            //    accumShotTime = accumShotTime.Add(gameTime.ElapsedGameTime);

            //    if (onWindowPosition.HasValue)
            //    {
            //        if (accumElapsedGameTime >= TimeSpan.FromMilliseconds(tickInMS))
            //        {
            //            if (gameMap.State == MapState.Scrolling && !isAnchored)
            //            {
            //                accumElapsedGameTime = TimeSpan.FromSeconds(0);
            //                onWindowTicks++;
            //                Vector2? candidateWindowPosition;

            //                var selectedSpeed = (OnWindowPosition.Value.Y < this.Size.Y * tileWidth * 2) ? 1 : speed;

            //                if (State == CharacterState.Combo)
            //                    candidateWindowPosition = onWindowPosition + speed * UP_DIRECTION;
            //                else
            //                    candidateWindowPosition = onWindowPosition + speed * direction;

            //                var mapCollisionType = CheckMapCollision(gameMap, candidateWindowPosition);

            //                if (!(lastMapCollisionType == mapCollisionType
            //                    && mapCollisionType == CollisionType.Blocked
            //                    && lastDirection == direction))
            //                {
            //                    if (!isBullet
            //                        && state == CharacterState.Alive
            //                        && candidateWindowPosition.Value.Y > 0
            //                        && State != CharacterState.Combo)
            //                    {
            //                        var collidedWithEnemy = CheckEnemyCollision(onScreenEnemies, candidateWindowPosition);

            //                        if (collidedWithEnemy || mapCollisionType == CollisionType.Blocked)
            //                        {
            //                            candidateWindowPosition = onWindowPosition;
            //                            while (collidedWithEnemy || mapCollisionType == CollisionType.Blocked)
            //                            {
            //                                candidateWindowPosition = candidateWindowPosition - speed * direction;
            //                                mapCollisionType = CheckMapCollision(gameMap, candidateWindowPosition);
            //                                collidedWithEnemy = CheckEnemyCollision(onScreenEnemies, candidateWindowPosition);
            //                            }
            //                            lastMapCollisionType = mapCollisionType;
            //                            if (!this.IsBullet && !this.IsFlying && this.State == CharacterState.Alive)
            //                            {
            //                                var candidateDirection = direction;
            //                                while (candidateDirection == direction)
            //                                {
            //                                    var directionIndex = (RandomProvider.GetThreadRandom().Next(0, 100)) % 4;
            //                                    var directions = new Vector2[] { DOWN_DIRECTION, LEFT_DIRECTION, RIGHT_DIRECTION, UP_DIRECTION };
            //                                    candidateDirection = directions[directionIndex];
            //                                }
            //                                direction = candidateDirection;
            //                                this.direction = InvertDirection();
            //                            }
            //                        }
            //                    }

            //                    lastDirection = direction;
            //                }

            //                onWindowPosition = candidateWindowPosition;
            //            }
            //        }

            //        accumElapsedGameTime = accumElapsedGameTime.Add(gameTime.ElapsedGameTime);
            //        if (!isAnchored)
            //            Position = (onWindowPosition.Value / scrollRowHeight) + new Vector2(0, scrollRows);

            //    }
            //}
        }
Exemple #20
0
 protected BaseDB(IBaseMap map) : this(GMConfig.ConnectionString, map)
 {
 }
Exemple #21
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, int tickCount, float scrollRows, List <IEnemy> onScreenEnemies, IBaseMap gameMap)
        {
            UpdateBlink(tickCount);

            if ((State == CharacterState.Alive || State == CharacterState.Combo) && onWindowPosition != null)
            {
                if (onWindowStartPosition == null)
                {
                    onWindowStartPosition = onWindowPosition;
                }

                if (accumElapsedGameTime >= TimeSpan.FromMilliseconds(tickInMS / 20f))
                {
                    if (gameMap.State == MapState.Scrolling && !isAnchored)
                    {
                        if (State == CharacterState.Combo)
                        {
                            onWindowPosition = onWindowPosition + PixelsPerSec * new Vector2(0, -1);
                        }
                        else
                        {
                            var rad = ((onWindowTicks % 360) / 360f) * 2 * Math.PI;

                            onWindowPosition +=
                                new Vector2((float)Math.Cos(rad), .5f);
                        }
                        accumElapsedGameTime = TimeSpan.FromSeconds(0);
                        onWindowTicks++;
                    }
                }
                accumElapsedGameTime = accumElapsedGameTime.Add(gameTime.ElapsedGameTime);

                Position = (onWindowPosition.Value / scrollRowHeight) + new Vector2(0, (int)(scrollRows));
            }
        }
Exemple #22
0
        public Action <TimeSpan, BaseVerticalShooter.GameModel.IBasePlayer> GetTimedAction(BaseEnemy enemy, IBasePlayer player, IBaseMap gameMap)
        {
            var thisBullet = enemy as EnemyBullet;
            var action     = new Action <TimeSpan, IBasePlayer>((t, p) =>
            {
                if (thisBullet.Owner != null &&
                    ((BaseEnemy)thisBullet.Owner).State == CharacterState.Alive)
                {
                    if (thisBullet.State == CharacterState.Alive)
                    {
                        var range = (thisBullet.Owner.Size * GameSettings.Instance.MapTileWidth) / 2f;
                        thisBullet.RadPosition     += thisBullet.RevsPerSec * ((float)t.TotalMilliseconds / 1000f) * (2f * (float)Math.PI);
                        var candidateWindowPosition =
                            ((thisBullet.Owner.Position + thisBullet.Size - new Vector2(0, gameMap.ScrollRows))
                             * thisBullet.TileWidth)
                            + range * new Vector2((float)Math.Cos(thisBullet.RadPosition), -(float)Math.Sin(thisBullet.RadPosition));

                        thisBullet.Rotation = -thisBullet.RadPosition;

                        //var mapCollisionType = CheckMapCollision(gameMap, candidateWindowPosition);
                        //if (mapCollisionType == CollisionType.None)
                        //{
                        thisBullet.OnWindowPosition = candidateWindowPosition;
                        //}
                        //else
                        //{
                        //    this.State = CharacterState.Dead;
                        //}
                        ((BaseEnemy)thisBullet.Owner).Reloaded = false;
                    }
                }

                if (thisBullet.Owner != null &&
                    ((BaseEnemy)thisBullet.Owner).State
                    == CharacterState.Dead)
                {
                    thisBullet.State = CharacterState.Dead;
                }
            });

            return(action);
        }
Exemple #23
0
 public RecordHistoryDetail(IDataReader reader, IBaseMap mapinstance) : base(reader, mapinstance)
 {
 }
Exemple #24
0
 public CompanyDetail(IDataReader reader, IBaseMap mapinstance) : base(reader, mapinstance)
 {
 }
 public VendorCountyRateDetail(IDataReader reader, IBaseMap mapinstance) : base(reader, mapinstance)
 {
 }
Exemple #26
0
 public BatchRecordDetail(IDataReader reader, IBaseMap mapinstance) : base(reader, mapinstance)
 {
 }
 public override void Update(GameTime gameTime, int tickCount, float scrollRows, List <IEnemy> onScreenEnemies, IBaseMap gameMap)
 {
     base.Update(gameTime, tickCount, scrollRows, onScreenEnemies, gameMap);
     if (this.State == CharacterState.Dead)
     {
         this.Owner = null;
     }
 }
Exemple #28
0
        private static void PlayerPosProcessCollision(Player player, IBaseMap map, ref Point newPos)
        {
            Point pos = player.Position;
            TinySize size = player.Size;
            bool stop = false, xStop = false, yStop = false;

            int mapWidth = map.Width, mapHeight = map.Height;

            int cellTs = (int)Math.Floor((float)pos.Y / ConstMap.PIXEL_SIZE);
            int cellTe = (int)Math.Floor((float)newPos.Y / ConstMap.PIXEL_SIZE);
            int cellLs = (int)Math.Floor((float)pos.X / ConstMap.PIXEL_SIZE);
            int cellLe = (int)Math.Floor((float)newPos.X / ConstMap.PIXEL_SIZE);

            int cellBs = (int)Math.Floor((float)(pos.Y + size.Height - 1) / ConstMap.PIXEL_SIZE);
            int cellBe = (int)Math.Floor((float)(newPos.Y + size.Height - 1) / ConstMap.PIXEL_SIZE);
            int cellRs = (int)Math.Floor((float)(pos.X + size.Width - 1) / ConstMap.PIXEL_SIZE);
            int cellRe = (int)Math.Floor((float)(newPos.X + size.Width - 1) / ConstMap.PIXEL_SIZE);

            int cellT = (int)Math.Floor((float)pos.Y / ConstMap.PIXEL_SIZE);
            int cellB = (int)Math.Floor((float)(pos.Y + size.Height - 1) / ConstMap.PIXEL_SIZE);

            int cellL = (int)Math.Floor((float)pos.X / ConstMap.PIXEL_SIZE);
            int cellR = (int)Math.Floor((float)(pos.X + size.Width - 1) / ConstMap.PIXEL_SIZE);

            switch (player.Direction)
            {
                case Direction.N:
                    {
                        for (int y = cellTs; y >= cellTe; y--)
                        {
                            if (y < 0 || y >= mapHeight || stop) break;
                            for (int x = cellL; x <= cellR; x++)
                            {
                                if (x < 0 || x >= mapWidth) continue;
                                if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                                {
                                    newPos.Y = y * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                    stop = true;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                case Direction.NW:
                    {
                        int tTotalDist = cellTs - cellTe;
                        int lTotalDist = cellLs - cellLe;
                        int maxTotalDist = Math.Max(tTotalDist, lTotalDist);

                        for (int i = 1; i <= maxTotalDist; i++)
                        {
                            if (xStop && yStop) break;

                            cellT--; cellB--; cellL--; cellR--;

                            for (int y = cellT; y <= cellB; y++)
                            {
                                if (y < 0 || y >= mapHeight) continue;

                                //Y
                                if (y == cellT && i <= tTotalDist)
                                {
                                    for (int x = cellL; x <= cellR; x++)
                                    {
                                        if (x < 0 || x >= mapWidth) continue;
                                        if (!yStop && (*map[(ushort)(x + 1), (ushort)cellT]).Type != TileType.Nothing)
                                        {
                                            newPos.Y = cellT * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                            yStop = true;
                                            break;
                                        }
                                    }
                                }

                                //X
                                if (!xStop && i <= lTotalDist &&
                                    (*map[(ushort)cellL, (ushort)(y + 1)]).Type != TileType.Nothing)
                                {
                                    newPos.X = cellL * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                    xStop = true;
                                    break;
                                }

                                if (xStop && yStop) break;
                            }
                        }
                        break;
                    }
                case Direction.NE:
                    {
                        int tTotalDist = cellTs - cellTe;
                        int rTotalDist = cellRe - cellRs;
                        int maxTotalDist = Math.Max(tTotalDist, rTotalDist);

                        for (int i = 1; i <= maxTotalDist; i++)
                        {
                            if (xStop && yStop) break;

                            cellT--; cellB--; cellL++; cellR++;

                            for (int y = cellT; y <= cellB; y++)
                            {
                                if (y < 0 || y >= mapHeight) continue;

                                //Y
                                if (y == cellT && i <= tTotalDist)
                                {
                                    for (int x = cellL; x <= cellR; x++)
                                    {
                                        if (x < 0 || x >= mapWidth) continue;
                                        if (!yStop && (*map[(ushort)(x - 1), (ushort)cellT]).Type != TileType.Nothing)
                                        {
                                            newPos.Y = cellT * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                            yStop = true;
                                            break;
                                        }
                                    }
                                }

                                //X
                                if (!xStop && i <= rTotalDist &&
                                    (*map[(ushort)cellR, (ushort)(y + 1)]).Type != TileType.Nothing)
                                {
                                    newPos.X = cellR * ConstMap.PIXEL_SIZE - size.Width;
                                    xStop = true;
                                    break;
                                }

                                if (xStop && yStop) break;
                            }
                        }
                        break;
                    }
                case Direction.S:
                    {
                        for (int y = cellBs; y <= cellBe; y++)
                        {
                            if (y < 0 || y >= mapHeight || stop) break;
                            for (int x = cellL; x <= cellR; x++)
                            {
                                if (x < 0 || x >= mapWidth) continue;
                                if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                                {
                                    newPos.Y = y * ConstMap.PIXEL_SIZE - size.Height;
                                    stop = true;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                case Direction.SW:
                    {
                        int bTotalDist = cellBe - cellBs;
                        int lTotalDist = cellLs - cellLe;
                        int maxTotalDist = Math.Max(bTotalDist, lTotalDist);

                        for (int i = 1; i <= maxTotalDist; i++)
                        {
                            if (xStop && yStop) break;

                            cellT++; cellB++; cellL--; cellR--;

                            for (int y = cellT; y <= cellB; y++)
                            {
                                if (y < 0 || y >= mapHeight) continue;

                                //Y
                                if (y == cellT && i <= bTotalDist)
                                {
                                    for (int x = cellL; x <= cellR; x++)
                                    {
                                        if (x < 0 || x >= mapWidth) continue;
                                        if (!yStop && (*map[(ushort)(x + 1), (ushort)cellB]).Type != TileType.Nothing)
                                        {
                                            newPos.Y = cellB * ConstMap.PIXEL_SIZE - size.Height;
                                            yStop = true;
                                            break;
                                        }
                                    }
                                }

                                //X
                                if (!xStop && i <= lTotalDist &&
                                    (*map[(ushort)cellL, (ushort)(y - 1)]).Type != TileType.Nothing)
                                {
                                    newPos.X = cellL * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                    xStop = true;
                                    break;
                                }

                                if (xStop && yStop) break;
                            }
                        }
                        break;
                    }
                case Direction.SE:
                    {
                        int bTotalDist = cellBe - cellBs;
                        int rTotalDist = cellRe - cellRs;
                        int maxTotalDist = Math.Max(bTotalDist, rTotalDist);

                        for (int i = 1; i <= maxTotalDist; i++)
                        {
                            if (xStop && yStop) break;

                            cellT++; cellB++; cellL++; cellR++;

                            for (int y = cellT; y <= cellB; y++)
                            {
                                if (y < 0 || y >= mapHeight) continue;

                                //Y
                                if (y == cellT && i <= bTotalDist)
                                {
                                    for (int x = cellL; x <= cellR; x++)
                                    {
                                        if (x < 0 || x >= mapWidth) continue;
                                        if (!yStop && (*map[(ushort)(x - 1), (ushort)cellB]).Type != TileType.Nothing)
                                        {
                                            newPos.Y = cellB * ConstMap.PIXEL_SIZE - size.Height;
                                            yStop = true;
                                            break;
                                        }
                                    }
                                }

                                //X
                                if (!xStop && i <= rTotalDist &&
                                    (*map[(ushort)cellR, (ushort)(y - 1)]).Type != TileType.Nothing)
                                {
                                    newPos.X = cellR * ConstMap.PIXEL_SIZE - size.Width;
                                    xStop = true;
                                    break;
                                }

                                if (xStop && yStop) break;
                            }
                        }
                        break;
                    }
                case Direction.W:
                    {
                        for (int x = cellLs; x >= cellLe; x--)
                        {
                            if (x < 0 || x >= mapWidth || stop) break;
                            for (int y = cellT; y <= cellB; y++)
                            {
                                if (y < 0 || y >= mapHeight) continue;
                                if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                                {
                                    newPos.X = x * ConstMap.PIXEL_SIZE + ConstMap.PIXEL_SIZE;
                                    stop = true;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                case Direction.E:
                    {
                        for (int x = cellRs; x <= cellRe; x++)
                        {
                            if (x < 0 || x >= mapWidth || stop) break;
                            for (int y = cellT; y <= cellB; y++)
                            {
                                if (y < 0 || y >= mapHeight) continue;
                                if ((*map[(ushort)x, (ushort)y]).Type != TileType.Nothing)
                                {
                                    newPos.X = x * ConstMap.PIXEL_SIZE - size.Width;
                                    stop = true;
                                    break;
                                }
                            }
                        }
                        break;
                    }
            }
        }
Exemple #29
0
 public SystemDetail(IDataReader reader, IBaseMap mapinstance) : base(reader, mapinstance)
 {
 }
Exemple #30
0
        public override void Update(GameTime gameTime, int tickCount, float scrollRows, List <IEnemy> onScreenEnemies, IBaseMap gameMap)
        {
            if (isDisassembling)
            {
                if (gameMap.State == MapState.Scrolling && !isAnchored)
                {
                    if (accumElapsedGameTime >= TimeSpan.FromMilliseconds(tickInMS))
                    {
                        splitDistance = splitDistance * 1.05f + 1;
                    }

                    if (splitDistance >= maxSplitDistance)
                    {
                        accumElapsedGameTime = TimeSpan.FromSeconds(0);
                        isDisassembling      = false;
                        isAssembling         = true;
                    }
                    else
                    {
                        accumElapsedGameTime = accumElapsedGameTime.Add(gameTime.ElapsedGameTime);
                    }
                }
            }
            else if (isAssembling)
            {
                if (gameMap.State == MapState.Scrolling && !isAnchored)
                {
                    if (accumElapsedGameTime >= TimeSpan.FromMilliseconds(tickInMS))
                    {
                        splitDistance = splitDistance / 1.05f - 1;
                    }

                    if (splitDistance <= 0)
                    {
                        accumElapsedGameTime = TimeSpan.FromSeconds(0);
                        isDisassembling      = false;
                        isAssembling         = false;
                    }
                    else
                    {
                        accumElapsedGameTime = accumElapsedGameTime.Add(gameTime.ElapsedGameTime);
                    }
                }
            }
            else
            {
                base.Update(gameTime, tickCount, scrollRows, onScreenEnemies, gameMap);
            }
        }
Exemple #31
0
 public Group2Detail(IDataReader reader, IBaseMap mapinstance) : base(reader, mapinstance)
 {
 }
Exemple #32
0
 public EmployeeHierarchyDetail(IDataReader reader, IBaseMap mapinstance) : base(reader, mapinstance)
 {
 }