public void ReDraw(ISkillArgs args, ItemInventory inventory, bool includeBack) { SimpleProto sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.InventoyUI; // 0 重绘,1 添加,2 删除, 3 更新 sp.Ks.Add(0); sp.Bs.Add(true); sp.Ks.Add(inventory.posList.Count); foreach (ItemPosition ip in inventory.posList) { FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey()); sp.Ins.Add(info.cat); sp.Ins.Add(info.id); sp.Ins.Add(ip.GetCount()); sp.Ss.Add(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY()); } FreeData fd = (FreeData)args.GetUnit("current"); sp.Ks.Add((int)BagCapacityUtil.GetCapacity(fd)); sp.Ks.Add((int)Math.Ceiling(BagCapacityUtil.GetWeight(fd))); SendMessageAction.sender.SendMessage(args, sp, 1, "current"); ChickenFuncUtil.UpdateBagCapacity(args, (int)Math.Ceiling(BagCapacityUtil.GetWeight(fd)), BagCapacityUtil.GetCapacity(fd)); }
public void Handle(SimpleProto data) { if (data.Bs[1] == true) { data.Bs[1] = false; SingletonManager.Get <FreeUiManager>().CacheUI(data.Ss[0], data); } else { var ui = Build(data); var old = SingletonManager.Get <FreeUiManager>().GetUi(ui.Key); if (old != null) { old.IsDisabled = true; SingletonManager.Get <FreeUiManager>().RemoveUi(old); Object.Destroy(old.gameObject); } SingletonManager.Get <FreeUiManager>().AddUi(ui); if (ui.AtBottom) { ui.gameObject.transform.SetSiblingIndex(0); } } }
/// <summary> /// 手雷加入背包 /// </summary> /// <param name="args"></param> private void HandleAddGrenade(IEventArgs args) { PlayerEntity playerEntity = ((FreeRuleEventArgs)args).GetPlayer(FreeArgConstant.PlayerCurrent); if (playerEntity != null) { int itemId = FreeUtil.ReplaceInt(ParaItemId, args); int count = FreeUtil.ReplaceInt(ParaItemCount, args); for (int i = 0; i < count; i++) { var helper = playerEntity.WeaponController().GrenadeHelper; playerEntity.WeaponController().TryHoldGrenade(itemId); SimpleProto message = new SimpleProto(); message.Ks.Add(8); message.Ins.Add(itemId); message.Bs.Add(true); message.Key = FreeMessageConstant.ChangeAvatar; FreeMessageSender.SendMessage(playerEntity, message); //playerEntity.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message); } } }
public SimpleProto ToMessage() { SimpleProto msg = FreePool.Allocate(); msg.Ins.Add(team); msg.Ins.Add(id); msg.Ins.Add(honor); msg.Ins.Add(kill); msg.Ins.Add(dead); msg.Ins.Add(assist); msg.Ins.Add(damage); msg.Ins.Add(ping); msg.Ins.Add(c4PlantCount); msg.Ins.Add(c4DefuseCount); msg.Ins.Add(badgeId); msg.Ins.Add(hitDownCount); msg.Ins.Add(resqueCount); msg.Bs.Add(isDead); msg.Bs.Add(hasC4); msg.Bs.Add(isHurt); msg.Ss.Add(name); msg.Ss.Add(teamName); return(msg); }
public override SimpleProto CreateChildren(IEventArgs args) { SimpleProto b = FreePool.Allocate(); b.Key = 1; return(b); }
public static void SendOpenSpecifyUIMessageS(PlayerEntity playerEntity) { SimpleProto sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.OpenSpecifyUI; SendMessage(playerEntity, sp); }
public void SimpleDataChanged(SimpleProto sp) { var method = sp.Key; var source = sp.Ss[0]; var key = GetKey(method, source); if (!_dic.ContainsKey(key)) { _dic[key] = new List <SimpleProto>(); } if (!_id2SourceDic.ContainsKey(method)) { _id2SourceDic[method] = new List <string>(); } _id2SourceDic[method].Add(source); var vec = _dic[key]; if (vec.Count < 10000) { vec.Add(sp); } _changeDic[key] = true; }
public void Handle(SimpleProto sp) { //if (clearTime == null) //{ // clearTime = new Dictionary<int, long>(); // notDone = new List<SimpleProto>(); //} //if (simpleUI.Ks.Count > 0 && simpleUI.Ks[0] == 5) //{ // HandleVisible(simpleUI, true); //} //else //{ // Handle(simpleUI, true); //} Contexts contexts = SingletonManager.Get <FreeUiManager>().Contexts1; var ui = contexts.ui.uI; ui.ChickenBagItemDataList = new List <IBaseChickenBagItemData>(); for (int i = 0; i < sp.Ks[1]; i++) { ChickenBagItemUiData data = new ChickenBagItemUiData(); data.cat = sp.Ins[i * 3]; data.id = sp.Ins[i * 3 + 1]; data.count = sp.Ins[i * 3 + 2]; ui.ChickenBagItemDataList.Add(data); data.key = sp.Ss[i]; } ui.TotalBagWeight = sp.Ks[2]; ui.CurBagWeight = sp.Ks[3]; }
private static bool HandleVisible(SimpleProto data, bool addNotDone) { int weaponKey = data.Ins[0]; bool show = data.Bs[0]; string pargs = data.Ss[0]; foreach (string part in pargs.Split(",")) { GameObject obj = GetGameObject(weaponKey, part.Trim()); if (obj != null) { obj.SetActive(show); } else { if (addNotDone) { notDone.Add(data); } return(false); } } return(true); }
public void Handle(SimpleProto simpleUI) { // var battleModel:BattleModel = GameModelLocator.getInstance().gameModel; var v = simpleUI.Ins[0]; // GlobalVars.allowMouseKeys = v; }
public static void HandleNoeDone() { if (notDone == null) { notDone = new List <SimpleProto>(); } for (int i = notDone.Count - 1; i >= 0; i--) { SimpleProto data = notDone[i]; if (data.Ks.Count > 0 && data.Ks[0] == 5) { if (HandleVisible(data, false)) { notDone.Remove(data); } } else { if (Handle(data, false)) { notDone.Remove(data); } } } }
public void Handle(SimpleProto data) { Contexts contexts = SingletonManager.Get <FreeUiManager>().Contexts1; var selfEntity = contexts.player.flagSelfEntity; var ui = contexts.ui.uI; var type = data.Ins[0]; var x = data.Fs[0]; var y = data.Fs[1]; var z = data.Fs[2]; var key = data.Ss[0]; var supplyPosMap = contexts.ui.map.SupplyPosMap; switch (type) { case (int)EMiniMapSupplyMark.SupplyAdd: MapFixedVector3 pos; if (!supplyPosMap.TryGetValue(key, out pos)) { supplyPosMap.Add(key, new MapFixedVector3(x, y, z)); } break; case (int)EMiniMapSupplyMark.SupplyRemove: supplyPosMap.Remove(key); break; case (int)EMiniMapSupplyMark.SupplyClear: supplyPosMap.Clear(); break; } }
private ItemBar AddItem(BagItem item, string key, string eventKey, string count) { ItemBar bar = new ItemBar(); SimpleProto model = SingletonManager.Get <FreeUiManager>().GetUIData(key); if (model == null) { Debug.LogWarningFormat("item '{0}' is not defined.", key); return(null); } FreePrefabComponent ff = new FreePrefabComponent(); ff.parentObject = parentBag; int realCount = 1; if (!string.IsNullOrEmpty(count)) { realCount = int.Parse(count); } TipUtil.AddTip(eventKey, new TipData(item.cat, item.id, realCount)); ff.Initial(model.Ss[2], model.Ss[3]); ff.SetValues("TEXT_ItemNumber" + FreeMessageConstant.SpilterField + count); ff.SetEvents(""); ff.SetAllEventKey(eventKey); bar.prefab = ff; bar.value = model.Ss[2].Split(FreeMessageConstant.SpliterStyle)[1]; return(bar); }
public void Handle(SimpleProto sp) { var totalTime = sp.Ks[0]; var key = sp.Ss[0]; var effect = SingletonManager.Get <FreeEffectManager>().GetEffect(key); if (effect != null) { if (sp.Fs.Count == 3) { effect.Move(sp.Fs[0], sp.Fs[1], sp.Fs[2]); } if (totalTime < 0) { effect.Visible = false; } else { effect.Visible = true; effect.Show(totalTime); } } }
private void HandleScore(IEventArgs args) { if (code == "WaitInfo") { SimpleProto message = FreePool.Allocate(); message.Key = FreeMessageConstant.ScoreInfo; message.Ks.Add(1); message.Ins.Add(FreeUtil.ReplaceInt("{playerCount}", args)); //Debug.Log(message.ToString()); SendMessageAction.sender.SendMessage(args, message, 4, string.Empty); } else if (code == "ScoreInfo") { SimpleProto message = FreePool.Allocate(); message.Key = FreeMessageConstant.ScoreInfo; message.Ks.Add(2); message.Bs.Add(true); message.Ins.Add(FreeUtil.ReplaceInt("{current.killNum}", args)); message.Ins.Add(FreeUtil.ReplaceInt("{startPlayerCount}", args)); //Debug.Log(message.ToString()); SendMessageAction.sender.SendMessage(args, message, 1, "current"); } }
public override void DoAction(IEventArgs args) { PlayerEntity player = GetPlayerEntity(args); if (player == null) { return; } if (args.Rule.ServerTime - player.statisticsData.Statistics.LastDeadTime <= 2900L) { return; } int oldObserveId = player.gamePlay.CameraEntityId; bool success = ObservePlayer(args, player, args.GetBool(observeEnemy), args.GetBool(wise)); if (!success) { if (noOneAction != null) { noOneAction.Act(args); } } if (oldObserveId != player.gamePlay.CameraEntityId) { SimpleProto sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.PlayerObserveTrigger; sp.Bs.Add(true); FreeMessageSender.SendMessage(player, sp); } }
public void Handle(SimpleProto data) { int ani = data.Ins[0]; var contexts = SingletonManager.Get <FreeUiManager>().Contexts1; PlayerAnimationAction.DoAnimation(contexts, ani, contexts.player.flagSelfEntity, false); }
public void Handle(SimpleProto data) { PlayerEntity player = SingletonManager.Get <FreeUiManager>().Contexts1.player.flagSelfEntity; if (player != null) { FreeData fd = (FreeData)player.freeData.FreeData; if (fd != null) { byte[] bs = new byte[data.Ins.Count]; for (int i = 0; i < bs.Length; i++) { bs[i] = (byte)data.Ins[i]; } try { List <ISkill> skills = (List <ISkill>)SerializeUtil.ByteToObject(bs); foreach (var skill in skills) { fd.GetUnitSkill().AddSkill(skill); } }catch (Exception e) { _logger.ErrorFormat("client skill initial failed.\n{0}", e.StackTrace); } } } }
public static void SendOpenSpecifyUIMessageC(PlayerEntity playerEntity) { SimpleProto openUIProto = FreePool.Allocate(); openUIProto.Key = FreeMessageConstant.OpenSpecifyUI; SendMessageC(playerEntity, openUIProto); }
public override void DoAction(IEventArgs args) { if (inter) { if (fd != null) { fd.freeInventory.StopUseItem(args, fd, inter); SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word72," + ip.key.GetName()); FreeMessageSender.SendMessage(fd.Player, msg); PlayerAnimationAction.DoAnimation(args.GameContext, PlayerAnimationAction.Stop, fd.Player); //FreeSoundUtil.Stop("use", args, fd); PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay); PlayerStateUtil.RemoveGameState(EPlayerGameState.UseItem, fd.Player.gamePlay); } } else { if (ip != null && fd != null) { UseItem(ip, fd, (ISkillArgs)args); fd.freeInventory.StopUseItem(args, fd, inter); PlayerAnimationAction.DoAnimation(args.GameContext, PlayerAnimationAction.Interrupt, fd.Player); PlayerStateUtil.RemoveGameState(EPlayerGameState.UseItem, fd.Player.gamePlay); } } }
public void Handle(SimpleProto simpleUI) { var ft = simpleUI.Ss[0]; var map = new Dictionary <string, IList <string> >(); for (var i = 1; i < simpleUI.Ss.Count - 1; i = i + 3) { var lang = simpleUI.Ss[i]; var type = simpleUI.Ss[i + 1]; var tip = simpleUI.Ss[i + 2]; if (type == TYPE_DESC) { ModeTips.SetDesc(lang, ft, tip); } else { if (!map.ContainsKey(lang)) { map.Add(lang, new List <string>()); } map[lang].Add(tip); } } foreach (var lang in map.Keys) { ModeTips.AddTip(lang, ft, map[lang]); } }
public void Update(IEventArgs args) { foreach (string key in currentBufs.Keys) { List <EffectBuf> list = currentBufs[key]; for (int i = list.Count - 1; i >= 0; i--) { if (args.Rule.ServerTime - list[i].startTime > list[i].time && list[i].time > 0) { list.Remove(list[i]); } } } float[] effects = new float[lastEffects.Length]; foreach (string key in currentBufs.Keys) { List <EffectBuf> list = currentBufs[key]; if (list.Count > 0) { EffectBuf buf = currentBufs[key][0]; effects[(int)buf.type] += buf.level; } } for (int i = 0; i < effects.Length; i++) { float last = lastEffects[i]; float current = effects[i]; if (last != current) { SimpleProto sp = null; switch ((EffectType)i) { case EffectType.SpeedUp: player.stateInterface.State.SetSpeedAffect(current); sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.PlayerMoveSpeedSet; sp.Fs.Add(current); FreeMessageSender.SendMessage(player, sp); break; case EffectType.SlowDown: player.stateInterface.State.SetSpeedAffect(current * -1); sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.PlayerMoveSpeedSet; sp.Fs.Add(current * -1); FreeMessageSender.SendMessage(player, sp); break; default: break; } } } lastEffects = effects; }
public override void DoAction(IEventArgs args) { if (string.IsNullOrEmpty(this.player)) { this.player = "current"; } var unit = GetPlayer(args); if (skills != null && unit != null) { foreach (var skill in skills) { unit.GetUnitSkill().AddSkill((ISkill)SerializeUtil.Clone(skill)); } byte[] bs = SerializeUtil.ObjectToByte(skills); SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ClientSkill; for (int i = 0; i < bs.Length; i++) { msg.Ins.Add(bs[i]); } FreeMessageSender.SendMessage(unit.Player, msg); } }
public void Handle(SimpleProto data) { Contexts contexts = SingletonManager.Get <FreeUiManager>().Contexts1; var ui = contexts.ui.uI; // 显示更新 if (data.Bs[0]) { // 显示并更新 if (data.Bs[1]) { contexts.ui.uISession.UiState[UiNameConstant.ChickenPlaneModel] = true; ui.CurPlayerCountInPlane = data.Ins[0]; ui.TotalPlayerCountInPlane = data.Ins[1]; } else { // 只更新 ui.CurPlayerCountInPlane = data.Ins[0]; ui.TotalPlayerCountInPlane = data.Ins[1]; } } else { // 隐藏 contexts.ui.uISession.UiState[UiNameConstant.ChickenPlaneModel] = false; } }
public override void DoAction(IEventArgs args) { if (string.IsNullOrEmpty(player)) { player = "current"; } FreeRuleEventArgs fr = (FreeRuleEventArgs)args; PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player); IParable item = args.GetUnit("item"); if (playerEntity != null && item != null) { SimpleProto message = FreePool.Allocate(); message.Key = FreeMessageConstant.ChangeAvatar; int itemId = FreeUtil.ReplaceInt("{item.itemId}", args); if (takeoff) { TakeOff(playerEntity, itemId); } else { PutOn(playerEntity, itemId); } ReduceDamageUtil.UpdateArmorAndHelmet((FreeData)playerEntity.freeData.FreeData); } }
protected override void InternalExecute() { var player = _contexts.player.flagSelfEntity; var controller = player.WeaponController(); if (!player.gamePlay.IsLifeState(EPlayerLifeState.Alive) || !player.gamePlay.CanAutoPick()) { return; } Collider[] colliders = Physics.OverlapCapsule(player.position.Value, player.bones.Head.position, 0.4f, UnityLayerManager.GetLayerMask(EUnityLayerName.UserInputRaycast)); foreach (Collider collider in colliders) { var rcTar = collider.transform.GetComponentInParent <RayCastTarget>(); if (rcTar == null) { continue; } if (SingletonManager.Get <GameModeConfigManager>().GetBagTypeById(_contexts.session.commonSession.RoomInfo.ModeId) == EBagType.Chicken) { var target = _contexts.sceneObject.GetEntityWithEntityKey(new EntityKey(rcTar.IdList[1], (short)EEntityType.SceneObject)); if (target.simpleItem.Category == (int)ECategory.Weapon && player.WeaponController().FilterAutoPickup(target.simpleItem.Id)) { var model = target.hasUnityObject ? target.unityObject.UnityObject : target.multiUnityObject.FirstAsset; if (CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, target.position.Value, model)) { continue; } SimpleProto pickUp = FreePool.Allocate(); pickUp.Key = FreeMessageConstant.PickUpItem; pickUp.Ins.Add(rcTar.IdList[1]); pickUp.Ins.Add(target.simpleItem.Category); pickUp.Ins.Add(target.simpleItem.Id); pickUp.Ins.Add(1); player.network.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, pickUp); } } else { _userCmdGenerator.SetUserCmd((userCmd) => { if (!userCmd.AutoPickUpEquip.Contains(rcTar.IdList[1])) { userCmd.AutoPickUpEquip.Add(rcTar.IdList[1]); } }); } } if (controller.AutoThrowing.HasValue && controller.AutoThrowing.Value) { if (null != _userCmdGenerator && controller.RelatedThrowAction.IsReady == true) { _userCmdGenerator.SetUserCmd((userCmd) => { userCmd.IsThrowing = true; }); controller.AutoThrowing = false; } } }
public void Handle(SimpleProto simpleUI) { var near = simpleUI.Fs[0]; var far = simpleUI.Fs[1]; var colorString = simpleUI.Ss[0]; var density = simpleUI.Fs[2]; var fogId = simpleUI.Ins[0]; var close = simpleUI.Bs[0]; Color color; ColorUtility.TryParseHtmlString(string.Format("#{0}", colorString), out color); _logger.DebugFormat("Fog close {0} fogId {1} near {2} far {3} color {4} colorString {6} density {5}", close, fogId, near, far, color, density, colorString); var fog = SingletonManager.Get <FogManager>().GetFog(fogId); if (close && fog != null) { SingletonManager.Get <FogManager>().RemoveFog(fogId); return; } if (!close) { } }
private void StopSave(PlayerEntity playerEntity, bool isInterrupted) { if (SharedConfig.IsServer) { playerEntity.gamePlay.SaveTime = 0; if (playerEntity.gamePlay.IsSave) { PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.RescueEnd, playerEntity, true); playerEntity.gamePlay.IsSave = false; } if (playerEntity.gamePlay.IsBeSave) { if (!isInterrupted) { playerEntity.gamePlay.IsStandPosture = false; //PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.Revive, playerEntity, true); } playerEntity.gamePlay.IsBeSave = false; } SimpleProto data = FreePool.Allocate(); data.Key = FreeMessageConstant.CountDown; data.Bs.Add(false); data.Fs.Add(0); data.Bs.Add(!isInterrupted); if (isInterrupted) { data.Ins.Add((int)ETipType.CanNotRescure); } FreeMessageSender.SendMessage(playerEntity, data); } }
public void Handle(SimpleProto data) { if (null != data) { int positionHandler = data.Ins[0]; Contexts contexts = SingletonManager.Get <FreeUiManager>().Contexts1; if (positionHandler == (int)EPositionHandler.EPosition_Init) { string type = data.Ss[0]; int mapId = contexts.session.commonSession.RoomInfo.MapId; Clear(); TestPositionManager.IniTable(mapId, type); List <TestPosition> testPositions = TestPositionManager.GetTestPositions(); for (int i = 0, maxi = (null == testPositions ? 0 : testPositions.Count); i < maxi; i++) { TestPosition testPosition = testPositions[i]; Vector3 position = new Vector3(testPosition.x, testPosition.y, testPosition.z); float rotation = testPosition.rotation; string timeStamp = testPosition.time; CreateGameObject(position, rotation, timeStamp); } } else if (positionHandler == (int)EPositionHandler.EPosition_Add) { Vector3 position = contexts.player.flagSelfEntity.position.Value; GameObject rootGo = contexts.player.flagSelfEntity.RootGo(); string timeStamp = TimeStamp(); CreateGameObject(position, rootGo.transform.eulerAngles.y, timeStamp); TestPositionManager.Add(position, rootGo.transform.eulerAngles.y, timeStamp); } else if (positionHandler == (int)EPositionHandler.EPosition_Remove) { Vector3 position = contexts.player.flagSelfEntity.position.Value; GameObject rootGo = contexts.player.flagSelfEntity.RootGo(); Bounds bounds = new Bounds(position, Vector3.one); ObjectTag[] objectTags = GameObject.FindObjectsOfType <ObjectTag>(); for (int i = 0, maxi = (null == objectTags ? 0 : objectTags.Length); i < maxi; i++) { ObjectTag objectTag = objectTags[i]; if (null == objectTag) { continue; } if (bounds.Contains(objectTag.transform.position)) { TestPositionManager.Delete(objectTag.gameObject.name); GameObject.DestroyImmediate(objectTag.gameObject); objectTags[i] = null; } } } } }
public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { FreeData fd = (FreeData)player.freeData.FreeData; room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd); string key = message.Ss[0]; int count = message.Ins[0]; if (key.StartsWith(ChickenConstant.BagDefault)) { ItemPosition ip = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager()); FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (ip.GetCount() > count) { ip.SetCount(ip.GetCount() - count); ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.FreeArgs, ip.GetInventory(), true); } else { ip.GetInventory().RemoveItem((ISkillArgs)room.FreeArgs, ip); } room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (Assets.XmlConfig.ECategory)info.cat, info.id, count, fd.Player.position.Value); } room.FreeArgs.Resume(PARA_PLAYER_CURRENT); }