//设置释放点位置 public void ShowSkillAttackRange(float x, float y) { if (skillAttackRange == null) { skillAttackRange = GameObject.FindObjectOfType <SkillAttackRange>(); } if (skillAttackRange == null) { Debug.LogError("没有找到 SkillReleaseRange 组件"); return; } Ray ray = Camera.main.ScreenPointToRay(new Vector3(x, y, 0)); RaycastHit hit; int layerMask; layerMask = LayerMask.GetMask("Road"); if (Physics.Raycast(ray, out hit, 100, layerMask)) { //targetPosition = hit.point; // skillReleaseDot; skillReleaseDot.position = hit.point; skillAttackRange.LookAt(skillReleaseDot.position); } else { skillReleaseDot.position = Vector3.zero; } skillAttackRange.visible = true; }
// Update is called once per frame virtual public void Update() { if (autoFindTarget && target == null) { GameObject targetGo = GameObject.FindGameObjectWithTag(targetTag); if (targetGo) { target = targetGo.transform; } } if (skillAttackRange == null) { skillAttackRange = GetComponent <SkillAttackRange>(); } else { distance = skillAttackRange.distance; } UpdateCircleVertices(); }
void TryInit() { if (player == null) { player = GameObject.FindGameObjectWithTag(playerTag); } if (skillReleaseRange == null) { skillReleaseRange = GameObject.FindObjectOfType <SkillReleaseRange>(); } if (skillAttackRange == null) { skillAttackRange = GameObject.FindObjectOfType <SkillAttackRange>(); if (skillAttackRange != null) { if (skillCastType == SkillCastType.SKILL_SECTOR) { skillAttackRange.skillAttackRangeType = SkillAttackRangeType.Sector; } else if (skillCastType == SkillCastType.SKILL_RECT) { skillAttackRange.skillAttackRangeType = SkillAttackRangeType.Rect; } else if (skillCastType == SkillCastType.SKILL_CIRCLE) { skillAttackRange.skillAttackRangeType = SkillAttackRangeType.Circle; } } } if (skillReleaseDot == null) { GameObject skillReleaseDotGo = GameObject.Find("SkillReleaseDot"); if (skillReleaseDotGo == null) { skillReleaseDotGo = new GameObject("SkillReleaseDot"); } if (skillReleaseDotGo != null) { skillReleaseDot = skillReleaseDotGo.transform; } } if (skillAttackDot == null) { GameObject skillAttackDotGo = GameObject.Find("SkillAttackDot"); if (skillAttackDotGo == null) { skillAttackDotGo = new GameObject("SkillAttackDot"); } if (skillAttackDotGo != null && skillAttackRange != null) { skillAttackDot = skillAttackDotGo.transform; skillAttackRange.target = skillAttackDot; } } if (player != null) { ani = player.GetComponent <Animation>(); //gameObject.GetComponent<Button>().onClick.AddListener(OnClick); } if (skill == null) { //测试数据 if (skillCastType == SkillCastType.SKILL_SECTOR) { skillAttackRange.rangeParameter = 90f; } else if (skillCastType == SkillCastType.SKILL_RECT) { skillAttackRange.rangeParameter = 2f; } else if (skillCastType == SkillCastType.SKILL_CIRCLE) { skillAttackRange.rangeParameter = 2.6f; } //ene 测试数据 } if (m_SkillRange == null) { m_SkillRange = Camera.main.GetComponent <SkillAttackRange>(); } }