Esempio n. 1
0
        public static void OnDeleteBlockReq(Player player, MemoryStream stream)
        {
            Ultilities.Print("OnDeleteBlockReq");
            CSDeleteBlockReq req = NetworkManager.Deserialize <CSDeleteBlockReq>(stream);

            Vector2Int chunk   = Ultilities.GetChunk(req.position);
            bool       deleted = TerrainData.RemoveBlockInChunk(chunk, req.position);

            CSDeleteBlockRes res = new CSDeleteBlockRes();

            if (deleted)
            {
                res.RetCode  = 0;
                res.position = req.position;
            }
            else
            {
                res.RetCode = 3;
            }
            NetworkManager.Enqueue(player.socket, ENUM_CMD.CS_DELETE_BLOCK_RES, res);
            if (deleted)
            {
                //同步给有该chunk视野的其他玩家
                foreach (Player p in TerrainData.GetChunkViewPlayers(chunk))
                {
                    if (p.id != player.id)
                    {
                        DeleteBlockNotify(p, req.position);
                    }
                }
            }
        }
Esempio n. 2
0
    static void Single_OnDeleteBlockReq(object obj, Action <object> callback)
    {
        CSDeleteBlockReq req = obj as CSDeleteBlockReq;
        CSDeleteBlockRes res = new CSDeleteBlockRes();

        res.RetCode = 0;
        DeleteBlock(req.position.ToVector3Int(), res.position);
        callback(res);
    }
Esempio n. 3
0
    void DeleteBlockReq(Vector3 pos)
    {
        CSDeleteBlockReq req = new CSDeleteBlockReq
        {
            position = new CSVector3Int
            {
                x = Mathf.RoundToInt(pos.x),
                y = Mathf.RoundToInt(pos.y),
                z = Mathf.RoundToInt(pos.z)
            }
        };

        NetworkManager.SendPkgToServer(ENUM_CMD.CS_DELETE_BLOCK_REQ, req, DeleteBlockRes);
    }
Esempio n. 4
0
    static void Single_OnDeleteBlockReq(object obj, Action <object> callback)
    {
        CSDeleteBlockReq req = obj as CSDeleteBlockReq;
        CSDeleteBlockRes res = new CSDeleteBlockRes();

        res.RetCode  = 0;
        res.position = req.position;
        if (dependenceDict.ContainsKey(req.position.ToVector3Int()))
        {
            dependenceDict.Remove(req.position.ToVector3Int());
        }
        if (orientationDict.ContainsKey(req.position.ToVector3Int()))
        {
            orientationDict.Remove(req.position.ToVector3Int());
        }
        callback(res);
    }