コード例 #1
0
 public ParticleParamaters(
     double start,
     double end,
     ParticleDirection particleDir,
     Vector2Range pos, OsbEasing ease,
     double dur, int partAmmount,
     bool randX       = false, bool randY         = true,
     bool sameYEnd    = false, bool randomYEnd    = false,
     Vector2?scale    = null, bool randomScale    = false,
     Vector2?rotation = null, bool randomRotation = false,
     double fade      = 1
     )
 {
     this.direction       = particleDir;
     this.Positions       = pos;
     this.easing          = ease;
     this.duration        = dur;
     this.particleAmmount = partAmmount;
     this.randomX         = randX;
     this.randomY         = randY;
     this.startTime       = start;
     this.endTime         = end;
     this.scale           = ((Vector2)scale).Equals(null) ? (Vector2)scale : new Vector2(1, 1);
     this.rotation        = ((Vector2)rotation).Equals(null) ? (Vector2)rotation : new Vector2(0, 0);
     this.randomRotation  = randomRotation;
     this.randomScale     = randomScale;
     this.sameYEnd        = sameYEnd;
     this.fade            = fade;
     this.randomYEnd      = randomYEnd;
 }
コード例 #2
0
    private void EmitParticles(bool fromCenter)
    {
        GameObject        particles = (GameObject)Instantiate(Resources.Load("TeleportParticles"), transform.position, Quaternion.identity);
        ParticleDirection pd        = particles.GetComponent <ParticleDirection>();

        pd.direction  = HelperFunctions.directionBetween(transform.position, target.position);
        pd.fromCenter = fromCenter;
        pd.Emit();
    }
コード例 #3
0
ファイル: PlayerEntity.cs プロジェクト: pacojq/Ferret
        public PlayerEntity()
        {
            Sprite[] sprites = FeContent.LoadSpriteSheet("character/charAtlas.feAsset");

            Animation           anim  = new Animation(sprites, "walk", .1f);
            AnimationController contr = new AnimationController(anim);

            Renderer          = new SpriteRenderer(sprites[0]);
            Renderer.Material = new Material(SandboxGame.TestEffect);

            AnimationComponent animComponent = new AnimationComponent(Renderer, contr);

            Bind(Renderer);
            Bind(animComponent);



            BoxCollider col = new BoxCollider(sprites[0].Width, sprites[0].Height, Vector2.Zero);

            Bind(col);

            col.OnCollisionEnter += o => FeLog.Debug($"PLAYER ENTER: {this}");
            col.OnCollisionExit  += o => FeLog.Debug($"PLAYER EXIT: {this}");


            ParticleType partType = new ParticleType(FeContent.LoadSprite("box.png"))
            {
                Lifetime       = ParticleLifetime.RandomRange(0.5f, 1f),
                StartAngle     = ParticleAngle.RandomRange(0, 360),
                StartSpeed     = ParticleSpeed.RandomRange(-2f, 2f),
                StartDirection = ParticleDirection.RandomRange(0, 360)
            };

            ParticleEmitter emitter = new ParticleEmitter(partType)
            {
                AutoEmit       = true,
                BurstCunt      = 5,
                EmitDelay      = 3,
                BurstSteps     = 8,
                BurstStepDelay = .1f
            };

            Bind(emitter);



            Bind(new PlayerComponent());
            //Bind(new PlayerComponentGamepad());
        }
コード例 #4
0
        private idBounds _bounds;                                                       // derived.
        #endregion

        #region Constructor
        public idParticleStage()
        {
            _distribution      = ParticleDistribution.Rectangle;
            _distributionParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };

            _direction      = ParticleDirection.Cone;
            _directionParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };

            _customPath      = ParticleCustomPath.Standard;
            _customPathParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };

            _orientation      = ParticleOrientation.View;
            _orientationParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };

            _randomDistribution = true;
        }
コード例 #5
0
        public ParticleType(Sprite sprite)
        {
            Sprite     = sprite;
            StartColor = Color.White;

            Lifetime = ParticleLifetime.Fixed(1f);

            StartSpeed   = ParticleSpeed.Fixed(0f);
            Acceleration = ParticleAcceleration.Fixed(0f);

            StartSize = ParticleSize.Fixed(1f);
            Growth    = ParticleGrowth.Fixed(0f);

            StartAngle = ParticleAngle.Fixed(0f);
            Rotation   = ParticleRotation.Fixed(0f);

            StartDirection = ParticleDirection.Fixed(0f);
        }
