示例#1
0
 private bool PerformFrameProxyRemove(ProxyObject sourceobject,BCBlockGameState gstate)
 {
     RemoveFromBall.Behaviours.Remove(this);
     RemoveFromBall.Behaviours.Add(new TempBallBehaviour());
     return true;
 }
示例#2
0
        public override bool HitBlock(BCBlockGameState currentstate, cBall ballobject, Block blockhit)
        {
            //increment NumExplosions:

            _TimesExploded++;

            float useradius = GetExplosionRadius();
            ExplosionEffect ee = new ExplosionEffect(ballobject.Location, useradius);
            currentstate.GameObjects.AddLast(ee);

            //if we reached the max, replace this behaviour with a temporary ball behaviour.
            if (_TimesExploded == MaxRadius)
            {

                //in order to remove a behaviour from the ball here, we need to set a proxy object...
                RemoveFromBall=ballobject;
                ProxyObject po = new ProxyObject(PerformFrameProxyRemove, null);
                //add it...
                currentstate.GameObjects.AddLast(po);

            }
            //if we also havea linear gravity behaviour and are going down, make us go up...

            if (ballobject.Behaviours.Any((w) => w.GetType() == typeof(LinearGravityBallBehaviour)))
            {
                ballobject.Velocity = new PointF(ballobject.Velocity.X,-Math.Abs(ballobject.Velocity.Y));

            }

            return base.HitBlock(currentstate, ballobject, blockhit);
        }