Exemplo n.º 1
0
        public GroundCombatState(GameManager gameManager, GraphicsDevice graphicsDevice, ContentManager contentManager, Planet planet) : base(gameManager, graphicsDevice, contentManager)
        {
            this.gameManager    = gameManager;
            this.graphicsDevice = graphicsDevice;
            SpriteBatch         = new SpriteBatch(graphicsDevice);

            viewController = new CombatViewController(this);
            GameManager.graphics.PreferredBackBufferWidth  = GameManager.window.ClientBounds.Width;
            GameManager.graphics.PreferredBackBufferHeight = GameManager.window.ClientBounds.Height;
            viewController.viewPortWidth  = GameManager.window.ClientBounds.Width;
            viewController.viewPortHeight = GameManager.window.ClientBounds.Height;
            GameManager.graphics.ApplyChanges(); // I'm not questioning why this works. I, Cato Sicarius, approve of this action, because I, Cato Sicarius, am the most well versed Captain when it comes to the Codex Astartes!

            screen           = new GroundCombatScreen(0, "bg_combat_grass", new MapFrameAlign(0, 0, 0, 0), planet, false);
            screen.Primitive = new PrimitiveBuddy.Primitive(graphicsDevice, SpriteBatch);
            Button startBattle = new Button("ui_but_0", "Start Combat", new CornerAlign(Corner.BOTTOMRIGHT, 144, 43), StartCombat);

            screen.AddButton(startBattle);


            // Squads are going to be selected by the player through the Attack screen.
            playerSquads.Clear();
            playerSquads.Add(new Squad(planet, GenerateTroops(4), "Space Marine"));
            playerSquads.Add(new Squad(planet, GenerateTroops(12), "Space Marine"));
            //playerSquads.Add(new Squad(planet, GenerateTroops(8)));
            GenerateGrid(playerSquads);
            screen.Squads = playerSquads;
        }
        public void Draw(SpriteBatch spriteBatch, CombatViewController view, Squad squad)
        {
            Rectangle rect = new Rectangle(squad.Position.ToPoint() + this.Position.ToPoint() - view.GetCameraPosition().ToPoint(), this.Size.ToPoint());

            if (squad.Selected)
            {
                spriteBatch.DrawRectangle(GetRectangle(view, squad), Color.Yellow);
            }

            if (squad.IsSquadLeader(this))
            {
                spriteBatch.DrawString(Assets.CourierNew, "" + squad.GetHealth(),
                                       rect.Location.ToVector2() - (Size / 2 + new Vector2(0, +4)), Color.White);
                spriteBatch.Draw(Assets.UITextures["gc_squadleader"], rect.Location.ToVector2(), null,
                                 Color.White, this.Rotation,
                                 new Vector2(Size.X / 2, Size.Y / 2),
                                 new Vector2(1, 1),
                                 SpriteEffects.None, 0);
            }
            else
            {
                spriteBatch.Draw(Assets.UITextures["gc_spacemarine"], rect.Location.ToVector2() - Size / 4, null,
                                 Color.White, this.Rotation,
                                 new Vector2(Size.X / 2, Size.Y / 2),
                                 new Vector2(1, 1),
                                 SpriteEffects.None, 0);
            }
        }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Debug.Log("Another Instance of CombatView was running");
     }
 }
Exemplo n.º 4
0
 public Troop GetTroopUnderMouse(CombatViewController view)
 {
     foreach (Troop troop in Troops)
     {
         if (troop.GetRectangle(view, this).Contains(view.GetMouse().Position))
         {
             //Debug.WriteLine("detected collision");
             return(troop);
         }
     }
     return(null);
 }