コード例 #6
0
    public void MarchingParticle(Layers layer, int startTime, int endTime, int divisor, string spriteFile, ParticleGeneration particleGenType, ParticleDirection direction)
    {
        if (particleGenType == ParticleGeneration.Pool)
        {
            using (var pool = new OsbSpritePool(GetLayer(layer), spriteFile, OsbOrigin.Centre, (sprite, sTime, eTime) => {
                sprite.Fade(sTime, Random(0.2f, 0.9f));
                sprite.Scale(sTime, Random(20f, 80f));
                if (direction == ParticleDirection.Top || direction == ParticleDirection.Bottom)
                {
                    sprite.MoveX(sTime, Random(-107, 757));
                }
                else if (direction == ParticleDirection.Left || direction == ParticleDirection.Right)
                {
                    sprite.MoveY(sTime, Random(0, 512));
                }

                if (eTime > endTime - GetBeatDuration(startTime, divisor) * 4) //Hide sprites if they cross the end time
                {
                    sprite.Fade(endTime, 0f);
                }
            }))
            {
                for (var sTime = (double)startTime; sTime <= endTime - GetBeatDuration(startTime, 1) * 4; sTime += GetBeatDuration(startTime, 2))
                {
                    var baseSpeed = Random(40, 120);
                    var eTime     = sTime + Math.Ceiling(930f / baseSpeed) * GetBeatDuration(startTime, 1);


                    var sprite = pool.Get(sTime, eTime);

                    bool fromTop     = direction == ParticleDirection.Bottom || direction == ParticleDirection.Right;
                    var  moveSpeed   = baseSpeed * (fromTop ? 1 : -1);
                    var  currentTime = sTime + (sTime - GetOffset((int)sTime)) % GetBeatDuration(startTime, 1);

                    if (direction == ParticleDirection.Bottom || direction == ParticleDirection.Top)
                    {
                        sprite.MoveY(sTime, fromTop ? -60 : 540);
                    }
                    else if (direction == ParticleDirection.Left || direction == ParticleDirection.Right)
                    {
                        sprite.MoveX(sTime, fromTop ? -130 : 800);
                    }


                    if (direction == ParticleDirection.Bottom || direction == ParticleDirection.Top)
                    {
                        while (fromTop ? sprite.PositionAt(currentTime).Y <540 : sprite.PositionAt(currentTime).Y> -60)
                        {
                            var yPos = sprite.PositionAt(currentTime).Y;
                            var yRot = sprite.RotationAt(currentTime);

                            sprite.MoveY(OsbEasing.OutExpo, currentTime, currentTime + GetBeatDuration(startTime, 1), yPos, yPos + moveSpeed);
                            sprite.Rotate(OsbEasing.OutExpo, currentTime, currentTime + GetBeatDuration(startTime, 1), yRot, yRot + Math.PI * 0.25f);

                            currentTime += GetBeatDuration(startTime, 1);
                        }
                    }
                    else if (direction == ParticleDirection.Left || direction == ParticleDirection.Right)
                    {
                        while (fromTop ? sprite.PositionAt(currentTime).X <800 : sprite.PositionAt(currentTime).X> -120)
                        {
                            var xPos = sprite.PositionAt(currentTime).X;
                            var xRot = sprite.RotationAt(currentTime);

                            sprite.MoveX(OsbEasing.OutExpo, currentTime, currentTime + GetBeatDuration(startTime, 1), xPos, xPos + moveSpeed);
                            sprite.Rotate(OsbEasing.OutExpo, currentTime, currentTime + GetBeatDuration(startTime, 1), xRot, xRot + Math.PI * 0.25f);

                            currentTime += GetBeatDuration(startTime, 1);
                        }
                    }
                    //thx Darky
                    if (Random(0, 4) > 0) //HACK move the time back in order to increase the particle count without running into syncing issues
                    {
                        sTime -= GetBeatDuration(startTime, 2);
                    }
                }
            }
        }
    }
