public static void LazyCreateEffect(EffectCode effectCode, Transform SpawnPoint)
 {
     if (effectCode == EffectCode.None) return;
     LSEffect effect = CreateEffect (effectCode);
     effect.CachedTransform.position = SpawnPoint.position;
     effect.Initialize ();
 }
 public static void LazyCreateEffect(EffectCode effectCode, Vector3 position, Quaternion rotation)
 {
     if (effectCode == EffectCode.None) return;
     LSEffect effect = CreateEffect (effectCode);
     effect.CachedTransform.position = position;
     effect.Initialize ();
 }
 public static LSEffect CreateEffect(EffectCode effectCode)
 {
     LSEffect effect = GenEffect (effectCode, -1);
     EffectActive[effect.ID] = true;
     Effects[effect.ID] = effect;
     return effect;
 }
Example #4
0
        private void CreateShader()
        {
            GraphicsLibrary graphicsLibrary = AlkaronCoreGame.Core.GraphicsLibrary;
            EffectCode      effectCode      = GetEffectCode(graphicsLibrary, CodeType.XNAEffect);

            if (effectCode == null)
            {
                Log.Error("Could not load Shader for platform: " + graphicsLibrary + " in Material: " + this.Name);
                return;
            }

            Effect = new Effect(AlkaronCoreGame.Core.GraphicsDevice, effectCode.ByteCode);
        }
Example #5
0
        public int Min(EffectCode effectCode, EffectInheritance inherit, byte paramOrder)
        {
            int min = Int32.MaxValue;

            foreach (var e in GetEffects(effectCode, inherit))
            {
                if ((int)e.Value[paramOrder] < min)
                {
                    min = (int)e.Value[paramOrder];
                }
            }
            return(min);
        }
Example #6
0
        public int Max(EffectCode effectCode, EffectInheritance inherit, byte paramOrder)
        {
            int max = Int32.MinValue;

            foreach (var e in GetEffects(effectCode, inherit))
            {
                if ((int)e.Value[paramOrder] > max)
                {
                    max = (int)e.Value[paramOrder];
                }
            }
            return(max);
        }
Example #7
0
        public List <Effect> GetEffects(EffectCode effectCode, EffectInheritance inherit = EffectInheritance.All)
        {
            var list = new List <Effect>();

            foreach (var tech in technologies)
            {
                list.AddRange(tech.GetEffects(effectCode, inherit, OwnerLocation));
            }
            if ((inherit & EffectInheritance.Upward) == EffectInheritance.Upward)
            {
                if (Parent != null)
                {
                    list.AddRange(Parent.GetEffects(effectCode, EffectInheritance.Upward | EffectInheritance.Self));
                }
            }
            return(list);
        }
Example #8
0
        /// <summary>
        /// Called when this effect is first created.
        /// </summary>
        /// <param name="myEffectCode">My effect code.</param>
        public void Setup(EffectCode myEffectCode)
        {
            MyEffectCode     = myEffectCode;
            CachedTransform  = base.transform;
            CachedGameObject = base.gameObject;
            CachedShuriken   = base.gameObject.GetComponent <ParticleSystem>();
            if (CachedShuriken)
            {
                CachedShurikenVals[0] = CachedShuriken.startSpeed;
                CachedShurikenVals[1] = CachedShuriken.startSize;
            }
            if (OnSetup.IsNotNull())
            {
                OnSetup();
            }
            GameObject.DontDestroyOnLoad(CachedGameObject);

            defaultScale = CachedTransform.localScale;
        }
Example #9
0
        internal List <Effect> GetEffects(EffectCode effectCode, EffectInheritance inherit, EffectLocation targetLocation)
        {
            var  list        = new List <Effect>();
            bool isSelf      = (inherit & EffectInheritance.Self) == EffectInheritance.Self;
            bool isInvisible = (inherit & EffectInheritance.Invisible) == EffectInheritance.Invisible;

            foreach (var effect in TechBase.Effects)
            {
                if (effect.Id != effectCode)
                {
                    continue;
                }
                if (!CheckLocation(OwnerLocation, effect.Location, targetLocation))
                {
                    continue;
                }

                if (isSelf)
                {
                    if (!effect.IsPrivate)
                    {
                        list.Add(effect);
                    }
                }

                if (!isInvisible)
                {
                    continue;
                }

                if (effect.IsPrivate)
                {
                    list.Add(effect);
                }
            }

            return(list);
        }
Example #10
0
 public static GameObject EmitEffect(EffectCode code, Vector3 pos)
 {
     return(Instantiate(Instance.effects[(int)code], pos, Quaternion.identity));
 }
Example #11
0
 public static GameObject EmitEffect(EffectCode code)
 {
     return(Instantiate(Instance.effects[(int)code]));
 }
        /// <summary>
        /// Called when this effect is first created.
        /// </summary>
        /// <param name="myEffectCode">My effect code.</param>
        public void Setup(EffectCode myEffectCode)
        {
            MyEffectCode = myEffectCode;
            CachedTransform = base.transform;
            CachedGameObject = base.gameObject;
            CachedShuriken = base.gameObject.GetComponent<ParticleSystem>();
            if(CachedShuriken){
                CachedShurikenVals[0] = CachedShuriken.startSpeed;
                CachedShurikenVals[1] = CachedShuriken.startSize;
            }
            if (OnSetup .IsNotNull ())
                OnSetup ();
            GameObject.DontDestroyOnLoad (CachedGameObject);

            defaultScale = CachedTransform.localScale;
        }
        private static LSEffect GenEffect(EffectCode effectCode, int id = -1)
        {
            FastStack<LSEffect> pool = EffectPool[effectCode];
            LSEffect effect = null;
            if (pool.Count > 0)
            {
                effect = pool.Pop ();
            }
            else {
                Debug.Log (effectCode);
                EffectDataItem dataItem = CodeDataMap[effectCode];
                effect = GameObject.Instantiate<GameObject> (dataItem.Prefab).GetComponent<LSEffect> ();
                effect.Setup (effectCode);
            }

            if (id == -1)
                id = GenerateID ();
            if (effect.Create (id))
            {
                return effect;
            }
            else {
                return GenEffect (effectCode, id);
            }
        }