原大逃杀模式初步完成
This commit is contained in:
1 parent
0f9602e900
commit
022fb20674
8 files changed
+107
-86
No files matched your search
+12
-4
@@ -85,14 +85,11 @@ func NewGameCore(db *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gsAppi
|
||||
sign = BigWorldAiSign
|
||||
}
|
||||
r.ai = r.CreateRobot(uid, name, sign)
|
||||
r.isStop = false
|
||||
WORLD_MANAGER.InitAiWorld(r.ai)
|
||||
COMMAND_MANAGER.SetSystem(r.ai)
|
||||
if !r.IsMainGs() {
|
||||
COMMAND_MANAGER.gmCmd.GMUnlockAllPoint(r.ai.PlayerId, 3)
|
||||
}
|
||||
USER_MANAGER.SetRemoteUserOnlineState(BigWorldAiUid, true, mainGsAppid)
|
||||
r.run()
|
||||
r.isStop = false
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -137,6 +134,17 @@ func (g *Game) CreateRobot(uid uint32, name string, sign string) *model.Player {
|
||||
g.PostEnterSceneReq(robot, &proto.PostEnterSceneReq{
|
||||
EnterSceneToken: world.GetEnterSceneToken(),
|
||||
})
|
||||
if uid == BigWorldAiUid {
|
||||
g.EntityForceSyncReq(robot, &proto.EntityForceSyncReq{
|
||||
MotionInfo: &proto.MotionInfo{
|
||||
Pos: &proto.Vector{X: 500.0, Y: 900.0, Z: -500.0},
|
||||
Rot: new(proto.Vector),
|
||||
},
|
||||
EntityId: world.GetPlayerWorldAvatarEntityId(robot, 10000007),
|
||||
})
|
||||
} else {
|
||||
COMMAND_MANAGER.gmCmd.GMUnlockAllPoint(uid, 3)
|
||||
}
|
||||
return robot
|
||||
}
|
||||
|
||||
|
||||
@@ -417,3 +417,15 @@ func (g *GMCmd) SendMsgToPlayer(cmdName string, userId uint32, msgJson string) {
|
||||
}
|
||||
GAME.SendMsg(cmdId, userId, 0, msg)
|
||||
}
|
||||
|
||||
func (g *GMCmd) StartPubg(v bool) {
|
||||
if world := WORLD_MANAGER.GetAiWorld(); WORLD_MANAGER.IsBigWorld(world) {
|
||||
world.StartPubg()
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GMCmd) StopPubg(v bool) {
|
||||
if world := WORLD_MANAGER.GetAiWorld(); WORLD_MANAGER.IsBigWorld(world) {
|
||||
world.StopPubg()
|
||||
}
|
||||
}
|
||||
@@ -136,9 +136,11 @@ func (c *CommandManager) PlayerInputCommand(player *model.Player, targetUid uint
|
||||
func (c *CommandManager) CallGMCmd(funcName string, paramList []string) bool {
|
||||
fn := c.gmCmdRefValue.MethodByName(funcName)
|
||||
if !fn.IsValid() {
|
||||
logger.Error("gm func not valid, func: %v", funcName)
|
||||
return false
|
||||
}
|
||||
if fn.Type().NumIn() != len(paramList) {
|
||||
logger.Error("gm func param num not match, func: %v, need: %v, give: %v", funcName, fn.Type().NumIn(), len(paramList))
|
||||
return false
|
||||
}
|
||||
in := make([]reflect.Value, fn.Type().NumIn())
|
||||
|
||||
@@ -35,7 +35,7 @@ type Pubg struct {
|
||||
areaPointList []*proto.MapMarkPoint // 客户端区域地图坐标列表
|
||||
}
|
||||
|
||||
func (w *World) NewPubg() {
|
||||
func (w *World) StartPubg() {
|
||||
w.pubg = &Pubg{
|
||||
world: w,
|
||||
blueAreaCenterPos: &model.Vector{X: 0.0, Y: 0.0, Z: 0.0},
|
||||
@@ -48,6 +48,13 @@ func (w *World) NewPubg() {
|
||||
areaReduceZSpeed: 0.0,
|
||||
areaPointList: make([]*proto.MapMarkPoint, 0),
|
||||
}
|
||||
w.pubg.RefreshArea()
|
||||
w.chatMsgList = make([]*proto.ChatInfo, 0)
|
||||
}
|
||||
|
||||
func (w *World) StopPubg() {
|
||||
w.pubg = nil
|
||||
TICK_MANAGER.CreateUserTimer(w.GetOwner().PlayerId, UserTimerActionPubgEnd, 30)
|
||||
}
|
||||
|
||||
func (p *Pubg) GetAreaPointList() []*proto.MapMarkPoint {
|
||||
@@ -74,7 +81,7 @@ func (p *Pubg) IsInBlueArea(pos *model.Vector) bool {
|
||||
func (p *Pubg) RefreshArea() {
|
||||
info := ""
|
||||
if p.phase == PUBG_PHASE_START {
|
||||
info = fmt.Sprintf("安全区已出现,当前%v位存活玩家。", len(p.GetAlivePlayerList()))
|
||||
info = fmt.Sprintf("安全区已生成,当前%v位存活玩家。", len(p.GetAlivePlayerList()))
|
||||
p.blueAreaCenterPos = &model.Vector{X: 500.0, Y: 0.0, Z: -500.0}
|
||||
p.blueAreaRadius = 2000.0
|
||||
p.safeAreaCenterPos = &model.Vector{X: 0.0, Y: 0.0, Z: 0.0}
|
||||
|
||||
@@ -174,7 +174,6 @@ func (t *TickManager) userTimerHandle(userId uint32, action int, data []any) {
|
||||
}
|
||||
GAME.ReLoginPlayer(worldPlayer.PlayerId, true)
|
||||
}
|
||||
world.pubg = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,15 +251,11 @@ func (t *TickManager) onDayChange(now int64) {
|
||||
|
||||
func (t *TickManager) onHourChange(now int64) {
|
||||
logger.Info("on hour change, time: %v", now)
|
||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if world.GetPubg() != nil {
|
||||
continue
|
||||
}
|
||||
world.NewPubg()
|
||||
pubg := world.GetPubg()
|
||||
pubg.RefreshArea()
|
||||
if world := WORLD_MANAGER.GetAiWorld(); WORLD_MANAGER.IsBigWorld(world) {
|
||||
if world.GetPubg() != nil {
|
||||
return
|
||||
}
|
||||
world.StartPubg()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,25 +278,19 @@ func (t *TickManager) onTick10Second(now int64) {
|
||||
|
||||
func (t *TickManager) onTick5Second(now int64) {
|
||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||
if WORLD_MANAGER.IsAiWorld(world) {
|
||||
if WORLD_MANAGER.IsBigWorld(world) && world.GetPubg() != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for applyUid := range world.owner.CoopApplyMap {
|
||||
GAME.PlayerDealEnterWorld(world.owner, applyUid, true)
|
||||
}
|
||||
}
|
||||
if world.GetOwner().SceneLoadState == model.SceneEnterDone {
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 多人世界其他玩家的坐标位置广播
|
||||
GAME.WorldPlayerLocationNotify(world)
|
||||
GAME.ScenePlayerLocationNotify(world)
|
||||
}
|
||||
}
|
||||
aiWorld := WORLD_MANAGER.GetAiWorld()
|
||||
if WORLD_MANAGER.IsBigWorld(aiWorld) && aiWorld.GetPubg() != nil {
|
||||
return
|
||||
}
|
||||
for applyUid := range aiWorld.GetOwner().CoopApplyMap {
|
||||
GAME.PlayerDealEnterWorld(aiWorld.GetOwner(), applyUid, true)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TickManager) onTickSecond(now int64) {
|
||||
@@ -310,48 +299,38 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
// 世界里所有玩家的网络延迟广播
|
||||
GAME.WorldPlayerRTTNotify(world)
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
pubg := world.GetPubg()
|
||||
if pubg == nil {
|
||||
continue
|
||||
}
|
||||
pubg.UpdateArea()
|
||||
scene := world.GetSceneById(world.GetOwner().SceneId)
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
if scenePlayer.PlayerId == world.GetOwner().PlayerId {
|
||||
continue
|
||||
}
|
||||
avatarEntityId := world.GetPlayerWorldAvatarEntityId(scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
|
||||
entity := scene.GetEntity(avatarEntityId)
|
||||
if entity.GetFightProp()[constant.FIGHT_PROP_CUR_HP] <= 0.0 {
|
||||
continue
|
||||
}
|
||||
if !pubg.IsInBlueArea(scenePlayer.Pos) {
|
||||
scene := world.GetSceneById(scenePlayer.SceneId)
|
||||
GAME.handleEvtBeingHit(scenePlayer, scene, &proto.EvtBeingHitInfo{
|
||||
AttackResult: &proto.AttackResult{
|
||||
AttackerId: 0,
|
||||
DefenseId: world.GetPlayerWorldAvatarEntityId(scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer)),
|
||||
Damage: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
alivePlayerList := pubg.GetAlivePlayerList()
|
||||
if len(alivePlayerList) <= 1 {
|
||||
if len(alivePlayerList) == 1 {
|
||||
info := fmt.Sprintf("『%v』大吉大利,今晚吃鸡。", alivePlayerList[0].NickName)
|
||||
GAME.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
}
|
||||
TICK_MANAGER.CreateUserTimer(world.GetOwner().PlayerId, UserTimerActionPubgEnd, 30)
|
||||
}
|
||||
}
|
||||
}
|
||||
// // GCG游戏Tick
|
||||
// for _, game := range GCG_MANAGER.gameMap {
|
||||
// game.onTick()
|
||||
// }
|
||||
if world := WORLD_MANAGER.GetAiWorld(); WORLD_MANAGER.IsBigWorld(world) {
|
||||
pubg := world.GetPubg()
|
||||
if pubg == nil {
|
||||
return
|
||||
}
|
||||
pubg.UpdateArea()
|
||||
scene := world.GetSceneById(world.GetOwner().SceneId)
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
if !pubg.IsInBlueArea(scenePlayer.Pos) {
|
||||
GAME.handleEvtBeingHit(scenePlayer, scene, &proto.EvtBeingHitInfo{
|
||||
AttackResult: &proto.AttackResult{
|
||||
AttackerId: 0,
|
||||
DefenseId: world.GetPlayerWorldAvatarEntityId(scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer)),
|
||||
Damage: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
alivePlayerList := pubg.GetAlivePlayerList()
|
||||
if len(alivePlayerList) <= 1 {
|
||||
if len(alivePlayerList) == 1 {
|
||||
info := fmt.Sprintf("『%v』大吉大利,今晚吃鸡。", alivePlayerList[0].NickName)
|
||||
GAME.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
}
|
||||
world.StopPubg()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TickManager) onTick200MilliSecond(now int64) {
|
||||
@@ -374,22 +353,21 @@ func (t *TickManager) onTick100MilliSecond(now int64) {
|
||||
GAME.RestoreCountStaminaHandler(player)
|
||||
}
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
hitList := bulletPhysicsEngine.Update(now)
|
||||
for _, rigidBody := range hitList {
|
||||
scene := world.GetSceneById(rigidBody.sceneId)
|
||||
defAvatarEntity := scene.GetEntity(rigidBody.hitAvatarEntityId)
|
||||
defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetAvatarEntity().GetUid())
|
||||
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
||||
AttackResult: &proto.AttackResult{
|
||||
AttackerId: rigidBody.avatarEntityId,
|
||||
DefenseId: rigidBody.hitAvatarEntityId,
|
||||
Damage: 100,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
if world := WORLD_MANAGER.GetAiWorld(); WORLD_MANAGER.IsBigWorld(world) {
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
hitList := bulletPhysicsEngine.Update(now)
|
||||
for _, rigidBody := range hitList {
|
||||
scene := world.GetSceneById(rigidBody.sceneId)
|
||||
defAvatarEntity := scene.GetEntity(rigidBody.hitAvatarEntityId)
|
||||
defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetAvatarEntity().GetUid())
|
||||
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
||||
AttackResult: &proto.AttackResult{
|
||||
AttackerId: rigidBody.avatarEntityId,
|
||||
DefenseId: rigidBody.hitAvatarEntityId,
|
||||
Damage: 100,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,6 @@ func (w *WorldManager) GetAiWorld() *World {
|
||||
func (w *WorldManager) InitAiWorld(owner *model.Player) {
|
||||
w.aiWorld = w.GetWorldById(owner.WorldId)
|
||||
w.aiWorld.ChangeToMultiplayer()
|
||||
|
||||
if w.IsBigWorld(w.aiWorld) {
|
||||
w.aiWorld.NewPhysicsEngine(w.sceneBlockAoiMap)
|
||||
}
|
||||
|
||||
@@ -152,6 +152,12 @@ func (g *Game) WorldPlayerLocationNotify(world *World) {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
playerWorldLocationInfo.PlayerLoc.Pos = new(proto.Vector)
|
||||
playerWorldLocationInfo.PlayerLoc.Rot = new(proto.Vector)
|
||||
}
|
||||
|
||||
worldPlayerLocationNotify.PlayerWorldLocList = append(worldPlayerLocationNotify.PlayerWorldLocList, playerWorldLocationInfo)
|
||||
}
|
||||
g.SendToWorldA(world, cmd.WorldPlayerLocationNotify, 0, worldPlayerLocationNotify)
|
||||
@@ -179,6 +185,12 @@ func (g *Game) ScenePlayerLocationNotify(world *World) {
|
||||
Z: float32(scenePlayer.Rot.Z),
|
||||
},
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
playerLocationInfo.Pos = new(proto.Vector)
|
||||
playerLocationInfo.Rot = new(proto.Vector)
|
||||
}
|
||||
|
||||
scenePlayerLocationNotify.PlayerLocList = append(scenePlayerLocationNotify.PlayerLocList, playerLocationInfo)
|
||||
// 载具位置
|
||||
for _, entityId := range scenePlayer.VehicleInfo.CreateEntityIdMap {
|
||||
|
||||
@@ -161,11 +161,14 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
|
||||
fightProp := defEntity.GetFightProp()
|
||||
currHp := fightProp[constant.FIGHT_PROP_CUR_HP]
|
||||
if currHp == 0.0 {
|
||||
return
|
||||
}
|
||||
currHp -= attackResult.Damage
|
||||
deltaHp := -attackResult.Damage
|
||||
if currHp < 0 {
|
||||
if currHp < 0.0 {
|
||||
deltaHp -= currHp
|
||||
currHp = 0
|
||||
currHp = 0.0
|
||||
}
|
||||
fightProp[constant.FIGHT_PROP_CUR_HP] = currHp
|
||||
g.EntityFightPropUpdateNotifyBroadcast(scene, defEntity)
|
||||
@@ -177,7 +180,7 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
EntityId: defEntity.GetId(),
|
||||
PropType: constant.FIGHT_PROP_CUR_HP,
|
||||
})
|
||||
if currHp == 0 {
|
||||
if currHp == 0.0 {
|
||||
defAvatarEntity := defEntity.GetAvatarEntity()
|
||||
g.KillPlayerAvatar(player, defAvatarEntity.GetAvatarId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
|
||||
@@ -199,7 +202,7 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
}
|
||||
}
|
||||
case constant.ENTITY_TYPE_MONSTER:
|
||||
if currHp == 0 {
|
||||
if currHp == 0.0 {
|
||||
g.KillEntity(player, scene, defEntity.GetId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
}
|
||||
case constant.ENTITY_TYPE_GADGET:
|
||||
|
||||
Reference in new issue
Block a user