示例#1
0
        public virtual void Draw()
        {
            spriteBatch.Begin();
            float w      = GameEngine.Instance.GraphicsDevice.ScissorRectangle.Width;
            float h      = GameEngine.Instance.GraphicsDevice.ScissorRectangle.Height;
            float scale  = Math.Min(w / 650f, h / 650f);
            int   shiftw = (int)(w / 2 - Math.Min(w, h) / 2);
            int   shifth = (int)(h / 2 - Math.Min(w, h) / 2);

            if (bkg != null)
            {
                spriteBatch.Draw(bkg, new Rectangle(shiftw, shifth, (int)Math.Min(w, h), (int)Math.Min(w, h)), Color.White);
            }

            //Currently visible achievement data
            MenuItem         mi  = menu_items[current];
            AchievementState ach = GameEngine.Instance.achievement_state;
            Texture2D        texture;

            if (ach.is_unlocked(mi.short_name))
            {
                texture = mi.texture;
            }
            else
            {
                texture = mi.lock_texture;
            }

            //Text location vectors
            Vector2 NamePos     = new Vector2(NAME_X * scale + shiftw, NAME_Y * scale + shifth);
            Vector2 NameOrigin  = Font1.MeasureString(mi.full_name) / 2;
            Vector2 ImageOrigin = new Vector2(texture.Width, texture.Height) / 2;
            Vector2 DescOrigin  = new Vector2(mi.desc_texture.Width, mi.desc_texture.Height) / 2;

            Color c = Color.DarkCyan;

            //Draw Achievement Name
            //spriteBatch.DrawString(Font1, mi.full_name, new Vector2(NamePos.X + 2, NamePos.Y + 2), Color.GhostWhite, 0, NameOrigin, 1.5f * scale, SpriteEffects.None, 0);
            //spriteBatch.DrawString(Font1, mi.full_name, NamePos, c, 0, NameOrigin, 1.5f * scale, SpriteEffects.None, 0);
            //Draw Description
            //spriteBatch.DrawString(Font1, mi.wrapped_desc, new Vector2(DescPos.X + 2, DescPos.Y + 2), Color.GhostWhite, 0, DescOrigin, 1.5f * scale, SpriteEffects.None, 0);
            //spriteBatch.DrawString(Font1, mi.wrapped_desc, DescPos, c, 0, DescOrigin, 1.5f * scale, SpriteEffects.None, 0);
            spriteBatch.Draw(mi.desc_texture, new Vector2(DESC_X * scale + shiftw, DESC_Y * scale + shifth), null, Color.GhostWhite, 0, DescOrigin, scale, SpriteEffects.None, 0);
            //Draw images
            spriteBatch.Draw(texture, new Vector2(IMG_X * scale + shiftw, IMG_Y * scale + shifth), null, Color.White, 0, ImageOrigin, scale, SpriteEffects.None, 0);
            spriteBatch.Draw(right_arrow, new Vector2(RIGHT_ARR_X * scale + shiftw, RIGHT_ARR_Y * scale + shifth), null, Color.White, 0, arrow_origin, 1, SpriteEffects.None, 0);
            spriteBatch.Draw(left_arrow, new Vector2(LEFT_ARR_X * scale + shiftw, LEFT_ARR_Y * scale + shifth), null, Color.White, 0, arrow_origin, 1, SpriteEffects.None, 0);
            //Draw main menu button
            spriteBatch.Draw(main_menu_btn, new Vector2(MENU_X * scale + shiftw, MENU_Y * scale + shifth), null, Color.White, 0, MenuOrigin, 1, SpriteEffects.None, 0);
            spriteBatch.End();
        }
示例#2
0
 public static AchievementState fromSaveFile()
 {
     try
     {
         SaveState        state = getSaveState();
         AchievementState s     = new AchievementState(state);
         s.game_progress_exists = true;
         return(s);
     }
     catch
     {
         return(new AchievementState());
     }
 }
示例#3
0
        public void EnterPressed()
        {
            String selected = menuView.GetCurrentName();

            menuView.ResetCurrent();
            if (selected.Equals("start"))
            {
                if (GameEngine.Instance.achievement_state.get_starting_level() >= 0)
                {
                    GameEngine.Instance.State = GameEngine.GameState.PLAYING;
                    GameEngine.Instance.StartNewLevel(GameEngine.Instance.achievement_state.get_starting_level());
                }
                else
                {
                    GameEngine.Instance.refreshMenus();
                    GameEngine.Instance.State = GameEngine.Instance.achievement_state.get_menu_world_state();
                }
            }
            else if (selected.Equals("levelselect"))
            {
                GameEngine.Instance.State = GameEngine.GameState.LEVEL_MENU;
            }
            else if (selected.Equals("Controls"))
            {
                GameEngine.Instance.State = GameEngine.GameState.CONTROL_MENU;
            }
            else if (selected.Equals("Achievements"))
            {
                GameEngine.Instance.State = GameEngine.GameState.ACHIEVEMENT_MENU;
            }
            else if (selected.Equals("Credits"))
            {
                GameEngine.Instance.StartNewLevel(GameEngine.CREDITS_LEVEL_ID);
                GameEngine.Instance.State = GameEngine.GameState.PLAYING;
            }
            else if (selected.Equals("exit"))
            {
                AchievementState.toSaveFile(GameEngine.Instance.achievement_state.toSaveState());
                GameEngine.Instance.Exit();
            }
        }
示例#4
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);
        }