override public void StartSkill() { var skill = gameObject.GetComponent <Skill>(); if (!skill || !skill.startGo || !skill.targetGo) { Finish(); return; } mountStartGo = SkillBase.Find(skill.startGo.transform, mountOfStartGo); if (!mountStartGo) { mountStartGo = skill.startGo.transform; } var mountTargetGo = SkillBase.Find(skill.targetGo.transform, mountOfTargetGo); if (!mountTargetGo) { mountTargetGo = skill.targetGo.transform; } lightningReceivers = new GameObject[1] { mountTargetGo.gameObject }; //Initialise the line renderers InitialiseLineRenderers(); }
public override void StartSkill(float speed) { Skill component = base.gameObject.GetComponent <Skill>(); if (!component || !component.startGo || !component.targetGo) { this.Finish(); return; } GameObject targetGo = component.targetGo; this.mountStartGo = SkillBase.Find(component.startGo.transform, this.mountOfStartGo); if (!this.mountStartGo) { this.mountStartGo = component.startGo.transform; } Transform transform = SkillBase.Find(targetGo.transform, this.mountOfTargetGo); if (!transform) { transform = targetGo.transform; } this.lightningReceivers = new GameObject[] { transform.gameObject }; this.InitialiseLineRenderers(); }
private void PlayParticle() { if (this.particle == null) { UnityEngine.Object.Destroy(this); return; } Skill component = base.gameObject.GetComponent <Skill>(); if (component && component.startGo) { Transform transform = SkillBase.Find(component.startGo.transform, this.mountOfStartGo); if (!transform) { transform = component.startGo.transform; } if (this.enableParticle) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.particle); if (this.particleAutoDestroy && gameObject.GetComponent <ParticleParentAutoDestroy>() == null) { gameObject.AddComponent <ParticleParentAutoDestroy>(); gameObject.GetComponent <ParticleParentAutoDestroy>().SetOnce(); } gameObject.transform.parent = transform; Vector3 b = new Vector3(UnityEngine.Random.Range(-this.radius, this.radius), 0f, UnityEngine.Random.Range(-this.radius, this.radius)); gameObject.transform.localPosition = Vector3.zero + this.distance + b; gameObject.transform.localRotation = Quaternion.identity; gameObject.AddComponent <SkillClearParticle>().onClear = delegate { UnityEngine.Object.Destroy(this); }; } } }
void PlayParticle() { if (particle == null) { Destroy(this); return; } var skill = gameObject.GetComponent <Skill>(); if (skill && skill.startGo) { var mount = SkillBase.Find(skill.startGo.transform, mountOfStartGo); if (!mount) { mount = skill.startGo.transform; } var particleGo = Instantiate(particle) as GameObject; if (particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { particleGo.AddComponent <ParticleParentAutoDestroy>(); } particleGo.transform.parent = mount; particleGo.transform.localPosition = Vector3.zero; particleGo.transform.localRotation = Quaternion.identity; } Destroy(this); }
private void Update() { if (this.state == SkillMoveToPositionInSpeed.State.delay) { this.delay -= Time.deltaTime; if (this.delay <= 0f) { this.state = SkillMoveToPositionInSpeed.State.start; } } if (this.state == SkillMoveToPositionInSpeed.State.start) { Skill component = base.gameObject.GetComponent <Skill>(); if (!component || !component.startGo) { this.StartTargetEvent(); return; } Transform transform = SkillBase.Find(component.startGo.transform, this.mountOfStartGo); if (!transform) { transform = component.startGo.transform; } this.mountTargetVec = component.targetPos; if (this.enableParticle) { this.particleGo = UnityEngine.Object.Instantiate <GameObject>(this.particle); if (this.particleAutoDestroy && this.particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { this.particleGo.AddComponent <ParticleParentAutoDestroy>(); } this.particleGo.transform.localPosition = Vector3.zero; this.particleGo.transform.position = transform.transform.position; this.particleGo.AddComponent <SkillClearParticle>().onClear = delegate { UnityEngine.Object.Destroy(this); }; } this.state = SkillMoveToPositionInSpeed.State.move; } else if (this.state == SkillMoveToPositionInSpeed.State.move) { if (!this.particleGo) { this.StartTargetEvent(); return; } this.particleGo.transform.position = Vector3.MoveTowards(this.particleGo.transform.position, this.mountTargetVec, this.speed * Time.deltaTime); if (this.orientToPath) { this.particleGo.transform.LookAt(this.mountTargetVec); } if ((this.mountTargetVec - this.particleGo.transform.position).magnitude <= 0.01f) { this.StartTargetEvent(); } } }
public Vector3 GetTargetHurtPos(SceneEntity target) { if (target == null) { return(Vector3.zero); } Transform transform = SkillBase.Find(target.model.transform, "Dummy002"); if (transform == null) { return(Vector3.zero); } return(transform.position); }
private static int Find(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 2); Transform parent = (Transform)ToLua.CheckUnityObject(L, 1, typeof(Transform)); string childname = ToLua.CheckString(L, 2); Transform obj = SkillBase.Find(parent, childname); ToLua.Push(L, obj); result = 1; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
private void PlayParticle() { if (this.particle == null) { UnityEngine.Object.Destroy(this); return; } Skill component = base.gameObject.GetComponent <Skill>(); if (component && component.startGo) { Transform transform = SkillBase.Find(component.startGo.transform, this.mountOfStartGo); if (!transform) { transform = component.startGo.transform; } if (this.enableParticle) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.particle); if (this.particleAutoDestroy && gameObject.GetComponent <ParticleParentAutoDestroy>() == null) { gameObject.AddComponent <ParticleParentAutoDestroy>(); gameObject.GetComponent <ParticleParentAutoDestroy>().SetOnce(); } if (this.particleMoveWithParent) { gameObject.transform.parent = transform; gameObject.transform.localPosition = Vector3.zero + this.distance; gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localScale = Vector3.one; } else { gameObject.transform.position = transform.position; gameObject.transform.rotation = transform.rotation; } } } UnityEngine.Object.Destroy(this); }
/// <summary> /// Starts the buff,创建一个特效挂载在目标身上 /// </summary> /// <param name="target">Target.</param> public GameObject StartBuff(GameObject target) { if (!target) { return(null); } var mountGo = SkillBase.Find(target.transform, mount); if (!mountGo) { mountGo = target.transform; } GameObject particle = Object.Instantiate(particleGo) as GameObject; if (particle) { particle.transform.parent = mountGo; particle.transform.localPosition = Vector2.zero; } Destroy(this.gameObject); return(particle); }
public GameObject StartBuff(GameObject target) { if (!target) { return(null); } Transform transform = SkillBase.Find(target.transform, this.mount); if (!transform) { transform = target.transform; } GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.particleGo); if (gameObject) { gameObject.transform.parent = transform; gameObject.transform.localPosition = Vector2.zero; gameObject.transform.localScale = Vector3.one; this.AddSound(gameObject); } UnityEngine.Object.Destroy(base.gameObject); return(gameObject); }
private void Update() { if (this.state == SkillCurveToTargetInTime.State.delay) { this.delay -= Time.deltaTime; if (this.delay <= 0f) { this.state = SkillCurveToTargetInTime.State.start; } } if (this.state == SkillCurveToTargetInTime.State.start) { Skill component = base.gameObject.GetComponent <Skill>(); if (!component || !component.startGo || !component.targetGo) { this.StartTargetEvent(); return; } GameObject targetGo = component.targetGo; Transform transform = SkillBase.Find(component.startGo.transform, this.mountOfStartGo); if (!transform) { transform = component.startGo.transform; } this.mountTargetGo = SkillBase.Find(targetGo.transform, this.mountOfTargetGo); if (!this.mountTargetGo) { this.mountTargetGo = targetGo.transform; } if (this.enableParticle) { this.particleGo = UnityEngine.Object.Instantiate <GameObject>(this.particle); if (this.particleAutoDestroy && this.particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { this.particleGo.AddComponent <ParticleParentAutoDestroy>(); } this.particleGo.transform.localPosition = Vector3.zero; this.particleGo.AddComponent <SkillClearParticle>().onClear = delegate { UnityEngine.Object.Destroy(this); }; } this.path = new Vector3[3]; this.path[0] = transform.transform.position; this.curTime = 0f; this.state = SkillCurveToTargetInTime.State.move; } else if (this.state == SkillCurveToTargetInTime.State.move) { this.curTime += Time.deltaTime; float num = this.curTime / this.time; if (num >= 1f) { this.StartTargetEvent(); } if (this.particleGo && this.mountTargetGo) { this.path[2] = this.mountTargetGo.transform.position; Vector3 a = this.path[2] - this.path[0]; float num2 = a.magnitude * 0.5f; this.path[1] = a * 0.5f + new Vector3(num2 * Mathf.Tan(0.0174532924f * this.deviationDegree.x), num2 * Mathf.Tan(0.0174532924f * this.deviationDegree.y), num2 * Mathf.Tan(0.0174532924f * this.deviationDegree.z)); Vector3 position = Spline.InterpConstantSpeed(this.path, num, this.easeType); this.particleGo.transform.position = position; if (this.orientToPath) { this.particleGo.transform.LookAt(Spline.InterpConstantSpeed(this.path, num + 0.05f, this.easeType)); } } } }
private void Update() { if (this.state == SkillCurveToTargetInSpeed.State.delay) { this.delay -= Time.deltaTime; if (this.delay <= 0f) { this.state = SkillCurveToTargetInSpeed.State.start; } } if (this.state == SkillCurveToTargetInSpeed.State.start) { Skill component = base.gameObject.GetComponent <Skill>(); if (!component || !component.startGo || !component.targetGo) { this.StartTargetEvent(); return; } GameObject targetGo = component.targetGo; Transform transform = SkillBase.Find(component.startGo.transform, this.mountOfStartGo); if (!transform) { transform = component.startGo.transform; } this.mountTargetGo = SkillBase.Find(targetGo.transform, this.mountOfTargetGo); if (!this.mountTargetGo) { this.mountTargetGo = targetGo.transform; } if (this.enableParticle) { this.particleGo = UnityEngine.Object.Instantiate <GameObject>(this.particle); if (this.particleAutoDestroy && this.particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { this.particleGo.AddComponent <ParticleParentAutoDestroy>(); } this.particleGo.transform.localPosition = Vector3.zero; this.particleGo.transform.position = transform.transform.position; this.particleGo.AddComponent <SkillClearParticle>().onClear = delegate { UnityEngine.Object.Destroy(this); }; } this.path = new Vector3[3]; this.path[0] = transform.transform.position; this.state = SkillCurveToTargetInSpeed.State.move; } else if (this.state == SkillCurveToTargetInSpeed.State.move) { if (!this.mountTargetGo || !this.particleGo) { this.StartTargetEvent(); return; } float magnitude = (this.mountTargetGo.transform.position - this.particleGo.transform.position).magnitude; if (magnitude <= 0.01f) { this.StartTargetEvent(); } else { this.path[2] = this.mountTargetGo.transform.position; Vector3 a = this.path[2] - this.path[0]; float num = a.magnitude * 0.5f; this.path[1] = a * 0.5f + new Vector3(num * Mathf.Tan(0.0174532924f * this.deviationDegree.x), num * Mathf.Tan(0.0174532924f * this.deviationDegree.y), num * Mathf.Tan(0.0174532924f * this.deviationDegree.z)); float num2 = Spline.PathLength(this.path); if (this.movePosition > num2) { this.movePosition = num2; } this.movePosition = Mathf.MoveTowards(this.movePosition, num2, this.speed * Time.deltaTime); if (this.movePosition > num2) { this.movePosition = num2; } if (this.movePosition >= num2) { this.StartTargetEvent(); } else { float num3 = this.movePosition / num2; Vector3 position = Spline.InterpConstantSpeed(this.path, num3, Easing.EaseType.linear); this.particleGo.transform.position = position; if (this.orientToPath) { this.particleGo.transform.LookAt(Spline.InterpConstantSpeed(this.path, num3 + 0.05f, Easing.EaseType.linear)); } } } } }
private void Update() { if (this.state == SkillMoveToPositionInTime.State.delay) { this.delay -= Time.deltaTime; if (this.delay <= 0f) { this.state = SkillMoveToPositionInTime.State.start; } } if (this.state == SkillMoveToPositionInTime.State.start) { Skill component = base.gameObject.GetComponent <Skill>(); if (!component || !component.startGo) { this.StartTargetEvent(); return; } this.mountTargetVec = component.targetPos; Transform transform = SkillBase.Find(component.startGo.transform, this.mountOfStartGo); if (!transform) { transform = component.startGo.transform; } if (this.enableParticle) { this.particleGo = UnityEngine.Object.Instantiate <GameObject>(this.particle); if (this.particleAutoDestroy && this.particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { this.particleGo.AddComponent <ParticleParentAutoDestroy>(); } this.particleGo.transform.localPosition = Vector3.zero; this.particleGo.AddComponent <SkillClearParticle>().onClear = delegate { UnityEngine.Object.Destroy(this); }; } this.path = new Vector3[] { transform.transform.position, this.mountTargetVec }; this.curTime = 0f; this.state = SkillMoveToPositionInTime.State.move; } else if (this.state == SkillMoveToPositionInTime.State.move) { this.curTime += Time.deltaTime; float num = this.curTime / this.time; if (num >= 1f) { this.StartTargetEvent(); } if (this.particleGo) { Vector3 position = Spline.InterpConstantSpeed(this.path, num, this.easeType); this.particleGo.transform.position = position; if (this.orientToPath) { this.particleGo.transform.LookAt(Spline.InterpConstantSpeed(this.path, num + 0.05f, this.easeType)); } } } }
void Update() { if (state == State.delay) { delay -= Time.deltaTime; if (delay <= 0.0f) { state = State.start; } } if (state == State.start) { var skill = gameObject.GetComponent <Skill>(); if (!skill || !skill.startGo || !skill.targetGo) { StartTargetEvent(); return; } var mountStartGo = SkillBase.Find(skill.startGo.transform, mountOfStartGo); if (!mountStartGo) { mountStartGo = skill.startGo.transform; } mountTargetGo = SkillBase.Find(skill.targetGo.transform, mountOfTargetGo); if (!mountTargetGo) { mountTargetGo = skill.targetGo.transform; } particleGo = Instantiate(particle) as GameObject; if (particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { particleGo.AddComponent <ParticleParentAutoDestroy>(); } particleGo.transform.localPosition = Vector3.zero; particleGo.transform.position = mountStartGo.transform.position; path = new Vector3[3]; path[0] = mountStartGo.transform.position; state = State.move; } else if (state == State.move) { if (!mountTargetGo || !particleGo) { StartTargetEvent(); return; } var distance = (mountTargetGo.transform.position - particleGo.transform.position).magnitude; if (distance <= 0.01f) { StartTargetEvent(); } else { path[2] = mountTargetGo.transform.position; var relative = path[2] - path[0]; var halfDis = relative.magnitude * 0.5f; path[1] = relative * 0.5f + new Vector3(halfDis * Mathf.Tan(Mathf.Deg2Rad * deviationDegree.x), halfDis * Mathf.Tan(Mathf.Deg2Rad * deviationDegree.y), halfDis * Mathf.Tan(Mathf.Deg2Rad * deviationDegree.z)); var pathLength = Spline.PathLength(path); if (movePosition > pathLength) { movePosition = pathLength; } movePosition = Mathf.MoveTowards(movePosition, pathLength, speed * Time.deltaTime); if (movePosition > pathLength) { movePosition = pathLength; } if (movePosition >= pathLength) { StartTargetEvent(); } else { var percentage = movePosition / pathLength; Vector3 curPos = Spline.InterpConstantSpeed(path, percentage); particleGo.transform.position = curPos; if (orientToPath) { particleGo.transform.LookAt(Spline.InterpConstantSpeed(path, percentage + 0.05f)); } } } } }
void Update() { if (state == State.delay) { delay -= Time.deltaTime; if (delay <= 0.0f) { state = State.start; } } if (state == State.start) { var skill = gameObject.GetComponent <Skill>(); if (!skill || !skill.startGo || !skill.targetGo) { StartTargetEvent(); return; } var mountStartGo = SkillBase.Find(skill.startGo.transform, mountOfStartGo); if (!mountStartGo) { mountStartGo = skill.startGo.transform; } mountTargetGo = SkillBase.Find(skill.targetGo.transform, mountOfTargetGo); if (!mountTargetGo) { mountTargetGo = skill.targetGo.transform; } particleGo = Instantiate(particle) as GameObject; if (particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { particleGo.AddComponent <ParticleParentAutoDestroy>(); } particleGo.transform.localPosition = Vector3.zero; particleGo.transform.position = mountStartGo.transform.position; state = State.move; } else if (state == State.move) { if (!mountTargetGo || !particleGo) { StartTargetEvent(); return; } particleGo.transform.position = Vector3.MoveTowards(particleGo.transform.position, mountTargetGo.transform.position, speed * Time.deltaTime); if (orientToPath) { particleGo.transform.LookAt(mountTargetGo.transform); } var relative = mountTargetGo.transform.position - particleGo.transform.position; if (relative.magnitude <= 0.01f) { StartTargetEvent(); } } }
void Update() { if (state == State.delay) { delay -= Time.deltaTime; if (delay <= 0.0f) { state = State.start; } } if (state == State.start) { var skill = gameObject.GetComponent <Skill>(); if (!skill || !skill.startGo || !skill.targetGo) { StartTargetEvent(); return; } var mountStartGo = SkillBase.Find(skill.startGo.transform, mountOfStartGo); if (!mountStartGo) { mountStartGo = skill.startGo.transform; } mountTargetGo = SkillBase.Find(skill.targetGo.transform, mountOfTargetGo); if (!mountTargetGo) { mountTargetGo = skill.targetGo.transform; } particleGo = Instantiate(particle) as GameObject; if (particleGo.GetComponent <ParticleParentAutoDestroy>() == null) { particleGo.AddComponent <ParticleParentAutoDestroy>(); } particleGo.transform.localPosition = Vector3.zero; path = new Vector3[3]; path[0] = mountStartGo.transform.position; curTime = 0.0f; state = State.move; } else if (state == State.move) { curTime += Time.deltaTime; float percentage = curTime / time; if (percentage >= 1.0f) { StartTargetEvent(); } if (particleGo && mountTargetGo) { path[2] = mountTargetGo.transform.position; var relative = path[2] - path[0]; var halfDis = relative.magnitude * 0.5f; path[1] = relative * 0.5f + new Vector3(halfDis * Mathf.Tan(Mathf.Deg2Rad * deviationDegree.x), halfDis * Mathf.Tan(Mathf.Deg2Rad * deviationDegree.y), halfDis * Mathf.Tan(Mathf.Deg2Rad * deviationDegree.z)); Vector3 curPos = Spline.InterpConstantSpeed(path, percentage, easeType); particleGo.transform.position = curPos; if (orientToPath) { particleGo.transform.LookAt(Spline.InterpConstantSpeed(path, percentage + 0.05f, easeType)); } } } }