惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
爱范儿
爱范儿
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
月光博客
月光博客
雷峰网
雷峰网
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
N
Netflix TechBlog - Medium
罗磊的独立博客
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Vulnerabilities – Threatpost
H
Help Net Security
博客园 - 【当耐特】
博客园_首页
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
L
Lohrmann on Cybersecurity
C
Cybersecurity and Infrastructure Security Agency CISA
P
Privacy International News Feed
Blog — PlanetScale
Blog — PlanetScale
C
CERT Recently Published Vulnerability Notes
P
Privacy & Cybersecurity Law Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cyberwarzone
Cyberwarzone
S
Schneier on Security
S
SegmentFault 最新的问题
C
Cyber Attacks, Cyber Crime and Cyber Security
S
Securelist

博客园 - 我们的游戏世界

最新贴图[Sumtec] [公告]Framework组的最新进展[Sumtec] 终于快忙出头了,开了个FTP给大家用[mikespook] 非常抱歉没有为大家做点什么[吹雪] 框架结构图(二)[Sumtec] DGF的详细解说[Sumtec] Framework组的工作报告[Sumtec] 提交了CsharpC&C DEMO的代码在cvs[steeven] 更加详细的ThreadPool测试报告[Sumtec] ThreadPool 测试结果的第一时间发布[Sumtec] GC的一个问题 [Koffer] [工作报告] Framework组的工作报告[Sumtec] [讨论] 分布式计算的Action,我的解决方案[Sumtec] 代码更新了。[Sumtec] Framework组最近的工作报告[Sumtec] 同学们,准备干活了[steeven] [引用资料][转帖] 玩家行为基本模式[[ IceSharK - PP.Poet ]] 微軟用.net開發的遊戲例子 mikespook 你的任务有没有进展啊?[Sumtec]
[游戏]服务器和客户端之间的同步策略[steeven]
我们的游戏世界 · 2004-05-27 · via 博客园 - 我们的游戏世界
  Client                            
  Player{ //Game.Me
1 void CommandA{
  cmd = new Command(methodInfo,args[]);
  server.channel.Send(cmd)
  }
  }
  Unit{
  event LocationChanged;
  ID; //该单元的在游戏中的唯一标志
  OwnerID; //该单元属于谁
  _Location;
  Location{
8 set{
  _Location = value;
  if (LocationChanged != null)
  LocationChanged(this,EventArgs.Empty);
 
 
  }
                                  Server 
  Channel{ //server端,每个channel属于某个用户
  int ID; //Player id
2 void OnCommand{
  server.CommandQueue.Add(ID,cmd);
  }
  }
  Server{
  void Main{
  while(true)
3 if (CommandQueue.count>0)
  processCommand();
  }
4 ProcessCommand(){
  Player p = FindPlayer(CommnadQueue.Peek().ID);
  cmd.method.invoke(p,p.Peek().args)//如果不用reflection,需要一个大的switch
  }
7 BroadcastCommand(players,cmd){
  foreach(p in players)
  p.channel.send(cmd);
  }
  }
  Player{ //注意这里的Player是服务器端
5 void CommandA{
  //check condition
  unit.Location = xxx; '//perform command
  //也许同步策略加到这里
  }
  Unit{
  event LocationChanged;
  ID; //该单元的在游戏中的唯一标志
  OwnerID; //该单元属于谁
  _Location;
  Location{
6 set{
  if (value != _Location){ //发生变化
  IList players = … //同步策略
  Server.Broadcast(players,new command(ID,methodInfo,value));
  }
  _Location = value;
  if (LocationChanged != null) //也可能通过这里注册Location同步策略分析器
  LocationChanged(this,EventArgs.Empty);
 
 
  }
  注释:                                                    
我更希望通过AOP把某些方法自动重定向或者同步到Server/Client端执行,编程上可以简化很多