protected ParticleEmmitor CreateAndAddSmokeEmmitor(int num)
        {
            ParticleEmmitor smallSmokeEmmitor1 = ParticleEmmitorFactory.CreateSmokeParticleEmmitor(me.SceneMgr, asteroid.Position);

            smallSmokeEmmitor1.EmmitingDirection = asteroid.Direction.Rotate(Math.PI);
            smallSmokeEmmitor1.Infinite          = true;
            smallSmokeEmmitor1.MinAngle          = (float)FastMath.DegToRad(15);
            smallSmokeEmmitor1.MaxAngle          = (float)FastMath.DegToRad(-15);
            smallSmokeEmmitor1.MinLife           = 1.2f;
            smallSmokeEmmitor1.MaxLife           = 1.5f;
            smallSmokeEmmitor1.Amount            = 30;
            smallSmokeEmmitor1.MinSize          *= 1.2f;
            smallSmokeEmmitor1.MaxSize          *= 1.2f;

            EmmitorDirectionCloneControl control = new EmmitorDirectionCloneControl(me);

            control.DirectionOfsetRotation = (float)Math.PI;
            smallSmokeEmmitor1.AddControl(control);

            IMovementControl c = asteroid.GetControlOfType <IMovementControl>();

            if (num == 0)
            {
                meNode.AddEmmitor(smallSmokeEmmitor1, new Vector(asteroid.Radius * 0.85, 0), false);
            }
            else if (num == 1)
            {
                meNode.AddEmmitor(smallSmokeEmmitor1, new Vector(asteroid.Radius * 0.85, asteroid.Radius * 0.2).Rotate((Math.PI / 4)), false);
            }
            else if (num == 2)
            {
                meNode.AddEmmitor(smallSmokeEmmitor1, new Vector(asteroid.Radius * 0.85, asteroid.Radius * 0.2).Rotate(-(Math.PI / 4)), false);
            }

            return(smallSmokeEmmitor1);
        }
Example #2
0
        protected override void UpdateControl(float tpf)
        {
            (me as IRotable).Rotation = (float)FastMath.DegToRad(Vector.AngleBetween(SharedDef.DEFAULT_VECTOR, (me as IMovable).Direction));

            //Logger.Debug("Rotation: " + (me as IRotable).Rotation + " vec(" + (me as IMovable).Direction.ToString() + ")");
        }
        private void CreateSpark()
        {
            ParticleNode node = new ParticleNode(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId()));

            // TODO spawn in a whole volume
            bool left = me.SceneMgr.GetRandomGenerator().Next(2) == 0 ? false : true;

            if (left)
            {
                Vector position = (meNode.Center - (meNode.Direction.Rotate(Math.PI / 4) * (asteroid.Radius)));
                position      += meNode.Direction * (asteroid.Radius * 1.5);
                node.Position  = position;
                node.Direction = meNode.Direction.Rotate(FastMath.DegToRad(-10));
            }
            else
            {
                Vector position = (meNode.Center - (meNode.Direction.Rotate(-Math.PI / 4) * (asteroid.Radius)));
                position      += meNode.Direction * (asteroid.Radius * 1.5);
                node.Position  = position;
                node.Direction = meNode.Direction.Rotate(FastMath.DegToRad(10));
            }

            float minSize = (float)FastMath.LinearInterpolate(0.2, 0.5, me.SceneMgr.GetRandomGenerator().NextDouble());
            float maxSize = minSize * 1.2f;

            ParticleEmmitor smokeEmmitor = ParticleEmmitorFactory.CreateBasicFire(me.SceneMgr, Color.FromArgb(80, 0, 0, 0));

            smokeEmmitor.Amount      = 20;
            smokeEmmitor.MinLife     = 0.3f;
            smokeEmmitor.MaxLife     = 0.4f;
            smokeEmmitor.MinSize     = minSize * 1.3f;
            smokeEmmitor.MaxSize     = maxSize * 1.3f;
            smokeEmmitor.SpawnRadius = 4f;
            smokeEmmitor.Infinite    = true;

            ParticleEmmitor fireEmmitor = ParticleEmmitorFactory.CreateBasicFire(me.SceneMgr, Color.FromArgb(150, 255, 100, 0));

            fireEmmitor.Amount   = 20;
            fireEmmitor.MinLife  = 0.1f;
            fireEmmitor.MaxLife  = 0.2f;
            fireEmmitor.MinSize  = minSize * 1.1f;
            fireEmmitor.MaxSize  = maxSize * 1.1f;
            fireEmmitor.Infinite = true;

            ParticleEmmitor fireEmmitor2 = ParticleEmmitorFactory.CreateBasicFire(me.SceneMgr, Color.FromArgb(200, 255, 200, 0));

            fireEmmitor2.Amount   = 20;
            fireEmmitor2.MinLife  = 0.1f;
            fireEmmitor2.MaxLife  = 0.1f;
            fireEmmitor2.MinSize  = minSize;
            fireEmmitor2.MaxSize  = maxSize;
            fireEmmitor2.Infinite = true;

            EmmitorGroup grp = new EmmitorGroup();

            grp.Add(smokeEmmitor);
            grp.Add(fireEmmitor);
            grp.Add(fireEmmitor2);

            node.AddEmmitorGroup(grp, new Vector(), false);

            NewtonianMovementControl nmc = new NewtonianMovementControl();

            nmc.Speed = (asteroid.GetControlOfType <IMovementControl>().RealSpeed / tpf) * 0.75f;
            node.AddControl(nmc);
            node.AddControl(new LimitedLifeControl((float)FastMath.LinearInterpolate(0.5, 2, me.SceneMgr.GetRandomGenerator().NextDouble())));

            me.SceneMgr.DelayedAttachToScene(node);
        }