Ejemplo n.º 1
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));
            }
        }
    }
Ejemplo n.º 2
0
 public int getCharacterPositionX(GeneticCharacter c)
 {
     return(Mathf.RoundToInt(c.getPosX()));
 }