示例#1
0
        public WorldView(World world, CameraClampMode cameraClampMode, InputHandler input)
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            World             = world;
            GameStatusHandler = new GameStatusHandler(GameStatus.OverlandMap);

            Input = input;

            Camera = new Camera(this, new Rectangle(0, 0, 1680, 1080), cameraClampMode, Input);
            var globalContextPresentation = CallContext <GlobalContextPresentation> .GetData("GlobalContextPresentation");

            globalContextPresentation.Camera = Camera;

            OverlandMapView         = new OverlandMapView(this, World.OverlandMap, Input);
            OverlandSettlementViews = new OverlandSettlementViews(this, World.Settlements, Input);
            StackViews     = new StackViews(this, World.Stacks, Input);
            SettlementView = new SettlementView(this, World.Settlements.Count > 0 ? World.Settlements[0] : new Settlement("Test", 1, PointI.Zero, 1, World.OverlandMap.CellGrid, new int[0]), Input);
            HudView        = new HudView(this, StackViews, Input);
            //Tooltip = new Tooltip(Vector2.Zero, Alignment.TopLeft, new Vector2(200.0f, 300.0f), "GUI_Textures_1.sp_frame", 25, 25, 25, 25, "tooltip") { Enabled = false };

            var context = CallContext <GlobalContextPresentation> .GetData("GlobalContextPresentation");

            Viewport        = new Viewport(0, 0, Camera.GetViewport.Width, Camera.GetViewport.Height, 0.0f, 1.0f);
            ViewportAdapter = new ScalingViewportAdapter(context.GraphicsDevice, Camera.GetViewport.Width, Camera.GetViewport.Height);

            MovementTypeImages = InitializeMovementTypeImages();
            ActionButtons      = InitializeActionButtons();
        }
示例#2
0
        internal HudView(WorldView worldView, StackViews stackViews, InputHandler input)
        {
            var x      = worldView.Camera.GetViewport.Right;
            var y      = 0;
            var width  = 1920 - x;
            var height = 1020;

            Area = new Rectangle(x, y, width, height); // 1680,0,240,1020

            var pairs = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("position1", "0;0"),
                new KeyValuePair <string, string>("size1", $"{width};{height}"),
                new KeyValuePair <string, string>("size2", $"{width - 20};{Convert.ToInt32(height * 0.15f)}"), // 15% of parent
                new KeyValuePair <string, string>("size3", $"{width - 20};{Convert.ToInt32(height * 0.20f)}"), // 20% of parent
                new KeyValuePair <string, string>("size4", $"{width - 20};{Convert.ToInt32(height * 0.30f)}")  // 30% of parent
            };

            var spec = ResourceReader.ReadResource("PhoenixGamePresentation.Views.HudViewControls.txt", Assembly.GetExecutingAssembly());

            Controls = ControlCreator.CreateFromSpecification(spec, pairs);
            Controls.SetOwner(this);

            WorldView  = worldView;
            StackViews = stackViews;

            worldView.CellGrid.NewCellSeen += NewCellSeen;

            SetupViewport(x, y, width, height + Controls["frmHudView.btnEndTurn"].Height); // 1680,0,240,1020 + 56 : btnEndTurn.Height = 56

            Input = input;
        }
示例#3
0
        private static void DrawUnitBadges(SpriteBatch spriteBatch, StackViews stackViews, StackView.StackView selectedStackView, Vector2 topLeftPosition)
        {
            var stackViewsSharingSameLocation = GetStackViewsSharingSameLocation(stackViews, selectedStackView);

            var i = 0;

            foreach (var stackView in stackViewsSharingSameLocation)
            {
                DrawUnitBadges(spriteBatch, stackViews, topLeftPosition, i, stackView);
                i += stackView.Count;
            }
        }
示例#4
0
        internal void LoadContent(ContentManager content)
        {
            Camera.LoadContent(content);
            OverlandMapView.LoadContent(content);
            OverlandSettlementViews.LoadContent(content);
            StackViews.LoadContent(content);
            SettlementView.LoadContent(content);
            HudView.LoadContent(content);
            //Tooltip.LoadContent(content);

            MovementTypeImages.LoadContent(content);
            ActionButtons.LoadContent(content, true);
        }
示例#5
0
        private static void DrawUnits(SpriteBatch spriteBatch, StackViews stackViews, StackView.StackView selectedStackView, PointI frmUnitsTopLeft, PointI frmUnitsBottomRight, EnumerableDictionary <IControl> actionButtons)
        {
            if (selectedStackView == null)
            {
                return;
            }

            var topLeftPosition = frmUnitsTopLeft.ToVector2() + new Vector2(10.0f, 10.0f);

            DrawUnitBadges(spriteBatch, stackViews, selectedStackView, topLeftPosition);
            DrawMovementTypeImages(spriteBatch, frmUnitsBottomRight, selectedStackView.GetMovementTypeImages());
            DrawActionButtons(spriteBatch, selectedStackView.Actions, actionButtons);
        }
