Наследование: MonoBehaviour
Пример #1
0
 private void PlacePart(ShipItem pressedItem, RectangularHull hull, Part newPart)
 {
     Particles.GenerateDeathParticles(newPart.Sprite, pressedItem.Position, 2, 0, false);
     hull.AddPart(newPart, pressedItem.LinkPosition);
     player.Parts.Add(newPart);
     newPart.Carrier = hull; //REDUNDANCY
 }
Пример #2
0
    private void UpdateGrab(UserInput input, Vector3 eyePos, Rotation eyeRot, Vector3 eyeDir, bool wantsToFreeze)
    {
        if (wantsToFreeze)
        {
            heldBody.BodyType = PhysicsBodyType.Static;

            if (GrabbedEntity.IsValid())
            {
                var freezeEffect = Particles.Create("particles/physgun_freeze.vpcf");
                freezeEffect.SetPos(0, heldBody.Transform.PointToWorld(GrabbedPos));
            }

            GrabEnd();
            return;
        }

        MoveTargetDistance(input.MouseWheel * TargetDistanceSpeed);

        if (input.Down(InputButton.Use))
        {
            EnableAngularSpring(true);
            DoRotate(eyeRot, input.MouseDelta * RotateSpeed);
        }
        else
        {
            EnableAngularSpring(false);
        }

        GrabMove(eyePos, eyeDir, eyeRot);
    }
Пример #3
0
    void Start()
    {
        // Seeding random
        UnityEngine.Random.InitState(247943128);

        particles = new Particles(nbParticles);

        for (int i = 0; i < nbParticles; i++)
        {
            //Create particle i
            Vector3 particlePos = new Vector3(
                UnityEngine.Random.Range(-xRange, xRange),
                UnityEngine.Random.Range(-yRange, yRange)
                );

            GameObject go = Instantiate(particlePrefab, particlePos, Quaternion.identity);

            // Setting random mass from range [1f, 10f]
            float mass = UnityEngine.Random.Range(lowerMass, upperMass);

            // Setting velocity
            Vector3 velocity = (Vector3.up) * 10f;
            //particles[i].GetComponent<Particle>().velocity = (Vector3.up + Vector3.right) * 10f;

            // Setting color depending on mass / RED = high mass / BLUE = low mass
            float rangedMass = (((mass - lowerMass)) / (upperMass - lowerMass));
            Color current    = Color.Lerp(low, high, rangedMass);

            go.GetComponent <SpriteRenderer>().material.color = current;

            particles.Add(i, mass, velocity, Vector3.zero, particlePos, go);
        }
    }
Пример #4
0
        public static void Main(string[] args)
        {
            //Set this to the foulder containing all assets used.
            string resourceFolder = "C:\\Users\\LukasFiddle\\Dropbox\\Public\\Monocle\\MonocleResources";

            /*  LabelExample example = new LabelExample(resourceFolder);
             * example.Run();
             *
             * /*
             *
             * AnimationExample example2 = new AnimationExample(resourceFolder);
             * example2.Run();       */

            /*ButtonExample example = new ButtonExample(resourceFolder);
             * example.Run(); */



            // TextExample example = new TextExample(resourceFolder);
            // example.Run();

            Particles example = new Particles(resourceFolder);

            example.Run();
        }
    public override void MoveInDirection(Vector3Int direction)
    {
        Level grid = GameController.Instance.Level;
        Tile  tile = grid.GetTileForPosition(transform.position + direction - Vector3Int.up);

        if (tile != null)
        {
            Debug.Log("move onto tile");
            if (tile.IsFree())
            {
                if (CurrentTile != null)
                {
                    CurrentTile.ReleaseUnit();
                }
                tile.AssignUnit(this);
                CurrentTile = tile;

                neighbours = base.CurrentTile.GetNeighbours();

                for (int i = 0; i < neighbours.Length; i++)
                {
                    if (neighbours[i].Unit == null)
                    {
                        continue;
                    }
                    if (neighbours[i].Unit.type == Type.Player)
                    {
                        continue;
                    }

                    if (neighbours[i].Unit.type == Unit.Type.Particle)
                    {
                        if (neighbours[i].Unit.GetComponent <Particles>().particleType == particleType)
                        {
                            fuseParticle = neighbours[i].Unit.GetComponent <Particles>();
                        }
                    }
                }

                if (fuseParticle != null)
                {
                    StartCoroutine(MoveToPosition(tile.Position, EvolveParticle));
                }
                else
                {
                    StartCoroutine(MoveToPosition(tile.Position));
                }
            }
        }
        else
        {
            if (CurrentTile != null)
            {
                CurrentTile.ReleaseUnit();
            }
            //LookAtPosition(CurrentTile.Position - direction);
            StartCoroutine(MoveToPosition(CurrentTile.Position + direction, BecomeTile));
            CurrentTile = null;
        }
    }
