Hi William,
Ok so step by step your saying:
1) instantiate timer on the server
2) send to each player currently ready (once i have more than 1) a time span
object
3) now start the servers timer
4) clients on receiving the timespan object start their timers
5) anyone new joins in this time they are sent the timespan as it stands on
the server at this stage (so maybe 20seconds left), they then start their
timers from there
6) when server hits 0 send the start game to all clients
Thats sounds like a good method, there is one more problem though. my game
can have 3 or 4 games upto 100 going at once. So each game needs its own
timer tracked independantly.
At first thought a TimerManager class springs to mind where i can have every
game running tracked via a unique id number and on a player joining a game i
check which game he/she has joined and return the time details from the
timemanager class for that game.
My only problem is from a design point of view this could get messy. It
would mean i would have to when i instantiate my games do something liek
this:
GameManager.CreateGame("Game1", 1);
TimerManager.Create(1);
where 1 is the unique id.
Ideally i would want the timermanager done inside the gamemanager class but
that class is serialised and sent to the client on connecting so they can
see all the available games. As a result i cant put the timer manager in
there as it would need to be serialisable and i cant serialise a timer.
Anyway round that? I dont want future coders to forget to create a
timermanager for each game, plus they would have to always stay in sync.
Look forward to your views.
"William Stacey [MVP]" <wi************@gmail.com> wrote in message
news:O5**************@TK2MSFTNGP03.phx.gbl...
Send a TimeSpan (say 30 seconds) to all clients. It is a duration in the
future so it will be relative to any timezone or system time. You can't
get
it *exact, but a second or two should not be an issue. If a client comes
in late, then that is just the way the ball bounces. Start your timer on
the server after the last client message is sent so that should give
everyone at least 30 seconds (for example) to connect - the first clients
may wait a tiny bit longer, but that should be ok.
--
William Stacey [MVP]
"Daniel" <Da*****@vestryonline.com> wrote in message
news:ua**************@TK2MSFTNGP03.phx.gbl...
| Hey guys
|
| Here is what i want to do. I have made a multiplayer game that needs to
when
| more than one player is ready start a countdown that the clients can
see,
| so players can still join in this time frame and then after the time
elapses
| the game starts.
|
| I am trying to do it lie this, my server controls all handling of the
game
| logic, deciding who wins, who is next to play etc. For all the players
to
| have their timers showing the same times i have created the timer on the
| server and this time is then serialised as part of the game object that
is
| sent to the clients.
|
| The idea being the clients receive that object and they will then
continue
| to be running the timer their end with it having started at the server
| theoretically making the timers go in sync.
|
| My problem is first of all that System.Timers objects cannot be
serialised.
|
| My second problem is i think this may be flawed, if it takes longer for
data
| to reach one client his timer will start slightly late etc.
|
| Anyone have any ideas how i can do this so all players see the same
timer??
|
| Thanks
|
|