public override void DoAction(IEventArgs args) { PlayerEntity p = GetPlayer(args).Player; p.playerMask.SelfMask = (byte)args.GetInt(SelfMask); p.playerMask.TargetMask = (byte)args.GetInt(TargetMask); }
public override void DoAction(IEventArgs args) { int realType = args.GetInt(type); int dis = args.GetInt(distance); int i = 1; UnitPosition up = pos.Select(args); Vector3 target = new Vector3(up.GetX(), up.GetY(), up.GetZ()); foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(args.GameContext.session.commonSession.RoomInfo.MapId).IDPints) { if (p.ID == realType) { foreach (MapConfigPoints.SavedPointData v in p.points) { if (IsNear(v.pos, target, dis)) { TriggerArgs ta = new TriggerArgs(); ta.AddPara(new FloatPara("x", v.pos.x)); ta.AddPara(new FloatPara("y", v.pos.y)); ta.AddPara(new FloatPara("z", v.pos.z)); ta.AddPara(new FloatPara("index", i++)); args.Act(action, ta); } } } } }
public override void DoAction(IEventArgs args) { var re = RoomEvent.AllocEvent <SetRoomStatusEvent>(); re.GameStatus = (ERoomGameStatus)args.GetInt(gameStatus); re.EnterStatus = (ERoomEnterStatus)args.GetInt(enterStatus); args.GameContext.session.serverSessionObjects.RoomEventDispatchter.AddEvent(re); }
public override void DoAction(IEventArgs args) { Initial(); if (index >= 0 && index < actions.Count) { IGameAction action = actions[index]; args.FreeContext.AiSuccess = false; args.FreeContext.OrderComplete = false; action.Act(args); if (frame != null) { frame.Act(args); } if (args.FreeContext.AiSuccess) { index++; } args.FreeContext.AiSuccess = false; if (index == actions.Count) { currentCount++; if (currentCount >= args.GetInt(repeat) && args.GetInt(repeat) > 0) { args.FreeContext.AiSuccess = true; } else { index = 0; } } if (!args.FreeContext.AiSuccess && condition != null && condition.Meet(args)) { index = actions.Count; args.FreeContext.AiSuccess = true; } if (args.FreeContext.OrderComplete) { args.FreeContext.AiSuccess = true; } args.FreeContext.OrderComplete = false; } }
public override void DoAction(IEventArgs args) { PlayerEntity player = GetPlayerEntity(args); Vector3 dropPos = UnityPositionUtil.ToVector3(pos.Select(args)); if (player != null) { RaycastHit hit; Ray ray = new Ray(player.position.Value, dropPos); if (Physics.Raycast(ray, out hit, Vector3.Distance(player.position.Value, dropPos), UnityLayers.SceneCollidableLayerMask)) { RaycastHit vhit; if (Physics.Raycast(hit.point, Vector3.down, out vhit, 10000, UnityLayers.SceneCollidableLayerMask)) { dropPos = vhit.point; } else { dropPos = hit.point; } } } SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args), dropPos); if (entity != null && !string.IsNullOrEmpty(time)) { entity.AddLifeTime(DateTime.Now, args.GetInt(time)); } Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args)); }
public override void DoAction(IEventArgs args) { PlayerEntity player = GetPlayerEntity(args); SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.PlayerPressKey; msg.Bs.Add(args.GetBool(press)); msg.Ss.Add(key); msg.Ins.Add(args.GetInt(time)); FreeMessageSender.SendMessage(player, msg); }
protected override void BuildMessage(IEventArgs args) { builder.Key = args.GetInt(key); if (fields != null) { for (int i = 0; i < fields.Count; i++) { switch (fields[i].type) { case KeyField: builder.Ks.Add(args.GetInt(fields[i].value)); break; case IntField: builder.Ins.Add(args.GetInt(fields[i].value)); break; case BoolField: builder.Bs.Add(args.GetBool(fields[i].value)); break; case StringField: builder.Ss.Add(args.GetString(fields[i].value)); break; case FloatField: builder.Fs.Add(args.GetFloat(fields[i].value)); break; case DoubleField: builder.Ds.Add(args.getDouble(fields[i].value)); break; case LongField: builder.Ls.Add(args.GetLong(fields[i].value)); break; } } } }
public override void DoAction(IEventArgs args) { PlayerEntity player = GetPlayerEntity(args); switch (type) { case (int)KeyType.Press: PlayerInterceptCommands.PressKeys(player, args.GetInt(key), args.GetInt(time)); break; case (int)KeyType.Intercept: PlayerInterceptCommands.InterceptKeys(player, args.GetInt(key), args.GetInt(time)); break; case (int)KeyType.Cancel: PlayerInterceptCommands.ClearKeys(player); break; default: break; } }
public override void DoAction(IEventArgs args) { SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args), UnityPositionUtil.ToVector3(pos.Select(args))); if (entity != null && !string.IsNullOrEmpty(time)) { entity.AddLifeTime(DateTime.Now, args.GetInt(time)); } Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args)); }
public override void DoAction(IEventArgs args) { FreeData fd = GetPlayer(args); int realTime = args.GetInt(time); if (realTime < 0) { fd.EffectBufs.RemoveEffect(args.GetString(effect), args.GetFloat(level)); } else { fd.EffectBufs.AddEffect(args.GetString(effect), args.GetFloat(level), realTime); } }
public override TestValue GetCaseValue(IEventArgs args) { TestValue tv = new TestValue(); FreeData fd = (FreeData)args.GetUnit(UnitTestConstant.Tester); if (fd != null) { EWeaponSlotType currentSlot = fd.Player.WeaponController().HeldSlotType; if (args.GetInt(slot) > 0) { currentSlot = FreeWeaponUtil.GetSlotType(args.GetInt(slot)); } WeaponScanStruct info = fd.Player.WeaponController().HeldWeaponAgent.ComponentScan; tv.AddField("id", info.ConfigId); tv.AddField("clip", info.Bullet); tv.AddField("carryClip", info.ReservedBullet); } return(tv); }
public override TestValue GetCaseValue(IEventArgs args) { TestValue tv = new TestValue(); FreeData fd = (FreeData)args.GetUnit(UnitTestConstant.Tester); if (fd != null) { EWeaponSlotType currentSlot = fd.Player.GetBagLogicImp().GetCurrentWeaponSlot(); if (args.GetInt(slot) > 0) { currentSlot = FreeWeaponUtil.GetSlotType(args.GetInt(slot)); } WeaponInfo info = fd.Player.GetBagLogicImp().GetWeaponInfo(currentSlot); tv.AddField("id", info.Id); tv.AddField("clip", info.Bullet); tv.AddField("carryClip", info.ReservedBullet); } return(tv); }
protected override void BuildMessage(IEventArgs args) { this.scope = "4"; builder.Key = FreeMessageConstant.AirLineData; builder.Bs.Add(false); Vector2 start = ChickenRuleVars.GetAirLineStartPos(args); Vector2 stop = ChickenRuleVars.GetAirLineStopPos(args); int totalTime = args.GetInt("{waitFlyTime}"); int startTime = args.GetInt("{canJumpTime}") / 1000; int forceTime = args.GetInt("{forceJumpTime}") / 1000; Vector2 from = start + (stop - start) * startTime / totalTime; Vector2 to = start + (stop - start) * forceTime / totalTime; Debug.LogFormat("{0} to {1}, {2} {3} {4}", from, to, totalTime, startTime, forceTime); builder.Fs.Add(from.x); builder.Fs.Add(from.y); builder.Fs.Add(to.x); builder.Fs.Add(to.y); }
public override void DoAction(IEventArgs args) { var player = GetPlayerEntity(args); if (null == player) { Logger.Error("player is null"); return; } player.WeaponController().BagLockState = islock; int v = args.GetInt(duration); if (player.hasTime && v > 0) { player.WeaponController().BagOpenLimitTIme = player.time.ClientTime + v; } }
public override void DoAction(IEventArgs args) { long serverTime = args.Rule.ServerTime; if (!string.IsNullOrEmpty(time) && realTime == 0) { realTime = args.GetInt(time); } if (startTime == 0) { startTime = serverTime; timePara = new IntPara(Time, 0); } timePara.SetValue(serverTime - startTime); args.TempUsePara(timePara); if (action != null) { action.Act(args); } if (realTime > 0 && serverTime - startTime >= realTime) { args.FreeContext.AiSuccess = true; startTime = 0; } if (condition != null && condition.Meet(args)) { args.FreeContext.AiSuccess = true; startTime = 0; } args.ResumePara(Time); }
//private List<PlayerEntity> _playerList = new List<PlayerEntity>(); public override void DoAction(IEventArgs args) { IParable unit = args.GetUnit("report"); if (null != unit && unit is SimpleParable) { SimpleParable sp = (SimpleParable)unit; GameOverPlayer goPlayer = (GameOverPlayer)sp.GetFieldObject(0); Dictionary <long, GameOverPlayer> goPlayerList = (Dictionary <long, GameOverPlayer>)sp.GetFieldObject(1); Dictionary <long, IPlayerInfo> playerInfoList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(2); Dictionary <long, IPlayerInfo> leavedInfoList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(3); RankType rankType = (RankType)ranktype; IPlayerInfo playerInfo; playerInfoList.TryGetValue(goPlayer.Id, out playerInfo); if (null == playerInfo) { return; } //逃跑玩家为所有游戏中的玩家的最后一名 if (playerInfo.StatisticsData.IsRunaway) { playerInfo.StatisticsData.Rank = playerInfoList.Count; } //编辑器传来的数据 string[] items = fields.Split(','); foreach (var item in items) { string[] vs = item.Split('='); if (vs.Length > 1) { goPlayer.Statistics[int.Parse(vs[0])] = args.GetInt(vs[1]); } else { Logger.ErrorFormat("字符串解析错误,请检查模式编辑器: {0}", fields); } } //团战模式填入两项人数参数 if (rankType == RankType.Group) { int playerCountRate = 0; int teamCountRate = 0; foreach (IPlayerInfo ipi in playerInfoList.Values) { if (ipi.StatisticsData.GameTime >= 3 * 60 * 1000) { playerCountRate++; } if (ipi.Camp == playerInfo.Camp) { teamCountRate++; } } foreach (IPlayerInfo ipi in leavedInfoList.Values) { if (ipi.StatisticsData.GameTime >= 3 * 60 * 1000) { playerCountRate++; } } goPlayer.Statistics[(int)EStatisticsID.ModePlayerCount] = teamCountRate; goPlayer.Statistics[(int)EStatisticsID.SectionPlayerCount] = playerCountRate; } if (issend) { switch (rankType) { case RankType.Group: if (!playerInfo.StatisticsData.IsRunaway) { List <IPlayerInfo> playerSortList = playerInfoList.Values.ToList(); GroupRank(playerSortList); } break; case RankType.Survival: if (args.GameContext.session.commonSession.RoomInfo.ModeId != GameRules.SoloSurvival) { SurvivalRank(playerInfoList.Values.ToList().Union(leavedInfoList.Values.ToList()).ToList(), goPlayerList); Logger.InfoFormat("组队吃鸡模式对玩家进行了排名"); } break; default: break; } goPlayer.Statistics[(int)EStatisticsID.Rank] = playerInfo.StatisticsData.Rank; goPlayer.Statistics[(int)EStatisticsID.RankAce] = playerInfo.StatisticsData.Rank == 1 ? 1 : 0; goPlayer.Statistics[(int)EStatisticsID.RankTen] = playerInfo.StatisticsData.Rank <= 10 ? 1 : 0; } else { //不算逃跑的离开玩家的数据保存,否则丢弃数据 if (!playerInfo.StatisticsData.IsRunaway && rankType == RankType.Survival) { GameOverPlayer savedGoPlayer = goPlayer.Clone(); if (goPlayerList.ContainsKey(savedGoPlayer.Id)) { Logger.ErrorFormat("房间GameOverPlayer列表中出现重复ID {0}", savedGoPlayer.Id); } else { goPlayerList.Add(savedGoPlayer.Id, savedGoPlayer); } } //不报告的情况下,将GameOverPlayer ID设为0 goPlayer.Id = 0L; } Logger.InfoFormat("Player {0} reported, Rank {1}", goPlayer.Id, goPlayer.Statistics[1]); } }
public override void DoAction(IEventArgs args) { var contexts = args.GameContext; var player = GetPlayerEntity(args); var factory = contexts.session.entityFactoryObject.SceneObjectEntityFactory; var slot = (EWeaponSlotType)slotIndex; var lastWeaponScan = player.WeaponController().GetWeaponAgent(slot).ComponentScan; bool generateSceneObj = player.WeaponController().DropWeapon(slot); if (!generateSceneObj || lastWeaponScan.IsUnSafeOrEmpty()) { return; } var unitPos = pos.Select(args); SceneObjectEntity weapon; if (fixDrop) { weapon = factory.CreateDropSceneWeaponObjectEntity(lastWeaponScan, unitPos.Vector3, args.GetInt(lifeTime)) as SceneObjectEntity; } else { weapon = factory.CreateDropSceneWeaponObjectEntity(lastWeaponScan, player, args.GetInt(lifeTime), null) as SceneObjectEntity; } if (null != weapon) { TriggerArgs ta = new TriggerArgs(); ta.AddPara(new IntPara("weaponId", lastWeaponScan.ConfigId)); ta.AddPara(new FloatPara("weaponx", weapon.position.Value.x)); ta.AddPara(new FloatPara("weapony", weapon.position.Value.y)); ta.AddPara(new FloatPara("weaponz", weapon.position.Value.z)); ta.AddUnit("current", (FreeData)player.freeData.FreeData); args.Trigger(FreeTriggerConstant.WEAPON_DROP, ta); } }
public override void DoAction(IEventArgs args) { IParable unit = args.GetUnit("report"); if (null != unit && unit is SimpleParable) { SimpleParable sp = (SimpleParable)unit; GameOverPlayer goPlayer = (GameOverPlayer)sp.GetFieldObject(0); Dictionary <long, GameOverPlayer> goPlayerList = (Dictionary <long, GameOverPlayer>)sp.GetFieldObject(1); Dictionary <long, IPlayerInfo> playerInfoList = new Dictionary <long, IPlayerInfo>(); Dictionary <long, IPlayerInfo> leavedInfoList = new Dictionary <long, IPlayerInfo>(); Dictionary <long, IPlayerInfo> infoList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(2); Dictionary <long, IPlayerInfo> leftList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(3); int TeamCapacity = (int)sp.GetFieldObject(4); Logger.InfoFormat("reporting player {0}, totoal player {1}, left player {2}", goPlayer.Id, infoList.Count, leftList.Count); RankType rankType = (RankType)ranktype; IPlayerInfo playerInfo; playerInfoList.TryGetValue(goPlayer.Id, out playerInfo); if (null == playerInfo) { Logger.InfoFormat("no IPlayerInfo of player {0}", goPlayer.Id); return; } //移除缺少数据的玩家 IPlayerInfo availablePlayer; List <long> keys = infoList.Keys.ToList(); foreach (long key in keys) { infoList.TryGetValue(key, out availablePlayer); if (availablePlayer == null || availablePlayer.StatisticsData == null) { Logger.InfoFormat("player {0} info not available", key); continue; } playerInfoList.Add(key, availablePlayer); } keys = leftList.Keys.ToList(); foreach (long key in keys) { leftList.TryGetValue(key, out availablePlayer); if (availablePlayer == null || availablePlayer.StatisticsData == null) { Logger.InfoFormat("left player {0} info not available", key); continue; } leavedInfoList.Add(key, availablePlayer); } //逃跑玩家为所有游戏中的玩家的最后一名 if (playerInfo.StatisticsData.IsRunaway) { playerInfo.StatisticsData.Rank = playerInfoList.Count; } //编辑器传来的数据 if (!string.IsNullOrEmpty(fields)) { string[] items = fields.Split(','); foreach (var item in items) { string[] vs = item.Split('='); if (vs.Length > 1) { goPlayer.Statistics[int.Parse(vs[0])] = args.GetInt(vs[1]); } else { Logger.ErrorFormat("字符串解析错误,请检查模式编辑器: {0}", fields); } } } //团战模式填入两项人数参数 if (rankType == RankType.Group) { int playerCountRate = 0; int teamCountRate = 0; foreach (IPlayerInfo ipi in playerInfoList.Values) { if (ipi.StatisticsData.GameJoinTime > 0 && args.Rule.ServerTime - ipi.StatisticsData.GameJoinTime >= 180000L) { playerCountRate++; } if (ipi.Camp == playerInfo.Camp) { teamCountRate++; } Logger.InfoFormat("player id {0} camp {1} game join time {2} played time {3}", ipi.PlayerId, ipi.Camp, ipi.StatisticsData.GameJoinTime, args.Rule.ServerTime - ipi.StatisticsData.GameJoinTime); } Logger.InfoFormat("game total player count {0} report send {1}", playerInfoList.Count, issend); goPlayer.Statistics[(int)EStatisticsID.ModePlayerCount] = teamCountRate; goPlayer.Statistics[(int)EStatisticsID.SectionPlayerCount] = playerCountRate; } if (issend) { switch (rankType) { case RankType.Group: if (!playerInfo.StatisticsData.IsRunaway) { List <IPlayerInfo> playerSortList = playerInfoList.Values.ToList(); GroupRank(playerSortList, playerInfo, TeamCapacity > 1); } break; case RankType.Survival: int modeId = args.GameContext.session.commonSession.RoomInfo.ModeId; if (modeId != GameRules.SoloSurvival && modeId != GameRules.LadderSoloSurvival && modeId != GameRules.AbyssSoloSurvival) { SurvivalRank(playerInfoList.Values.ToList().Union(leavedInfoList.Values.ToList()).ToList(), goPlayerList, args, playerInfo); } break; default: break; } goPlayer.Statistics[(int)EStatisticsID.Rank] = playerInfo.StatisticsData.Rank; goPlayer.Statistics[(int)EStatisticsID.RankAce] = playerInfo.StatisticsData.Rank == 1 ? 1 : 0; goPlayer.Statistics[(int)EStatisticsID.RankTen] = playerInfo.StatisticsData.Rank <= 10 ? 1 : 0; } else { //不算逃跑的离开玩家的数据保存,否则丢弃数据 if (!playerInfo.StatisticsData.IsRunaway && rankType == RankType.Survival) { GameOverPlayer savedGoPlayer = goPlayer.Clone(); if (goPlayerList.ContainsKey(savedGoPlayer.Id)) { Logger.ErrorFormat("房间GameOverPlayer列表中出现重复ID {0}", savedGoPlayer.Id); } else { goPlayerList.Add(savedGoPlayer.Id, savedGoPlayer); } } //不报告的情况下,将GameOverPlayer ID设为0 goPlayer.Id = 0L; } } }