Пример #6
0
 public override void processParticle(Particles.Particle p)
 {
     if (p.type == type && !Unlocked)
     {
         count++;
     }
 }
Пример #7
0
 public override void processParticle(Particles.Particle p)
 {
     if (p.type == Particles.Particle_Type.Fire)
     {
         counter++;
     }
 }
Пример #8
0
        /// <summary>
        /// Update particles
        /// </summary>
        public void Update(GameTime gameTime)
        {
            Rectangle rect = new Rectangle((int)Level.MainCamera.Position.X - 400, (int)Level.MainCamera.Position.Y - 400, Game.MainWindow.Manager.GraphicsDevice.PresentationParameters.BackBufferWidth + 400, Game.MainWindow.Manager.GraphicsDevice.PresentationParameters.BackBufferHeight + 400);

            for (int particle = 0; particle < Particles.Count; particle++)
            {
                Particle p = Particles[particle];
                if (p == null)
                {
                    Particles.RemoveAt(particle);
                    particle--;
                    continue;
                }
                if (rect.Contains(p.Position.ToPoint()))
                {
                    p.Update(gameTime, Game.keyboardState, Game.oldKeyBoardState);  //Update each particle
                }
                else
                {
                    Particles.RemoveAt(particle);
                    particle--;
                    continue;
                }
                if (Particles[particle].TTL <= 0) //Remove old particles
                {
                    Particles.RemoveAt(particle);
                    particle--;
                }
            }
        }
Пример #9
0
 public void processParticle(Particles.Particle p)
 {
     foreach(var a in achievements)
     {
         a.processParticle(p);
     }
 }
        public void Update(GameTime gameTime)
        {
            elapsedTime += (float)gameTime.ElapsedGameTime.TotalMilliseconds;//sätter så at det räknas i millisekunder

            if (elapsedTime > maxLife / maxParticleCount)// om tiden är större än max livet delat på max partiklar så körs denna!
            {
                if (offset < maxParticleCount)// går in i denna om nu en partikels tid är ute
                {

                    particels[offset] = new Particles();
                    resetParticle(particels[offset]);// kör om med samma partiklar från början

                    offset++;
                    elapsedTime = 0;// och startar om tiden för dessa!
                }
            }

            for (int i = 0; i < offset; i++)
            {
                particels[i].Update(gameTime);

                if (particels[i].age > maxLife)
                    resetParticle(particels[i]);
            }
        }
Пример #11
0
    protected virtual void KillEffects()
    {
        Beam?.Destroy(true);
        Beam       = null;
        BeamActive = false;

        EndNoHit?.Destroy(false);
        EndNoHit = null;

        if (lastGrabbedEntity.IsValid())
        {
            foreach (var child in lastGrabbedEntity.Children.OfType <ModelEntity>())
            {
                if (child is Player)
                {
                    continue;
                }

                if (child.Components.TryGet <Glow>(out var childglow))
                {
                    childglow.Active = false;
                }
            }

            if (lastGrabbedEntity.Components.TryGet <Glow>(out var glow))
            {
                glow.Active = false;
            }

            lastGrabbedEntity = null;
        }
    }
