Example #1
0
 public void Update()
 {
     lifeTime--;
     Position += Velocity;
     rotation += (float)Math.PI / 15;
     Position  = LinkGame.LoopAroundCheck(Position);
     if (LinkGame.random.Next(2) == 0)
     {
         new Particle(Position, LinkGame.PolarVector(1, (float)LinkGame.random.NextDouble() * (float)Math.PI * 2), 2f);
     }
     for (int i = 0; i < LinkGame.gameRings.Count; i++)
     {
         if ((LinkGame.gameRings[i].Position - this.Position).Length() < LinkGame.gameRings[i].radius)
         {
             for (int p = 0; p < LinkGame.gameRings[i].radius; p++)
             {
                 new Particle(LinkGame.gameRings[i].Position, LinkGame.PolarVector((float)LinkGame.random.NextDouble() * 4 + 1, (float)LinkGame.random.NextDouble() * 2 * (float)Math.PI), 2f + (float)LinkGame.random.NextDouble() * 3);
             }
             LinkGame.gameRings[i].linkedTo = null;
             LinkGame.gameRings[i]          = null;
             LinkGame.gameRings.RemoveAt(i);
             LinkGame.gameProjectiles.Remove(this);
             LinkGame.sounds[2].Play(.5f, 1f, 1f);
         }
     }
     if (lifeTime <= 0)
     {
         LinkGame.gameProjectiles.Remove(this);
         for (int p = 0; p < 5; p++)
         {
             new Particle(Position, LinkGame.PolarVector(3, (float)LinkGame.random.NextDouble() * (float)Math.PI * 2), 2f);
         }
     }
 }
Example #2
0
        public void Update()
        {
            this.energy++;
            if (this.energy > this.maxEnergy)
            {
                this.energy = this.maxEnergy;
            }
            this.time++;
            if (this.LinkedToPlayer != -1)
            {
                this.Position = LinkGame.gamePlayers[this.LinkedToPlayer].Position;
                LinkGame.gamePlayers[this.LinkedToPlayer].energy += this.energy;
                this.energy = 0;
            }
            if (this.linkedTo != null && !LinkGame.gameRings.Contains(this.linkedTo))
            {
                this.linkedTo = null;
            }
            foreach (Ring otherRing in LinkGame.gameRings)
            {
                if (this.LinkedToPlayer == -1 && this != otherRing)
                {
                    while ((this.Position - LinkGame.screenLoopAdjust(Position, otherRing.Position)).Length() < this.radius + otherRing.radius)
                    {
                        float direction = LinkGame.ToRotation(this.Position - LinkGame.screenLoopAdjust(Position, otherRing.Position));
                        this.Position += LinkGame.PolarVector(1, direction);
                        if (otherRing.LinkedToPlayer == -1)
                        {
                            otherRing.Position -= LinkGame.PolarVector(1, direction);
                        }
                    }

                    if (this.linkedTo == null && (this.Position - LinkGame.screenLoopAdjust(this.Position, otherRing.Position)).Length() < 100 + this.radius + otherRing.radius && otherRing.linkedTo != this)
                    {
                        this.linkedTo           = otherRing;
                        LinkGame.playeLinkSound = true;
                    }
                }
            }
            if (this.linkedTo != null)
            {
                this.linkedTo.energy += this.energy;
                this.energy           = 0;
                if ((this.Position - LinkGame.screenLoopAdjust(this.Position, this.linkedTo.Position)).Length() > 100 + this.radius + this.linkedTo.radius)
                {
                    float direction = LinkGame.ToRotation(LinkGame.screenLoopAdjust(this.Position, this.linkedTo.Position) - this.Position);
                    this.Position += LinkGame.PolarVector(3, direction);
                }
            }
            this.Position = LinkGame.LoopAroundCheck(this.Position);
        }