private void Cleaving(SkillUI skillUIElement, int times) { if (times >= cleavingTimes) { return; } for (int index = 0; index < cleavingAmount; index++) { SkillUI ghostSkillUIElement = ResourceUtils.AddAndGetComponent <SkillUI>(GlobalDefinitions.RESOURCE_PATH_SKILL + data.resourceID); ghostSkillUIElement.IgnoreCollisionMap(true); ghostSkillUIElement.transform.position = skillUIElement.transform.position; ghostSkillUIElement.positionLastFrame = skillUIElement.transform.position; ghostSkillUIElement.transform.localScale = Vector2.one; ghostSkillUIElement.data = skillUIElement.data; ghostSkillUIElement.owner = skillUIElement.owner; ghostSkillUIElement.gameObject.AddComponent <ComponentDefaultEffect>().spinEnabled = false; ghostSkillUIElement.animator.Play(AnimationDefs.Run.ToString().ToLower()); ghostSkillUIElement.OnUpdate = () => { if (ghostSkillUIElement.positionLastFrame.y > ghostSkillUIElement.transform.position.y) { ghostSkillUIElement.body2D.isKinematic = false; ghostSkillUIElement.collider2D.enabled = true; ghostSkillUIElement.OnHit = () => { Cleaving(ghostSkillUIElement, times + 1); }; } }; } }
private void OnAnimationEventTriggered(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameIndex) { animator.AnimationEventTriggered -= OnAnimationEventTriggered; tk2dSpriteAnimationFrame frame = clip.GetFrame(frameIndex); if (frame.eventInfo == AnimationTriggerDefs.SkillApply.ToString()) { Vector3 startPoint = this.skillUIElement.transform.position; float degree = Mathf.Atan2(targetPosition.y - startPoint.y, targetPosition.x - startPoint.x) * Mathf.Rad2Deg; float angle = degree * Mathf.Deg2Rad; this.skillUIElement.Apply(owner, data, angle); for (int index = 0; index < shotAmount; index++) { SkillUI skillUIElement = ResourceUtils.AddAndGetComponent <SkillUI>(GlobalDefinitions.RESOURCE_PATH_SKILL + data.resourceID); skillUIElement.transform.SetParent(owner.componentsHolder.transform); skillUIElement.IgnoreCollisionMap(true); skillUIElement.transform.position = startPoint; skillUIElement.transform.localScale = Vector2.one; angle = (degree - shotDegree * (index + 1)) * Mathf.Deg2Rad; skillUIElement.Apply(owner, data, angle); } for (int index = 0; index < shotAmount; index++) { skillUIElement = ResourceUtils.AddAndGetComponent <SkillUI>(GlobalDefinitions.RESOURCE_PATH_SKILL + data.resourceID); skillUIElement.transform.SetParent(owner.componentsHolder.transform); skillUIElement.IgnoreCollisionMap(true); skillUIElement.transform.position = startPoint; skillUIElement.transform.localScale = Vector2.one; angle = (degree + shotDegree * (index + 1)) * Mathf.Deg2Rad; skillUIElement.Apply(owner, data, angle); } Destroy(this); this.skillUIElement = null; } }
private void Fire() { for (int index = 0; index < meteorAmount; index++) { Vector2 position = (Random.insideUnitCircle * radius) + startPoint; SkillUI skillUIElement = ResourceUtils.AddAndGetComponent <SkillUI>(GlobalDefinitions.RESOURCE_PATH_SKILL + data.resourceID); skillUIElement.transform.position = position; skillUIElement.transform.localScale = Vector3.one; skillUIElement.IgnoreCollisionMap(true); skillUIElement.Visible(false); skillUIElement.FadeIn(3.0f); skillUIElement.Apply(owner, data, -Mathf.PI / 6.0f); } }
protected override IEnumerator RunProcessor() { yield return(base.RunProcessor()); for (int index = 0; index < startPoints.Length; index++) { SkillUI skillUIElement = ResourceUtils.AddAndGetComponent <SkillUI>(GlobalDefinitions.RESOURCE_PATH_SKILL + data.resourceID); skillUIElement.transform.position = startPoints[index]; skillUIElement.transform.localScale = Vector3.one; skillUIElement.IgnoreCollisionMap(true); skillUIElement.Visible(false); skillUIElement.FadeIn(3.0f); skillUIElement.Apply(owner, data, 0); yield return(new WaitForSeconds(interval)); } Cancel(); }