Пример #12
0
        /// <summary>
        /// R_Init
        /// </summary>
        public void Initialise( )
        {
            for (var i = 0; i < _Frustum.Length; i++)
            {
                _Frustum[i] = new Plane( );
            }

            Host.Commands.Add("timerefresh", TimeRefresh_f);
            //Cmd.Add("envmap", Envmap_f);
            //Cmd.Add("pointfile", ReadPointFile_f);

            if (Host.Cvars.NoRefresh == null)
            {
                Host.Cvars.NoRefresh     = Host.CVars.Add("r_norefresh", false);
                Host.Cvars.DrawEntities  = Host.CVars.Add("r_drawentities", true);
                Host.Cvars.DrawViewModel = Host.CVars.Add("r_drawviewmodel", true);
                Host.Cvars.Speeds        = Host.CVars.Add("r_speeds", false);
                Host.Cvars.FullBright    = Host.CVars.Add("r_fullbright", false);
                Host.Cvars.LightMap      = Host.CVars.Add("r_lightmap", false);
                Host.Cvars.Shadows       = Host.CVars.Add("r_shadows", false);
                //_MirrorAlpha = Host.CVars.Add( "r_mirroralpha", "1" );
                Host.Cvars.WaterAlpha = Host.CVars.Add("r_wateralpha", 1f);
                Host.Cvars.Dynamic    = Host.CVars.Add("r_dynamic", true);
                Host.Cvars.NoVis      = Host.CVars.Add("r_novis", false);

                Host.Cvars.glFinish           = Host.CVars.Add("gl_finish", false);
                Host.Cvars.glClear            = Host.CVars.Add("gl_clear", 0f);
                Host.Cvars.glCull             = Host.CVars.Add("gl_cull", true);
                Host.Cvars.glTexSort          = Host.CVars.Add("gl_texsort", true);
                Host.Cvars.glSmoothModels     = Host.CVars.Add("gl_smoothmodels", true);
                Host.Cvars.glAffineModels     = Host.CVars.Add("gl_affinemodels", false);
                Host.Cvars.glPolyBlend        = Host.CVars.Add("gl_polyblend", true);
                Host.Cvars.glFlashBlend       = Host.CVars.Add("gl_flashblend", true);
                Host.Cvars.glPlayerMip        = Host.CVars.Add("gl_playermip", 0);
                Host.Cvars.glNoColors         = Host.CVars.Add("gl_nocolors", false);
                Host.Cvars.glKeepTJunctions   = Host.CVars.Add("gl_keeptjunctions", false);
                Host.Cvars.glReportTJunctions = Host.CVars.Add("gl_reporttjunctions", false);
                Host.Cvars.glDoubleEyes       = Host.CVars.Add("gl_doubleeys", true);
            }

            if (Host.Video.Device.Desc.SupportsMultiTexture)
            {
                Host.CVars.Set("gl_texsort", 0.0f);
            }

            Particles.InitParticles( );
            Particles.InitParticleTexture( );

            // reserve 16 textures
            PlayerTextures = new BaseTexture[16];

            for (var i = 0; i < PlayerTextures.Length; i++)
            {
                PlayerTextures[i] = BaseTexture.FromDynamicBuffer(Host.Video.Device, "_PlayerTexture{i}", new ByteArraySegment(new Byte[512 * 256 * 4]), 512, 256, false, false);
            }

            TextureChains = new TextureChains();
            Occlusion     = new Occlusion(Host, TextureChains);
        }
Пример #13
0
        public override void Update(float delta)
        {
            Frame = RelativeFrame.FromPoint(Body, Vector3.Zero);

            DxVector3    position = new DxVector3(Body.LinearPosition.X, Body.LinearPosition.Y, Body.LinearPosition.Z);
            DxQuaternion quat     = new DxQuaternion(Body.AngularPosition.X, Body.AngularPosition.Y, Body.AngularPosition.Z, Body.AngularPosition.W);

            Transform = Matrix.RotationQuaternion(quat) * Matrix.Translation(position);

            Vector3 steering = new Vector3();

            steering.X = (Frame.LinearPosition.X < 0) ? 3 : -3;
            steering.Z = (Frame.LinearPosition.Z < 0) ? 3 : -3;

            const int Thrust = 150;

            steering.Y = Thrust;
            if (Frame.LinearPosition.Y > 0)
            {
                steering.Y = Math.Min(Thrust, Frame.LinearPosition.Y + 20);
            }

            //Body.AccumulateLocalCentralForce(force);
            Body.AccumulateLocalForce(steering, new Vector3(0, -2, 0));
            //Body.AccumulateGlobalCentralForce(new Vector3(y: -9.81f));
            Body.LinearDampening  = new Vector3(0.5f);
            Body.AngularDampening = new Vector3(0.5f);
            Body.Integrate(delta);
            Body.ClearForces();

            // Eject particles
            countdown += delta;
            while (countdown > 0.01f)
            {
                var body = new Body();
                body.LinearPosition  = RelativeFrame.ToGlobalPoint(Body, new Vector3(y: -8));
                body.LinearVelocity  = Body.LinearVelocity;
                body.AngularPosition = Body.AngularPosition;
                body.ApplyLocalCentralImpulse(new Vector3(0, -steering.Y, 0));
                body.AccumulateGlobalCentralForce(new Vector3(y: 10));
                body.LinearDampening = new Vector3(0.2f);
                Particles.Insert(0, body);
                countdown -= 0.01f;
            }

            if (Particles.Count > 100)
            {
                Particles.RemoveRange(100, Particles.Count - 100);
            }
            ParticleMesh.IndexCount = Particles.Count;

            for (int i = 0; i < Particles.Count; i++)
            {
                Particles[i].Integrate(delta);
                ParticleMesh.Dynamic[i].Position = Particles[i].LinearPosition;
            }

            ParticleMesh.UpdateDynamic();
        }
