public void AddDrop(DropComponent drop) { if (drop == null) { return; } // 如果掉落已经存在,不要处理 var oldDrop = GetDrop(drop.Id); if (oldDrop != null) { GameDebug.LogError("重复的掉落,id为" + drop.Id); return; } if (mDrops == null) { mDrops = new List <DropComponent>(); mDrops.Clear(); } mDrops.Add(drop); // 如果当前正在任务导航,则先拾取掉落,重新导航就可以了 // 自动战斗的ai会自动拾取掉落的,所以这里要屏蔽 if (TargetPathManager.Instance.IsNavigating == true && InstanceManager.Instance.IsAutoFighting == false && TaskManager.Instance.NavigatingTask != null && SceneHelp.Instance.IsInWildInstance() == true) { TaskHelper.TaskGuide(TaskManager.Instance.NavigatingTask); } }
public BehaviourReturnCode ActionWalkToTargetDrop() { if (RunningProperty.AI.Machine.CurrentStateType == BehaviourMachine.State.WALK) { return(BehaviourReturnCode.Failure); } DropComponent drop = InstanceDropManager.Instance.GetDrop(RunningProperty.TargetDropId); if (drop == null) { RunningProperty.TargetDropId = 0; return(BehaviourReturnCode.Success); } Vector3 dropPos = drop.transform.position; if (AIHelper.RoughlyEqual(dropPos, RunningProperty.SelfActorPos)) { RunningProperty.TargetDropId = 0; RunningProperty.AI.PathWalker.IsWalkingToDropPos = false; RunningProperty.AI.Machine.SwitchToState(BehaviourMachine.State.EMPTY); return(BehaviourReturnCode.Success); } RunningProperty.TargetActor = null; RunningProperty.AI.PathWalker.WalkTo(dropPos); RunningProperty.AI.PathWalker.IsWalkingToDropPos = true; RunningProperty.AI.Machine.SwitchToState(BehaviourMachine.State.WALK); return(BehaviourReturnCode.Failure); }
/// <summary> /// 获取指定范围内最靠近的掉落 /// </summary> /// <param name="range">范围值</param> /// <returns></returns> public DropComponent GetNearestDrop(float range = float.MaxValue) { Actor localPlayer = Game.Instance.GetLocalPlayer(); float minDistance = float.MaxValue; DropComponent nearestDrop = null; if (localPlayer != null) { if (mDrops != null) { Vector3 localPlayerPosition = localPlayer.Trans.position; foreach (var drop in mDrops) { if (drop.CanPick == true && drop.IsInCD == false && drop.IsBossChip == false) { float distance = Vector3.Distance(drop.transform.position, localPlayerPosition); if (distance <= range && distance < minDistance) { minDistance = distance; nearestDrop = drop; } } } } } return(nearestDrop); }
public BehaviourReturnCode ActionSetTargetDrop() { if (RunningProperty.SelfActor == null) { return(BehaviourReturnCode.Success); } if (HookSettingManager.Instance.AutoPickDrop == false) { RunningProperty.TargetDropId = 0; return(BehaviourReturnCode.Success); } if (RunningProperty.TargetDropId > 0) { return(BehaviourReturnCode.Success); } bool isFull = ItemManager.Instance.BagIsFull(1); if (InstanceDropManager.Instance.Drops != null) { float minDistance = float.MaxValue; Vector3 selfPos = RunningProperty.SelfActor.transform.position; DropComponent nearestDrop = null; foreach (DropComponent drop in InstanceDropManager.Instance.Drops) { if (drop != null && drop.DropInfo != null && HookSettingManager.Instance.CheckIsInAutoPickDropGoodsSettingInfo(drop.DropInfo.gid) == true) { if ((drop.DropInfo.type == GameConst.GIVE_TYPE_GOODS || drop.DropInfo.type == GameConst.GIVE_TYPE_EQUIP) && isFull == true) { } else { if (drop.CanPick == true && drop.IsInCD == false && drop.IsBossChip == false) { selfPos.y = 0; Vector3 dropPos = drop.transform.position; dropPos.y = 0; float distance = Vector3.Distance(selfPos, dropPos); if (distance <= RunningProperty.MotionRadius && distance < minDistance) { minDistance = distance; nearestDrop = drop; } } } } } if (nearestDrop != null) { RunningProperty.TargetDropId = nearestDrop.Id; return(BehaviourReturnCode.Success); } } return(BehaviourReturnCode.Success); }
public void RemoveDrop(DropComponent drop) { if (drop == null) { GameDebug.LogError("Error in remove drop, drop is null!!!"); return; } if (mDrops != null) { mDrops.Remove(drop); } //mDropsScreenRect.Remove(drop.DropInfo.oid); }
protected virtual void HandleServerData(ushort protocol, byte[] data) { switch (protocol) { case NetMsg.MSG_NWAR_DROP: { var pack = S2CPackBase.DeserializePack <S2CNwarDrop>(data); //GameDebug.LogError(">>>MSG_NWAR_DROP"); CreateDrops(pack.drops, (DropComponent.EDropType)pack.drop_type, pack.em_id); return; } case NetMsg.MSG_NWAR_PICK: { var pack = S2CPackBase.DeserializePack <S2CNwarPick>(data); //GameDebug.LogError("Recv MSG_NWAR_PICK: " + pack.oid + ", " + pack.drop_type); PickDropImpl(pack.uuid, pack.oid, (DropComponent.EDropType)pack.drop_type); return; } case NetMsg.MSG_NWAR_PICK_FAIL: { var pack = S2CPackBase.DeserializePack <S2CNwarPickFail>(data); if (pack.reason == 1) // 物品已消失 { DestroyDrop(pack.oid); UINotice.Instance.ShowMessage(DBConstText.GetText("DROP_IS_DISAPPEAR")); } else if (pack.reason == 2) // 物品拾取次数已满 { UINotice.Instance.ShowMessage(DBConstText.GetText("DROP_REACH_LIMIT")); DropComponent drop = InstanceDropManager.Instance.GetDrop(pack.oid); if (drop != null) { drop.CanPick = false; drop.CanNotPickReason = pack.reason; } } return; } default: break; } }
protected virtual void HandleServerData(ushort protocol, byte[] data) { switch (protocol) { case NetMsg.MSG_NWAR_PICK_BOSS_CHIP_START: { //开始拾取 //GameDebug.LogError("recv MSG_NWAR_PICK_BOSS_CHIP_START"); var pack = S2CPackBase.DeserializePack <S2CNwarPickBossChipStart>(data); if (pack.action.uuid == Game.Instance.LocalPlayerTypeID) { return; } if (SceneHelp.Instance.IsInWorldBossExperienceInstance) { return; //世界BOSS体验副本,不显示其他人的拾取操作 } Actor actor = ActorManager.Instance.GetPlayer(pack.action.uuid); if (actor == null || actor.IsPlayer() == false) { return; } Player player = actor as Player; UnityEngine.Vector3 kPos = UnityEngine.Vector3.zero; kPos = PhysicsHelp.GetPosition(pack.action.pos.px / 100.0f, pack.action.pos.py / 100.0f); DropComponent drop_com = InstanceDropManager.Instance.GetDrop(pack.action.oid); if (drop_com != null && drop_com.transform.parent != null) { kPos = drop_com.transform.position; } player.StartPickUpBossChipEffect(kPos); } return; case NetMsg.MSG_NWAR_PICK_BOSS_CHIP_STOP: { var pack = S2CPackBase.DeserializePack <S2CNwarPickBossChipStop>(data); Actor actor = ActorManager.Instance.GetPlayer(pack.uuid); if (actor == null || actor.IsPlayer() == false) { return; } if (SceneHelp.Instance.IsInWorldBossExperienceInstance && actor.IsLocalPlayer == false) { return; //世界BOSS体验副本,不显示其他人的拾取操作 } Player player = actor as Player; player.FinishPickUpEffect(); if (pack.type == 0 && player.IsLocalPlayer) { //如果是主角完成,需要发送拾取协议给后端 2017/12/28 FinishPickImmediately(); //if ((mDropInfo.type == GameConst.GIVE_TYPE_GOODS || mDropInfo.type == GameConst.GIVE_TYPE_EQUIP) && ItemManager.Instance.BagIsFull(1) == true) //{ // UINotice.Instance.ShowMessage(DBConstText.GetText("BAG_IS_FULL")); // return; //} //C2SNwarPick msg = new C2SNwarPick(); //msg.oid = mDropInfo.oid; //msg.drop_type = mDropType; //NetClient.GetBaseClient().SendData<C2SNwarPick>(NetMsg.MSG_NWAR_PICK, msg); //mHasSendPickPackage = true; //mSendPickPackageTime = Time.realtimeSinceStartup; //xc.ui.ugui.UIManager.Instance.ShowWindow("UIBossFragmentsWindow", mDropInfo.gid, mDropInfo.num); } } return; default: break; } }
void OnStartPickUpLocalPlayer(CEventBaseArgs data_param) { if (data_param == null) { return; } if ((data_param is CEventEventParamArgs) == false) { return; } CEventEventParamArgs data = data_param as CEventEventParamArgs; if (data.mMoreParam == null) { return; } if (data.mMoreParam.Length <= 1) { return; } PkgDropGive drop_info = data.mMoreParam[0] as PkgDropGive; uint drop_type = 0; drop_type = uint.Parse(data.mMoreParam[1] as string); if (drop_info == null) { return; } if (mTimer != null) { return; } xc.InstanceManager.Instance.IsAutoFighting = false;//停止自动挂机 mTimer = new Utils.Timer(100, true, 200, UpdatePick); mDropInfo = drop_info; mDropType = drop_type; mStartPickTime = Time.realtimeSinceStartup; Actor local_player = xc.Game.Instance.GetLocalPlayer(); Vector3 drop_com_pos = local_player.transform.position; DropComponent drop_com = InstanceDropManager.Instance.GetDrop(drop_info.oid); if (local_player != null && drop_com != null) { drop_com_pos = drop_com.transform.position; (local_player as Player).StartPickUpBossChipEffect(drop_com.transform.position); } C2SNwarPickBossChipStart reply = new C2SNwarPickBossChipStart(); reply.action = new PkgNwarPickBossChip(); reply.action.uuid = local_player.UID.obj_idx; reply.action.oid = mDropInfo.oid; reply.action.pos = new PkgNwarPos(); reply.action.pos.px = (int)(drop_com_pos.x * 100); reply.action.pos.py = (int)(drop_com_pos.y * 100); NetClient.GetCrossClient().SendData <C2SNwarPickBossChipStart>(NetMsg.MSG_NWAR_PICK_BOSS_CHIP_START, reply); string sound_path = "Assets/" + ResPath.Sound_ui_xihun; m_pick_boss_sound_id = xc.AudioManager.Instance.PlayAudio_dynamic_out(sound_path, false, 1); }
public ItemEntity() { Object.Type = WorldObjectType.Item; Drop = new DropComponent(); }