Пример #1
0
        public bool Callback(BCBlockGameState gamestate)
        {
            //iterate through all balls...
            BCBlockGameState.Soundman.PlaySound("RANDOMY");

            foreach (cBall iterateball in gamestate.Balls)
            {
                var gotspeed = iterateball.getMagnitude();
                //set a new velocity with that speed.
                iterateball.Velocity = BCBlockGameState.GetRandomVelocity(gotspeed);
                //add some randomly coloured lightorbs...
                foreach (Color addcolor in chosencolors)
                {
                    LightOrb lo = new LightOrb(iterateball.Location, addcolor, 17);
                    PointF usevelocity = BCBlockGameState.GetRandomVelocity(2, 5, BCBlockGameState.GetAngle(new PointF(0, 0), iterateball.Velocity));
                    BCBlockGameState.VaryVelocity(usevelocity, Math.PI / 4);
                    lo.Velocity = usevelocity;
                    gamestate.Particles.Add(lo);

                }

            }

            return true;
        }
Пример #2
0
 public void EatOrb(GameObject objectToEat)
 {
     if (eating)
     {
         LightOrb otherOrb = objectToEat.GetComponent <LightOrb>();
         collectedOrbs.Add(otherOrb.ink);
         objectionManager.EatColor(otherOrb.ink);
         AddSubfish(otherOrb.ink);
         Destroy(objectToEat);
         objectionManager.CheckIfDone();
     }
 }
Пример #3
0
    void OnCollisionEnter(Collision collision)
    {
        GameObject other = collision.gameObject;

        if (other.gameObject.GetComponent <LightOrb>() != null)
        {
            otherOrb = other.gameObject.GetComponent <LightOrb>();

            if (!otherOrb.attractingToOtherOrb)
            {
                StartAttractingOtherOrb();
                otherOrb.StartAttractingOtherOrb(this);
            }

            Debug.Log("Other Orb found");
        }
    }
