예제 #1
0
        public void Update(GameTime gametime, Map_GUI map)
        {
            /*if (issuedShoot == true)//check if client issued SHOOT#
             * {
             *  bullet.isShot(position, currentDirection,map);
             *  issuedShoot = false;
             * }
             * bullet.Update(gametime,map);*/

            if (count % 60 == 0)
            {
                if (count != 0)
                {
                    currentDirection = getDirection();
                    position.Y       = 32 * getYValue();
                    position.X       = 32 * getXValue();
                }
            }

            /* Tank is not rendered if either dead or not a valid contestant,else should be rendered for
             * any other serverStringReply*/

            if (getServerStringReply() == "DEAD#" || getServerStringReply() == "NOT_A_VALID_CONTESTANT#")
            {
            }
            else
            {
                rectangle = new Rectangle((int)position.X, (int)position.Y, textureUp.Width, textureUp.Height); //since all images are same size
            }
            rectangle = new Rectangle((int)position.X, (int)position.Y, textureUp.Width, textureUp.Height);     //since all images are same size
            //count++;
        }
예제 #2
0
 public void Update(GameTime gametime, Map_GUI map)
 {
     if (count != 0)
     {
         setPosition(position);
         isHit(position, map);
     }
     rectangle = new Rectangle((int)position.X, (int)position.Y, textureUp.Width, textureUp.Height);//since all images are same size
     count++;
 }
예제 #3
0
 public void isShot(Vector2 newPosition, int newDirection, Map_GUI map)
 {
     //Console.WriteLine("is in isshot");
     shot             = true;//setting inital position
     currentDirection = newDirection;
     position         = newPosition;
     //setPosition(newPosition);
     this.map = map;
     //isHit(position,map);
     setFinalPosition();
 }
예제 #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = 960;
            graphics.PreferredBackBufferHeight = 640;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Window.Title = "TANK BATTLES";

            handler  = new ResponseHandler();
            decision = new Decision();
            com      = new Communicator();
            map      = new Map_GUI();
            join();
            setGrid();
            Player[] playersD = handler.getDataStorage().getPlayers();
            Player   p;

            for (int i = 0; i < 5; i++)
            {
                p          = playersD[i];
                players[i] = new Player_GUI(p.getX(), p.getY(), p.getDirection(), p.getID());
            }
            base.Initialize();
        }
예제 #5
0
        public void isHit(Vector2 newPosition, Map_GUI map)
        {
            //if newPosition or positions on the way contains a player

            int x = (int)newPosition.X / 32;
            int y = (int)newPosition.Y / 32;

            //Brick = 1, Stone = 2
            if (x > 2 && x < 7 && y > 2 && y < 7)
            {
                #region
                if (currentDirection == 0)//change y,x const
                {
                    #region
                    for (int i = y + 3; i >= y; i--)
                    {
                        int num = map.Contents[i, x];
                        if (num == 1 || num == 2)
                        {
                            if (num == 2)
                            {
                                hit = true;
                            }
                            else
                            {
                                var brick  = map.BrickTiles.First(d => d.Rectangle.X == (x * map.Size) && d.Rectangle.Y == (i * map.Size));
                                int damage = brick.getDamageLevel();
                                if (damage != 4)
                                {
                                    hit = true;
                                }
                            }
                            break;
                        }
                    }
                    #endregion
                }
                else if (currentDirection == 2)//change y,x const
                {
                    #region
                    for (int i = y - 3; i <= y; i++)
                    {
                        int num = map.Contents[i, x];
                        if (num == 1 || num == 2)
                        {
                            if (num == 2)
                            {
                                hit = true;
                            }
                            else
                            {
                                var brick  = map.BrickTiles.First(d => d.Rectangle.X == (x * map.Size) && d.Rectangle.Y == (i * map.Size));
                                int damage = brick.getDamageLevel();
                                if (damage != 4)
                                {
                                    hit = true;
                                }
                            }
                            break;
                        }
                    }
                    #endregion
                }
                else if (currentDirection == 1)//change x,y const
                {
                    #region
                    for (int i = x - 3; i <= x; i++)
                    {
                        int num = map.Contents[y, i];
                        if (num == 1 || num == 2)
                        {
                            if (num == 2)
                            {
                                hit = true;
                            }
                            else
                            {
                                var brick  = map.BrickTiles.First(d => d.Rectangle.X == (i * map.Size) && d.Rectangle.Y == (y * map.Size));
                                int damage = brick.getDamageLevel();
                                if (damage != 4)
                                {
                                    hit = true;
                                }
                            }
                            break;
                        }
                    }
                    #endregion
                }
                else if (currentDirection == 3)//change x,y const
                {
                    #region
                    for (int i = x + 3; i > x; i--)
                    {
                        int num = map.Contents[y, i];
                        if (num == 1 || num == 2)
                        {
                            if (num == 2)
                            {
                                hit = true;
                            }
                            else
                            {
                                var brick  = map.BrickTiles.First(d => d.Rectangle.X == (i * map.Size) && d.Rectangle.Y == (y * map.Size));
                                int damage = brick.getDamageLevel();
                                if (damage != 4)
                                {
                                    hit = true;
                                }
                            }
                            break;
                        }
                    }
                    #endregion
                }
            }
            #endregion
        }