Пример #14
0
    public void PerformHitscan()
    {
        ActualAssert(ParentPlayer != null);

        Vector3 Origin   = ParentPlayer.Cam.GlobalTransform.origin;
        Vector3 Endpoint = Origin + new Vector3(0, 0, -Range)
                           .Rotated(new Vector3(1, 0, 0), Deg2Rad(ParentPlayer.CamJoint.RotationDegrees.x + ParentPlayer.Cam.RotationDegrees.x))
                           .Rotated(new Vector3(0, 1, 0), Deg2Rad(ParentPlayer.RotationDegrees.y));
        Vector3 BaseEndpoint = Endpoint;

        int PelletsLeft = CurrentWeapon.PelletCount;

        while (PelletsLeft > 0)
        {
            if (CurrentWeapon.Kind == WeaponKind.SHOTGUN)
            {
                const int DeviationDistance = 18;
                Endpoint = BaseEndpoint + new Vector3(
                    Game.Rng.Next(DeviationDistance) * RandomSign(),
                    Game.Rng.Next(DeviationDistance) * RandomSign(),
                    Game.Rng.Next(DeviationDistance) * RandomSign()
                    );
            }

            var Exclude = new Godot.Collections.Array()
            {
                ParentPlayer
            };
            PhysicsDirectSpaceState      State   = GetWorld().DirectSpaceState;
            Godot.Collections.Dictionary Results = State.IntersectRay(Origin, Endpoint, Exclude, 1 | 2);

            if (Results.Count > 0)
            {
                var Position = (Vector3)Results["position"];
                var Normal   = (Vector3)Results["normal"];

                if (Results["collider"] is Hitbox Box)
                {
                    int Damage = CurrentWeapon.BodyDamage;
                    if (Box.Kind == HitboxKind.HEAD)
                    {
                        Damage = CurrentWeapon.HeadDamage;
                    }

                    Box.Damage(Damage);

                    Sfx.PlaySfxSpatially(SfxCatagory.FLESH_HIT, 0, Position, 0);
                }
                else
                {
                    Sfx.PlaySfxSpatially(SfxCatagory.BULLET_HIT, 0, Position, 0);
                }

                Particles.Spawn(Particle.PISTOL_IMPACT, Position, Normal);
            }

            PelletsLeft -= 1;
        }
    }
Пример #15
0
 public void fixChildRefs(string newFolder)
 {
     for (int i = 0; i < Particles.Count(); i++)
     {
         Particle p = Particles.ElementAt(i);
         p.fixChildRefs(newFolder);
     }
 }
Пример #16
0
        public Global UpdateGlobalMemory(Particles particle, Global globalMemory)
        {
            globalMemory.GNotes   = particle.Notes;
            globalMemory.GTimes   = particle.Times;
            globalMemory.GFitness = particle.Fitness;

            return(globalMemory);
        }
Пример #17
0
 protected override void HandleCollision(ICollidable c2)
 {
     if (c2 is Enemy || c2 is Wall)
     {
         Particles.GenerateParticles(Position, 5, 0, Sprite.MColor);
         Death();
     }
 }
Пример #18
0
        protected override void LoadContent()
        {
            effect           = new BasicEffect(GraphicsDevice);
            explosion        = Particles.CreateSource(position, rand.Next(10, 101));
            explosion.Effect = effect;

            base.LoadContent();
        }
Пример #19
0
 public void resize(int percentage)
 {
     for (int i = 0; i < Particles.Count(); i++)
     {
         Particle p = Particles.ElementAt(i);
         p.resize(percentage);
     }
 }
Пример #20
0
 public void changeColor(string[] rgb)
 {
     for (int i = 0; i < Particles.Count(); i++)
     {
         Particle p = Particles.ElementAt(i);
         p.changeColor(rgb);
     }
 }