Пример #4
0
        public override bool PerformFrame(BCBlockGameState gamestate)
        {
            //hitscan. We only "take" a single frame to hit something.
            //first, normalize the Velocity.
            _Velocity = _Velocity.Normalize();

            //now, starting from _Origin, advance position by _Velocity until we hit a block or leave the gamearea.
            List<Block> blockshit = new List<Block>();
            PointF currpos = _Origin;
            PointF lastpos = _Origin;
            bool scancomplete = false;
            int spawnjump = 0;
            int particlecomparator = Math.Max(gamestate.Particles.Count-500, 2);
            //particlecomparator is our modulus. This will be modulo'd with spawnjump each iteration

            while (!scancomplete)
            {
                spawnjump++;
                currpos = new PointF(currpos.X + _Velocity.X, currpos.Y + _Velocity.Y);

                PointF diff = new PointF(currpos.X-lastpos.X,currpos.Y-lastpos.Y);
                //spawn some particles here.
                if (spawnjump>particlecomparator && Tracer)
                {
                    spawnjump = 0;
                    for (int i = 0; i < 1; i++)
                    {

                            float randomspot = (float)BCBlockGameState.rgen.NextDouble();
                            PointF randomoffset = new PointF(currpos.X + diff.X * randomspot, currpos.Y + diff.Y * randomspot);
                            if (BCBlockGameState.rgen.NextDouble() > 0.5)
                            {
                                DustParticle dp = new DustParticle(randomoffset, 3, 25, _BulletColor);
                                dp.Important = true;
                                gamestate.Particles.Add(dp);
                            }
                            else
                            {
                                LightOrb dp = new LightOrb(randomoffset, Color.Green, 16);
                                dp.TTL = 25;

                                dp.Important = true;
                                gamestate.Particles.Add(dp);
                            }
                    }
                }

                //are we outside gamearea?
                if (!gamestate.GameArea.Contains(currpos.ToPoint()))
                    scancomplete = true;

                //have we hit a block?
                var hitblock = BCBlockGameState.Block_HitTestOne(gamestate.Blocks, currpos);
                if (hitblock != null && !blockshit.Contains(hitblock))
                {
                    blockshit.Add(hitblock);

                    if(_Strength == HitscanStrengthConstants.hitscan_bullet)
                    {
                        //create a bullet at currpos, make it go in our direction.
                        Bullet bb = new Bullet(currpos, _Velocity, false);
                        bb.BulletBrush = new SolidBrush(Color.Transparent); //invisible bullet...
                        gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() => gamestate.GameObjects.AddLast(bb)));
                    }
                else if(_Strength==HitscanStrengthConstants.hitscan_hit)
                    {

                    gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() => BCBlockGameState.Block_Hit(gamestate, hitblock, _Velocity)));
                    }

                    if (!Penetrate) scancomplete = true;
                }

                lastpos = currpos;
            }

            if (!Tracer)
            {
                DustParticle pa = new DustParticle(Origin, 800,9000,Color.Transparent);
                DustParticle pb = new DustParticle(currpos,800,9000,Color.Transparent);

                pa.Velocity = PointF.Empty;
                pb.Velocity = PointF.Empty;

                LineParticle ls = new LineParticle(pa, pb,new Pen(Color.Yellow,1));
                ls.Important = true;
                ls.TTL = 750;
                gamestate.Particles.Add(ls);

                //show the impact point.
                PointF Impactpoint = currpos;
                for (int i = 0; i < 14 * BCBlockGameState.Settings.ParticleGenerationFactor; i++)
                {
                    Particle xp = BCBlockGameState.rgen.NextDouble() > 0.5 ?
                        (Particle)
                        new EmitterParticle(Impactpoint,(gstate,emitter,aint,bint)=>
                            {
                                float ssspeed = (float)BCBlockGameState.rgen.NextDouble() * 5 + 2;
                                PointF ssusespeed = BCBlockGameState.VaryVelocity(new PointF(0,-ssspeed), Math.PI / 10);
                                DustParticle addit = new DustParticle(emitter.Location, 40);
                                addit.Velocity = ssusespeed;
                                return addit;
                            })
                            : (Particle)new DustParticle(Impactpoint);
                    float speed = (float)BCBlockGameState.rgen.NextDouble() * 5 + 2;
                    PointF usespeed = BCBlockGameState.VaryVelocity(new PointF(0,-speed), Math.PI / 10);
                    xp.Velocity = usespeed;
                    gamestate.Particles.Add(xp);
                }

            }

            return true; //we only exist for one frame.
        }
