示例#1
0
 public override void CollisionedBy(CollisionBase collision)
 {
     // reward out of screen
     if (collision.GetType() == Type.GetType("gArkanoid.Entities.OutputLine"))
     {
         Board.RemoveReward(this);
     }
 }
        public static IEnumerable <VFXNamedExpression> GetParameters(
            CollisionBase block,
            IEnumerable <VFXNamedExpression> baseParameters)
        {
            var expressions = baseParameters;

            expressions = expressions.Concat(FluvioFXBlock.GetSolverDataExpressions(block));

            foreach (var expression in expressions)
            {
                yield return(expression);
            }
            ;

            yield return(new VFXNamedExpression(VFXValue.Constant(1.0f) / VFXBuiltInExpression.DeltaTime, "invDt"));
        }
示例#3
0
        public override void CollisionedBy(CollisionBase collision)
        {
            // brick hit by ball
            if (collision.GetType() == Type.GetType("gArkanoid.Entities.Ball"))
            {
                lives--;

                if (lives == 0)
                {
                    Board.RemoveBrick(this);
                    GameControl.AddScorePoints((int)this.brickType);

                    // reward & explosion
                    this.GenerateReward();
                    this.GenerateExplosion();

                    // play de 'hit' sound from a separate thread (performance problems)
                    // Thread thread = new Thread(new ThreadStart(PlaySound));
                    // thread.Start();
                }
            }

            // brick hit by shot
            if (collision.GetType() == Type.GetType("gArkanoid.Entities.Shot"))
            {
                // destroy the brick & shot
                Board.RemoveBrick(this);
                Board.RemoveShot((Shot)collision);
                GameControl.AddScorePoints((int)this.brickType);

                // reward & explosion
                this.GenerateReward();
                this.GenerateExplosion();

                // play de 'hit' sound from a separate thread (performance problems)
                // Thread oThread = new Thread(new ThreadStart(PlaySound));
                // oThread.Start();
            }
        }
示例#4
0
        public static IEnumerable <VFXNamedExpression> GetParameters(
            CollisionBase block,
            IEnumerable <VFXNamedExpression> baseParameters)
        {
            var expressions = baseParameters;

            expressions = expressions.Concat(InitializeSolver.GetExpressions(
                                                 block,
                                                 SolverDataParameters.Fluid_Density |
                                                 SolverDataParameters.Fluid_MinimumDensity |
                                                 SolverDataParameters.Fluid_GasConstant |
                                                 SolverDataParameters.KernelSize |
                                                 SolverDataParameters.KernelFactors
                                                 ));

            foreach (var expression in expressions)
            {
                yield return(expression);
            }
            ;

            yield return(new VFXNamedExpression(VFXValue.Constant(1.0f) / VFXBuiltInExpression.DeltaTime, "invDt"));
        }
示例#5
0
        public static IEnumerable <VFXAttributeInfo> GetAttributes(
            CollisionBase block,
            IEnumerable <VFXAttributeInfo> baseAttributes)
        {
            var hasPreviousPosition = block.GetData().IsCurrentAttributeWritten(FluvioFXAttribute.PreviousPosition);

            if (hasPreviousPosition)
            {
                yield return(new VFXAttributeInfo(FluvioFXAttribute.PreviousPosition, VFXAttributeMode.Read));
            }

            foreach (var attribute in baseAttributes)
            {
                yield return(attribute);
            }

            yield return(new VFXAttributeInfo(VFXAttribute.ParticleId, VFXAttributeMode.Read));

            yield return(new VFXAttributeInfo(VFXAttribute.Mass, VFXAttributeMode.Read));

            yield return(new VFXAttributeInfo(FluvioFXAttribute.DensityPressure, VFXAttributeMode.ReadWrite));

            yield return(new VFXAttributeInfo(FluvioFXAttribute.Force, VFXAttributeMode.ReadWrite));
        }
        public override void CollisionedBy(CollisionBase collision)
        {
            // playerpad hit a reward
            if (collision.GetType() == Type.GetType("gArkanoid.Entities.Reward"))
            {
                Board.RemoveReward((Reward)collision);
                GameControl.AddScorePoints((int)((Reward)collision).RewardType);

                switch (((Reward)collision).RewardType)
                {
                case Reward.eRewardType.None: break;

                case Reward.eRewardType.WidePad:
                    RewardWidePad();
                    break;

                case Reward.eRewardType.FirePad:
                    RewardShotingPad();
                    break;

                case Reward.eRewardType.SlowBall:
                    SlowBallEventHandler oSlowBallEventHandler = SlowBallRewardEvent;

                    if (oSlowBallEventHandler != null)     // invoke the delegates
                    {
                        oSlowBallEventHandler(this, new EventArgs());
                    }
                    break;

                case Reward.eRewardType.DemolitionBall:
                    DemolitionBallEventHandler oDemolitionBallEventHandler = DemolitionBallRewardEvent;

                    if (oDemolitionBallEventHandler != null)     // invoke the delegates
                    {
                        oDemolitionBallEventHandler(this, new EventArgs());
                    }
                    break;

                case Reward.eRewardType.DoubleBall:
                    DoubleBallEventHandler oDoubleBallEventHandler = DoubleBallRewardEvent;

                    if (oDoubleBallEventHandler != null)     // invoke the delegates
                    {
                        oDoubleBallEventHandler(this, new EventArgs());
                    }
                    break;

                case Reward.eRewardType.TripleBall:
                    TripleBallEventHandler oTripleBallEventHandler = TripleBallRewardEvent;

                    if (oTripleBallEventHandler != null)     // invoke the delegates
                    {
                        oTripleBallEventHandler(this, new EventArgs());
                    }
                    break;

                case Reward.eRewardType.WinLevel:
                    WinLevelEventHandler oWinLevelEventHandler = WinLevelRewardEvent;

                    if (oWinLevelEventHandler != null)     // invoke the delegates
                    {
                        oWinLevelEventHandler(this, new EventArgs());
                    }
                    break;

                default: break;
                }
            }
        }
 public static void RemoveItemForCollision(CollisionBase collision)
 {
     collisionObjects.Remove(collision);
 }
 public static void RegisterItemForCollision(CollisionBase collision, int position)
 {
     collisionObjects.Insert(position, collision);
 }
 public static void RegisterItemForCollision(CollisionBase collision)
 {
     collisionObjects.Add(collision);
 }