コード例 #7
0
        /// <summary>
        /// Sets the stage to a default state.
        /// </summary>
        public void Default()
        {
            _material       = idE.DeclManager.FindMaterial("_default");
            _totalParticles = 100;
            _spawnBunching  = 1.0f;
            _particleLife   = 1.5f;
            _timeOffset     = 0.0f;
            _deadTime       = 0.0f;

            _distribution         = ParticleDistribution.Rectangle;
            _distributionParms[0] = 8.0f;
            _distributionParms[1] = 8.0f;
            _distributionParms[2] = 8.0f;
            _distributionParms[3] = 0.0f;

            _direction         = ParticleDirection.Cone;
            _directionParms[0] = 90.0f;
            _directionParms[1] = 0.0f;
            _directionParms[2] = 0.0f;
            _directionParms[3] = 0.0f;

            _orientation         = ParticleOrientation.View;
            _orientationParms[0] = 0.0f;
            _orientationParms[1] = 0.0f;
            _orientationParms[2] = 0.0f;
            _orientationParms[3] = 0.0f;

            _customPath         = ParticleCustomPath.Standard;
            _customPathParms[0] = 0.0f;
            _customPathParms[1] = 0.0f;
            _customPathParms[2] = 0.0f;
            _customPathParms[3] = 0.0f;
            _customPathParms[4] = 0.0f;
            _customPathParms[5] = 0.0f;
            _customPathParms[6] = 0.0f;
            _customPathParms[7] = 0.0f;

            _gravity      = 1.0f;
            _worldGravity = false;

            _offset = Vector3.Zero;

            _animationFrames = 0;
            _animationRate   = 0.0f;
            _initialAngle    = 0.0f;

            _speed         = new idParticleParameter(150.0f, 150.0f, null);
            _rotationSpeed = new idParticleParameter(0.0f, 0.0f, null);
            _size          = new idParticleParameter(4.0f, 4.0f, null);
            _aspect        = new idParticleParameter(1.0f, 1.0f, null);

            _color              = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            _fadeColor          = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
            _fadeInFraction     = 0.1f;
            _fadeOutFraction    = 0.25f;
            _fadeIndexFraction  = 0.0f;
            _boundsExpansion    = 0.0f;
            _randomDistribution = true;
            _entityColor        = false;
            _cycleTime          = (int)(_particleLife + _deadTime) * 1000;
        }
コード例 #8
0
		/// <summary>
		/// Sets the stage to a default state.
		/// </summary>
		public void Default()
		{
			_material = idE.DeclManager.FindMaterial("_default");
			_totalParticles = 100;
			_spawnBunching = 1.0f;
			_particleLife = 1.5f;
			_timeOffset = 0.0f;
			_deadTime = 0.0f;

			_distribution = ParticleDistribution.Rectangle;
			_distributionParms[0] = 8.0f;
			_distributionParms[1] = 8.0f;
			_distributionParms[2] = 8.0f;
			_distributionParms[3] = 0.0f;

			_direction = ParticleDirection.Cone;
			_directionParms[0] = 90.0f;
			_directionParms[1] = 0.0f;
			_directionParms[2] = 0.0f;
			_directionParms[3] = 0.0f;

			_orientation = ParticleOrientation.View;
			_orientationParms[0] = 0.0f;
			_orientationParms[1] = 0.0f;
			_orientationParms[2] = 0.0f;
			_orientationParms[3] = 0.0f;

			_customPath = ParticleCustomPath.Standard;
			_customPathParms[0] = 0.0f;
			_customPathParms[1] = 0.0f;
			_customPathParms[2] = 0.0f;
			_customPathParms[3] = 0.0f;
			_customPathParms[4] = 0.0f;
			_customPathParms[5] = 0.0f;
			_customPathParms[6] = 0.0f;
			_customPathParms[7] = 0.0f;

			_gravity = 1.0f;
			_worldGravity = false;

			_offset = Vector3.Zero;

			_animationFrames = 0;
			_animationRate = 0.0f;
			_initialAngle = 0.0f;

			_speed = new idParticleParameter(150.0f, 150.0f, null);
			_rotationSpeed = new idParticleParameter(0.0f, 0.0f, null);
			_size = new idParticleParameter(4.0f, 4.0f, null);
			_aspect = new idParticleParameter(1.0f, 1.0f, null);

			_color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
			_fadeColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
			_fadeInFraction = 0.1f;
			_fadeOutFraction = 0.25f;
			_fadeIndexFraction = 0.0f;
			_boundsExpansion = 0.0f;
			_randomDistribution = true;
			_entityColor = false;
			_cycleTime = (int) (_particleLife + _deadTime) * 1000;
		}
コード例 #9
0
		private idBounds _bounds;							// derived.
		#endregion

		#region Constructor
		public idParticleStage()
		{
			_distribution = ParticleDistribution.Rectangle;
			_distributionParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };

			_direction = ParticleDirection.Cone;
			_directionParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };

			_customPath = ParticleCustomPath.Standard;
			_customPathParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };

			_orientation = ParticleOrientation.View;
			_orientationParms = new float[] { 0.0f, 0.0f, 0.0f, 0.0f };

			_randomDistribution = true;
		}