Example #1
0
 public void AddMsg(WorlData data)
 {
     lock (messages)
     {
         messages.AddRange(data.datas);
     }
 }
Example #2
0
    /// <summary>
    /// 发送状态
    /// </summary>
    public void sendWorldState()
    {
        // 收集世界的状况。 在一个真实的应用程序中,可以过滤状态以避免泄露数据
        // (例如不可见敌人的位置)
        WorlData world = new WorlData();

        foreach (var entity in entities.Values)
        {
            EntityData ed = new EntityData();
            ed.entity_id            = entity.entity_id;
            ed.position             = entity.x;
            ed.last_processed_input = this.last_processed_input[entity.entity_id];
            world.datas.Add(ed);
        }

        foreach (var item in KcpSessions)
        {
            item.Value.Send <WorlData>(2, world);
        }
    }