Example #1
0
 public override void Reflect(int start, int end, Reflexio.Level.ReflectionOrientation ref_or)
 {
     int[] new_pos = { -1, -1 };
     try
     {
         new_pos = level.ContinuousToDiscrete(this.Body.Position);
     }
     catch (NullReferenceException)
     {
     };
     DiscX = new_pos[0];
     DiscY = new_pos[1];
     base.Reflect(start, end, ref_or);
     try
     {
         this.Body.ApplyForce(new Vector2(0, 0.1f), Body.Position);
     }
     catch (NullReferenceException)
     { };
 }
Example #2
0
 public override void Reflect(int start, int end, Reflexio.Level.ReflectionOrientation ref_or)
 {
 }
Example #3
0
        public override void Reflect(int start, int end, Reflexio.Level.ReflectionOrientation ref_or)
        {
            if (is_reflectable)
            {
                if (ref_or == Level.ReflectionOrientation.HORIZONTAL)
                {
                    if (DiscY >= start && DiscY <= end)
                    {
                        startX = DiscX;
                        startY = DiscY;
                        DiscY  = (start + end) - DiscY;

                        reflectionVelocity      = new Vector2((DiscX - startX) * level.ROW_SCALE, (DiscY - startY) * level.COL_SCALE) * Level.SCALE / Level.REFLECTION_PAUSE_TIME;
                        reflectionStartPosition = this.Body.Position * Level.SCALE;
                        is_being_reflected      = true;
                        #if SINUSODIAL
                        is_being_reflected_straight   = true;
                        is_being_reflected_diagonally = false;
                        #endif
                        this.reflected_horizontal = !this.reflected_horizontal;
                        this.Body.SetTransform(level.DiscreteToContinuousMidPoint(DiscX, DiscY, width, height), this.Body.Rotation);
                    }
                }
                else if (ref_or == Level.ReflectionOrientation.VERTICAL)
                {
                    if (DiscX >= start && DiscX <= end)
                    {
                        startX = DiscX;
                        startY = DiscY;
                        DiscX  = (start + end) - DiscX;

                        reflectionVelocity      = new Vector2((DiscX - startX) * level.ROW_SCALE, (DiscY - startY) * level.COL_SCALE) * Level.SCALE / Level.REFLECTION_PAUSE_TIME;
                        reflectionStartPosition = this.Body.Position * Level.SCALE;
                        is_being_reflected      = true;
                        #if SINUSODIAL
                        is_being_reflected_straight   = true;
                        is_being_reflected_diagonally = false;
                        #endif

                        this.reflected_vertical = !this.reflected_vertical;
                        this.Body.SetTransform(level.DiscreteToContinuousMidPoint(DiscX, DiscY, width, height), this.Body.Rotation);
                    }
                }
                else if (ref_or == Level.ReflectionOrientation.DIAGONAL)
                {
                    startX = DiscX;
                    startY = DiscY;

                    if (start == 1)
                    {
                        DiscX = DiscY;
                        DiscY = startX;
                    }
                    if (start == -1)
                    {
                        DiscX = level.NUM_COLS - DiscY - 1;
                        DiscY = level.NUM_ROWS - startX - 1;
                    }

                    reflectionVelocity      = new Vector2((DiscX - startX) * level.ROW_SCALE, (DiscY - startY) * level.COL_SCALE) * Level.SCALE / Level.REFLECTION_PAUSE_TIME;
                    reflectionStartPosition = this.Body.Position * Level.SCALE;
                    is_being_reflected      = true;
                    #if SINUSODIAL
                    is_being_reflected_straight   = false;
                    is_being_reflected_diagonally = true;
                    #endif

                    this.reflected_horizontal = !this.reflected_horizontal;
                    this.reflected_vertical   = !this.reflected_vertical;
                    this.Body.SetTransform(level.DiscreteToContinuousMidPoint(DiscX, DiscY, width, height), this.Body.Rotation);
                }

                // Check for collisions between reflectable and non-reflectable objects
                CheckForCollisionWithNonReflectableObject();
            }
        }
Example #4
0
 /// <summary>
 /// Reflects the body. Reflect if start &lt;= Discrete Position &lt;= end
 /// </summary>
 /// <param name="start">The start of the reflection region, in discrete units. INCLUSIVE.</param>
 /// <param name="end">The end of the reflection region, in discrete units. INCLUSIVE</param>
 public abstract void Reflect(int start, int end, Reflexio.Level.ReflectionOrientation ref_or);