Exemplo n.º 1
0
        public CollisionController(GameManager gameManager)
        {
            GameManager      = gameManager;
            MoveVector       = Vector2.Zero;
            SurroundingTiles = new Tuple <Vector2, int, Vector2> [8];

            CurrentTile = new CollisionTile(SqrtSize);
            CurrentTile.CalculateTilePos(gameManager.player.Position, 0);
            TileArea = CalculateArea(CurrentTile.A,
                                     CurrentTile.B,
                                     CurrentTile.D,
                                     CurrentTile.C);

            GenerateGrid(gameManager.GameWorld.WorldSize * 4,
                         gameManager.GameWorld.WorldSize * 4);

            // Placing collision tiles in these places below:
            // (feel free to test or remove this)
            Grid[0][0] = new Tuple <Vector2, int>(Grid[0][0].Item1, 1);
            Grid[0][2] = new Tuple <Vector2, int>(Grid[0][2].Item1, 1);
            Grid[0][4] = new Tuple <Vector2, int>(Grid[0][4].Item1, 1);
            Grid[0][6] = new Tuple <Vector2, int>(Grid[0][6].Item1, 1);
            Grid[0][8] = new Tuple <Vector2, int>(Grid[0][8].Item1, 1);

            CalcSurrTiles();
        }
Exemplo n.º 2
0
 private Boolean IsColliding(Player player, CollisionTile collisionTile)
 {
     if ((CalculateArea(player.NextPos, collisionTile.A, collisionTile.D) +
          CalculateArea(player.NextPos, collisionTile.D, collisionTile.C) +
          CalculateArea(player.NextPos, collisionTile.C, collisionTile.B) +
          CalculateArea(player.NextPos, collisionTile.B, collisionTile.A)) < TileArea)
     {
         return(true);
     }
     return(false);
 }