Пример #21
0
 internal void DrawOnShiftInterface(ShiftInterface shiftInterface)
 {
     Particles.ForEach(p => shiftInterface.drawOnOverlay(p));
     Projectiles.ForEach(p => shiftInterface.drawOnOverlay(p));
     Collectables.ForEach(c => shiftInterface.drawOnOverlay(c));
     Enemies.ForEach(e => shiftInterface.drawOnOverlay(e));
     shiftInterface.drawOnOverlay(MainPlayer);
 }
Пример #22
0
 public void clearParticles()
 {
     if (Particles != null)
     {
         Particles.Clear();
     }
     Particles = new List <Particle>();
 }
Пример #23
0
        public Particle(Vector2 position, Vector2 direction)
        {
            Particles.Add(this);
            this.Position = position;
            this.Heading  = direction;

            Renderer = new ParticleRenderer(this);
        }
Пример #24
0
 /*
  * Restores the player's health by a certain amount.
  * Passing a negative number indicates that the player has taken damage.
  */
 public void RestoreHealth(int restoredHealth)
 {
     Health += restoredHealth;
     if (restoredHealth < 0)
     {
         Particles.Spawn(gameObject, Particles.Type.BloodLight, 0f, -0.5f, -1f, gameObject.transform);
     }
 }
Пример #25
0
 protected override void HandleCollision(ICollidable c2)
 {
     if (c2 is Enemy && Team != EntityConstants.GetStatsFromID(EntityConstants.TEAM, IDs.DEFAULT_ENEMY) || c2 is Player && Team == EntityConstants.GetStatsFromID(EntityConstants.TEAM, IDs.DEFAULT_ENEMY) || c2 is Wall)
     {
         Particles.GenerateDeathParticles(Sprite, Position, 2, Angle, false);
     }
     base.HandleCollision(c2);
 }
Пример #26
0
 public string GetEffectName(float value)
 {
     foreach (var effect in Particles.Where(effect => effect.Id == value))
     {
         return(effect.Name);
     }
     return("");
 }
Пример #27
0
 public override void _Ready()
 {
     _rigidShape                  = GetNode <CollisionShape>("Collision_Shape");
     _grenadeMesh                 = GetNode <MeshInstance>("Grenade");
     _blastArea                   = GetNode <Area>("Blast_Area");
     _explosionParticles          = GetNode <Particles>("Explosion");
     _explosionParticles.Emitting = false;
     _explosionParticles.OneShot  = true;
 }
Пример #28
0
    protected virtual void ShootEffects()
    {
        Host.AssertClient();

        PlaySound("rust_pistol.shoot");
        Particles.Create("particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle");

        ViewModelEntity?.SetAnimParam("fire", true);
    }
Пример #29
0
 /// <summary>
 /// Initializes the decoration node
 /// </summary>
 public void Initialise()
 {
     _crashParticles = GetNode <Particles>("CrashSparkles");
     _flashLight     = GetNode <Light>("FlashLight");
     _flashSprite    = GetNode <BubbleSprite>("FlashSprite");
     _errorLight     = GetNode <Light>("ErrorLight");
     _errorSprite1   = GetNode <BubbleSprite>("ErrorSprite1");
     _errorSprite2   = GetNode <BubbleSprite>("ErrorSprite2");
 }
Пример #30
0
 //Posar un argument mes per entrar la constant elastica de la molla.
 public Springs(Particles a, Particles b, float elast, float dampi, int springtype)
 {
     this.a          = a;
     this.b          = b;
     this.elast      = elast;
     this.dampi      = dampi;
     this.springType = springtype;
     this.restLength = (a.Position - b.Position).magnitude;
 }
Пример #31
0
    protected void CreateEffects()
    {
        if (effects != null)
        {
            return;
        }

        effects = Particles.Create("particles/physgun_end_nohit.vpcf");
    }
Пример #32
0
 internal void DrawMinimap(Camera camera)
 {
     Map.DrawMap(camera);
     Particles.ForEach(p => camera.DrawMinimap(p));
     Projectiles.ForEach(p => camera.DrawMinimap(p));
     Collectables.ForEach(c => camera.DrawMinimap(c));
     Enemies.ForEach(e => camera.DrawMinimap(e));
     camera.DrawMinimap(MainPlayer);
 }
