Skip to content

Commit 3308f85

Browse files
committed
update data
1 parent 06886f9 commit 3308f85

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/classcode/NetSnakeClt.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ func (this *NetDataConn) HandleCltProtocol2Snake(protocol2 interface{}, Protocol
3434
func (this *NetDataConn) EntryGameSnake(ProtocolData map[string]interface{}) {
3535
// 进入游戏 进行匹配
3636
fmt.Println("玩家进行匹配!!!")
37+
// 1 匹配算法 --》匹配在线玩家的
38+
39+
// 2 返回数据
40+
data := &Proto2.S2S_PlayerEntryGame{
41+
Protocol: Proto.G_Snake_Proto,
42+
Protocol2: Proto2.S2S_PlayerEntryGameProto2,
43+
RoomID: 1,
44+
MapPlayer: nil,
45+
}
46+
// 发送数据给客户端了
47+
this.PlayerSendMessage(data)
3748
return
3849
}
3950

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/snake/NetRec.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ func HandleCltProtocol2Snake(protocol2 interface{}, ProtocolData map[string]inte
103103
{
104104
fmt.Println("贪吃蛇:玩家进入游戏的协议!!!")
105105
// 玩家进入游戏的协议
106-
// this.EntryGameSnake(ProtocolData)
106+
EntryGameSnake(ProtocolData)
107+
}
108+
case float64(Proto2.S2S_PlayerEntryGameProto2):
109+
{
110+
fmt.Println("贪吃蛇:玩家匹配成功协议!!!")
111+
// 玩家进入游戏的协议
112+
// EntryGameSnake(ProtocolData)
107113
}
108114

109115
default:
@@ -113,4 +119,8 @@ func HandleCltProtocol2Snake(protocol2 interface{}, ProtocolData map[string]inte
113119
return
114120
}
115121

116-
func
122+
func EntryGameSnake(ProtocolData map[string]interface{}) {
123+
StrToken := ProtocolData["Token"].(string)
124+
fmt.Println("贪吃蛇:玩家进入游戏的协议!!!", StrToken)
125+
return
126+
}

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/class3/src/snake/tmain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func init() {
6464
if initNet() {
6565
// 匹配 对战操作
6666
// initMatch(connbak)
67-
initbak()
67+
// initbak() ----bak
6868

6969
return
7070
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package player
2+
3+
// 玩家的结构信息
4+
type PlayerSt struct {
5+
UID int
6+
Name string
7+
HeadURL string
8+
CoinNum int
9+
}

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/vender/src/Proto/Proto2/Proto2Snake.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package Proto2
22

3+
import (
4+
"LollipopGo/LollipopGo/player"
5+
)
6+
37
const (
48
ININSNAKE = iota
59
C2S_PlayerLoginSProto2 // PlayerLoginSProto2 == 1 登陆协议
@@ -47,7 +51,8 @@ type C2S_PlayerEntryGame struct {
4751
type S2S_PlayerEntryGame struct {
4852
Protocol int
4953
Protocol2 int
50-
RoomID int //房间ID
54+
RoomID int //房间ID
55+
MapPlayer map[int]*player.PlayerSt // 玩家的结构信息
5156
}
5257

5358
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)