Ok, so first you can visit
rozklad-pkp.pl, there you can find train timetable and fares (after you chose connection and click 'Details for selected' hit 'Tariff' below to see fare). Fare in Poland a lot depends on train type you choose, so if it is possible, might be a good idea to avoid expensive ExpressInterCity (EIC), Express (Ex) and EuroCity (EC) trains, but instead use TLK or InterRegio (IR), on the above website you can see a type of train next to every departure. For instance, Krakow-Wroclaw by InterRegio train will cost you just 43 PLN, with TLK 52 PLN, but with EuroCity 103 PLN. And since travel time is almost the same in each case, there is simply no reason to take more expensive train. Same idea with other segments of your trip: Wroclaw-Poznan with EIC train will be 92 PLN, with TLK - 40, while with Regio only 26 PLN. Poznan-Torun is 24 PLN with Regio train, 31 with InterRegio and 38 PLN with TLK
Regarding tickets it is not necessary to buy those in advance, since most of the train don't require obligatory seat reservation, so you can just arrive at the station 10min. or so before departure, buy the ticket and board the train taking any free seat. But in case you do want to buy tickets in advance, then it is possible. For TLK, EIC, Ex and EC train you can do it via
PKP InterCity website (we also created a step by step guide on how to purchase train tickets in Poland with PKP InterCity -
http://europetrainsguide.com/Advice/How-to-Buy-Train-Tickets/Poland-PKP.html ). For InterRegio trains you can purchase ticket via
PKP Regionalne website, but again it doesn't really worth a hassle, you'll spend more time figuring out how to buy online, then buying at the ticket counter already at the station