Пример #1
0
        public int Distance(ref CCPointI p)
        {
            var hside = X - p.X;
            var vside = Y - p.Y;

            return((int)Math.Sqrt(hside * hside + vside * vside));
        }
Пример #2
0
        public CCBoundingBoxI Transform(CCAffineTransform matrix)
        {
            var top    = MinY;
            var left   = MinX;
            var right  = MaxX;
            var bottom = MaxY;

            var topLeft     = new CCPointI(left, top);
            var topRight    = new CCPointI(right, top);
            var bottomLeft  = new CCPointI(left, bottom);
            var bottomRight = new CCPointI(right, bottom);

            matrix.Transform(ref topLeft.X, ref topLeft.Y);
            matrix.Transform(ref topRight.Y, ref topRight.Y);
            matrix.Transform(ref bottomLeft.X, ref bottomLeft.Y);
            matrix.Transform(ref bottomRight.X, ref bottomRight.Y);

            int minX = Math.Min(Math.Min(topLeft.X, topRight.X), Math.Min(bottomLeft.X, bottomRight.X));
            int maxX = Math.Max(Math.Max(topLeft.X, topRight.X), Math.Max(bottomLeft.X, bottomRight.X));
            int minY = Math.Min(Math.Min(topLeft.Y, topRight.Y), Math.Min(bottomLeft.Y, bottomRight.Y));
            int maxY = Math.Max(Math.Max(topLeft.Y, topRight.Y), Math.Max(bottomLeft.Y, bottomRight.Y));

            return(new CCBoundingBoxI(minX, minY, maxX, maxY));
        }
Пример #3
0
        public CCBoundingBoxI Transform(CCAffineTransform matrix)
        {
            var top = MinY;
            var left = MinX;
            var right = MaxX;
            var bottom = MaxY;

            var topLeft = new CCPointI(left, top);
            var topRight = new CCPointI(right, top);
            var bottomLeft = new CCPointI(left, bottom);
            var bottomRight = new CCPointI(right, bottom);

            matrix.Transform(ref topLeft.X, ref topLeft.Y);
            matrix.Transform(ref topRight.Y, ref topRight.Y);
            matrix.Transform(ref bottomLeft.X, ref bottomLeft.Y);
            matrix.Transform(ref bottomRight.X, ref bottomRight.Y);

            int minX = Math.Min(Math.Min(topLeft.X, topRight.X), Math.Min(bottomLeft.X, bottomRight.X));
            int maxX = Math.Max(Math.Max(topLeft.X, topRight.X), Math.Max(bottomLeft.X, bottomRight.X));
            int minY = Math.Min(Math.Min(topLeft.Y, topRight.Y), Math.Min(bottomLeft.Y, bottomRight.Y));
            int maxY = Math.Max(Math.Max(topLeft.Y, topRight.Y), Math.Max(bottomLeft.Y, bottomRight.Y));

            return new CCBoundingBoxI(minX, minY, maxX, maxY);
        }
Пример #4
0
 public void ExpandToPoint(ref CCPointI point)
 {
     ExpandToPoint(point.X, point.Y);
 }
Пример #5
0
 public void ExpandToCircle(ref CCPointI point, int radius)
 {
     ExpandToCircle(point.X, point.Y, radius);
 }
Пример #6
0
 public bool Equals(CCPointI other)        
 {            
     return this == other;       
 }
Пример #7
0
 public bool Equals(ref CCPointI p)
 {
     return X == p.X && Y == p.Y;
 }
Пример #8
0
        public int Distance(ref CCPointI p)
        {
            var hside = X - p.X;
            var vside = Y - p.Y;

            return (int)Math.Sqrt(hside * hside + vside * vside);
        }
Пример #9
0
 public void ExpandToPoint(ref CCPointI point)
 {
     ExpandToPoint(point.X, point.Y);
 }
Пример #10
0
 public void ExpandToCircle(ref CCPointI point, int radius)
 {
     ExpandToCircle(point.X, point.Y, radius);
 }
Пример #11
0
 public bool Equals(CCPointI other)
 {
     return(this == other);
 }
Пример #12
0
 public bool Equals(ref CCPointI p)
 {
     return(X == p.X && Y == p.Y);
 }
Пример #13
0
        List<character> placeEnemiesRandomly()
        {
            List<character> enemies = new List<character>();
            int tileDimension = (int)TileTexelSize.Width;
            int numberOfColumns = (int)MapDimensions.Size.Width;
            int numberOfRows = (int)MapDimensions.Size.Height;
            CCTileMapCoordinates randomTile;
            CCPoint randomLocation;
            for (int i =0; i < (Int32.Parse(MapPropertyNamed("numEnemies"))+level); i++)
            {   
                int randCol = CCRandom.GetRandomInt(0, numberOfColumns - 1);
                int randRow = CCRandom.GetRandomInt(0, numberOfRows - 1);

                randomTile = new CCTileMapCoordinates(randCol, randRow);

                //if you randomly chose a non-walkable tile OR another char is on that tile
                if (character.checkSingleTileWithProperties(randomTile, "walkable", "true")
                    && !isTileOccupied(randomTile))
                {

                    randomLocation = LayerNamed("Map").TilePosition(randomTile);
                    randomLocation = new CCPointI((int)randomLocation.X + tileDimension / 2, (int)randomLocation.Y + tileDimension / 2);
                    enemies.Add(new character("enemyChar", 5, randomLocation, availableWeapons[i+1] ));//CCRandom.GetRandomInt(0,availableWeapons.Count-1)]  ));
                }
                else
                    i--;
                
            }
            return enemies;
        }
Пример #14
0
 //Calls the tileHandler on EVERY map tile
 void loopTiles(character oldUser)
 {
     int tileDimension = (int)TileTexelSize.Width;
     int numberOfColumns = (int)MapDimensions.Size.Width;
     int numberOfRows = (int)MapDimensions.Size.Height;
     CCPointI world = new CCPointI(0, 0);
     // Tile maps can have multiple layers, so let's loop through all of them:
     foreach (CCTileMapLayer layer in TileLayersContainer.Children)
     {
         // Loop through the columns and rows to find all tiles
         for (int column = 0; column < numberOfColumns; column++)
         {
             // We're going to add tileDimension / 2 to get the position
             // of the center of the tile - this will help us in 
             // positioning entities, and will eliminate the possibility
             // of floating point error when calculating the nearest tile:
             world.X = tileDimension * column + tileDimension / 2;
             for (int row = 0; row < numberOfRows; row++)
             {
                 // See above on why we add tileDimension / 2
                 world.Y = tileDimension * row + tileDimension / 2;
                 tileHandler(world, layer, oldUser, true);
             }
         }
     }
 }