当前位置: 首页>>代码示例>>C#>>正文


C# BCBlockGameState类代码示例

本文整理汇总了C#中BCBlockGameState的典型用法代码示例。如果您正苦于以下问题:C# BCBlockGameState类的具体用法?C# BCBlockGameState怎么用?C# BCBlockGameState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BCBlockGameState类属于命名空间,在下文中一共展示了BCBlockGameState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BehaviourAdded

        /// <summary>
        /// sealed override, responsible for most of the bulk of the work of the TimedBehaviour.
        /// </summary>
        /// <param name="toPaddle"></param>
        /// <param name="gamestate"></param>
        public override sealed void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
        {
            //call base implementation
            base.BehaviourAdded(toPaddle, gamestate);
            //check if we are SingleInstance. If so, that means that there can only be one instance at a time, which may not be surprising given the name.
            if (SingleInstance())
            {
                //check for existing instances of our class. If found, add our delay time to them.
                foreach (var iterate in (from p in toPaddle.Behaviours where p != this select p))
                {
                    if (iterate.GetType() == GetType())
                    {
                        //if same type, change delay, and break from routine.
                        (iterate as TimedPaddleBehaviour).ChangeDelayTime(gamestate, _BehaviourTime, true);
                        //make sure this instance get's removed, too! we are redundant now.
                        gamestate.NextFrameCalls.Enqueue
                            (new BCBlockGameState.NextFrameStartup(() => toPaddle.Behaviours.Remove(this)));

                        return;
                    }
                }
            }

            //if we are either not singleinstance or we are single instance but there are no existing  behaviours of our type attached,
            //do the stuff to add us.
            DelayIdentifier = gamestate.DelayInvoke(_BehaviourTime, TimeDelayRoutine, new object[] {gamestate});
            //if we have ability music, we play it now. Use the SoundManager's capacity to handle temporary music, which works rather well.
            if (_AbilityMusic != "") BCBlockGameState.Soundman.PlayTemporaryMusic(_AbilityMusic, 1.0f, true);
            //hook Death function. If the paddle dies, obviously the time delay will break out early, so we will need to stop the temporary music ourself.
            toPaddle.OnDeath += new Func<Paddle, bool>(toPaddle_OnDeath);
            //call abstract method for initialization.
            TimedBehaviourInitialize(toPaddle, gamestate);
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:38,代码来源:TimedPaddleBehaviour.cs

示例2: getPowerup

 public override bool getPowerup(BCBlockGameState gstate,Paddle onPaddle, GamePowerUp gpower)
 {
     if(onPaddle==null) return false;
     //don't accept it.
     //reject it with great prejudice.
     //move the location temporarily.
     PointF oldposition = gpower.Location;
     SizeF oldsize = gpower.Size;
     gpower.Location = PointF.Empty;
     //draw to a temporary bitmap.
     Bitmap drawtothis = new Bitmap(16, 16);
     Graphics useg = Graphics.FromImage(drawtothis);
     useg.Clear(Color.Transparent);
     gpower.Draw(useg);
     //reset position.
     gpower.Location = oldposition;
     gpower.Size = oldsize;
     //get average.
     var averagedpixel = Color.FromArgb((int)((from p in drawtothis.getPixels() select p.ToArgb()).Average()));
     ExplosionEffect ee = new ExplosionEffect(gpower.Location, 72);
     ee.ExplosionColor = averagedpixel;
     ee.DamageBlocks = false;
     ee.DamagePaddle = false;
     gstate.Defer(() => gstate.GameObjects.AddLast(ee));
     //move  gpower to above the paddle, and invert the Y speed.
     gpower.Location = new PointF(gpower.Location.X, onPaddle.BlockRectangle.Top - gpower.getRectangle().Height - 1);
     gpower.Velocity = new PointF(gpower.Velocity.X, -Math.Abs(gpower.Velocity.Y)*1.1f);
     return true;
 }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:29,代码来源:DeflectorBehaviour.cs

示例3: getRespawnCandidates

        /// <summary>
        /// routine finds all the blocks that can be candidates for respawning.
        /// </summary>
        /// <returns></returns>
        public static List<Block> getRespawnCandidates(BCBlockGameState stateobj)
        {
            //first, we copy the Blocks from the state. This is to prevent a race condition. Note that
            //since it is a shallow clone, it shouldn't have a huge impact on memory usage.
            if (stateobj.PlayingLevel == null) return new List<Block>();
            List<Block> clonedlist;
            try
            {
                clonedlist = stateobj.Blocks.ShallowClone().ToList();

            }
            catch
            {
                return new List<Block>();
            }

            //the primary "issue" here is that we cloned them to make them disparate entities, so we can't just do a direct comparison.
            //truly, the best we can do is compare BlockRectangles. This has something of a weird effect in that Blocks that move can and may very well be
            //"respawned" by virtue of them no longer being in their original positions. It sounds like it could be an interestiong quirk and there isn't
            //a whole lot I can do to prevent it without keeping track of a lot of crap, so I'll see how that goes.

            //get all blocks in stateobj.PlayingLevel.levelblocks for which there is no block in clonedlist with the same BlockRectangle...

            var queried = from bb in stateobj.PlayingLevel.levelblocks
                          where (bb.GetType() != typeof(FrustratorBlock) &&
                                 !(clonedlist.Any((wep) => wep.BlockRectangle == bb.BlockRectangle)))
                          select bb;

            //convert to list, and return.
            return queried.ToList();
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:35,代码来源:FrustratorBlock.cs

示例4: Callback

        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;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:25,代码来源:RandomizerPowerup.cs

示例5: StickyBehaviour

 public StickyBehaviour(BCBlockGameState stateobject)
 {
     //add a hook to the stateobject's targetarea...
     //((PictureBox) stateobject.TargetObject).MouseClick += new MouseEventHandler(StickyBehaviour_MouseClick);
     //((PictureBox)stateobject.TargetObject).MouseClick += new MouseEventHandler(StickyBehaviour_MouseClick);
     stateobject.ClientObject.ButtonDown += ClientObject_ButtonDown;
     stateobject.ClientObject.ButtonUp += ClientObject_ButtonUp;
 }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:8,代码来源:StickyBehaviour.cs

示例6: BuilderShotBehaviour

        public BuilderShotBehaviour(BCBlockGameState stateobject)
        {
            gstate = stateobject;
            //stateobject.ClientObject.ButtonDown += new Func<ButtonConstants, bool>(ClientObject_ButtonDown);
            //stateobject.ClientObject.ButtonUp += new Func<ButtonConstants, bool>(ClientObject_ButtonUp);

            gstate.ClientObject.ButtonDown += ClientObject_ButtonDown;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:8,代码来源:BuilderShotBehaviour.cs

示例7: getAboveBlocks

 public static IEnumerable<Block> getAboveBlocks(BCBlockGameState gstate, RectangleF testrect)
 {
     var aboveblocks = from b in gstate.Blocks where b.BlockRectangle.IntersectsWith(testrect) select b;
     return from bb in aboveblocks
            where Math.Abs(bb.CenterPoint().Y - testrect.CenterPoint().Y) >
                Math.Abs(bb.CenterPoint().X - testrect.CenterPoint().Y)
            select bb;
 }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:8,代码来源:FallingBlockObject.cs

示例8: PerformFrame

        public override bool PerformFrame(BCBlockGameState gamestate)
        {
            if (removeobject is BasePaddleBehaviour)
                ((BasePaddleBehaviour) removeobject).BehaviourRemoved(RemoveFrompaddle, gamestate);

            RemoveFrompaddle.Behaviours.Remove(removeobject);
            Debug.Print("removed...");

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:10,代码来源:BehaviourRemoverProxy.cs

示例9: BallSplit

        private bool BallSplit(BCBlockGameState gs)
        {
            List<cBall> removethese = new List<cBall>();
            List<cBall> addballs = new List<cBall>();
            if (gs.PlayerPaddle != null)
            {
                //check for Sticky...
                if (gs.PlayerPaddle.Behaviours.Any((w) => w is StickyBehaviour))
                {
                    foreach (var unstick in gs.PlayerPaddle.Behaviours.Where((w) => w is StickyBehaviour))
                        ((StickyBehaviour)unstick).ReleaseAllBalls();

                }

            }
            //            foreach(var splitball in (from m in gs.Balls where !m.hasBehaviour(typeof(TempBallBehaviour)) select m))
            foreach (var splitball in gs.Balls)
            {
                //split splitball into SplitCount new balls.
                //first, take note of the absolute speed of the ball.
                double magnitude = splitball.TotalSpeed;
                //how big will the angle be between them?
                double anglediff = (Math.PI * 2) / SplitCount;
                double startangle = BCBlockGameState.rgen.NextDouble() * Math.PI * 2;

                for (int i = 0; i < SplitCount; i++)
                {
                    double fireangle = startangle + (anglediff * i);

                    PointF usevelocity = new PointF((float)(Math.Cos(fireangle) * magnitude), (float)(Math.Sin(fireangle) * magnitude));

                    //clone the ball...
                    //use the proper type of the object, it could be a subclass!
                    cBall ballcreate = (cBall)Activator.CreateInstance(splitball.GetType(), splitball);

                    //set the velocity of the clone to the calculated value.

                    ballcreate.Velocity = usevelocity;
                    addballs.Add(ballcreate);

                }

                removethese.Add(splitball);
            }
            foreach (var addit in addballs) gs.Balls.AddLast(addit);

            foreach (cBall removeit in removethese)
            {
                gs.Balls.Remove(removeit);

            }
            BCBlockGameState.Soundman.PlaySound("ELECTRICLASER", false);
            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:54,代码来源:BallSplitterPowerup.cs

示例10: GivePowerTo

        public override bool GivePowerTo(BCBlockGameState gamestate, GameCharacter gamechar)
        {
            BCBlockGameState.Soundman.PlaySound("1up");
            BasicFadingText bft = new BasicFadingText("1-Up", Location, new PointF(0, -2), new Font(BCBlockGameState.GetMonospaceFont(), 14), new Pen(Color.Black,2), new SolidBrush(Color.Green), 500);

            gamestate.playerLives++;
            gamestate.Forcerefresh = true;
            gamestate.Defer(() => gamestate.GameObjects.AddLast(bft));

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:11,代码来源:GameCharacter.cs

示例11: BehaviourAdded

        public override void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
        {
            ownerpaddle = toPaddle;

            //remove any existing terminator behaviour.
            foreach (var loopbeh in toPaddle.Behaviours)
            {
                if (loopbeh is TerminatorBehaviour)
                    gstate.GameObjects.AddLast(new BehaviourRemoverProxy(toPaddle, loopbeh));
            }

            base.BehaviourAdded(toPaddle, gamestate);
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:13,代码来源:BuilderShotBehaviour.cs

示例12: PerformFrame

        public override void PerformFrame(BCBlockGameState gamestate, Paddle pPaddle)
        {
            var rg = BCBlockGameState.rgen;
            base.PerformFrame(gamestate, pPaddle);
            useoverlaybrush = new SolidBrush(new HSLColor(rg.NextDouble()*240, 240f, 120f));
            //spawn a sparkle.
            var paddlerect = pPaddle.Getrect();
            PointF randompoint = new PointF(paddlerect.Left + (float) (paddlerect.Width*rg.NextDouble()),
                                            paddlerect.Top + (float) (paddlerect.Height*rg.NextDouble()));

            Sparkle s = new Sparkle(randompoint, BCBlockGameState.GetRandomVelocity(0, 2),
                                    new HSLColor(rg.NextDouble()*240, 240, 120));
            gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() => gamestate.Particles.Add(s)));
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:14,代码来源:InvinciblePaddleBehaviour.cs

示例13: BehaviourAdded

        public override void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
        {
            base.BehaviourAdded(toPaddle, gamestate);
            gamestate.Defer(()=>{
                                    addedobject = new ProxyObject((po, gs) =>
                                                                      {

                                                                          PerformFrame(toPaddle, gamestate);
                                                                          return false;

                                                                      }, null);
                                    gamestate.GameObjects.AddLast(addedobject);
            });
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:14,代码来源:DeflectorBehaviour.cs

示例14: PowerupCallback

        public bool PowerupCallback(BCBlockGameState gamestate)
        {
            //PaddleMinusPowerup makes the paddle smaller...
            if ((gamestate.PlayerPaddle.PaddleSize.Width) > paddlesizechangeamount + 10)
            {

                SizeF changedsize = new SizeF(gamestate.PlayerPaddle.PaddleSize.Width - paddlesizechangeamount, gamestate.PlayerPaddle.PaddleSize.Height);
                //gamestate.PlayerPaddle.PaddleSize =
                //give it a size object that will change it's size...
                gamestate.PlayerPaddle.Behaviours.Add(new PaddleBehaviours.SizeChangeBehaviour(changedsize, new TimeSpan(0, 0, 0, 1)));
                BCBlockGameState.Soundman.PlaySound("shrink");
            }
            AddScore(gamestate, -5, "Paddle--");
            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:15,代码来源:PaddleMinusPowerup.cs

示例15: PerformBlockHit

        public override bool PerformBlockHit(BCBlockGameState parentstate, cBall ballhit)
        {
            bool nodef = false;
            DefaultHitSound = "";

            if(!Silent) PlayBlockSound(ballhit, "METAL");
            RaiseBlockHit(parentstate, ballhit, ref nodef);

            //temporary code for testing powerup:
            //invincible blocks will now "emerge" a mushroom.
            //MushroomPower mp = new MushroomPower(this);
            //parentstate.GameObjects.AddLast(mp);

            return false;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:15,代码来源:InvincibleBlock.cs


注:本文中的BCBlockGameState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。