Beispiel #1
0
 public float getCharacterPositionCost(GeneticCharacter c)
 {
     if (this.mapModel != null)
     {
         return(this.mapModel.getCharacterPositionCost(c));
     }
     else
     {
         return(float.MaxValue);
     }
 }
Beispiel #2
0
    /*
     * CHARACTERS
     */
    public void characterMove(GeneticCharacter c, float newX, float newY)
    {
        int new_x = Mathf.RoundToInt(newX);
        int new_y = Mathf.RoundToInt(newY);

        // Check if the new Position is a valid Tile
        if (this.isUsefulPosition(new_x, new_y))
        {
            int old_x    = Mathf.RoundToInt(c.getPosX());
            int old_y    = Mathf.RoundToInt(c.getPosY());
            int oldIndex = this.graphIndexFromTile(old_x, old_y);
            int newIndex = this.graphIndexFromTile(new_x, new_y);

            // Check if there is a edge between the new Position and the old one
            if (this.graph.isAdjacent(oldIndex, newIndex) != null)
            {
                c.setPos(new Vector2(new_x, new_y));
            }
        }
    }
Beispiel #3
0
 public float getCharacterPositionCost(GeneticCharacter c)
 {
     return(this.mapTiles[getCharacterPositionY(c)][getCharacterPositionX(c)].VertexCost);
 }
Beispiel #4
0
 private bool checkCharacterPosition(GeneticCharacter c)
 {
     return(this.isUsefulPosition(getCharacterPositionX(c), getCharacterPositionY(c)));
 }
Beispiel #5
0
 public int getCharacterGraphPosition(GeneticCharacter c)
 {
     return(this.graphIndexFromTile(getCharacterPositionX(c), getCharacterPositionY(c)));
 }
Beispiel #6
0
 public int getCharacterPositionY(GeneticCharacter c)
 {
     return(Mathf.RoundToInt(c.getPosY()));
 }