Пример #33
0
        static void Main(string[] args)
        {
            PSO pso = new PSO(10, 50, 0.9, 0.9);

            Particles[] population = new Particles[Particles.PopulationSize];
            population = Particles.CreatePopulation(population);

            pso.Start(population);
        }
Пример #34
0
 internal void DrawObjects(Camera camera)
 {
     Map.DrawTiles(camera);
     Particles.ForEach(p => camera.Draw(p));
     Projectiles.ForEach(p => camera.Draw(p));
     Collectables.ForEach(c => camera.Draw(c));
     Enemies.ForEach(e => camera.Draw(e));
     camera.Draw(MainPlayer);
 }
	/**
	 * Récupère la puissance du vent en fonction de la force
	 * des éléments météorologiques.
	 */
	float GetWind(Particles.Strengh strengh){
		if(strengh == Particles.Strengh.LOW){
			return 0;
		}else if(strengh == Particles.Strengh.MEDIUM){
			return 3f;
		}if(strengh == Particles.Strengh.HIGH){
			return 8f;
		}

		return 0;
	}
	/**
	 * Récupère la puissance de la pluie en fonction de la force
	 * des éléments météorologiques.
	 */
	float GetRain(Particles.Strengh strengh){
		if(strengh == Particles.Strengh.LOW){
			return 2f;
		}else if(strengh == Particles.Strengh.MEDIUM){
			return 5f;
		}if(strengh == Particles.Strengh.HIGH){
			return 8f;
		}

		return 0;
	}
Пример #37
0
	/**
	 * Met à jour les variables de la force des vagues en fonction
	 * de la force des éléments météorologiques.
	 */
	public void UpdateWater(Particles.Strengh strengh){
		if(strengh == Particles.Strengh.LOW){
			Init();
		}else if(strengh == Particles.Strengh.MEDIUM){
			waterMaterial.SetVector("_GAmplitude", new Vector4(0.14f,0.76f,0.175f,mediumAmplitude));
			waterMaterial.SetVector("_GFrequency", new Vector4(0.5f,0.38f,0.59f,mediumFrequency));
			waterMaterial.SetVector("_GSpeed", new Vector4(-3f,2f,1f,mediumSpeed));
		}else if(strengh == Particles.Strengh.HIGH){
			waterMaterial.SetVector("_GAmplitude", new Vector4(0.14f,0.76f,0.175f,highAmplitude));
			waterMaterial.SetVector("_GFrequency", new Vector4(0.5f,0.38f,0.59f,highFrequency));
			waterMaterial.SetVector("_GSpeed", new Vector4(-3f,2f,1f,highSpeed));
		} 
	}
        // denna kommer reseta allt
        private void resetParticle(Particles particle)
        {
            //Camera camera = new Camera();
            Vector2 position = new Vector2(500, 500);//börjar på positionen
            float speed = 0.3f;//farten på partiklarna
            Vector2 velocity = new Vector2((float)r.NextDouble() * 2f - 1f, (float)r.NextDouble() * 2f - 1f);

            velocity.Normalize();
            velocity = velocity * speed;

            float rotation = (float)r.NextDouble()*2f*(float)Math.PI;//denna kommer rotera partiklarna lite
            float allTheRadians = 2f * (float)Math.PI;// gör så att partiklarna roterar runt mitten av spriten
            float rotationSpeed = ((float)r.NextDouble() * allTheRadians - allTheRadians / 2f) / 300f;

            particle.Reset(position, velocity, rotation, rotationSpeed, (float)r.NextDouble()*20+10);// kommer ge allt sina värden när man ska skapa om dom!
        }
        public Base(World world, Vector2 position, bool isVertical, Particles.ParticleSystem fire)
            : base(world)
        {
            health = isVertical ? 20 : 40;
            vertical = isVertical;
            warning = 0;
            fireParticles = fire;

            Position = position / 100;
            BodyType = BodyType.Static;
            Rotation = 0;
            if (vertical) FixtureFactory.AttachRectangle(texV.Width / 100f, texV.Height / 100f, 1, Vector2.Zero, this);
            else FixtureFactory.AttachRectangle(texH.Width / 100f, texH.Height / 100f, 1, Vector2.Zero, this);
            OnCollision += (fA, fB, c) =>
            {
                if (!(fB.Body is Projectile)) return true;

                var p = (Projectile)fB.Body;

                if (p.Damage == 0) return true;

                damage += p.Damage;

                hitSnd.Play(0.2f, -p.Damage / 20f, 0);

                fireParticles.AddParticle(new Vector3(p.Position.X * 100 - 512, 0, p.Position.Y * 100 - 384),
                    Vector3.Zero, p.Damage * 2 + 8);

                if (damage >= health)
                {
                    var pos = new Vector3(position.X - 512, 0, position.Y - 384);
                    if (vertical) pos.Z -= texV.Height / 2f;
                    else pos.X -= texH.Width / 2f;

                    for (int i = 0; vertical && i <= texV.Height || !vertical && i <= texH.Width; i+=2)
                    {
                        fireParticles.AddParticle(pos, Vector3.Zero);

                        if (vertical) pos.Z += 2;
                        else pos.X += 2;
                    }
                }

                return true;
            };
        }