Пример #5
0
        public override bool PerformFrame(BCBlockGameState gamestate)
        {
            bool retval = base.PerformFrame(gamestate);

                //add some particles around the edges of the explosion, moving outward...
                if (gamestate.Particles.Count((w)=>!w.Important) < BCBlockGameState.MaxParticles)
                {
                    for (int i = 0; i < (int)(25f * BCBlockGameState.ParticleGenerationFactor); i++)
                    {
                        const float speedmult = 1;
                        //choose a random Angle...
                        double randomangle = Math.PI * 2 * BCBlockGameState.rgen.NextDouble();
                        //create the appropriate speed vector, based on our radius...
                        double usespeed = (_CurrentRadius / _MaxRadius) * speedmult;
                        //should be proportional to how close we are to the maximum radius; max radius will have particles move 1...
                        usespeed += ((BCBlockGameState.rgen.NextDouble() * 0.6) - 0.3);

                        PointF addpointLocation = new PointF(Location.X + (float)Math.Cos(randomangle) * _CurrentRadius,
                                                             Location.Y + (float)Math.Sin(randomangle) * _CurrentRadius);

                        //create a dustparticle...
                        PointF PointSpeed = new PointF((float)(Math.Cos(randomangle) * usespeed),
                                                       (float)(Math.Sin(randomangle) * usespeed));
                        Particle addparticle = null;
                        if (i % 5 != 0)
                        {
                            addparticle = new DustParticle(addpointLocation, PointSpeed);

                        }
                        else if (_ShowOrbs)
                        {
                            //LightOrb...
                            LightOrb lo = new LightOrb(addpointLocation, ExplosionColor,
                                                       (float)BCBlockGameState.rgen.NextDouble() * 10 + 5);
                            lo.Velocity = PointSpeed;
                            addparticle = lo;

                        }

                        if (addparticle != null) gamestate.Particles.Add(addparticle);

                    }
                }

                //each frame, check for blocks that are within the given radius. Hell with it, we'll check their centerpoints...

                if (gamestate.PlayerPaddle != null)
                {
                    //if(

                    if (DamagePaddle && BCBlockGameState.RectangleIntersectsCircle(gamestate.PlayerPaddle.Getrect(), Location, _CurrentRadius))
                    {

                        gamestate.PlayerPaddle.HP -= 1f;
                    }
                }

                if (_EffectObjects)
                {
                    //find all GameObjects that implement IExplodable.
                    //we might be bothered to do the same for Balls, I suppose. No promises.

                    IEnumerable<IExplodable> result = BCBlockGameState.Join<IExplodable>(
                        (from ball in gamestate.Balls where ball is IExplodable && (BCBlockGameState.Distance(Location,ball.Location) < _CurrentRadius)  select ball as IExplodable),
                        (from obj in gamestate.GameObjects where obj is IExplodable select obj as IExplodable));

                        //in order to prevent contention issues, we will defer the loop that "effects" each item until the next gametick iteration starts.
                    gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() =>
                    {
                        foreach (var iterateresult in result)
                        {

                            PointF useVelocityEffect = new PointF(Math.Max(1,Velocity.X),Math.Max(1,Velocity.Y));

                            iterateresult.ExplosionInteract(this, Location, useVelocityEffect);

                        }

                    }));

                }

                List<Block> removethese = new List<Block>();
                if (_DamageBlocks)
                {
                    var blowemup = from p in gamestate.Blocks
                                   where
                                       BCBlockGameState.Distance(Location.X, Location.Y, p.CenterPoint().X,
                                                                 p.CenterPoint().Y) < _CurrentRadius
                                   select p;
                    if (blowemup.Any())
                    {
                        foreach (var loopblock in blowemup)
                        {
                            //destroy it.

                            if (loopblock is DestructionBlock)
                            {
                                //special handling for combos
                                Debug.Print("DestructionBlock detected in ExplosionEffect...");
                                (loopblock as DestructionBlock).ComboCount = this.ComboCount + 1;

                            }
                            if (DestroyAll || loopblock.MustDestroy())
                            {
                                loopblock.StandardSpray(gamestate);
                                removethese.Add(loopblock);
                            }

                        }

                        lock (gamestate.Blocks)
                        {
                            foreach (Block removeit in removethese)
                            {
                                //get angle between the center of the explosion and the block's center.
                                double Angle = BCBlockGameState.GetAngle(CenterPoint(), removeit.CenterPoint());
                                int useSpeed = BCBlockGameState.ClampValue((int)_MaxRadius / 2, 1, 5);
                                PointF useVelocity = BCBlockGameState.GetVelocity(useSpeed, Angle);
                                cBall tempball = new cBall(new PointF(removeit.CenterPoint().X-useVelocity.X,removeit.CenterPoint().Y-useVelocity.Y), useVelocity);
                                tempball.PreviousVelocity = useVelocity;
                                tempball.Behaviours.Add(new TempBallBehaviour());
                                //add a proxy behaviour to remove it as well.
                                //tempball.Behaviours.Add(new ProxyBallBehaviour("ExplosionEffect", null, proxyperformframe, null, null, null, null, null, null));
                                //gamestate.Balls.AddLast(tempball);

                                List<cBall> discardlist = new List<cBall>();
                                try
                                {
                                    //this is... well, cheating...

                                    //we cannot add GameObjects to the List, except by plopping them in the ref AddedObject parameter.
                                    //however, we cannot "force" the PerformBlockHit of a block (say a destruction block) to add a GameObject (another ExplosionEffect, in that case)

                                    //we cheat. we swap out the entire gamestate.GameObject LinkedList with a new one, call the routine, and then
                                    //we add any added GameObjects to our ref parameter, and swap the old list back in, hoping nobody notices our
                                    //audacity to fiddle with core game state objects...
                                    var copiedref = gamestate.GameObjects;
                                    gamestate.GameObjects = new LinkedList<GameObject>();

                                    removeit.PerformBlockHit(gamestate, tempball);
                                    gamestate.Blocks.Remove(removeit);
                                    var tempadded = gamestate.GameObjects;
                                    gamestate.GameObjects = copiedref;
                                    //now we add the ones we need to add to our ref array. I feel dirty.
                                    gamestate.Defer(() =>
                                    {
                                        foreach (var iterate in tempadded)
                                        {
                                            gamestate.GameObjects.AddLast(iterate);
                                        }

                                    });

                                }
                                catch
                                {

                                }
                                //we don't add the ball to our GameState, so we don't have to worry about it persisting :D

                                //the idea is that we want to invoke the actions of the block (which for many blocks will simply be destroyed).
                                //at the same time, some blocks might react weirdly to having temporary balls tossed into their centers, so we make it so the ball will only live for
                                //two frames by adding a proxyballbehaviour that ensure that.
                                //gamestate.Blocks.Remove(removeit);
                                gamestate.Forcerefresh = true;
                            }

                            //changed: instead of removing them, create a temporary ball at their center point.

                        }

                    }
                }

                return retval;
        }
