Ejemplo n.º 1
0
 public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
 {
     validPoints.Clear();
     foreach (Point2 dir in legalMoves)
     {
         Point2 checkPoint = origin + dir;
         if (!checkPointOutOfBounds(checkPoint))
         {
             Tile tileAtPoint = mapProperties.getTile(checkPoint);
             if (checkTileNeutral(tileAtPoint))
             {
                 validPoints.Add(checkPoint);
             }
             else
             {
                 while (checkTileOwned(tileAtPoint) && !checkTileContainsEntity(tileAtPoint))
                 {
                     validPoints.Add(checkPoint);
                     checkPoint += dir;
                     if (checkPointOutOfBounds(checkPoint))
                     {
                         break;
                     }
                     tileAtPoint = mapProperties.getTile(checkPoint);
                 }
             }
         }
     }
     return validPoints;
 }
Ejemplo n.º 2
0
    public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
    {
        validPoints.Clear();
        Point2 checkPoint;
        foreach (Point2 dir in legalMoves)
        {
            checkPoint = origin;
            for (int i = 0; i < attackRange; i++)
            {
                checkPoint += dir;
                if (checkPointOutOfBounds(checkPoint))
                {
                    break;
                }
                print(mapProperties);

                Tile tileAtPoint = mapProperties.getTile(checkPoint);
                if (checkTileContainsObstacle(tileAtPoint))
                {
                    break;
                }
                validPoints.Add(checkPoint);
            }
        }
        return validPoints;
    }
Ejemplo n.º 3
0
    public override bool performAction(Point2 tilePoint, MapProperties mapProperties)
    {
        List<Point2> affectedTiles = getAffectedTiles(getEntity().getCurrentTile().getLocation(), tilePoint, mapProperties);
        foreach (Point2 p in affectedTiles)
        {
            Tile tileAtPoint = mapProperties.getTile(p);
            if (checkTileContainsEnemy(tileAtPoint))
            {
                tileAtPoint.getCurrentEntity().takeDamage();
            }
            tileAtPoint.setTileType(getEntity().entityType);

        }
        return true;
    }
Ejemplo n.º 4
0
 public override List<Point2> getAffectedTiles(Point2 origin, Point2 effectedTile, MapProperties mapProperties)
 {
     Point2 checkPoint = origin;
     List<Point2> affectedTiles = new List<Point2>();
     foreach (Point2 p in legalMoves)
     {
         checkPoint = origin + p;
         if (!checkPointOutOfBounds(checkPoint))
         {
             Tile tileAtPoint = mapProperties.getTile(checkPoint);
             if (!checkTileContainsObstacle(tileAtPoint))
             {
                 affectedTiles.Add(checkPoint);
             }
         }
     }
     return affectedTiles;
 }
Ejemplo n.º 5
0
 public override List<Point2> getAffectedTiles(Point2 origin, Point2 effectedTile, MapProperties mapProperties)
 {
     List<Point2> affectedTiles = new List<Point2>();
     Point2 dir = effectedTile - origin;
     dir.normalizeValues();
     Point2 checkPoint = origin;
     for (int i = 0; i < attackRange; i++)
     {
         checkPoint += dir;
         if (checkPointOutOfBounds(checkPoint))
         {
             break;
         }
         Tile tileAtPoint = mapProperties.getTile(checkPoint);
         if (checkTileContainsObstacle(tileAtPoint))
         {
             break;
         }
         affectedTiles.Add(tileAtPoint.getLocation());
     }
     return affectedTiles;
 }
Ejemplo n.º 6
0
 public override bool performAction(Point2 tilePoint, MapProperties mapProperties)
 {
     foreach (Point2 p in validPoints)
     {
         if (tilePoint == p)
         {
             List<Point2> affectedTiles = getAffectedTiles(getEntity().getCurrentTile().getLocation(), p, mapProperties);
             mapProperties.getTile(affectedTiles[0]).setEntity(null);
             mapProperties.getTile(affectedTiles[1]).setEntity(getEntity());
             return true;
         }
     }
     return false;
 }