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

推荐订阅源

H
Hacker News: Front Page
A
About on SuperTechFans
腾讯CDC
罗磊的独立博客
博客园 - Franky
Last Week in AI
Last Week in AI
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
云风的 BLOG
云风的 BLOG
L
LangChain Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
D
Docker
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recorded Future
Recorded Future
Vercel News
Vercel News
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
J
Java Code Geeks
有赞技术团队
有赞技术团队
V
V2EX
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
Jina AI
Jina AI
B
Blog RSS Feed
H
Help Net Security
N
Netflix TechBlog - Medium
Latest news
Latest news
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
C
Cisco Blogs
Microsoft Security Blog
Microsoft Security Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
P
Proofpoint News Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
T
Threatpost

博客园 - 我们的游戏世界

最新贴图[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端执行,编程上可以简化很多