示例#10
0
 public override void CollisionedBy(CollisionBase oCollision)
 {
     // no nothnig
 }
示例#11
0
        public override void CollisionedBy(CollisionBase collision)
        {
            // ball out of screen
            if (collision.GetType() == Type.GetType("gArkanoid.Entities.OutputLine"))
            {
                Balls.RemoveBall(this);
            }

            // ball hit playerpad: invert vertical direction
            if (collision.GetType() == Type.GetType("gArkanoid.Entities.PlayerPad"))
            {
                // check into what part of cPlayerPad is the ball collisioning (left border, pad center, right border)
                if (this.X + BALL_WIDTH < collision.Location.X + 20)   // left border

                {
                    mov_x -= 1;                      // fixed direction change
                    mov_x -= GenerateRandomFactor(); // plus little random direction change

                    if (mov_x < MIN_SIDE_ONE)
                    {
                        mov_x = MIN_SIDE_ONE;                       // -1.41
                    }
                    mov_y = -1 * CalculateSideTwo(mov_x);
                }
                else if (this.X > collision.Location.X + collision.GetWidth() - 20)     // right border

                {
                    mov_x += 1;                      // fixed direction change
                    mov_x += GenerateRandomFactor(); // plus little random direction change

                    if (mov_x > MAX_SIDE_ONE)
                    {
                        mov_x = MAX_SIDE_ONE;                       // 1.41
                    }
                    mov_y = -1 * CalculateSideTwo(mov_x);
                }
                else     // pad center
                {
                    mov_y *= -1;
                }
            }

            // ball hit a brick
            // detect brick face collisioned, invert ball direction acording to that
            // check 4 posibles directions of the ball (UpLeft, UpRight, DownLeft, DownRight)
            if (collision.GetType() == Type.GetType("gArkanoid.Entities.Brick"))
            {
                // no change ball direction if the ball is in demolition state
                if (Balls.IsDemolitionBallState())
                {
                    return;
                }

                int delta_x, delta_y;

                if (mov_x < 0 && mov_y < 0)   // ball UpLeft

                // posibles brick faces colisioned: right, buttom, right&buttom
                {
                    delta_x = (collision.Location.X + collision.GetWidth()) - this.Location.X;
                    delta_y = (collision.Location.Y + collision.GetHeight()) - this.Location.Y;

                    if (delta_x > delta_y)   // buttom
                    {
                        mov_y *= -1;
                    }
                    else if (delta_x < delta_y)     // right
                    {
                        mov_x *= -1;
                    }
                    else     // both
                    {
                        mov_y *= -1; mov_x *= -1;
                    }
                }

                else if (mov_x >= 0 && mov_y < 0) // ball UpRight
                {
                    // posibles brick faces colisioned: left, buttom, left&buttom
                    delta_x = (this.Location.X + this.GetWidth()) - collision.Location.X;
                    delta_y = (collision.Location.Y + collision.GetHeight()) - this.Location.Y;

                    if (delta_x > delta_y)   // buttom
                    {
                        mov_y *= -1;
                    }
                    else if (delta_x < delta_y)     // left
                    {
                        mov_x *= -1;
                    }
                    else     // both
                    {
                        mov_y *= -1; mov_x *= -1;
                    }
                }

                else if (mov_x < 0 && mov_y >= 0) // ball DownLeft
                {
                    // posibles brick faces colisioned: right, top, right&top
                    delta_x = (collision.Location.X + collision.GetWidth()) - this.Location.X;
                    delta_y = (this.Location.Y + this.GetHeight()) - this.Location.Y;

                    if (delta_x > delta_y)   // top
                    {
                        mov_y *= -1;
                    }
                    else if (delta_x < delta_y)     // right
                    {
                        mov_x *= -1;
                    }
                    else     // both
                    {
                        mov_y *= -1; mov_x *= -1;
                    }
                }

                else if (mov_x >= 0 && mov_y >= 0) // ball DownRight
                {
                    // posibles brick faces colisioned: left, top, left&top
                    delta_x = (this.Location.X + this.GetWidth()) - collision.Location.X;
                    delta_y = (this.Location.Y + this.GetHeight()) - this.Location.Y;

                    if (delta_x > delta_y)   // top
                    {
                        mov_y *= -1;
                    }
                    else if (delta_x < delta_y)     // right
                    {
                        mov_x *= -1;
                    }
                    else     // both
                    {
                        mov_y *= -1; mov_x *= -1;
                    }
                }
            }
        }
示例#12
0
 public override void CollisionedBy(CollisionBase collision)
 {
     // do nothing
 }