public void InitDefault()
        {
            Birth.AddKey(0, 1.0f);
            Life.AddKey(0, 10.0f);
            Thickness.AddKey(0, 1.0f);
            Velocity.AddKey(0, new Vector3(0, 1, 0));


            MyAnimatedPropertyVector4 colorKey = new MyAnimatedPropertyVector4(Color.Name);

            colorKey.AddKey(0, new Vector4(1, 0, 0, 1));
            colorKey.AddKey(1, new Vector4(0, 0, 1, 1));
            Color.AddKey(0, colorKey);

            MyAnimatedPropertyFloat radiusKey = new MyAnimatedPropertyFloat(Radius.Name);

            radiusKey.AddKey(0, 1.0f);
            Radius.AddKey(0, radiusKey);

            MyAnimatedPropertyTransparentMaterial materialKey = new MyAnimatedPropertyTransparentMaterial(Material.Name);

            materialKey.AddKey(0, MyTransparentMaterials.GetMaterial("Smoke"));
            Material.AddKey(0, materialKey);

            LODBirth.AddKey(0, 1.0f);
            LODBirth.AddKey(MyConstants.MAX_PARTICLE_DISTANCE_DEFAULT, 0f);
            LODRadius.AddKey(0, 1.0f);

            PivotDistVar.SetValue(1.0f);

            AccelerationVar.SetValue(0.0f);

            UseLayerSorting.SetValue(false);
            SortLayer.SetValue(-1);
        }
        /// <summary>
        /// Only for some testing values
        /// </summary>
        public void InitDefault()
        {
            Birth.AddKey(0, 1.0f);
            Life.AddKey(0, 10.0f);
            Thickness.AddKey(0, 1.0f);
            Velocity.AddKey(0, new Vector3(0, 1, 0));


            MyAnimatedPropertyVector4 colorKey = new MyAnimatedPropertyVector4(Color.Name);

            colorKey.AddKey(0, new Vector4(1, 0, 0, 1));
            colorKey.AddKey(1, new Vector4(0, 0, 1, 1));
            Color.AddKey(0, colorKey);

            MyAnimatedPropertyFloat radiusKey = new MyAnimatedPropertyFloat(Radius.Name);

            radiusKey.AddKey(0, 1.0f);
            Radius.AddKey(0, radiusKey);

            MyAnimatedPropertyTransparentMaterial materialKey = new MyAnimatedPropertyTransparentMaterial(Material.Name);

            materialKey.AddKey(0, MyTransparentMaterials.GetMaterial("Smoke"));
            Material.AddKey(0, materialKey);

            LODBirth.AddKey(0, 1.0f);
            LODRadius.AddKey(0, 1.0f);

            UseLayerSorting.SetValue(false);
            SortLayer.SetValue(-1);
        }
示例#3
0
 void Awake()
 {
     sr           = GetComponent <SpriteRenderer>();
     spriteColour = sr.color;
     _street      = GetComponentInParent <Street>().streetID;
     _layer       = initLayer;
     Recalc();
     SSSs.Add(this);
 }
        //  For sorting generations if needed
        public int CompareTo(object compareToObject)
        {
            MyParticleGeneration compareToGeneration = (MyParticleGeneration)compareToObject;

            if (UseLayerSorting && compareToGeneration.UseLayerSorting)
            {
                return(SortLayer.GetValue <int>().CompareTo(compareToGeneration.SortLayer.GetValue <int>()));
            }

            return(0);
        }