Exemplo n.º 5
0
        public override void Render(SpriteBatch spriteBatch, ViewController view)
        {
            base.Render(spriteBatch, view); // TODO Change background to match planet type.
            CombatViewController combatView = (CombatViewController)view;
            string  name     = planet.GetName();
            Vector2 nameSize = Assets.ARJULIAN.MeasureString(name);

            spriteBatch.DrawString(Assets.ARJULIAN, name, new Vector2(view.viewPortWidth / 2 - nameSize.X / 2, 2), Color.White);
            if (combatView.IsDeploying())
            {
                string  deploymentPhase = "Deployment Phase (Press shift to give initial move orders and place individual troops)";
                Vector2 deploymentSize  = Assets.ARJULIAN.MeasureString(deploymentPhase);
                spriteBatch.DrawString(Assets.ARJULIAN, deploymentPhase, new Vector2(view.viewPortWidth / 2 - deploymentSize.X / 2, nameSize.Y + 2),
                                       Color.White);
            }

            for (int currentSquad = 0; currentSquad < Squads.Count; currentSquad++)
            {
                Squad squad = Squads[currentSquad];
                for (int i = 0; i < squad.Troops.Count; i++)
                {
                    Troop troop = squad.Troops[i];
                    troop.Draw(spriteBatch, combatView, squad);
                    //string leaderTag = i == Squads.Count - 1 ? "L" : "";
                    //spriteBatch.DrawString(Assets.ARJULIAN, $"{troop.Health} i {i}",
                    //                       squad.Position + new Vector2(troop.Position.X, troop.Position.Y - 10) - combatView.GetCameraPosition(),
                    //                       Color.White);
                }
            }
            if (combatView.currentlySelectedTroop != null)
            {
                //spriteBatch.DrawString(Assets.ARJULIAN, $"cur: {currentlySelectedTroop}") // draw currently selected troop id
            }
            if (combatView.assigningOrder)
            {
                /*Rectangle rect = new Rectangle(position.ToPoint().X,
                 *  position.ToPoint().Y,
                 *  Math.Abs((orderEnd - position).ToPoint().X),
                 *  Math.Abs((orderEnd - position).ToPoint().Y));*/
                Debug.WriteLine("drawing order arrow");
                spriteBatch.Draw(Assets.UITextures["order_move_arrow"], combatView.GetStartPositionOfOrder() - combatView.GetCameraPosition(), null,
                                 Color.White, combatView.GetOrderRotation(),
                                 new Vector2(0, 16),
                                 new Vector2(combatView.GetOrderScale(), 1 + combatView.GetOrderScale() / 20),
                                 SpriteEffects.None, 0);

                //Debug.WriteLine($"PX: {position.X}, PY: {position.Y}, RX: {rect.X}, RY: {rect.Y}, RW: {rect.Width}, RH: {rect.Height}, RO: {rot}");
            }
        }
 public bool IsCollidingWithAny(CombatViewController view, Squad thisSquad, Squad otherSquad)
 {
     foreach (Troop otherTroop in otherSquad.Troops)
     {
         if (this != otherTroop)
         {
             if (GetRectangle(view, thisSquad).Intersects(otherTroop.GetRectangle(view, otherSquad)))
             {
                 return(true);
             }
         }
     }
     //Debug.WriteLine("checking for collision");
     return(false);
 }
 public bool IsCollidingWith(CombatViewController view, Squad thisSquad, Squad otherSquad, Troop otherTroop)
 {
     return(GetRectangle(view, thisSquad).Intersects(otherTroop.GetRectangle(view, otherSquad)));
 }
 public bool MouseOver(CombatViewController view, Squad squad) // Will probably have to be moved to ViewController.S
 {
     return(GetRectangle(view, squad).Contains(Mouse.GetState().Position));
 }
 public Rectangle GetRectangle(CombatViewController view, Squad squad)
 {
     return(new Rectangle((Position + squad.Position - view.GetCameraPosition()).ToPoint() - Size.ToPoint().Multiply(0.5f), Size.ToPoint()));
 }
Exemplo n.º 10
0
 public CombatController()
 {
     card_combat_controller = new CombatCardController();
     arena_controller       = new ArenaController();
     combat_view_controller = new CombatViewController();
 }