Пример #1
0
 public override void CollidedWithNonReflectableObject(ReflectableObject ro)
 {
     if (!(ro is Wall))
     {
         this.is_inside_non_reflectable_object = false;
     }
 }
Пример #2
0
        public void Initialize()
        {
            buddydeath = 0;
            // If game is being in full screen update the SCALE

            /*if (GameEngine.Instance.full_screen)
             * {
             *  int min = Math.Min(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
             *  GameEngine.Instance.ResizeWindow(min, min);
             *  Vector2 size = GameEngine.Instance.GetWindowSize();
             *  SCALE = size.X < size.Y ? size.X / WIDTH : size.Y / HEIGHT;
             * }
             * else // Else rescale to the size you want
             * {
             *  GameEngine.Instance.ResizeWindow((int)(WIDTH * SCALE), (int)(HEIGHT * SCALE));
             * }*/
            GameEngine.Instance.UpdateShiftAmount();
            ROW_SCALE = WIDTH / NUM_ROWS;
            COL_SCALE = HEIGHT / NUM_COLS;
            AABB aabb = new AABB();

            aabb.LowerBound = new Vector2(-MARGIN, -MARGIN);
            aabb.UpperBound = new Vector2(WIDTH + MARGIN, HEIGHT + MARGIN);
            world           = new World(gravity);
            succeeded       = false;
            World.ContactManager.BeginContact += ContactManager.BeginContact;
            World.ContactManager.EndContact   += ContactManager.EndContact;
            pauseMenu    = new PauseMenu(this);
            gameOverMenu = new GameOverMenu(this);
            gamestate    = GameState.Unzip;
            unzipTexture = new AnimationTexture(GameEngine.Instance.GetTexture("unzip"), 5, 3, 3);
            zipTexture   = new AnimationTexture(GameEngine.Instance.GetTexture("zip"), 5, 3, 3);
            unzipTexture.ResetCurrentFrame();
            zipTexture.ResetCurrentFrame();
            zippedTexture = GameEngine.Instance.GetTexture("zippedbkg");
            haze          = new Texture2D(GameEngine.Instance.GraphicsDevice, 1, 1);
            rect          = new Rectangle(0, 0, (int)(Level.WIDTH * Level.SCALE + GameEngine.shiftAmount.X), (int)(Level.HEIGHT * Level.SCALE + GameEngine.shiftAmount.Y));
            haze.SetData(new Color[] { new Color(0, 0, 0, 255) });
            // Flush all the non-reflectable objects from the previous levels
            ReflectableObject.FlushNonReflectableObjects();
            ContactManager.ClearContactList();
            Block.FlushGameBlocks();

            reflection_color_time = 0;

            reflection_current_blue  = MIN_REFLECTION_COLOR_BLUE;
            reflection_current_green = MIN_REFLECTION_COLOR_GREEN;
            reflection_current_red   = MIN_REFLECTION_COLOR_RED;

            slope_red   = 2 * (MAX_REFLECTION_COLOR_RED - MIN_REFLECTION_COLOR_RED) / (REFLECTION_COLOR_END_TIME);
            slope_green = 2 * (MAX_REFLECTION_COLOR_GREEN - MIN_REFLECTION_COLOR_GREEN) / (REFLECTION_COLOR_END_TIME);
            slope_blue  = 2 * (MAX_REFLECTION_COLOR_BLUE - MIN_REFLECTION_COLOR_BLUE) / (REFLECTION_COLOR_END_TIME);
        }