示例#5
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        Human human = collision.gameObject.GetComponent <Human>();

        //If collided with human
        if (human != null && Activated && !human.falling)
        {
            Transform shadow = human.gameObject.transform.Find("Shadow");
            if (shadow != null)
            {
                Debug.Log(shadow);
                Destroy(shadow.gameObject);
            }
            human.StopAllCoroutines();

            SortLayer sortLayer = human.gameObject.GetComponent <SortLayer>();
            sortLayer.offset = -6000;
            human.gameObject.transform.GetChild(0).GetComponent <SortParent>().offset = -1;

            Vector3 humanpos = human.transform.position;
            Vector3 newPos   = Vector3.Lerp(humanpos, gameObject.transform.position, 0.1f);

            Vector3 thisPos = gameObject.transform.position;

            if (Vector3.Magnitude(humanpos - newPos) < 0.1f)
            {
                collision.gameObject.GetComponent <Collider2D>().enabled = false;
                Drop(human);
            }
            else
            {
                human.transform.position = newPos;
            }
        }
        if (collision.gameObject.tag == "Roomba")
        {
            Roomba roomba = collision.gameObject.GetComponent <Roomba>();
            roomba.bodyCarried = false;
        }
        else
        {
            collision.gameObject.transform.parent = border.transform;
        }
    }
        public void Init()
        {
            System.Diagnostics.Debug.Assert(Birth == null);

            AddProperty(MyGenerationPropertiesEnum.Birth, new MyAnimatedPropertyFloat("Birth"));
            AddProperty(MyGenerationPropertiesEnum.BirthVar, new MyConstPropertyFloat("Birth var"));

            AddProperty(MyGenerationPropertiesEnum.Life, new MyAnimatedPropertyFloat("Life"));
            AddProperty(MyGenerationPropertiesEnum.LifeVar, new MyConstPropertyFloat("Life var"));

            AddProperty(MyGenerationPropertiesEnum.Velocity, new MyAnimatedPropertyVector3("Velocity"));
            AddProperty(MyGenerationPropertiesEnum.VelocityDir, new MyConstPropertyEnum("Velocity dir", typeof(MyVelocityDirEnum), s_velocityDirStrings));

            AddProperty(MyGenerationPropertiesEnum.Angle, new MyAnimatedPropertyFloat("Angle"));
            AddProperty(MyGenerationPropertiesEnum.AngleVar, new MyConstPropertyFloat("Angle var"));

            AddProperty(MyGenerationPropertiesEnum.RotationSpeed, new MyAnimatedPropertyFloat("Rotation speed"));
            AddProperty(MyGenerationPropertiesEnum.RotationSpeedVar, new MyConstPropertyFloat("Rotation speed var"));

            AddProperty(MyGenerationPropertiesEnum.Radius, new MyAnimatedProperty2DFloat("Radius"));
            AddProperty(MyGenerationPropertiesEnum.RadiusVar, new MyAnimatedPropertyFloat("Radius var"));

            AddProperty(MyGenerationPropertiesEnum.Color, new MyAnimatedProperty2DVector4("Color"));
            AddProperty(MyGenerationPropertiesEnum.ColorVar, new MyAnimatedPropertyFloat("Color var"));

            AddProperty(MyGenerationPropertiesEnum.Material, new MyAnimatedProperty2DTransparentMaterial("Material", MyTransparentMaterialInterpolator.Switch));

            AddProperty(MyGenerationPropertiesEnum.ParticleType, new MyConstPropertyEnum("Particle type", typeof(MyParticleTypeEnum), s_particleTypeStrings));

            AddProperty(MyGenerationPropertiesEnum.Thickness, new MyAnimatedPropertyFloat("Thickness"));

            AddProperty(MyGenerationPropertiesEnum.Enabled, new MyConstPropertyBool("Enabled"));
            Enabled.SetValue(true);

            AddProperty(MyGenerationPropertiesEnum.BlendTextures, new MyConstPropertyBool("Blend textures"));
            BlendTextures.SetValue(true);

            AddProperty(MyGenerationPropertiesEnum.EnableCustomRadius, new MyConstPropertyBool("Enable custom radius"));
            AddProperty(MyGenerationPropertiesEnum.EnableCustomVelocity, new MyConstPropertyBool("Enable custom velocity"));
            AddProperty(MyGenerationPropertiesEnum.EnableCustomBirth, new MyConstPropertyBool("Enable custom birth"));

            AddProperty(MyGenerationPropertiesEnum.OnDie, new MyConstPropertyGenerationIndex("OnDie"));
            OnDie.SetValue(-1);
            AddProperty(MyGenerationPropertiesEnum.OnLife, new MyConstPropertyGenerationIndex("OnLife"));
            OnLife.SetValue(-1);

            AddProperty(MyGenerationPropertiesEnum.LODBirth, new MyAnimatedPropertyFloat("LODBirth"));
            AddProperty(MyGenerationPropertiesEnum.LODRadius, new MyAnimatedPropertyFloat("LODRadius"));

            AddProperty(MyGenerationPropertiesEnum.MotionInheritance, new MyAnimatedPropertyFloat("Motion inheritance"));

            AddProperty(MyGenerationPropertiesEnum.UseLayerSorting, new MyConstPropertyBool("Use layer sorting"));
            AddProperty(MyGenerationPropertiesEnum.SortLayer, new MyConstPropertyInt("Sort layer"));
            AddProperty(MyGenerationPropertiesEnum.AlphaAnisotropic, new MyConstPropertyBool("Alpha anisotropic"));

            AddProperty(MyGenerationPropertiesEnum.Gravity, new MyConstPropertyFloat("Gravity"));

            Thickness.AddKey(0, 1.0f);

            LODBirth.AddKey(0, 1.0f);
            LODRadius.AddKey(0, 1.0f);

            UseLayerSorting.SetValue(false);
            SortLayer.SetValue(-1);

            m_emitter.Init();
        }