示例#6
0
        private static void DrawUnitBadge(SpriteBatch spriteBatch, StackViews stackViews, Vector2 centerPosition, PhoenixGameLibrary.Unit unit, StackView.StackView stackView)
        {
            // draw background
            var sourceRectangle      = stackView.IsSelected ? stackViews.SquareGreenFrame.ToRectangle() : stackViews.SquareGrayFrame.ToRectangle();
            var destinationRectangle = new Rectangle((int)centerPosition.X, (int)centerPosition.Y, stackView.ScreenFrame.Width, stackView.ScreenFrame.Height);

            spriteBatch.Draw(stackViews.GuiTextures, destinationRectangle, sourceRectangle, Color.White, 0.0f, new Vector2(sourceRectangle.Width * Constants.ONE_HALF, sourceRectangle.Height * Constants.ONE_HALF), SpriteEffects.FlipVertically, 0.0f);

            // draw unit icon
            var frame = stackViews.UnitAtlas.Frames[unit.UnitTypeTextureName];

            sourceRectangle      = frame.ToRectangle();
            destinationRectangle = new Rectangle((int)centerPosition.X, (int)centerPosition.Y, sourceRectangle.Width, sourceRectangle.Height);
            spriteBatch.Draw(stackViews.UnitTextures, destinationRectangle, sourceRectangle, Color.White, 0.0f, new Vector2(sourceRectangle.Width * Constants.ONE_HALF, sourceRectangle.Height * Constants.ONE_HALF), SpriteEffects.None, 0.0f);
        }
示例#7
0
        private static void DrawUnitBadges(SpriteBatch spriteBatch, StackViews stackViews, Vector2 topLeftPosition, int index, StackView.StackView stackView)
        {
            var x = topLeftPosition.X + 30;
            var y = topLeftPosition.Y + 30;

            foreach (var unit in stackView.Stack)
            {
                var indexMod3       = index % 3;
                var indexDividedBy3 = index / 3; // Floor
                var xOffset         = (stackView.ScreenFrame.Width + 10.0f) * indexMod3;
                var yOffset         = (stackView.ScreenFrame.Height + 10.0f) * indexDividedBy3;
                DrawUnitBadge(spriteBatch, stackViews, new Vector2(x + xOffset, y + yOffset), unit, stackView);
                index++;
            }
        }
示例#8
0
        internal void Update(GameTime gameTime)
        {
            var deltaTime = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            Camera.Update(deltaTime);

            OverlandMapView.Update(deltaTime);
            OverlandSettlementViews.Update(deltaTime);
            StackViews.Update(deltaTime);

            SettlementView.Settlement = World.Settlements.Selected;
            if (SettlementView.Settlement != null)
            {
                SettlementView.Update(gameTime, null);
            }

            HudView.Update(gameTime);
            StackViews.RemoveDeadUnits();
        }
示例#9
0
        private static List <StackView.StackView> GetStackViewsSharingSameLocation(StackViews stackViews, StackView.StackView selectedStackView)
        {
            var stackViews2 = new List <StackView.StackView>();

            if (selectedStackView == null)
            {
                return(stackViews2);
            }

            foreach (var stackView in stackViews)
            {
                if (stackView.LocationHex == selectedStackView.LocationHex) // same location
                {
                    stackViews2.Add(stackView);
                }
            }

            return(stackViews2);
        }
示例#10
0
        internal static List <UnitView> GetUnitsToDraw(StackViews stackViews, StackView.StackView selectedStackView)
        {
            var topLeftPosition = new Vector2(20, 510);

            var unitViews = new List <UnitView>();

            var stackViewsSharingSameLocation = GetStackViewsSharingSameLocation(stackViews, selectedStackView);

            var i = 0;

            foreach (var stackView in stackViewsSharingSameLocation)
            {
                var unitViewsToAdd = GetUnitBadgesToDraw(topLeftPosition, i, stackView);
                unitViews.AddRange(unitViewsToAdd);
                i += stackView.Count;
            }

            return(unitViews);
        }
示例#11
0
        internal void Draw(SpriteBatch spriteBatch)
        {
            OverlandMapView.Draw(spriteBatch, Camera);
            OverlandSettlementViews.Draw(spriteBatch, Camera);
            StackViews.Draw(spriteBatch, Camera);

            HudView.Draw(spriteBatch);

            //if (Tooltip.Enabled)
            //{
            //    var originalViewport = spriteBatch.GraphicsDevice.Viewport;
            //    spriteBatch.GraphicsDevice.Viewport = Viewport;
            //    spriteBatch.Begin(samplerState: SamplerState.PointWrap, transformMatrix: ViewportAdapter.GetScaleMatrix());
            //    Tooltip.Draw(spriteBatch);
            //    spriteBatch.End();
            //    spriteBatch.GraphicsDevice.Viewport = originalViewport;
            //}

            SettlementView.Draw(spriteBatch);
        }
示例#12
0
 private void BtnClick(object sender, ButtonClickEventArgs e)
 {
     StackViews.DoAction(e.Action);
 }
示例#13
0
        internal bool IsMouseHoveringOverAStack(Point mouseLocation)
        {
            var stackViewHoveredOver = StackViews.GetStackViewFromLocation(mouseLocation);

            return(stackViewHoveredOver != null);
        }
示例#14
0
 internal void SelectStack(StackView.StackView stackView)
 {
     StackViews.SelectStack(stackView);
 }
示例#15
0
        internal (bool selectStack, StackView.StackView stackToSelect) CheckForSelectionOfStack(Point mouseLocation)
        {
            var selectStack = StackViews.CheckForSelectionOfStack(mouseLocation);

            return(selectStack);
        }
示例#16
0
 public void BeginTurn()
 {
     World.BeginTurn();
     StackViews.BeginTurn();
 }