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 data) { int ani = data.Ins[0]; var contexts = SingletonManager.Get <FreeUiManager>().Contexts1; PlayerAnimationAction.DoAnimation(contexts, ani, contexts.player.flagSelfEntity, false); }
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 static void UseAnimation(Contexts contexts, FreeData fd, string key) { FreeItemInfo info = GetItemInfo(key); if (info.cat == 13 && (info.id == 103)) { PlayerAnimationAction.DoAnimation(contexts, 0, fd.Player); } if (info.cat == 13 && (info.id == 105)) { PlayerAnimationAction.DoAnimation(contexts, 4, fd.Player); } if (info.cat == 13 && (info.id == 102 || info.id == 104)) { PlayerAnimationAction.DoAnimation(contexts, 1, fd.Player); } if (info.cat == 13 && (info.id == 101)) { PlayerAnimationAction.DoAnimation(contexts, 2, fd.Player); } if (info.cat == 13 && (info.id == 100)) { PlayerAnimationAction.DoAnimation(contexts, 3, fd.Player); } }
public override void DoAction(IEventArgs args) { if (inter) { if (fd != null) { fd.freeInventory.StopUseItem(args, fd); UseCommonAction use = new UseCommonAction(); use.key = "showBottomTip"; use.values = new List <ArgValue>(); use.values.Add(new ArgValue("msg", "{desc:10072,{item.name}}")); args.TempUse("current", fd); args.TempUse("item", ip); use.Act(args); args.Resume("current"); args.Resume("item"); PlayerAnimationAction.DoAnimation(PlayerAnimationAction.Stop, fd.Player); FreeSoundUtil.Stop("use", args, fd); PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay); } } else { if (ip != null && fd != null) { UseItem(ip, fd, (ISkillArgs)args); fd.freeInventory.StopUseItem(args, fd); } } }
private void StopSave(PlayerEntity playerEntity, bool isInterrupted, IUserCmd cmd) { 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) { PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.Revive, playerEntity, true); } playerEntity.gamePlay.IsBeSave = false; } } if (playerEntity.gamePlay.IsBeSave && !isInterrupted) { playerEntity.stateInterface.State.SetPostureCrouch(); } playerEntity.gamePlay.IsInteruptSave = isInterrupted; }
public HoldWeaponHandler(PlayerEntity playerEntity) : base(playerEntity) { var weaponController = playerEntity.WeaponController(); interruptAction = () => { PlayerAnimationAction.DoAnimation(null, 120, playerEntity); recoveredSlotType = weaponController.UnArmWeapon(false); }; recoverAction = () => weaponController.ArmWeapon(recoveredSlotType, true); filterFunc = () => !weaponController.IsHeldSlotEmpty; }
public void Handle(SimpleProto data) { int ani = data.Ins[0]; var contexts = SingletonManager.Get <FreeUiManager>().Contexts1; switch (ani) { case PlayerAnimationAction.SuccessPose: contexts.player.flagSelfEntity.stateInterface.State.StartSuccessPose(data.Ins[1]); break; default: PlayerAnimationAction.DoAnimation(contexts, ani, contexts.player.flagSelfEntity, false); break; } }
public void AutoPickupWeapon(PlayerEntity player, List <int> sceneKeys) { for (int i = 0; i < sceneKeys.Count; i++) { SceneObjectEntity sceneEntity = sceneObjectEntityFactory.GetSceneEntity(sceneKeys[i]) as SceneObjectEntity; if (sceneEntity == null || !sceneEntity.hasWeaponObject || sceneEntity.isFlagDestroy) { continue; } EWeaponType_Config configType = (EWeaponType_Config)SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(sceneEntity.weaponObject.ConfigId).Type; if (!configType.CanAutoPick()) { continue; } if (configType == EWeaponType_Config.TacticWeapon && !sceneEntity.IsCanPickUpByPlayer(player)) { continue; } var newWeaponScan = (WeaponScanStruct)sceneEntity.weaponObject; bool pickupResult = player.WeaponController().AutoPickUpWeapon(newWeaponScan); if (!pickupResult) { continue; } sceneObjectEntityFactory.DestroySceneWeaponObjectEntity(sceneEntity.entityKey.Value); if (player.WeaponController().HeldConfigId == sceneEntity.weaponObject.ConfigId && SharedConfig.IsServer) { PlayerAnimationAction.DoAnimation(null, PlayerAnimationAction.PickUp, player, true); } IEventArgs args = commonSession.FreeArgs as IEventArgs; if (null != args) { TriggerArgs ta = new TriggerArgs(); ta.AddPara(new IntPara("weaponId", sceneEntity.weaponObject.ConfigId)); ta.AddUnit("current", (FreeData)player.freeData.FreeData); args.Trigger(FreeTriggerConstant.WEAPON_PICKUP, ta); } } }
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) { PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.Revive, playerEntity, true); } playerEntity.gamePlay.IsBeSave = false; } } playerEntity.gamePlay.IsInteruptSave = isInterrupted; }
public static void AddItemToPlayer(ServerRoom room, PlayerEntity player, int entityId, int cat, int id, int count, string toInv = "") { SceneObjectEntity entity = room.RoomContexts.sceneObject.GetEntityWithEntityKey(new Core.EntityComponent.EntityKey(entityId, (short)EEntityType.SceneObject)); FreeMoveEntity freeMoveEntity = null; if (entity == null || entity.isFlagDestroy) { freeMoveEntity = room.RoomContexts.freeMove.GetEntityWithEntityKey(new Core.EntityComponent.EntityKey(entityId, (short)EEntityType.FreeMove)); if (freeMoveEntity == null) { return; } } room.FreeArgs.TempUse("current", (FreeData)player.freeData.FreeData); if (!FreeItemConfig.Contains(cat, id)) { return; } FreeItemInfo item = FreeItemConfig.GetItemInfo(cat, id); CreateItemToPlayerAction action = new CreateItemToPlayerAction(); FreeData fd = (FreeData)player.freeData.FreeData; action.name = "default"; switch (item.cat) { case (int)ECategory.Weapon: if (item.subType == "w1") { action.name = "w1"; int c1 = fd.freeInventory.GetInventoryManager().GetInventory("w1").posList.Count; int c2 = fd.freeInventory.GetInventoryManager().GetInventory("w2").posList.Count; if (toInv.StartsWith("w1")) { action.name = "w1"; if (c1 > 0) { DropItem(action.name, fd, room); } } else if (toInv.StartsWith("w2")) { action.name = "w2"; if (c2 > 0) { DropItem(action.name, fd, room); } } else { if (c1 > 0 && c2 == 0) { action.name = "w2"; } if (c1 > 0 && c2 > 0) { int currentKey = FreeWeaponUtil.GetWeaponKey(fd.Player.WeaponController().HeldSlotType); if (currentKey == 0) { currentKey = 1; } if (currentKey == 1 || currentKey == 2) { action.name = "w" + currentKey; } else { action.name = "w1"; } DropItem(action.name, fd, room); } } } else if (item.subType == "w2") { action.name = "w3"; DropItem(action.name, fd, room); } else if (item.subType == "w3") { action.name = "w4"; DropItem(action.name, fd, room); } else if (item.subType == "w4") { action.name = "default"; } break; case (int)ECategory.Avatar: action.name = item.subType; DropItem(item.subType, fd, room); break; case (int)ECategory.WeaponPart: action.name = AutoPutPart(fd, item, toInv, room); break; default: break; } //handleDropOne(new string[] { "w2" }, action, item, fd, room, entity); //handleAddToDefault(new string[] { "p1", "p2", "p3", "p4", "p5" }, action, item, fd, room, entity); action.key = FreeItemConfig.GetItemKey(item.cat, item.id); bool canAdd = true; if (action.name == "default") { canAdd = BagCapacityUtil.CanAddToBag(room.FreeArgs, fd, item.cat, item.id, count); } if (canAdd) { PlayerAnimationAction.DoAnimation(room.RoomContexts, PlayerAnimationAction.Interrupt, fd.Player, true); PlayerAnimationAction.DoAnimation(room.RoomContexts, 101, fd.Player, true); if (!string.IsNullOrEmpty(action.key)) { action.count = count.ToString(); action.SetPlayer("current"); room.FreeArgs.TempUse("current", fd); action.Act(room.FreeArgs); room.FreeArgs.Resume("current"); } else { Debug.LogError(item.cat + "-" + item.key + " not existed"); } if (entity != null) { entity.isFlagDestroy = true; } if (freeMoveEntity != null) { freeMoveEntity.isFlagDestroy = true; } //Debug.LogErrorFormat("destroy entity {0}", entity != null); FreeSoundUtil.PlayOnce("pick", 225, room.FreeArgs, fd); } room.FreeArgs.Resume("current"); }
public void ExecuteUserCmd(IPlayerUserCmdGetter getter, IUserCmd cmd) { PlayerEntity myEntity = getter.OwnerEntity as PlayerEntity; if (null == myEntity) { return; } var myState = myEntity.stateInterface.State; if (myEntity.gamePlay.IsSave || myEntity.gamePlay.IsBeSave) { PlayerEntity teamEntity = _contexts.player.GetEntityWithEntityKey(myEntity.gamePlay.SavePlayerKey); if (null == teamEntity) { StopSave(myEntity, true); return; } if (myEntity.time.ClientTime - myEntity.gamePlay.SaveTime >= saveTime) { if (myEntity.gamePlay.IsSave) { myEntity.statisticsData.Statistics.SaveCount++; } else { myEntity.statisticsData.Statistics.BeSaveCount++; myEntity.gamePlay.CurHp = myEntity.gamePlay.MaxHp * 0.1f; if (SharedConfig.IsServer) { myEntity.gamePlay.ChangeLifeState(EPlayerLifeState.Alive, myEntity.time.ClientTime); } } try { var args = _contexts.session.commonSession.FreeArgs as IEventArgs; if (args != null && SharedConfig.IsServer) { TriggerArgs ta = new TriggerArgs(); ta.AddUnit("savor", (FreeData)(myEntity.gamePlay.IsSave ? myEntity.freeData.FreeData : teamEntity.freeData.FreeData)); ta.AddUnit("saved", (FreeData)(myEntity.gamePlay.IsSave ? teamEntity.freeData.FreeData : myEntity.freeData.FreeData)); args.Trigger(FreeTriggerConstant.PLAYER_RESCUE_SUCCESS, ta); } } catch (Exception e) { _logger.ErrorFormat("player rescue success trigger failed", e); } StopSave(myEntity, false); return; } if (Vector3.Distance(myEntity.position.Value, teamEntity.position.Value) > SharedConfig.MaxSaveDistance) { StopSave(myEntity, true); StopSave(teamEntity, true); return; } if (myEntity.gamePlay.IsSave) { if (!cmd.IsF || myState.NeedInterruptRescue() || !myEntity.gamePlay.IsLifeState(EPlayerLifeState.Alive) || GetAngle(myEntity, teamEntity) > SharedConfig.MaxSaveAngle) { StopSave(myEntity, true); StopSave(teamEntity, true); return; } } else { if (myEntity.gamePlay.IsDead()) { StopSave(myEntity, true); StopSave(teamEntity, true); return; } } } if (cmd.IsUseAction && cmd.UseType == (int)EUseActionType.Player && myEntity.gamePlay.IsSave == false && myState.GetCurrentMovementState() == MovementInConfig.Idle && myState.GetCurrentPostureState() != PostureInConfig.Land && myState.GetCurrentPostureState() != PostureInConfig.Prone) { PlayerEntity saveEntity = _contexts.player.GetEntityWithEntityKey(new EntityKey(cmd.UseEntityId, (int)EEntityType.Player)); if (saveEntity != null && SharedConfig.IsServer) { PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.Rescue, myEntity, true); myEntity.gamePlay.IsSave = true; myEntity.gamePlay.SaveTime = myEntity.time.ClientTime; myEntity.gamePlay.SavePlayerKey = saveEntity.entityKey.Value; saveEntity.gamePlay.IsBeSave = true; saveEntity.gamePlay.SaveTime = saveEntity.time.ClientTime; saveEntity.gamePlay.SavePlayerKey = myEntity.entityKey.Value; SimpleProto data = FreePool.Allocate(); data.Key = FreeMessageConstant.CountDown; data.Bs.Add(true); data.Fs.Add(saveTime / 1000); FreeMessageSender.SendMessage(myEntity, data); FreeMessageSender.SendMessage(saveEntity, data); } } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity myEntity = owner.OwnerEntity as PlayerEntity; if (null == myEntity) { return; } if (myEntity.gamePlay.IsSave || myEntity.gamePlay.IsBeSave) { PlayerEntity teamEntity = _contexts.player.GetEntityWithEntityKey(myEntity.gamePlay.SavePlayerKey); if (null == teamEntity) { StopSave(myEntity, true); return; } if (myEntity.time.ClientTime - myEntity.gamePlay.SaveTime >= SharedConfig.SaveNeedTime) { if (myEntity.gamePlay.IsSave) { myEntity.statisticsData.Statistics.SaveCount++; } else { myEntity.statisticsData.Statistics.BeSaveCount++; myEntity.gamePlay.CurHp = myEntity.gamePlay.MaxHp * 0.1f; myEntity.gamePlay.ChangeLifeState(EPlayerLifeState.Alive, myEntity.time.ClientTime); } StopSave(myEntity, false); return; } if (Vector3.Distance(myEntity.position.Value, teamEntity.position.Value) > SharedConfig.MaxSaveDistance) { StopSave(myEntity, true); StopSave(teamEntity, true); return; } if (myEntity.gamePlay.IsSave) { if (myEntity.stateInterface.State.NeedInterruptRescue((PostureInConfig)myEntity.gamePlay.SaveEnterState) || !myEntity.gamePlay.IsLifeState(EPlayerLifeState.Alive) || GetAngle(myEntity, teamEntity) > SharedConfig.MaxSaveAngle) { StopSave(myEntity, true); StopSave(teamEntity, true); return; } } else { if (myEntity.gamePlay.IsDead()) { StopSave(myEntity, true); StopSave(teamEntity, true); return; } } } if (cmd.IsUseAction && cmd.UseType == (int)EUseActionType.Player) { PlayerEntity saveEntity = _contexts.player.GetEntityWithEntityKey(new EntityKey(cmd.UseEntityId, (int)EEntityType.Player)); if (saveEntity != null && SharedConfig.IsServer) { PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.Rescue, myEntity, true); myEntity.gamePlay.IsSave = true; myEntity.gamePlay.SaveEnterState = (int)myEntity.stateInterface.State.GetCurrentPostureState(); myEntity.gamePlay.SaveTime = myEntity.time.ClientTime; myEntity.gamePlay.SavePlayerKey = saveEntity.entityKey.Value; saveEntity.gamePlay.IsBeSave = true; saveEntity.gamePlay.SaveTime = saveEntity.time.ClientTime; saveEntity.gamePlay.SavePlayerKey = myEntity.entityKey.Value; } } }
public static bool AddItemToPlayer(ServerRoom room, PlayerEntity player, int entityId, int cat, int id, int count, string toInv = "") { SceneObjectEntity entity = room.RoomContexts.sceneObject.GetEntityWithEntityKey(new EntityKey(entityId, (short)EEntityType.SceneObject)); FreeMoveEntity freeMoveEntity = null; if (entity == null || entity.isFlagDestroy) { freeMoveEntity = room.RoomContexts.freeMove.GetEntityWithEntityKey(new EntityKey(entityId, (short)EEntityType.FreeMove)); if (freeMoveEntity == null) { return(false); } } FreeData fd = (FreeData)player.freeData.FreeData; room.ContextsWrapper.FreeArgs.TempUse("current", fd); if (!FreeItemConfig.Contains(cat, id)) { return(false); } FreeItemInfo item = FreeItemConfig.GetItemInfo(cat, id); CreateItemToPlayerAction action = new CreateItemToPlayerAction(); action.name = ChickenConstant.BagDefault; switch (item.cat) { case (int)ECategory.Weapon: if (item.subType == ChickenConstant.ItemCatPrimeWeapon) { action.name = ChickenConstant.BagPrimeWeapon; int c1 = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagPrimeWeapon).posList.Count; int c2 = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagSecondaryWeapon).posList.Count; if (toInv.StartsWith(ChickenConstant.BagPrimeWeapon)) { action.name = ChickenConstant.BagPrimeWeapon; if (c1 > 0) { DropItem(action.name, fd, room); } } else if (toInv.StartsWith(ChickenConstant.BagSecondaryWeapon)) { action.name = ChickenConstant.BagSecondaryWeapon; if (c2 > 0) { DropItem(action.name, fd, room); } } else { if (c1 > 0 && c2 == 0) { action.name = ChickenConstant.BagSecondaryWeapon; } if (c1 > 0 && c2 > 0) { int currentKey = FreeWeaponUtil.GetWeaponKey(fd.Player.WeaponController().HeldSlotType); if (currentKey == 0) { currentKey = 1; } if (currentKey == 1 || currentKey == 2) { action.name = "w" + currentKey; } else { action.name = ChickenConstant.BagPrimeWeapon; } DropItem(action.name, fd, room); } } } else if (item.subType == ChickenConstant.ItemCatPistolWeapon) { action.name = ChickenConstant.BagPistolWeapon; DropItem(action.name, fd, room); } else if (item.subType == ChickenConstant.ItemCatMeleeWeapon) { action.name = ChickenConstant.BagMeleeWeapon; DropItem(action.name, fd, room); } else if (item.subType == ChickenConstant.ItemCatGrenadeWeapon) { action.name = ChickenConstant.BagDefault; } else if (item.subType == ChickenConstant.ItemCatArmor) { action.name = ChickenConstant.BagArmor; if (entity != null) { count = entity.armorDurability.CurDurability; } DropItem(action.name, fd, room); } else if (item.subType == ChickenConstant.ItemCatHelmet) { action.name = ChickenConstant.BagHelmet; if (entity != null) { count = entity.armorDurability.CurDurability; } DropItem(action.name, fd, room); } break; case (int)ECategory.Avatar: action.name = item.subType; DropItem(item.subType, fd, room); break; case (int)ECategory.WeaponPart: action.name = AutoPutPart(fd, item, toInv, room); break; default: break; } action.key = FreeItemConfig.GetItemKey(item.cat, item.id); int canCount = 0; if (action.name == ChickenConstant.BagDefault) { canCount = BagCapacityUtil.CanAddToBagCount(room.ContextsWrapper.FreeArgs, fd, item.cat, item.id, count); } else if (item.type == ChickenConstant.ItemCatAvatar || action.name == ChickenConstant.BagHelmet || action.name == ChickenConstant.BagArmor) { canCount = count; } else { canCount = 1; } bool pickupSuccess = false; if (canCount > 0 && !string.IsNullOrEmpty(action.name)) { PlayerAnimationAction.DoAnimation(room.RoomContexts, PlayerAnimationAction.Interrupt, fd.Player, true); PlayerAnimationAction.DoAnimation(room.RoomContexts, PlayerAnimationAction.PickUp, fd.Player, true); PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay); if (!string.IsNullOrEmpty(action.key)) { action.count = canCount.ToString(); action.SetPlayer("current"); room.ContextsWrapper.FreeArgs.TempUse("current", fd); action.Act(room.ContextsWrapper.FreeArgs); room.ContextsWrapper.FreeArgs.Resume("current"); if (count > canCount) { SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word80," + count + "," + canCount); FreeMessageSender.SendMessage(fd.Player, msg); room.ContextsWrapper.FreeArgs.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity((ECategory)item.cat, item.id, count - canCount, entity == null ? freeMoveEntity.position.Value : entity.position.Value); } pickupSuccess = true; } else { Debug.LogError(item.cat + "-" + item.key + " not existed"); } if (entity != null) { entity.isFlagDestroy = true; } if (freeMoveEntity != null) { freeMoveEntity.isFlagDestroy = true; if (freeMoveEntity.freeData.Cat == FreeEntityConstant.DeadBox) { var deadBox = room.ContextsWrapper.FreeArgs.GameContext.freeMove.GetEntityWithEntityKey(new EntityKey(freeMoveEntity.freeData.IntValue, (short)EEntityType.FreeMove)); if (deadBox != null && deadBox.freeData.EmptyDelete) { if (deadBox.freeData.IntValue > 1) { deadBox.freeData.IntValue--; } else { deadBox.isFlagDestroy = true; } } } } } room.ContextsWrapper.FreeArgs.Resume("current"); return(pickupSuccess); }