示例#7
0
    bool SpwanObjectAt(GameObject obj, Transform parent)
    {
        if (parent == null)
        {
            return(false);
        }
        GameObject swpanObj = null;

        var posProperty = parent.GetComponent <PositionProperty>();

        if (posProperty == null)
        {
            return(false);
        }

        if (posProperty.positionType == EnemySpwanPosition.FixedPosition)
        {
            swpanObj = (GameObject)Instantiate(obj, parent.position, parent.rotation);
            swpanObj.transform.parent = parent.transform;
        }
        else if (posProperty.positionType == EnemySpwanPosition.RandomPosition)
        {
            Vector3 postion = new Vector3(posProperty.GetRandomX(), parent.position.y, parent.position.z);
            swpanObj = (GameObject)Instantiate(obj);
            swpanObj.transform.SetParent(parent);
            swpanObj.transform.position = postion;
        }
        if (swpanObj != null)
        {
            //避免重叠
            float timeFlag = Time.time / 100000;
            timeFlag = timeFlag - Mathf.FloorToInt(timeFlag);
            swpanObj.transform.position += new Vector3(0, 0, -timeFlag);
            //swpanObj.transform. = parent.transform;
            swpanObj.transform.localScale = parent.transform.lossyScale;

            //disable mask
            if (!posProperty.enableMask)
            {
                var mask = swpanObj.transform.FindChild("mask");
                mask.gameObject.SetActive(false);
            }
            EnemyEmerge ee = parent.GetComponent <EnemyEmerge>();
            if (ee != null)
            {
                EnemyEmerge enew = swpanObj.AddComponent <EnemyEmerge>();
                enew.CopyFrom(ee);
                enew.RunEmerge();
            }

            //敌人的属性
            GAFEnemy e = swpanObj.GetComponent <GAFEnemy>();
            if (e == null)
            {
                Debug.Log("Dont have Enemy component!");
                e = swpanObj.AddComponent <GAFEnemy>();
            }

            e.EnhanceByTurn(1 + currentTurn * enhancePerTurn + currentWave * enhancePerWave);
            SortLayer sl = parent.GetComponent <SortLayer>();
            if (sl != null && sl.layerName != "")
            {
                SpriteRenderer[] render = swpanObj.GetComponentsInChildren <SpriteRenderer>();
                if (render != null && render.Length > 0)
                {
                    for (int i = 0; i < render.Length; i++)
                    {
                        render[i].sortingLayerName = sl.layerName;
                    }
                }

                var sortlayer = swpanObj.AddComponent <GAFSortLayer>();
                sortlayer.sortLayerName = sl.layerName;
            }
            //是否能够横向漫游
            EnemyWanderX[] wanders = swpanObj.GetComponents <EnemyWanderX>();
            if (wanders != null && wanders.Length > 0)
            {
                for (int i = 0; i < wanders.Length; i++)
                {
                    if (wanders[i].GetType() == typeof(EnemyWanderRunX))
                    {
                        wanders[i].enabled = posProperty.allowRunX;
                    }
                    else
                    {
                        wanders[i].enabled = posProperty.allowWanderX;
                    }
                    wanders[i].minMovementX = posProperty.minMovementX;
                    wanders[i].maxMovementX = posProperty.maxMovementX;
                }
            }

            //通知GameManager ,产生了敌人
            AddAliveEmeny();
            needCreateEnemy--;
            return(true);
        }
        return(false);
    }