Пример #6
0
        public override bool PerformFrame(BCBlockGameState gamestate)
        {
            bool rval = base.PerformFrame(gamestate);

                for (int i = 0; i < (int)(50f * BCBlockGameState.ParticleGenerationFactor); i++)
                {
                    const float speedmult = 1;
                    //choose a random Angle...
                    double randomangle = Math.PI * 2 * BCBlockGameState.rgen.NextDouble();
                    //create the appropriate speed vector, based on our radius...
                    double usespeed = (_CurrentRadius / _MaxRadius) * speedmult; //should be proportional to how close we are to the maximum radius; max radius will have particles move 1...
                    usespeed += ((BCBlockGameState.rgen.NextDouble() * 0.5) - 0.25);

                    PointF addpointLocation = new PointF(Location.X + (float)Math.Cos(randomangle) * _CurrentRadius, Location.Y + (float)Math.Sin(randomangle) * _CurrentRadius);

                    //create a dustparticle...
                    Particle addparticle = null;
                    if ((i % 5 == 0) && _ShowOrbs)
                    {
                        addparticle = new LightOrb(addpointLocation, Color.Blue, 5 + (float)(BCBlockGameState.rgen.NextDouble() * 10));
                    }
                    else
                    {
                        addparticle = new WaterParticle(addpointLocation,
                                                                      new PointF((float)(Math.Cos(randomangle) * usespeed),
                                                                                 (float)(Math.Sin(randomangle) * usespeed)));
                    }

                    if (addparticle != null)
                    {
                        addparticle.Velocity = new PointF(addparticle.Velocity.X + Velocity.X, addparticle.Velocity.Y + Velocity.Y);
                        gamestate.Particles.Add(addparticle);
                    }

                }

                //is this the first call?
                if (!flInit)
                {
                    flInit = true;
                    //initialize data structures.
                    //the idea here is that createblocklocations will store the offset from the CreationEffect's location, rather than an absolute position.
                    for (float x = -_MaxRadius; x < (_MaxRadius); x += BlockCreateSize.Width)
                    {
                        for (float y = -_MaxRadius; y < (_MaxRadius); y += BlockCreateSize.Height)
                        {
                            //add a new rectangle to that cache
                            RectangleF createrect = new RectangleF(x, y, BlockCreateSize.Width, BlockCreateSize.Height);
                            //add it to the list.
                            createblocklocations.Add(createrect);

                        }

                    }

                }
                //createblocklocations has the offsets from our position. LINQ-ee-fy it to see if any need to be created.
                var createthese = from q in createblocklocations where BCBlockGameState.Distance(0, 0, q.CenterPoint().X, q.CenterPoint().Y) < _CurrentRadius select q;
                List<RectangleF> removethese = new List<RectangleF>();
                if (createthese.Any())
                {
                    //we need to create some blocks we do.
                    foreach (RectangleF looprect in createthese)
                    {

                        //create the PROPER rectanglef structure by cloning this one and offseting the clone.
                        RectangleF userect = looprect;
                        userect.Offset(Location.X, Location.Y);
                        Block createdblock = DefaultCreationFunction(gamestate, userect);
                        //add this block to the game.
                        gamestate.Blocks.AddLast(createdblock);
                        removethese.Add(looprect);

                    }

                    foreach (var removeit in removethese)
                    {
                        createblocklocations.Remove(removeit);

                    }

                    gamestate.Forcerefresh = true;

                }

                return rval;
        }
