Exemple #1
0
        public override void Begin(Single p_lifetime, FXArgs p_args)
        {
            base.Begin(p_lifetime, p_args);
            if (m_Prefab == null)
            {
                Debug.LogError("Prefab not defined!");
                ForceFinish();
                return;
            }
            Quaternion p_rotation;

            if (m_ProjectileDir)
            {
                Vector3 forward = p_args.BeginPointTransform.position - p_args.EndPointTransform.position;
                forward.Normalize();
                p_rotation = Quaternion.LookRotation(forward, m_UpAxis);
            }
            else
            {
                Vector3 forward2 = Vector3.Reflect(Vector3.forward, m_UpAxis);
                p_rotation = Quaternion.LookRotation(forward2, m_UpAxis);
            }
            GameObject gameObject = Helper.Instantiate <GameObject>(m_Prefab, p_args.EndPointTransform.position, p_rotation);

            gameObject.transform.localScale = m_Scale;
            if (m_AttachToTransform)
            {
                gameObject.transform.parent = p_args.EndPointTransform;
            }
            if (!m_SpawnAndForget)
            {
                m_Instance = gameObject;
            }
            SendBroadcastBeginEffect <UnityEventArgs <FXArgs> >(gameObject, new UnityEventArgs <FXArgs>(this, p_args));
        }
        public override void Begin(Single p_lifetime, FXArgs p_args)
        {
            base.Begin(p_lifetime, p_args);
            m_SpawnPerTarget = Math.Max(m_SpawnPerTarget, 1);
            UnityEventArgs <FXArgs> p_args2 = new UnityEventArgs <FXArgs>(this, p_args);

            if (m_ImpactPrefab != null)
            {
                GameObject gameObject = Helper.Instantiate <GameObject>(m_ImpactPrefab, p_args.TargetTransform.position);
                if (m_AttachToTransform)
                {
                    gameObject.transform.parent = p_args.TargetTransform;
                }
                m_Instance = gameObject;
                SendBroadcastBeginEffect <UnityEventArgs <FXArgs> >(gameObject, p_args2);
            }
            if (p_args.Targets != null && m_TargetsImpactPrefab != null)
            {
                m_TargetInstances = new List <GameObject>(p_args.Targets.Count);
                foreach (GameObject gameObject2 in p_args.Targets)
                {
                    Transform  transform = gameObject2.transform;
                    GameObject gameObject;
                    if (!String.IsNullOrEmpty(m_TargetsTag))
                    {
                        FXTags component = gameObject2.GetComponent <FXTags>();
                        if (component != null)
                        {
                            GameObject[] array = component.Find(m_TargetsTag);
                            if (array.Length > 1)
                            {
                                for (Int32 i = 0; i < m_SpawnPerTarget; i++)
                                {
                                    transform  = array.RandomElement <GameObject>().transform;
                                    gameObject = Helper.Instantiate <GameObject>(m_TargetsImpactPrefab, transform.position);
                                    if (m_AttachToTargetTransforms)
                                    {
                                        gameObject.transform.parent = transform;
                                    }
                                    m_TargetInstances.Add(gameObject);
                                    SendBroadcastBeginEffect <UnityEventArgs <FXArgs> >(gameObject, p_args2);
                                }
                                continue;
                            }
                            transform = array.RandomElement <GameObject>().transform;
                        }
                    }
                    gameObject = Helper.Instantiate <GameObject>(m_TargetsImpactPrefab, transform.position);
                    if (m_AttachToTargetTransforms)
                    {
                        gameObject.transform.parent = transform;
                    }
                    m_TargetInstances.Add(gameObject);
                    SendBroadcastBeginEffect <UnityEventArgs <FXArgs> >(gameObject, p_args2);
                }
            }
        }
