private void OnUserStartAttack(UserInfo user, float x, float y, float z) { GfxSystem.PublishGfxEvent("Ai_InputAttackCmd", "Input", user.GetId(), x, y, z); }
private void OnUserSkill(UserInfo user, int skillId) { //user.SkillController.PushSkill(SkillCategory.kAttack, ScriptRuntime.Vector3.Zero); GfxSystem.PublishGfxEvent("Ai_InputSkillCmd", "Input", user.GetId()); }
internal void Tick() { long now = TimeUtility.GetServerMilliseconds(); m_LastTickIntervalMs = now - m_LastTickTime; m_LastTickTime = now; if (WorldSystem.Instance.IsObserver && !WorldSystem.Instance.IsFollowObserver) { bool keyPressed = false; float x = 0.5f, y = 0.5f; if (GfxSystem.IsKeyPressed(Keyboard.Code.A)) { x = 0.1f; keyPressed = true; } else if (GfxSystem.IsKeyPressed(Keyboard.Code.D)) { x = 0.9f; keyPressed = true; } if (GfxSystem.IsKeyPressed(Keyboard.Code.W)) { y = 0.1f; keyPressed = true; } else if (GfxSystem.IsKeyPressed(Keyboard.Code.S)) { y = 0.9f; keyPressed = true; } if (keyPressed) { WorldSystem.Instance.UpdateObserverCamera(x, y); } return; } UserInfo playerself = WorldSystem.Instance.GetPlayerSelf(); if (null == playerself) { return; } // if move input is disable // MotionStatus is MoveStop, and MotionChanged is reflect the change accordingly if (EnableMoveInput) { if (!IsKeyboardControl()) { CheckJoystickControl(); } } if (!m_IsJoystickControl) { pm_.Update(EnableMoveInput); } MovementStateInfo msi = playerself.GetMovementStateInfo(); Vector3 pos = msi.GetPosition3D(); //LogSystem.Debug("Pos : {0}, Dir : {1}", pos.ToString(), playerself.GetMovementStateInfo().GetFaceDir()); bool reface = false; if (m_LastTickIsSkillMoving && !msi.IsSkillMoving) { reface = true; } //操作同步机制改为发给服务器同时本地就开始执行(服务器转发给其它客户端,校验失败则同时发回原客户端进行位置调整) Vector3 mouse_pos = new Vector3(GfxSystem.GetMouseX(), GfxSystem.GetMouseY(), GfxSystem.GetMouseZ()); if (pm_.MotionStatus == PlayerMovement.Motion.Moving || pm_.JoyStickMotionStatus == PlayerMovement.Motion.Moving) { if (pm_.MotionChanged || pm_.JoyStickMotionChanged || !m_LastTickIsMoving) { StopAiMove(); playerself.SkillController.AddBreakSkillTask(); float moveDir = RoundMoveDir(pm_.MoveDir); //GfxSystem.GfxLog("PlayerControl.Tick MoveDir:{0} RoundMoveDir:{1}", pm_.MoveDir, moveDir); if (!m_LastTickIsMoving || !Geometry.IsSameFloat(moveDir, m_lastMoveDir)) { msi.SetMoveDir(moveDir); //ControlSystemOperation.AdjustCharacterMoveDir(playerself.GetId(), moveDir); msi.IsMoving = true; msi.TargetPosition = Vector3.Zero; if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene()) { NetworkSystem.Instance.SyncPlayerMoveStart(moveDir); } } if (EnableRotateInput) { if (reface || !m_LastTickIsMoving || !Geometry.IsSameFloat(pm_.MoveDir, m_lastDir)) { msi.SetFaceDir(pm_.MoveDir); //ControlSystemOperation.AdjustCharacterFaceDir(playerself.GetId(), pm_.MoveDir); msi.SetWantFaceDir(pm_.MoveDir); if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene()) { NetworkSystem.Instance.SyncFaceDirection(pm_.MoveDir); } } } m_lastDir = pm_.MoveDir; m_lastMoveDir = moveDir; } m_LastTickIsMoving = true; } else { if (m_LastTickIsMoving) { playerself.SkillController.CancelBreakSkillTask(); playerself.GetMovementStateInfo().IsMoving = false; if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene()) { NetworkSystem.Instance.SyncPlayerMoveStop(); } if (EnableRotateInput) { if (reface) { msi.SetFaceDir(m_lastDir); //ControlSystemOperation.AdjustCharacterFaceDir(playerself.GetId(), m_lastDir); msi.SetWantFaceDir(m_lastDir); if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene()) { NetworkSystem.Instance.SyncFaceDirection(m_lastDir); } } } } m_LastTickIsMoving = false; } m_LastTickIsSkillMoving = msi.IsSkillMoving; old_mouse_pos_ = mouse_pos_; mouse_pos_.X = GfxSystem.GetMouseX(); mouse_pos_.Y = GfxSystem.GetMouseY(); UserAiStateInfo aiInfo = playerself.GetAiStateInfo(); if (null != aiInfo && (int)AiStateId.Idle == aiInfo.CurState) { m_lastSelectObjId = -1; } }
internal void Update(bool move_enable) { UserInfo playerself = WorldSystem.Instance.GetPlayerSelf(); if (playerself == null || playerself.IsDead()) { return; } KeyHit kh = KeyHit.None; if (move_enable) { if (ArkCrossEngineSpatial.SpatialObjType.kNPC == playerself.GetRealControlledObject().SpaceObject.GetObjType()) { NpcInfo npcInfo = playerself.GetRealControlledObject().CastNpcInfo(); if (null != npcInfo) { if (!npcInfo.CanMove) { return; } } } if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.W))) { kh |= KeyHit.Up; } if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.A))) { kh |= KeyHit.Left; } if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.S))) { kh |= KeyHit.Down; } if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.D))) { kh |= KeyHit.Right; } } Motion m = kh == KeyHit.None ? Motion.Stop : Motion.Moving; MotionChanged = MotionStatus != m || last_key_hit_ != kh; if (MotionChanged) { //GfxSystem.GfxLog("MotionChanged:{0}!={1} || {2}!={3}", MotionStatus, m, last_key_hit_, kh); } last_key_hit_ = kh; MotionStatus = m; MoveDir = CalcMoveDir(kh); if (MoveDir < 0) { MotionStatus = Motion.Stop; } if (MotionChanged) { //GfxSystem.GfxLog("InputMoveDir:{0} Pos:{1}", MoveDir, playerself.GetMovementStateInfo().GetPosition3D().ToString()); } }
private void CheckJoystickControl() { UserInfo playerself = WorldSystem.Instance.GetPlayerSelf(); if (null == playerself) { return; } float dir = GfxSystem.GetJoystickDir(); if (dir < 0) { dir += c_2PI; } Vector3 target_pos = new Vector3(GfxSystem.GetJoystickTargetPosX(), GfxSystem.GetJoystickTargetPosY(), GfxSystem.GetJoystickTargetPosZ()); UpdateMoveState(playerself, target_pos, dir); }
private void SummonPartner(int key_code, int what) { RoleInfo roleself = LobbyClient.Instance.CurrentRole; if (null == roleself) { return; } UserInfo playerself = WorldSystem.Instance.GetPlayerSelf(); if (null == playerself) { return; } /// if ((int)Keyboard.Event.Up == what) { // summonpartner PartnerInfo partnerInfo = roleself.PartnerStateInfo.GetActivePartner(); if (null != partnerInfo) { Data_Unit data = new Data_Unit(); data.m_Id = -1; data.m_LinkId = partnerInfo.LinkId; data.m_CampId = playerself.GetCampId(); data.m_Pos = playerself.GetMovementStateInfo().GetPosition3D(); data.m_RotAngle = 0; data.m_AiLogic = partnerInfo.GetAiLogic(); data.m_AiParam[0] = ""; data.m_AiParam[1] = ""; data.m_AiParam[2] = partnerInfo.GetAiParam().ToString(); data.m_IsEnable = true; NpcInfo npc = WorldSystem.Instance.NpcManager.AddNpc(data); if (null != npc) { AppendAttributeConfig aac = AppendAttributeConfigProvider.Instance.GetDataById(partnerInfo.GetAppendAttrConfigId()); float inheritAttackAttrPercent = partnerInfo.GetInheritAttackAttrPercent(); float inheritDefenceAttrPercent = partnerInfo.GetInheritDefenceAttrPercent(); if (null != aac) { // attack npc.GetBaseProperty().SetAttackBase(Operate_Type.OT_Absolute, (int)(playerself.GetActualProperty().AttackBase *inheritAttackAttrPercent)); npc.GetBaseProperty().SetFireDamage(Operate_Type.OT_Absolute, playerself.GetActualProperty().FireDamage *inheritAttackAttrPercent); npc.GetBaseProperty().SetIceDamage(Operate_Type.OT_Absolute, playerself.GetActualProperty().IceDamage *inheritAttackAttrPercent); npc.GetBaseProperty().SetPoisonDamage(Operate_Type.OT_Absolute, playerself.GetActualProperty().PoisonDamage *inheritAttackAttrPercent); // defence npc.GetBaseProperty().SetHpMax(Operate_Type.OT_Absolute, (int)(playerself.GetActualProperty().HpMax *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetEnergyMax(Operate_Type.OT_Absolute, (int)(playerself.GetActualProperty().EnergyMax *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetADefenceBase(Operate_Type.OT_Absolute, (int)(playerself.GetActualProperty().ADefenceBase *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetMDefenceBase(Operate_Type.OT_Absolute, (int)(playerself.GetActualProperty().MDefenceBase *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetFireERD(Operate_Type.OT_Absolute, playerself.GetActualProperty().FireERD *inheritDefenceAttrPercent); npc.GetBaseProperty().SetIceERD(Operate_Type.OT_Absolute, playerself.GetActualProperty().IceERD *inheritDefenceAttrPercent); npc.GetBaseProperty().SetPoisonERD(Operate_Type.OT_Absolute, playerself.GetActualProperty().PoisonERD *inheritDefenceAttrPercent); // reset hp & energy npc.SetHp(Operate_Type.OT_Absolute, npc.GetActualProperty().HpMax); npc.SetEnergy(Operate_Type.OT_Absolute, npc.GetActualProperty().EnergyMax); } npc.SetAIEnable(true); npc.GetSkillStateInfo().RemoveAllSkill(); npc.BornTime = TimeUtility.GetServerMilliseconds(); List <int> skillList = partnerInfo.GetSkillList(); if (null != skillList) { for (int i = 0; i < skillList.Count; ++i) { SkillInfo skillInfo = new SkillInfo(skillList[i]); npc.GetSkillStateInfo().AddSkill(skillInfo); } } npc.SkillController = new SwordManSkillController(npc, GfxModule.Skill.GfxSkillSystem.Instance); npc.OwnerId = playerself.GetId(); playerself.PartnerId = npc.GetId(); EntityManager.Instance.CreateNpcView(npc.GetId()); if (partnerInfo.BornSkill > 0) { SkillInfo skillInfo = new SkillInfo(partnerInfo.BornSkill); npc.GetSkillStateInfo().AddSkill(skillInfo); npc.SkillController.ForceStartSkill(partnerInfo.BornSkill); } CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId()); if (null != view) { GfxSystem.SetLayer(view.Actor, "PhysicObj"); } } } } }
public static void ExecObjMoveCommand(int objId, float x, float y, float z) { Vector3 pos = new Vector3(x, y, z); CharacterInfo obj = WorldSystem.Instance.GetCharacterById(objId); UserInfo user = obj as UserInfo; if (null != user) { if (!user.UnityPathFinding) { List <Vector3> waypoints = user.SpatialSystem.FindPath(user.GetMovementStateInfo().GetPosition3D(), pos, 1); waypoints.Add(pos); UserAiStateInfo aiInfo = user.GetAiStateInfo(); AiData_ForMoveCommand data = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>(); if (null == data) { data = new AiData_ForMoveCommand(waypoints); aiInfo.AiDatas.AddData(data); } data.WayPoints = waypoints; data.Index = 0; data.EstimateFinishTime = 0; data.IsFinish = false; aiInfo.ChangeToState((int)AiStateId.MoveCommand); } else { UserAiStateInfo aiInfo = user.GetAiStateInfo(); AiData_ForMoveCommand data = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>(); if (null == data) { data = new AiData_ForMoveCommand(null); aiInfo.AiDatas.AddData(data); } user.PathFindingFinished = false; user.GetAiStateInfo().ChangeToState((int)AiStateId.PathFinding); user.GetAiStateInfo().PreviousState = (int)AiStateId.MoveCommand; GfxSystem.ForMoveCommandPathToTarget(user, pos); } } else { NpcInfo npc = obj as NpcInfo; if (null != npc) { if (!npc.UnityPathFinding) { List <Vector3> waypoints = npc.SpatialSystem.FindPath(npc.GetMovementStateInfo().GetPosition3D(), pos, 1); waypoints.Add(pos); NpcAiStateInfo aiInfo = npc.GetAiStateInfo(); AiData_ForMoveCommand data = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>(); if (null == data) { data = new AiData_ForMoveCommand(waypoints); aiInfo.AiDatas.AddData(data); } data.WayPoints = waypoints; data.Index = 0; data.EstimateFinishTime = 0; data.IsFinish = false; aiInfo.ChangeToState((int)AiStateId.MoveCommand); } else { NpcAiStateInfo aiInfo = npc.GetAiStateInfo(); AiData_ForMoveCommand data = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>(); if (null == data) { data = new AiData_ForMoveCommand(null); aiInfo.AiDatas.AddData(data); } npc.PathFindingFinished = false; npc.GetAiStateInfo().ChangeToState((int)AiStateId.PathFinding); npc.GetAiStateInfo().PreviousState = (int)AiStateId.MoveCommand; GfxSystem.ForMoveCommandPathToTarget(npc, pos); } } } }
public void OnGfxHitTarget(int id, int impactId, int targetId, int hitCount, int skillId, int duration, float x, float y, float z, float dir, long hit_count_id) { CharacterInfo sender = WorldSystem.Instance.GetCharacterById(id); CharacterInfo target = WorldSystem.Instance.GetCharacterById(targetId); UserInfo playerSelf = WorldSystem.Instance.GetPlayerSelf(); bool hitCountChanged = false; bool playerHitCountChange = false; long curTime = TimeUtility.GetLocalMilliseconds(); UpdateHitTalent(sender, hit_count_id); // 攻击 if (hitCount > 0) { CombatStatisticInfo senderCombatInfo = sender.GetCombatStatisticInfo(); int last_count = senderCombatInfo.MultiHitCount; if (IsImpactHaveDamage(impactId)) { hitCountChanged = senderCombatInfo.UpdateMultiHitCount(hit_count_id, hitCount, curTime); } if (id == WorldSystem.Instance.PlayerSelfId && null != playerSelf) { if (senderCombatInfo.MultiHitCount >= 1 && last_count != senderCombatInfo.MultiHitCount) { GfxSystem.PublishGfxEvent("ge_hitcount", "ui", senderCombatInfo.MultiHitCount); playerHitCountChange = hitCountChanged; } } CombatStatisticInfo targetCombatInfo = target.GetCombatStatisticInfo(); targetCombatInfo.HitCount += hitCount; if (targetId == WorldSystem.Instance.PlayerSelfId && null != playerSelf) { if (WorldSystem.Instance.IsELiteScene()) { RoleInfo roleInfo = LobbyClient.Instance.CurrentRole; SceneResource curScene = WorldSystem.Instance.GetCurScene(); if (null != roleInfo && null != curScene && roleInfo.GetSceneInfo(WorldSystem.Instance.GetCurSceneId()) == 2) { //当前在挑战3星通关 GfxSystem.PublishGfxEvent("ge_pve_fightinfo", "ui", 0, targetCombatInfo.HitCount, curScene.SceneConfig.m_CompletedHitCount, 0); } playerHitCountChange = true; } } } if (playerHitCountChange && null != playerSelf && (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene())) { CombatStatisticInfo combatInfo = playerSelf.GetCombatStatisticInfo(); ArkCrossEngineMessage.Msg_CR_HitCountChanged msg = new ArkCrossEngineMessage.Msg_CR_HitCountChanged(); msg.max_multi_hit_count = combatInfo.MaxMultiHitCount; msg.hit_count = combatInfo.HitCount; Network.NetworkSystem.Instance.SendMessage(msg); } if (null != sender && null != target) { int hit_count = 0; hit_count = sender.GetCombatStatisticInfo().MultiHitCount; OnGfxStartImpact(sender.GetId(), impactId, target.GetId(), skillId, duration, new Vector3(x, y, z), dir, hit_count); } }
protected virtual bool UpdateVisible(bool visible) { GfxSystem.SetGameObjectVisible(m_Actor, visible); return(visible); }
internal void AddAttachedObject(int objectId, string path) { GfxSystem.AttachGameObject(objectId, m_Actor, path); }
protected void DestroyActor() { GfxSystem.DestroyGameObject(m_Actor); Release(); }
private void PursuitHandler(UserInfo user, AiCommandDispatcher aiCmdDispatcher, long deltaTime) { if (user.IsDead()) { user.GetMovementStateInfo().IsMoving = false; return; } if (user.IsUnderControl()) { user.GetMovementStateInfo().IsMoving = false; return; } if (user.GetSkillStateInfo().IsSkillActivated()) { user.GetMovementStateInfo().IsMoving = false; return; } UserAiStateInfo info = user.GetAiStateInfo(); AiData_UserSelf_General data = GetAiData(user); if (null != data) { CharacterInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(user, info.Target); if (null != target) { float dist = (float)user.GetActualProperty().AttackRange; float distGoHome = (float)user.GohomeRange; Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D(); Vector3 srcPos = user.GetMovementStateInfo().GetPosition3D(); float powDist = Geometry.DistanceSquare(srcPos, targetPos); float powDistToHome = Geometry.DistanceSquare(srcPos, info.HomePos); TryCastSkill(user, target, powDist); // 大于攻击距离 跑向目标 if (powDist > m_AttackRange * m_AttackRange) { info.Time += deltaTime; if (info.Time > m_IntervalTime) { info.Time = 0; if (!user.UnityPathFinding) { AiLogicUtility.PathToTargetWithoutObstacle(user, data.FoundPath, targetPos, m_IntervalTime, true, this); } else { if (info.PreviousState != (int)AiStateId.PathFinding) { user.PathFindingFinished = false; GfxSystem.UserSelfGeneralPathToTarget(user, targetPos); ChangeToState(user, (int)AiStateId.PathFinding); } else { AiLogicUtility.PathToTargetWithoutObstacle(user, data.FoundPath, targetPos, m_IntervalTime, true, this); } } } } else { user.GetMovementStateInfo().IsMoving = false; NotifyUserMove(user); } } else { user.GetMovementStateInfo().IsMoving = false; NotifyUserMove(user); info.Time = 0; ChangeToState(user, (int)AiStateId.Idle); } } }
public virtual void OnTick() { if (m_CurSkillNode != null && m_CurSkillNode.IsAlreadyPressUp) { if (StopSkill(m_CurSkillNode, SwordManSkillController.SKILL_PRESS_UP)) { m_CurSkillNode.IsAlreadyPressUp = false; } } DealBreakSkillTask(); UpdateAttacking(); UpdateSkillNodeCD(); if (m_WaiteSkillBuffer.Count <= 0) { return; } SkillNode node = m_WaiteSkillBuffer[m_WaiteSkillBuffer.Count - 1]; if (node == null) { m_WaiteSkillBuffer.Remove(node); return; } SkillNode nextNode = null; if ((node.Category == SkillCategory.kSkillQ || node.Category == SkillCategory.kSkillE) && m_WaiteSkillBuffer.Count >= 2) { SkillNode lastone = m_WaiteSkillBuffer[m_WaiteSkillBuffer.Count - 2]; if (node.Category == SkillCategory.kSkillQ && lastone.SkillQ != null && lastone.SkillQ.SkillId == node.SkillId) { nextNode = node; node = lastone; } else if (node.Category == SkillCategory.kSkillE && lastone.SkillE != null && lastone.SkillE.SkillId == node.SkillId) { nextNode = node; node = lastone; } } if (m_CurSkillNode == null || IsSkillCanBreak(m_CurSkillNode, node)) { SkillCannotCastType cannot_type = SkillCannotCastType.kUnknow; if (!IsSkillCanStart(node, out cannot_type)) { LogSystem.Debug("skill can't start"); if (IsPlayerSelf()) { GfxSystem.PublishGfxEvent("ge_skill_cannot_cast", "ui", cannot_type); GfxSystem.PublishGfxEvent("ge_skill_false", "ui"); HideSkillTip(node.Category); } m_WaiteSkillBuffer.Clear(); return; } if (m_CurSkillNode != null) { if (StopSkill(m_CurSkillNode, node)) { m_CurSkillNode.IsAlreadyPressUp = false; } } if (StartSkill(node)) { OnSkillStart(node); if (nextNode != null) { m_WaiteSkillBuffer.Add(nextNode); } PostSkillStart(node); } } }
public virtual void PushSkill(SkillCategory category, Vector3 targetpos) { //LogSystem.Debug("in push skill {0}", category); CancelBreakSkillTask(); if (CanInput(category)) { SkillNode target_node = AddCategorySkillNode(category); if (/*target_node != null && */ IsSkillInCD(target_node)) { HideSkillTip(category); LogSystem.Debug("-----skill is in cd"); if (IsPlayerSelf()) { if (SkillControlMode.kTouch == m_ControlMode) { GfxSystem.PublishGfxEvent("ge_skill_false", "ui"); } else { GfxSystem.PublishGfxEvent("ge_skill_cannot_cast", "ui", SkillCannotCastType.kInCD); } } m_WaiteSkillBuffer.RemoveAt(m_WaiteSkillBuffer.Count - 1); return; } //LogSystem.Debug("add skill success!"); if (target_node != null) { target_node.TargetPos = targetpos; if (SkillCategory.kSkillQ != category && SkillCategory.kSkillE != category) { List <SkillNode> qeSkills = new List <SkillNode>(); if (target_node.SkillQ != null) { qeSkills.Add(target_node.SkillQ); } if (target_node.SkillE != null) { qeSkills.Add(target_node.SkillE); } if (m_SkillQECanInputHandler != null) { m_SkillQECanInputHandler(GetWaitInputTime(m_CurSkillNode), qeSkills); } } } else { HideSkillTip(category); LogSystem.Debug("----not find skill " + category); if (category != SkillCategory.kSkillQ && category != SkillCategory.kSkillE) { if (IsPlayerSelf()) { GfxSystem.PublishGfxEvent("ge_skill_false", "ui"); } } } } else { LogSystem.Debug("skill can't input"); } }
internal void SetIndicatorTargetType(int targetType) { GfxSystem.SendMessage(m_IndicatorActor, "SetIndicatorTarget", targetType); }