private void EscapeHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime) { if (!CanAiControl(npc)) { npc.GetMovementStateInfo().IsMoving = false; return; } NpcAiStateInfo info = npc.GetAiStateInfo(); AiData_Npc_Bluelf data = GetAiData(npc); if (null != data) { data.EscapeTime += deltaTime; CharacterInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(npc, info.Target); if (null != target) { Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D(); Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D(); float powDist = Geometry.DistanceSquare(srcPos, targetPos); if (powDist < m_SafeRange * m_SafeRange) { Vector3 escapePos = Vector3.Zero; if (AiLogicUtility.GetEscapeTargetPos(npc, target, 3.0f, ref escapePos)) { info.Time += deltaTime; if (info.Time > m_IntervalTime) { NotifyNpcRun(npc); info.Time = 0; AiLogicUtility.PathToTargetWithoutObstacle(npc, data.FoundPath, escapePos, m_IntervalTime, true, this); } } else { LogSystem.Debug("Can't find WalkAble place"); } } else { TryCastSkill(npc, GetCanCastSkillId(npc, (float)Math.Sqrt(powDist)), target); npc.GetMovementStateInfo().IsMoving = false; NotifyNpcMove(npc); info.Time = 0; data.EscapeTime = 0; ChangeToState(npc, (int)AiStateId.Pursuit); } } else { NotifyNpcTargetChange(npc); npc.GetMovementStateInfo().IsMoving = false; NotifyNpcMove(npc); info.Time = 0; ChangeToState(npc, (int)AiStateId.Idle); } if (data.EscapeTime > m_MaxEscapeTime) { data.EscapeTime = 0; npc.GetMovementStateInfo().IsMoving = false; NotifyNpcMove(npc); info.Time = 0; ChangeToState(npc, (int)AiStateId.Pursuit); } } }
internal static void ChangeScene(int sceneId) { LogSystem.Debug("GameControler.ChangeScene {0}", sceneId); WorldSystem.Instance.ChangeScene(sceneId); }
public void ResetViewed(int radius) { m_Viewed = new bool[radius * 2 + 1, radius * 2 + 1]; LogSystem.Debug("FovViewed reset."); }
private void BuildImpl() { m_BuildStack.Push(0); m_BuildStack.Push(m_PointNum); m_BuildStack.Push(0); while (m_BuildStack.Count >= 3) { int begin = m_BuildStack.Pop(); int end = m_BuildStack.Pop(); int node = m_BuildStack.Pop(); m_KdTree[node].m_Begin = begin; m_KdTree[node].m_End = end; float minX = m_Points[begin].X; float maxX = minX; float minZ = m_Points[begin].Z; float maxZ = minZ; for (int i = begin + 1; i < end; ++i) { float newX = m_Points[i].X; float newZ = m_Points[i].Z; if (minX > newX) { minX = newX; } else if (maxX < newX) { maxX = newX; } if (minZ > newZ) { minZ = newZ; } else if (maxZ < newZ) { maxZ = newZ; } } m_KdTree[node].m_MinX = minX; m_KdTree[node].m_MaxX = maxX; m_KdTree[node].m_MinZ = minZ; m_KdTree[node].m_MaxZ = maxZ; if (end - begin > c_MaxLeafSize) { bool isVertical = (maxX - minX > maxZ - minZ); float splitValue = (isVertical ? 0.5f * (maxX + minX) : 0.5f * (maxZ + minZ)); int left = begin; int right = end; while (left < right) { while (left < right && (isVertical ? m_Points[left].X : m_Points[left].Z) < splitValue) { ++left; } while (right > left && (isVertical ? m_Points[right - 1].X : m_Points[right - 1].Z) >= splitValue) { --right; } if (left < right) { Vector3 tmp = m_Points[left]; m_Points[left] = m_Points[right - 1]; m_Points[right - 1] = tmp; ++left; --right; } } if (left == end) { --left; } int leftSize = left - begin; if (leftSize == 0) { ++leftSize; ++left; } m_KdTree[node].m_Left = node + 1; m_KdTree[node].m_Right = node + 1 + (2 * leftSize - 1); if (m_KdTree[node].m_Left >= m_MaxNodeNum || m_KdTree[node].m_Right >= m_MaxNodeNum) { LogSystem.Error("PointKdTree Error, node:{0} left:{1} right:{2} leftSize:{3} begin:{4} end:{5} maxNodeNum:{6}", node, left, right, leftSize, begin, end, m_MaxNodeNum); } m_BuildStack.Push(m_KdTree[node].m_Left); m_BuildStack.Push(left); m_BuildStack.Push(begin); m_BuildStack.Push(m_KdTree[node].m_Right); m_BuildStack.Push(end); m_BuildStack.Push(left); } } }
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"); } }
public static void LogCallStack() { LogSystem.Debug("LogCallStack:\n{0}\n", Environment.StackTrace); }