Exemple #3
0
        public override void Begin(Single p_lifetime, FXArgs p_args)
        {
            base.Begin(p_lifetime, p_args);
            Transform transform;

            if (!String.IsNullOrEmpty(m_Tag))
            {
                FXTags component = p_args.Origin.GetComponent <FXTags>(true);
                if (component == null)
                {
                    Debug.Log("Effect require FXTags component on " + p_args.Origin, p_args.Origin);
                    ForceFinish();
                    return;
                }
                transform = component.FindOne(m_Tag).transform;
            }
            else
            {
                transform = p_args.BeginPointTransform;
            }
            m_Start        = transform.position;
            m_StartTangent = p_args.EndPointTransform.position - m_Start;
            Single magnitude = m_StartTangent.magnitude;

            m_StartTangent.Normalize();
            m_StartTangent   = Quaternion.LookRotation(m_StartTangent) * Quaternion.Euler(-Random.Range(m_CurveVertical.x, m_CurveVertical.y), Random.Range(m_CurveHorizontal.x, m_CurveHorizontal.y), 0f) * new Vector3(0f, 0f, magnitude);
            m_TimeLength     = magnitude / (m_Speed + Single.Epsilon);
            m_FinishMoveTime = Time.time + m_TimeLength;
            GameObject gameObject = Helper.Instantiate <GameObject>(m_Prefab, m_Start);

            m_Instance            = gameObject.transform;
            m_Instance.localScale = m_Scale;
            if (!String.IsNullOrEmpty(m_StartSound))
            {
                AudioController.Play(m_StartSound, m_Start, null);
            }
            if (!String.IsNullOrEmpty(m_FlightLoopSound))
            {
                m_LoopSound = AudioController.Play(m_FlightLoopSound, m_Instance);
            }
            Single z;
            Single x;

            if (5f > Mathf.Abs(Vector3.Distance(transform.position + new Vector3(5f, m_TargetOffset_Y, 0f), p_args.EndPointTransform.position) - Vector3.Distance(transform.position + new Vector3(-5f, m_TargetOffset_Y, 0f), p_args.EndPointTransform.position)))
            {
                z = 0f;
                x = Random.Range(-5, 5);
            }
            else
            {
                x = 0f;
                z = Random.Range(-5, 5);
            }
            m_TargetOffset = new Vector3(x, m_TargetOffset_Y, z);
            Update();
            SendBroadcastBeginEffect <UnityEventArgs <FXArgs> >(gameObject, new UnityEventArgs <FXArgs>(this, p_args));
        }
Exemple #4
0
 public override void Begin(Single p_lifetime, FXArgs p_args)
 {
     base.Begin(p_lifetime, p_args);
     if (m_ImpactPrefab != null)
     {
         UnityEventArgs <FXArgs> p_args2 = new UnityEventArgs <FXArgs>(this, p_args);
         Transform transform             = null;
         FXTags    component             = p_args.Origin.GetComponent <FXTags>();
         if (component != null)
         {
             GameObject gameObject = component.FindOne("CastSpot");
             if (gameObject != null)
             {
                 transform = gameObject.transform;
             }
         }
         GameObject gameObject2;
         if (transform != null)
         {
             gameObject2 = Helper.Instantiate <GameObject>(m_ImpactPrefab, transform.transform.position);
             transform.AddChildAlignOrigin(gameObject2.transform);
         }
         else
         {
             gameObject2 = Helper.Instantiate <GameObject>(m_ImpactPrefab, p_args.OriginTransform.position);
         }
         m_Instance = gameObject2;
         ChainLightning component2 = m_Instance.GetComponent <ChainLightning>();
         if (p_args.Targets != null)
         {
             foreach (GameObject gameObject3 in p_args.Targets)
             {
                 if (!String.IsNullOrEmpty(m_TargetsTag))
                 {
                     FXTags component3 = gameObject3.GetComponent <FXTags>();
                     if (component3 != null)
                     {
                         component2.Targets.Add(component3.FindOne(m_TargetsTag));
                     }
                     else
                     {
                         component2.Targets.Add(gameObject3);
                     }
                 }
                 else
                 {
                     component2.Targets.Add(gameObject3);
                 }
             }
         }
         else
         {
             component2.Targets.Add(p_args.Target);
         }
         SendBroadcastBeginEffect <UnityEventArgs <FXArgs> >(gameObject2, p_args2);
     }
 }
Exemple #5
0
 public virtual void Begin(Single p_lifetime, FXArgs p_args)
 {
     if (p_args == null)
     {
         throw new ArgumentNullException("args");
     }
     m_Lifetime      = p_lifetime;
     m_FinishTime    = Time.time + p_lifetime;
     EffectArguments = p_args;
 }
Exemple #6
0
 public override void Begin(Single p_lifetime, FXArgs p_args)
 {
     base.Begin(p_lifetime, p_args);
     m_freezeTime = Time.time + 0.5f;
     m_target     = p_args.Target;
     if (m_spawner != null)
     {
         m_spawner = Helper.Instantiate <GameObject>(m_spawner, m_target.transform.position);
     }
 }
