Skip to content

Instantly share code, notes, and snippets.

@dested
Last active June 13, 2017 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dested/e5ec9f49faba73ae51b9ecf43e1ab94b to your computer and use it in GitHub Desktop.
Save dested/e5ec9f49faba73ae51b9ecf43e1ab94b to your computer and use it in GitHub Desktop.
public class ServerGame : Game
{
public override void MakePlayer()
{
MainPlayer = new ServerPlayer();
}
public void Tick()
{
MainPlayer.ServerThing();//Unavailable without casting
}
}
public abstract class Game
{
public Player MainPlayer { get; set; }
public abstract void MakePlayer();
public void Tick() { }
}
public class ClientGame : Game
{
public override void MakePlayer()
{
MainPlayer = new ClientPlayer();
}
public void Tick()
{
MainPlayer.ClientThing();//Unavailable without casting
}
}
public class ServerPlayer : Player
{
public void ServerThing() { }
}
public abstract class Player
{
}
public class ClientPlayer : Player
{
public void ClientThing() { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment