public static void Begin(GameObject target, Vector3 startPosition, Vector3 endPosition, float speed, float targetSpeed, iTween.EventDelegate complete = null) { SkillLineTrack track = target.AddComponent <SkillLineTrack>() as SkillLineTrack; track.SetParameters(startPosition, endPosition, speed, targetSpeed, complete); }
public virtual void CreateFlyParticle() { bool isCreate = false; foreach (SkillEffectData.SkillFlyParticleData flyParticleData in skillDataSlot._skillEffectData._skillFlyParticleList) { if (currTrackTime >= flyParticleData._delayTime) { // tzz added for null if (skillUser == null) { continue; } // Play fly sound if (null != flyParticleData._skillSound) { Debug.Log("skillUser " + skillUser.gameObject.name + "Sound " + flyParticleData._skillSound._soundName); Globals.Instance.MSoundManager.PlaySoundEffect(flyParticleData._skillSound._soundName); } Vector3 startPosition = skillUser.transform.position; // Create multiple missile effects foreach (SkillDataSlot.AttackTargetData attackTargetData in skillDataSlot._attackTargetDataList.Values) { UnityEngine.Object obj = Resources.Load(flyParticleData._particleName); if (null == obj) { isCreate = true; Debug.Log("[Skill]: Cann't find the fly effect name " + flyParticleData._particleName); continue; } // Calculate the Projectile ParticleEffect information GUIBattleMain battle = Globals.Instance.MGUIManager.GetGUIWindow <GUIBattleMain>(); FightCellSlot target = battle.GetFightCellSlot(attackTargetData._targetID); Vector3 endPosition = target.transform.position; float missileHorzSpeed = flyParticleData.speed * Globals.Instance.MGUIManager.widthRatio; float targetHorzSpeed = 0.0f; // target.MoveSpeed; if (attackTargetData._moveState == (int)GameData.BattleGameData.MoveState.STOP) { targetHorzSpeed = 0.0f; } startPosition.z += FightCellSlot.EffectSkillOffset; endPosition.z += FightCellSlot.EffectSkillOffset; GameObject go = Globals.Instance.M3DItemManager.CreateEZ3DItem(obj, startPosition); go.transform.position = startPosition; obj = null; // Release it // Rotate the fly particle Vector3 dir = endPosition - startPosition; dir.Normalize(); float dotVal = Vector3.Dot(Vector3.right, dir); float degAngle = Mathf.Rad2Deg * Mathf.Acos(dotVal); Vector3 dirCross = Vector3.Cross(Vector3.right, dir); if (Vector3.Dot(dirCross, Vector3.forward) < 0) { degAngle = 360.0f - degAngle; } go.transform.rotation = Quaternion.AngleAxis(degAngle, Vector3.forward); if (skillDataSlot.IsCureSkill()) { SkillTimerTrack.Begin(go, 0.001f, delegate() { Globals.Instance.M3DItemManager.DestroyEZ3DItem(go); OnTouchTarget(); OnSkillEnd(); }); } else { SkillLineTrack.Begin(go, startPosition, endPosition, missileHorzSpeed, targetHorzSpeed, delegate() { Globals.Instance.M3DItemManager.DestroyEZ3DItem(go); // Complete delegate OnTouchTarget(); OnSkillEnd(); }); } isCreate = true; skillState = SkillState.FLY; } // End foreach } } isFlyParticleCreated = isCreate; }