Exemple #7
0
 public override void Begin(Single p_lifetime, FXArgs p_args)
 {
     base.Begin(p_lifetime, p_args);
     if (m_FadeInFX == null && m_LoopFX == null && m_FadeOutFX == null)
     {
         Debug.LogError("BuffFX: Begin: no FX specified!");
     }
     else
     {
         if (m_FadeInFX != null)
         {
             m_FadeInFX = Helper.Instantiate <FXBase>(m_FadeInFX);
         }
         if (m_LoopFX != null)
         {
             m_LoopFX = Helper.Instantiate <FXBase>(m_LoopFX);
         }
         if (m_FadeOutFX != null)
         {
             m_FadeOutFX = Helper.Instantiate <FXBase>(m_FadeOutFX);
         }
     }
     if (m_FadeInFX != null)
     {
         m_FadeInFX.Begin(p_lifetime, p_args);
     }
     if (!String.IsNullOrEmpty(m_FadeInAudioID))
     {
         AudioController.Play(m_FadeInAudioID, EffectArguments.TargetTransform);
     }
     m_IsStarted = true;
     if (m_DestroyFadeInAfter != -1f)
     {
         m_DestroyFadeInAfter += Time.deltaTime;
     }
 }
Exemple #8
0
 protected virtual void OnDestroy()
 {
     EffectArguments = null;
 }
Exemple #9
0
        public override void Begin(Single p_lifetime, FXArgs p_args)
        {
            base.Begin(p_lifetime, p_args);
            GameObject gameObject = p_args.Origin;

            m_isSlotPos = false;
            if (m_SpawnTarget == ETarget.TARGET)
            {
                gameObject  = p_args.Target;
                m_isSlotPos = false;
            }
            else if (m_SpawnTarget == ETarget.SLOT_ORIGIN)
            {
                targetpos   = p_args.SlotOriginPosition;
                m_isSlotPos = true;
            }
            else if (m_SpawnTarget == ETarget.SLOT_TARGET)
            {
                targetpos   = p_args.SlotTargetPosition;
                m_isSlotPos = true;
            }
            m_Instances = new List <GameObject>();
            if (!String.IsNullOrEmpty(m_Tag))
            {
                FXTags component = gameObject.GetComponent <FXTags>();
                if (component != null)
                {
                    GameObject[] array = component.Find(m_Tag);
                    m_Instances.Capacity = array.Length;
                    m_Instances.AddRange(array);
                }
                else
                {
                    m_Instances.Add(gameObject);
                }
            }
            else
            {
                m_Instances.Add(gameObject);
            }
            Quaternion quaternion           = Quaternion.LookRotation(p_args.SlotForward);
            UnityEventArgs <FXArgs> p_args2 = new UnityEventArgs <FXArgs>(this, p_args);

            for (Int32 i = 0; i < m_Instances.Count; i++)
            {
                if (!(m_Instances[i] == null))
                {
                    Transform  transform = m_Instances[i].transform;
                    GameObject gameObject2;
                    if (!m_isSlotPos)
                    {
                        gameObject2 = Helper.Instantiate <GameObject>(m_Prefab, transform.position, (!m_InheritTransformRotation) ? quaternion : transform.rotation);
                    }
                    else
                    {
                        gameObject2 = Helper.Instantiate <GameObject>(m_Prefab, targetpos, quaternion);
                    }
                    if (m_AttachToTransform)
                    {
                        transform.AddChild(gameObject2.transform);
                    }
                    SendBroadcastBeginEffect <UnityEventArgs <FXArgs> >(gameObject2, p_args2);
                    m_Instances[i] = gameObject2;
                }
            }
        }
Exemple #10
0
        public void OnBeginEffect(UnityEventArgs p_args)
        {
            FXArgs fxargs = (FXArgs)p_args.EventArgs;

            m_slotTargetY = fxargs.SlotTargetPosition.y + 0.1f;
        }
Exemple #11
0
 public override void Begin(Single p_lifetime, FXArgs p_args)
 {
     base.Begin(p_lifetime, p_args);
     m_Instance = Camera.main.gameObject.AddComponent(m_postFXScriptName);
 }