Пример #1
0
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "HeroBashContent");

            overworldMap = content.Load<Map>("maps/overworld");
            overworldCamera = new Camera(ScreenManager.GraphicsDevice.Viewport, overworldMap);
            //overworldCamera.Position = new Vector2(0, (((overworldMap.Height / 2) * overworldMap.TileHeight)+(overworldMap.TileHeight/2)) - (overworldCamera.Height / 2));

            texBG = content.Load<Texture2D>("blank-white");
            texScoreBG = content.Load<Texture2D>("blank");
            texDistance = content.Load<Texture2D>("distance");
            texArrow = content.Load<Texture2D>("overworld-arrow");

            heroPos = new Vector2(0, 0);
            princessPos = new Vector2(0, 0);

            Vector2 locPos = new Vector2((2 * overworldMap.TileWidth) + (overworldMap.TileWidth / 2), (overworldMap.Height * overworldMap.TileHeight) / 2);
            int numLocs = 0;
            for (int stage = 0; stage <= 8; stage++)
            {
                if (stage <= 4)
                    numLocs++;
                else
                    numLocs--;

                locPos.Y = ((overworldMap.Height * overworldMap.TileHeight) / 2) - (((numLocs - 1) * (overworldMap.TileHeight * locationSpacing)) / 2);

                for (int level = 0; level < numLocs; level++)
                {
                    OverworldLocation loc = new OverworldLocation();
                    loc.Position = locPos;
                    loc.Stage = stage;
                    loc.Level = level;
                    Locations.Add(loc);

                    locPos.Y += overworldMap.TileHeight * locationSpacing;

                    if (loc.Stage == GameManager.CurrentStage && loc.Level + 1 == GameManager.CurrentLevel)
                    {
                        overworldCamera.Position = loc.Position - new Vector2(200, (overworldCamera.Height / 2));
                        overworldCamera.Target = loc.Position - new Vector2(200, (overworldCamera.Height / 2));

                        princessPos = loc.Position;
                        princessStartPos = loc.Position;
                    }
                }

                locPos.X += overworldMap.TileWidth * locationSpacing;

            }

            foreach (OverworldLocation sourceLoc in Locations)
            {
                foreach (OverworldLocation loc in Locations)
                {
                    if (loc.Stage == sourceLoc.Stage + 1)
                    {
                        if (loc.Stage <= 4)
                        {
                            if (loc.Level == sourceLoc.Level || loc.Level == sourceLoc.Level + 1)
                            {
                                sourceLoc.LinkedLocations.Add(loc);
                            }
                        }
                        else
                        {
                            if (loc.Level == sourceLoc.Level || loc.Level == sourceLoc.Level - 1)
                            {
                                sourceLoc.LinkedLocations.Add(loc);
                            }
                        }
                    }
                }
            }

            Overall = new ScoreBoard(ScoreBoardType.NearbyOverall, ScreenManager.Font, texScoreBG, texBG, GameManager.CurrentPlaythrough, GameManager.CurrentStage, GameManager.Hero.Level, GameManager.CurrentTime);
            Weekly = new ScoreBoard(ScoreBoardType.NearbyWeekly, ScreenManager.Font, texScoreBG, texBG, GameManager.CurrentPlaythrough, GameManager.CurrentStage, GameManager.Hero.Level, GameManager.CurrentTime);
            MyScores = new ScoreBoard(ScoreBoardType.MyNearbyScores, ScreenManager.Font, texScoreBG, texBG, GameManager.CurrentPlaythrough, GameManager.CurrentStage, GameManager.Hero.Level, GameManager.CurrentTime);
        }
Пример #2
0
        public override void HandleInput(InputState input)
        {
            OverworldLocation currentLoc = null;
            foreach (OverworldLocation loc in Locations)
            {
                if (loc.Stage == GameManager.CurrentStage && loc.Level + 1 == GameManager.CurrentLevel)
                {
                    currentLoc = loc;
                }
            }

            if (input.TapPosition.HasValue)
            {
                foreach (OverworldLocation ll in currentLoc.LinkedLocations)
                {
                    Rectangle testRect = new Rectangle((int)((ll.Position.X - (locationSize.X / 2) - overworldCamera.Position.X)), (int)((ll.Position.Y - (locationSize.Y / 2) - overworldCamera.Position.Y)), (int)locationSize.X, (int)locationSize.Y);
                    if(testRect.Contains(new Point((int)input.TapPosition.Value.X,(int)input.TapPosition.Value.Y)))
                    {
                        targetLocation = ll;
                        princessTarget = ll.Position;
                        princessMoving = true;
                    }
                }
            }

            base.HandleInput(input);
        }