Exemple #1
0
        public void SetupNoise(float startNoiseAmt, float falloffTime)
        {
            startNoise = startNoiseAmt;
            falloff    = falloffTime;

            this.startTime = OwningWorld.CurrentTime();
        }
Exemple #2
0
 public void SetupGib(Vector Position, Vector Velocity)
 {
     this.velocity = Velocity;
     this.SetPosition(Position);
     this.dieTime   = OwningWorld.CurrentTime() + (float)CMath.Rand.NextDouble() * 5f + 2;
     this.startTime = OwningWorld.CurrentTime();
 }
Exemple #3
0
        public void SetupBullet(Vector Position, Vector Velocity)
        {
            this.velocity = Velocity;
            this.SetPosition(Position);

            this.spawnTime = OwningWorld.CurrentTime();
            this.lifeTime  = 5f;
        }
Exemple #4
0
        public override void Think(float curTime, float deltaTime)
        {
            SetPosition(this.Position.X + velocity.X, this.Position.Y + velocity.Y);

            if (dieTime < OwningWorld.CurrentTime())
            {
                this.Destroy();
            }
        }
Exemple #5
0
        public override Vector[] Draw(float curTime, out int length)
        {
            int numPoints = (int)(15 * (1 - (OwningWorld.CurrentTime() - spawnTime) / lifeTime));

            numPoints = Math.Max(numPoints, 0);
            Vector[] p = Render.DrawLine(this.Position, this.Position - this.velocity * 0.05f, numPoints);

            length = p.Length;
            return(p);
        }
Exemple #6
0
        public void Explode()
        {
            for (int i = 0; i < 8; i++)
            {
                Vector away = new Vector(1, 0).Rotate((float)((i / 4f - 1f) * Math.PI * 2 + CMath.Rand.NextDouble() * 2f));

                AsteroidGibs gib = OwningWorld.Create <AsteroidGibs>();
                gib.SetupGib(this.Position, away * (float)(CMath.Rand.NextDouble() * 2 + 0.1f));
            }

            OwningWorld.Create <Noise>().SetupNoise(200, 0.2f);
            explodeTime = OwningWorld.CurrentTime();
            //this.Destroy();
        }
Exemple #7
0
        public override void Think(float curTime, float deltaTime)
        {
            float noiseLeft = CMath.Lerp(1 - (startTime + falloff - OwningWorld.CurrentTime()) / falloff, startNoise, 0);

            Console.WriteLine(noiseLeft);
            noiseLeft = Math.Max(noiseLeft, 0);

            OwningWorld.SetNoise(noiseLeft);

            if (noiseLeft <= 0)
            {
                this.Destroy();
            }
        }
Exemple #8
0
        public override void Think(float curTime, float deltaTime)
        {
            SetPosition(this.Position + velocity * deltaTime);

            Asteroid[] asses = OwningWorld.GetByType <Asteroid>();
            foreach (Asteroid ass in asses)
            {
                if (ass.Within(this.Position) && !ass.MarkedForDelete && !ass.Exploding)
                {
                    ass.Explode();
                    this.Destroy();
                    break;
                }
            }

            if (OwningWorld.CurrentTime() - spawnTime > lifeTime)
            {
                this.Destroy();
            }
        }
Exemple #9
0
 private float getRadius()
 {
     return((OwningWorld.CurrentTime() - startTime / (dieTime - startTime)) * 25);
 }