Пример #7
0
        public static void spawnpoof(BCBlockGameState bstate, Block cloned)
        {
            Random rg = BCBlockGameState.rgen;
            for (int i = 0; i < 6; i++)
            {
                //choose a random location within the block.
                PointF randomspot =
                    new PointF((float) (rg.NextDouble()*cloned.BlockRectangle.Width + cloned.BlockRectangle.Left),
                               (float) (rg.NextDouble()*cloned.BlockRectangle.Height + cloned.BlockRectangle.Top));
                //now, a random speed.
                PointF randomspeed = BCBlockGameState.GetRandomVelocity(0.5f, 2);
                //and last, a random radius...
                float useradius = (float) (rg.NextDouble()*cloned.BlockRectangle.Width);

                LightOrb addorb = new LightOrb(randomspot, Color.Blue, useradius);

                addorb.Velocity = randomspeed;
                bstate.Particles.Add(addorb);
            }
        }
        private void ShootFunction(int chargeticks)
        {
            // TerminatorBehaviour Power Levels
            // Each Terminator Power up will add one to the power.
            //Power Level One: Machine gun
            // Power level Two: Shoot a single ball from the center of the paddle upwards.
            // Power Level Three: similar to Level one, but it shoots from each side of the paddle.
            //power level Four: shoots a single laser from the center of the paddle.
            //power level Five: shoots a laser from each side.
            // power level Six: Shoot a single ball from the center of the paddle upwards: however,
            //this will have a laserspinball behaviour, delay set to half a second.
            //power level Seven, same as five, but with laser spin
            //power level eight: SpinShot.

            if (mstate.PlayerPaddle == null) return;

            //only shoot if we are the first in the list of behaviours that are this type....
            if (!mstate.PlayerPaddle.Behaviours.Contains(this)) return;
            if (mstate.PlayerPaddle.Behaviours.First((x) => x.GetType() == typeof (TerminatorBehaviour)) == this)
            {
                if (mstate.PlayerPaddle.Energy == 0)
                {
                    BCBlockGameState.Soundman.PlaySound("shootfail");
                    //and, again, showmanship at work- "shoot" some black light orbs... to simulate smoke...

                    for (int i = 0; i < 6; i++)
                    {
                        PointF usespeed = new PointF(0, (float) (-3 - (BCBlockGameState.rgen.NextDouble())));
                        usespeed = BCBlockGameState.VaryVelocity(usespeed, Math.PI/6);
                        LightOrb addorb = new LightOrb(mstate.PlayerPaddle.Getrect().CenterPoint(),
                                                       BCBlockGameState.rgen.NextDouble() > 0.5d
                                                           ? Color.Black
                                                           : Color.Gray,
                                                       15 + (float) (15*BCBlockGameState.rgen.NextDouble()));
                        addorb.Velocity = usespeed;
                        addorb.VelocityDecay = new PointF(0.9f, 0.85f);
                        mstate.Particles.Add(addorb);
                        //take damage, too...
                    }
                    mstate.PlayerPaddle.HP -= 10;
                    return;
                }
                else
                {
                    BCBlockGameState.Soundman.PlaySound("firelaser");
                }
                mstate.PlayerPaddle.Energy--;
                Paddle pad = mstate.PlayerPaddle;
                RectangleF paddlerect = mstate.PlayerPaddle.Getrect();
                PointF MiddleTop = new PointF(paddlerect.Left + (paddlerect.Width/2), paddlerect.Top);
                PointF LeftTop = new PointF(paddlerect.Left, paddlerect.Top);
                PointF RightTop = new PointF(paddlerect.Right, paddlerect.Top);
                Pen ChosenPenColor = new Pen(Color.Blue, 2);
                //TODO: make it depend on the paddle health. (blue when full, red when damaged).

                //if the powerlevel exceeds MaxPowerup...
                if (PowerLevel > MaxPowerup)
                {
                    MachineGunTimer = new Timer(MachineGun, null, 60, 130); //120 ms delay...
                }
                //if it's larger than powerLevel*2, set it to powerLevel*2...
                if (PowerLevel > PowerLevel*2) PowerLevel = PowerLevel*2;
                int pPowerLevel = ((PowerLevel - 1)%(MaxPowerup)) + 1;
                //Power Level One: Machine gun

                if (pPowerLevel == 1)
                {
                    if (PowerLevel == 1)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            Bullet firebullet =
                                new Bullet(
                                    new PointF(
                                        mstate.PlayerPaddle.Getrect().Left + (mstate.PlayerPaddle.Getrect().Width/2),
                                        mstate.PlayerPaddle.Getrect().Top),
                                    BCBlockGameState.VaryVelocity(new PointF(0, -10), Math.PI/7));
                            mstate.GameObjects.AddLast(firebullet);
                        }
                    }
                    else
                    {
                        Bullet firebullet =
                            new Bullet(
                                new PointF(
                                    mstate.PlayerPaddle.Getrect().Left + (mstate.PlayerPaddle.Getrect().Width/2),
                                    mstate.PlayerPaddle.Getrect().Top),
                                BCBlockGameState.VaryVelocity(new PointF(0, -10), Math.PI/7));
                        mstate.GameObjects.AddLast(firebullet);
                    }
                }
                else if (pPowerLevel == 2)
                {
                    // Power level Two: Shoot a single ball from the center of the paddle upwards. (temp)
                    cBall shootball = new cBall(MiddleTop,
                                                BCBlockGameState.VaryVelocity(new PointF(0, -8), Math.PI/8));
                    shootball.Radius = 3;
                    shootball.DrawColor = Color.Yellow;
                    shootball.DrawPen = new Pen(Color.GreenYellow);
                    shootball.Behaviours.Add(new TempBallBehaviour());
                    mstate.ShootBalls.AddRange(new cBall[] {shootball});
                }
                else if (pPowerLevel == 3)
                {
                    // Power Level Three: similar to Level one, but it shoots from each side of the paddle.
                    PointF[] Originspots = new PointF[] {LeftTop, RightTop};
                    foreach (PointF ShotOrigin in Originspots)
                    {
                        cBall shootit = new cBall(ShotOrigin,
                                                  BCBlockGameState.VaryVelocity(new PointF(0f, -8.8f), Math.PI/8.8f));
                        shootit.Radius = 3;
                        shootit.DrawColor = Color.Yellow;
                        shootit.DrawPen = new Pen(Color.RoyalBlue);
                        shootit.Behaviours.Add(new TempBallBehaviour());
                        mstate.ShootBalls.Add(shootit);
                    }
                }
                else if (pPowerLevel == 4)
                {
                    //weak hitscan, straight upwards.
                    HitscanBullet hsb = new HitscanBullet(paddlerect.TopCenter(), new PointF(0, -2));
                    hsb.Penetrate = false;
                    hsb.Strength = HitscanBullet.HitscanStrengthConstants.hitscan_bullet;
                    mstate.GameObjects.AddLast(hsb);
                    BCBlockGameState.Soundman.PlaySound("laser2");
                }
                else if (pPowerLevel == 5)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        PointF selectedvelocity = BCBlockGameState.VaryVelocity(new PointF(0, -8), Math.PI/16);
                        HitscanBullet hsb = new HitscanBullet(paddlerect.TopCenter(), selectedvelocity);
                        hsb.Penetrate = false;
                        hsb.Strength = HitscanBullet.HitscanStrengthConstants.hitscan_bullet;
                        mstate.GameObjects.AddLast(hsb);
                        BCBlockGameState.Soundman.PlaySound("laser2");
                    }
                }
                else if (pPowerLevel == 6)
                {
                    //power level Four: shoots a single laser from the center of the paddle.
                    LaserShot ShootLaser = new LaserShot(MiddleTop, new PointF(0, -9), ChosenPenColor, 36);
                    mstate.GameObjects.AddLast(ShootLaser);
                }
                else if (pPowerLevel == 7)
                {
                    PointF[] Originspots = new PointF[] {LeftTop, RightTop};
                    PointF usevelocity = BCBlockGameState.VaryVelocity(new PointF(0f, -8.8f), Math.PI/8.9f);
                    foreach (PointF ShotOrigin in Originspots)
                    {
                        LaserShot ShootLaser = new LaserShot(ShotOrigin, usevelocity, ChosenPenColor);
                        mstate.GameObjects.AddLast(ShootLaser);
                        //power level Five: shoots a laser from each side.
                    }
                }
                else if (pPowerLevel == 8)
                {
                    cBall shootball = new cBall(MiddleTop,
                                                BCBlockGameState.VaryVelocity(new PointF(0f, -1f), Math.PI/10));
                    shootball.Behaviours.Add(new LaserSpinBehaviour(new TimeSpan(0, 0, 0, 0, 300)));
                    shootball.Behaviours.Add(new TempBallBehaviour());
                    shootball.Radius = 3;
                    shootball.DrawColor = Color.Yellow;
                    shootball.DrawPen = new Pen(Color.GreenYellow);
                    mstate.ShootBalls.Add(shootball);
                    // power level Six: Shoot a single ball from the center of the paddle upwards: however,
                    //this will have a laserspinball behaviour, delay set to half a second.
                }
                else if (pPowerLevel == 9)
                {
                    //power level Seven, same as five, but with laser spin
                    //also same as 6 but with two of them...
                    PointF[] Originspots = new PointF[] {LeftTop, RightTop};
                    foreach (PointF ShotOrigin in Originspots)
                    {
                        cBall shootball = new cBall(ShotOrigin,
                                                    BCBlockGameState.VaryVelocity(new PointF(0f, -9f), Math.PI/10));
                        shootball.Behaviours.Add(new LaserSpinBehaviour(new TimeSpan(0, 0, 0, 300)));
                        shootball.Behaviours.Add(new TempBallBehaviour());
                        shootball.Radius = 3;
                        shootball.DrawColor = Color.Yellow;
                        shootball.DrawPen = new Pen(Color.GreenYellow);
                        mstate.ShootBalls.Add(shootball);
                    }
                }
                else if (pPowerLevel == 10)
                {
                    //spinshot
                    PointF selectedspeed = BCBlockGameState.VaryVelocity(new PointF(0, -9f), Math.PI/10);
                    SpinShot shootit = new SpinShot(mstate,
                                                    new PointF(
                                                        mstate.PlayerPaddle.Getrect().Left +
                                                        (mstate.PlayerPaddle.Getrect().Width/2),
                                                        mstate.PlayerPaddle.Getrect().Top), 12, 16,
                                                    ((float) Math.PI/6), selectedspeed);

                    mstate.GameObjects.AddLast(shootit);
                }
            }
            else
            {
                Debug.Print("Terminator Behaviour not first Terminator in behaviours collection... ignoring...");
            }
        }
Пример #9
0
        public override List<Block> PerformFrame(BCBlockGameState ParentGameState, ref List<cBall> ballsadded, ref List<cBall> ballsremove)
        {
            /*
            PreviousVelocity = Velocity;
            //returns the blocks that were affected by the frame (changed or moved).
            PointF NextPosition = new PointF(Location.X + Velocity.X, Location.Y + Velocity.Y);
            RectangleF NextPositionBorders = new RectangleF(NextPosition.X - Radius, NextPosition.Y - Radius, Radius, Radius);
            NormalizeSpeed();
            if (ballsadded == null) ballsadded = new List<cBall>();
            RectangleF rectangleborders = new RectangleF(Location.X - Radius, Location.Y - Radius, Radius, Radius);
            PrevLocation = Location;
            Location = NextPosition;
            bool doemit=false;
            CheckWallCollision(ParentGameState.GameArea, getRect(), ref doemit);
            if (ParentGameState.PlayerPaddle != null)
                ParentGameState.PlayerPaddle.CheckImpact(ParentGameState, this,false);
            //FrustratorBalls only hit Destroyed Blocks.
             * */

            mm = ((mm + 1) % 2);
            usehue += 2;
            usehue %= 240;
            //spawn a lightorb in a random colour.
            if (mm == 0)
            {
                Color drawcolor = new HSLColor((float)usehue, 240, 120);
                LightOrb lo = new LightOrb(Location, drawcolor, 12);
                lo.TTL = 30;
                ParentGameState.Particles.Add(lo);
            }
            return base.PerformFrame(ParentGameState, ref ballsadded, ref ballsremove);
        }
Пример #10
0
        protected override void StandardSpray(BCBlockGameState parentstate, cBall ballhit)
        {
            //add lightorbs, too!
            //one in each cardinal direction.
            double usespeed = 4;
            double currangle = 0;
            double angleincrement = Math.PI / 4;
            while (currangle < Math.PI * 2)
            {
                PointF velocityuse = new PointF((float)(Math.Cos(currangle) * usespeed), (float)(Math.Sin(currangle) * usespeed));
                LightOrb makeorb = new LightOrb(BlockRectangle.CenterPoint(), SwitchData[State].StateColor, 24);
                makeorb.Velocity = velocityuse;
                parentstate.Particles.Add(makeorb);

                currangle += angleincrement;
            }
        }
Пример #11
0
        private void PerformFrame(Paddle toPaddle,BCBlockGameState gstate)
        {
            //add a random lightorb.
            if (offsetcall++ > 10)
            {
                offsetcall = 0;
                Color chosencolor = new HSLColor(BCBlockGameState.rgen.NextDouble() * 240, 240, 128);
                LightOrb lo = new LightOrb(toPaddle.BlockRectangle.RandomSpot(BCBlockGameState.rgen), chosencolor, 32);
                lo.Velocity = BCBlockGameState.GetRandomVelocity(0, 3);
                gstate.Defer(() => gstate.Particles.Add(lo));

            }
        }
Пример #12
0
 public void StartAttractingOtherOrb(LightOrb orbToAttract)
 {
     otherOrb = orbToAttract;
     StartAttractingOtherOrb();
 }