Пример #3
0
        private static bool CheckPlayerInsideObject(ReflectableObject obj)
        {
            float diff = (GameEngine.Instance.currentLevel.player.Body.Position - obj.Body.Position).Length();

            if (diff < obj.width / 2 - INSIDE_OBJECT_EPS)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        public override void CollidedWithNonReflectableObject(ReflectableObject ro)
        {
            if (ro is Wall)
            {
                ro.CompletelyRemove();

                /*if (se.State == SoundState.Playing)
                 *  se.Stop();*/
                SoundManager.PlaySound("destroy");
            }

            if (ro is Block)
            {
                ro.CompletelyRemove();
                Block.gameBlocks.Remove((Block)ro);

                /*if (se.State == SoundState.Playing)
                 *  se.Stop();*/
                SoundManager.PlaySound("destroy");
                level.Buddydeath();
            }
        }
Пример #5
0
 public virtual void CollidedWithNonReflectableObject(ReflectableObject ro)
 {
 }
Пример #6
0
        public static bool BeginContact(Contact contact)
        {
            if (GameEngine.Instance.currentLevel.is_peeking)
            {
                return(false);
            }

            var obj1  = contact.FixtureA.Body.UserData;
            var obj2  = contact.FixtureB.Body.UserData;
            var body1 = contact.FixtureA.Body;
            var body2 = contact.FixtureB.Body;
            var ud1   = contact.FixtureA.UserData;
            var ud2   = contact.FixtureB.UserData;

            if ((obj1 is Player && !(obj2 is Player)) ||
                (obj2 is Player && !(obj1 is Player)))
            {
                Player p     = obj1 is Player ? (Player)obj1 : (Player)obj2;
                var    other = obj1 is Player ? obj2 : obj1;
                if (!objects_in_contact.Contains(other))
                {
                    objects_in_contact.Add(other);
                }

                if (other is Reflexio.Wall)
                {
                    ReflectableObject obj = (ReflectableObject)other;
                    if (CheckPlayerInsideObject(obj))
                    {
                        GameEngine.Instance.currentLevel.SetGameOver(false);
                        GameEngine.Instance.achievement_state.death_by_wall(); //Achievement Logic - 'failure is an option'
                    }
                    PlayerGroundedStart(contact);
                    return(true);
                }
                // Collision with Block
                else if (other is Reflexio.Block)
                {
                    ReflectableObject obj = (ReflectableObject)other;
                    if (CheckPlayerInsideObject(obj))
                    {
                        GameEngine.Instance.currentLevel.SetGameOver(false);
                        GameEngine.Instance.achievement_state.death_by_block(); //Achievement logic - 'failure is an option'
                    }
                    PlayerGroundedStart(contact);
                    return(true);
                }
                // Collision With collectible
                else if (other is Reflexio.Collectible)
                {
                    if (!((Collectible)other).is_inside_non_reflectable_object)
                    {
                        ((Collectible)other).CollectedByPlayer();
                    }
                }
                // Collision with Spike
                else if (other is Reflexio.Spike)
                {
                    Spike s = (Reflexio.Spike)other;
                    if (spikes_in_contact.Contains(s))
                    {
                        return(false);
                    }
                    if (CheckPlayerInsideObject((ReflectableObject)s))
                    {
                        GameEngine.Instance.currentLevel.SetGameOver(false);
                        GameEngine.Instance.achievement_state.death_by_spike_collision(); //Achievement logic - 'failure is an option'
                    }
                    bool consider = PlayerSpikeContactStarted(s);
                    if (!consider)
                    {
                        return(false);
                    }
                    PlayerGroundedStart(contact);
                    return(true);
                }
                // Collision with Door
                else if (other is Reflexio.Door)
                {
                    Door d = (Reflexio.Door)other;
                    if (d.IsOpen() && !d.is_inside_non_reflectable_object && CheckPlayerInsideObject(d))
                    {
                        GameEngine.Instance.currentLevel.SetGameOver(true);
                        //Achievement logic - speed achievements and completion achievements
                        GameEngine.Instance.achievement_state.register_level_complete_time(GameEngine.Instance.currentLevelPos, GameEngine.Instance.currentLevelStopwatch.ElapsedMilliseconds);
                        GameEngine.Instance.achievement_state.complete_level(GameEngine.Instance.currentLevelPos,
                                                                             GameEngine.Instance.currentLevel.buddydeath);
                        AchievementState.toSaveFile(GameEngine.Instance.achievement_state.toSaveState());
                    }
                    //else
                    //    PlayerGroundedStart(contact);
                    return(false);
                }
            }

            if (obj1 is Switch && !(obj2 is Player) || obj2 is Switch && !(obj1 is Player))
            {
                Switch s = obj1 is Switch ? (Switch)obj1 : (Switch)obj2;
                s.PressSwitch((PhysicsObject)(obj1 is Switch ? obj2 : obj1));
                return(false);
            }

            if (obj1 is Block || obj2 is Block)
            {
                object other = obj1 is Block ? obj2 : obj1;
                return(!(other is Key || other is Switch));
            }
            return(false);
        }