Пример #40
0
	/**
	 * Met à jour les variables de la force du vent en fonction
	 * de la force des éléments météorologiques.
	 */
	public void UpdateWind(Particles.Strengh strengh){

		if(strengh == Particles.Strengh.LOW){
			Init ();
		}else if(strengh == Particles.Strengh.MEDIUM){
			windZone.windMain = mediumStrengh;
			windZone.windPulseMagnitude = mediumStrengh;
			windZone.windTurbulence = mediumStrengh;

			tGenerator.tData.wavingGrassStrength = mediumStrengh;
		}else if(strengh == Particles.Strengh.HIGH){
			windZone.windMain = highStrengh;
			windZone.windPulseMagnitude = highStrengh;
			windZone.windTurbulence = highStrengh;

			tGenerator.tData.wavingGrassStrength = highStrengh;
		} 
	}
Пример #41
0
 void Awake()
 {
     m_Colors = Colors;
     m_Game = Game;
     m_Music = Music;
     m_Particles = Particles;
     m_Prefabs = Prefabs;
     m_Sprites = Sprites;
     m_Score = Score;
     m_SoundFX = SoundFX;
     m_Timer = Timer;
     if (!MainMenu)
         m_Camera = Camera;
     m_Strings = TextStrings;
     m_Input = InputHandler;
     if (MainMenu)
         m_interMain = MainMenu;
     else if(HUD)
         m_interGame = HUD;
     else if (CreateMode)
         m_interCreate = CreateMode;
 }
	/**
	 * Met à jour les paramètre de l'ambience sonore.
	 */
	public void UpdateParameter(int season, Particles.Strengh strengh){
		if(season == 0 || season == 3){
			ambienceBirds.setValue(1f);
		}else{
			ambienceBirds.setValue(0f);
		}

		//Summer || Winter || Spring
		if(season == 0 || season == 2 || season == 3){
			float wind = GetWind(strengh);
			float rain = 0f;

			StopCoroutine("TweenParameter");
			StartCoroutine(TweenParameter(wind, rain));
		//Autumn
		}else if(season == 1){
			float wind = GetWind(strengh);
			float rain = GetRain(strengh);

			StopCoroutine("TweenParameter");
			StartCoroutine(TweenParameter(wind, rain));
		}
	}
Пример #43
0
 public abstract void processParticle(Particles.Particle p);
Пример #44
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load shaders
            fxParticles = Content.Load<Effect>("Shaders\\Particles");
            fxParticles.Parameters["Texture"].SetValue(Content.Load<Texture2D>("Textures\\Particle"));

            box = new TransparentBox(GraphicsDevice);

            // load font
            font = Content.Load<SpriteFont>("Fonts\\Debug");

            this.Components.Add(fpsCounter = new FPSCounter(this));

            int pCount = 0;
            // Particles
            particles = new Particles(fxParticles);
            float pOffset = particles.ParticleRadius * 2;
            Color color = Color.White;
            for (int x = 0; x < 5; x++)
            {
                for (int z = 0; z < 5; z++)
                {
                    for (int y = 0; y < 10; y++)
                    {
                        if (pCount >= 50 && pCount < 100)
                            color = Color.Red;
                        else if (pCount >= 100 && pCount < 150)
                            color = Color.Yellow;
                        else if (pCount >= 150 && pCount < 200)
                            color = Color.Green;
                        else if(pCount >= 200 && pCount < 250)
                            color = Color.CornflowerBlue;

                        particles.Add(new Particle(new Vector3(x, y, z) * pOffset, particles.GetRandomVelocity(), color));
                        pCount++;
                    }
                }
            }

            color = Color.Red;
        }