Exemplo n.º 1
0
 //clears the commands list
 private void ClearPath()
 {
     commands.Clear();
     sqrPath.Clear();
     targetPack = null;
     targetCoin = null;
 }
Exemplo n.º 2
0
        //get the lifepack with the least cost path
        public void GetBestHealth(Square[] sqrs, LifePack[] packs, Square current, int direction, out List<StarNode> bestP, out LifePack targetPack)
        {
            AStar ast = new AStar(sqrs, mapSize);
            List<StarNode> bestPath = null;
            LifePack target  = null;
            int minCost = int.MaxValue;

            foreach (LifePack pack in packs)
            {
                int index = (int)(pack.position.X + (pack.position.Y * mapSize));
                List<StarNode> path = ast.calculatePath(current, sqrs[index], direction);
                int cost = path[path.Count - 1].cost;

                if ((cost < minCost) && ((cost * Util.Constants.Timeout) < pack.remainTime))
                {
                    bestPath = path;
                    minCost = cost;
                    target = pack;
                }
            }

            bestP = bestPath;
            targetPack = target;
        }
Exemplo n.º 3
0
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = Util.Constants.ScreenWidth;
            graphics.PreferredBackBufferHeight = Util.Constants.ScreenHeight;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Window.Title = "Battle Tanks";
            //mapSize = Util.Constants.MapSize;
            scale = Util.Constants.Scale;
            offset = Util.Constants.Offset;
            imageSize = Util.Constants.ImageSize;
            //Console.WriteLine(imageSize);
            cmn = new Communicator(serverIP,clientIP, serverPortNumber, clientPortNumber);
            playersSet = false;
            commands = new List<int>();
            sqrPath = new List<Square>();

            targetCoin = new Data_Items.Coin(0,0,0,0,0);
            targetPack = new Data_Items.LifePack(0, 0, 0, 0);
            lastTime = 0;
            shootcount = (float)0.1;
            sendOK = false;
            opMode = "";
            lastCommand = -1;
            lastSquare = null;

            isInRange = false;
            rangeDir = 0;
            skip = false;

            playerDead = false;
            gameInitializing = false;
            gameFinished = false;

            rect = new Texture2D(graphics.GraphicsDevice, 90, 30);
            Color[] data = new Color[90 * 30];
            for (int i = 0; i < data.Length; ++i)
                data[i] = Color.White;
            rect.SetData(data);

            tableBack = new Texture2D(graphics.GraphicsDevice, 385, 215);
            data = new Color[385 * 215];
            for (int i = 0; i < data.Length; ++i)
                data[i] = Color.White;
            tableBack.SetData(data);

            base.Initialize();
        }