示例#1
0
文件: Noise.cs 项目: Foohy/Austeroids
        public void SetupNoise(float startNoiseAmt, float falloffTime)
        {
            startNoise = startNoiseAmt;
            falloff    = falloffTime;

            this.startTime = OwningWorld.CurrentTime();
        }
示例#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();
 }
示例#3
0
        public void SetupBullet(Vector Position, Vector Velocity)
        {
            this.velocity = Velocity;
            this.SetPosition(Position);

            this.spawnTime = OwningWorld.CurrentTime();
            this.lifeTime  = 5f;
        }
示例#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();
            }
        }
示例#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);
        }
示例#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();
        }
示例#7
0
文件: Noise.cs 项目: Foohy/Austeroids
        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();
            }
        }
示例#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();
            }
        }
示例#9
0
 private float getRadius()
 {
     return((OwningWorld.CurrentTime() - startTime / (dieTime - startTime)) * 25);
 }