public UIStatBackground(GameBoard game, LiveUnit rep, int xPos, int yPos, int width, int height) : base(game, xPos, yPos, width, height)
 {
     this.rep = rep;
     //Draw the skill boundaries window
     this.skillBoundaries = new Rectangle(xPos + 1, yPos - 60, width - 2, 55);
     //Create buttons for both active skills
     this.active1         = new UISkillButton(game, 1, rep.Abilities[1], this.rep, xPos + 6, yPos - 54, 83, 8);
     this.active2         = new UISkillButton(game, 2, rep.Abilities[2], this.rep, xPos + 6, yPos - 42, 83, 8);
     this.active1.visible = true;
     this.active2.visible = true;
     //Create buttons for movement, default attack, and both passives
     this.move             = new UIDefaultActionButton(game, 0, rep, xPos + 6, yPos - 30, 16, 16);
     this.attack           = new UIDefaultActionButton(game, 1, rep, xPos + 27, yPos - 30, 16, 16);
     this.passive1         = new UIDefaultActionButton(game, 2, rep, xPos + 49, yPos - 30, 16, 16);
     this.passive2         = new UIDefaultActionButton(game, 3, rep, xPos + 72, yPos - 30, 16, 16);
     this.move.visible     = true;
     this.attack.visible   = true;
     this.passive1.visible = true;
     this.passive2.visible = true;
     //Create stat text for all unit stats
     this.health     = new UIStatText(game, rep, stat.health, xPos + 7, yPos + 6, 28, 28);
     this.damage     = new UIStatText(game, rep, stat.damage, xPos + 33, yPos + 6, 28, 28);
     this.range      = new UIStatText(game, rep, stat.range, xPos + 65, yPos + 6, 28, 28);
     this.speed      = new UIStatText(game, rep, stat.speed, xPos + 4, yPos + 19, 28, 28);
     this.critChance = new UIStatText(game, rep, stat.critChance, xPos + 34, yPos + 19, 28, 28);
     this.critDamage = new UIStatText(game, rep, stat.critDamage, xPos + 64, yPos + 19, 28, 28);
 }
Beispiel #2
0
        public UIUnit(GameBoard game, LiveUnit rep, int xIndex, int yIndex, int xPos, int yPos, int width, int height) : base(game, xPos, yPos, width, height)
        {
            //Save the reference to the object being represented
            this.representing = rep;

            //Save this object's index in the UIGrid
            this.xInd = xIndex;
            this.yInd = yIndex;

            //Create UI elements for this unit

            if (!rep.ContainsBuffType(BuffType.IsUnselectable))
            {
                //Healthbar
                this.healthBar             = new UIHealthBar(game, this, xPos - 4, yPos, 59, 2);
                this.healthBar.visible     = true;
                this.healthBar.layer       = 97;
                this.healthBar.mouseEvents = false;
                //Actions Indicator
                this.movesLeft             = new UIMovesLeft(game, this, xPos + 42, yPos + 8, 15, 12);
                this.movesLeft.visible     = true;
                this.movesLeft.layer       = 97;
                this.movesLeft.mouseEvents = false;
                //Create the active display elements
                this.activeWindowWrapper             = new UIStatBackground(game, this.representing, xPos - 22, yPos - 40, 95, 35);
                this.activeWindowWrapper.visible     = true;
                this.activeWindowWrapper.layer       = 96;
                this.activeWindowWrapper.mouseEvents = false;
            }
        }
Beispiel #3
0
 //Constructor
 public UIStatText(GameBoard game, LiveUnit rep, stat display, int xPos, int yPos, int width, int height) : base(game, xPos, yPos, width, height)
 {
     this.rep         = rep;
     this.toDisplay   = display;
     this.mouseEvents = false;
     this.visible     = true;
     this.layer       = 95;
 }
Beispiel #4
0
 //Move a UI unit as well as it's corrosponding LiveUnit
 public void Move(int xStart, int yStart, int xEnd, int yEnd)
 {
     if (Utils.RangeContains(0, this.width - 1, xStart, xEnd) && Utils.RangeContains(0, this.height - 1, yStart, yEnd))
     {
         LiveUnit cur = dataGrid.Get(xStart, yStart);
         cur.sprite.xInd = xEnd;
         cur.sprite.yInd = yEnd;
         cur.sprite.MoveTo((xEnd * 63) + 6 + margin, (yEnd * 63) - 21 + margin);
         dataGrid.Move(xStart, yStart, xEnd, yEnd);
     }
     else
     {
         throw new IndexOutOfRangeException("Provided movement coordinates Out of Bounds");
     }
 }
        public UIDefaultActionButton(GameBoard game, int hOra, LiveUnit unit, int xPos, int yPos, int width, int height) : base(game, xPos, yPos, width, height)
        {
            this.hOra = hOra;
            if (this.hOra == 0)
            {
                this.thisSprite = move;
            }
            else if (this.hOra == 1)
            {
                this.thisSprite = attack;
            }
            else if (this.hOra == 2)
            {
                this.thisSprite = passive1;
            }
            else if (this.hOra == 3)
            {
                this.thisSprite = passive2;
            }

            this.layer = 95;
            this.lrep  = unit;
            //Create a hover text box
            if (this.hOra == 0)
            {
                this.flavorText = new UITextBox(game, "Move Unit // This unit can move " + (this.lrep.speed - 1) + " this turn.", xPos, yPos, 89, 12);
            }
            else if (this.hOra == 1)
            {
                this.flavorText = new UITextBox(game, this.lrep.Abilities[0].Title + " // " + this.lrep.Abilities[0].Tooltip, xPos, yPos, 89, 12);
            }
            else if (this.hOra == 2)
            {
                if (this.lrep.Abilities.Count > 3)
                {
                    this.flavorText = new UITextBox(game, this.lrep.Abilities[3].Title + " // " + this.lrep.Abilities[3].Tooltip, xPos, yPos, 89, 12);
                }
            }
            else if (this.hOra == 3)
            {
                if (this.lrep.Abilities.Count > 4)
                {
                    this.flavorText = new UITextBox(game, this.lrep.Abilities[4].Title + " // " + this.lrep.Abilities[4].Tooltip, xPos, yPos, 89, 12);
                }
            }
        }
        public UISkillButton(GameBoard game, int skillNum, Ability ability, LiveUnit unit, int xPos, int yPos, int width, int height) : base(game, xPos, yPos, width, height)
        {
            this.skillNum = skillNum;
            if (this.skillNum == 1)
            {
                this.thisSprite = skill1;
            }
            else if (this.skillNum == 2)
            {
                this.thisSprite = skill2;
            }

            this.layer = 95;
            this.rep   = ability;
            this.lrep  = unit;
            //Create a hover text box
            this.flavorText = new UITextBox(game, this.rep.Title + " // " + this.rep.Tooltip, xPos, yPos, width, 12);
        }
Beispiel #7
0
        //Constructor
        public UIGrid(Grid dataGrid)
        {
            //Save the width and height of the grid
            this.width  = dataGrid.width;
            this.height = dataGrid.height;
            //Save the grid
            this.dataGrid = dataGrid;

            //Create a grid of UIGridCells equal in size to the data grid
            this.grid = new UIGridCell[this.height, this.width];

            //Set the margin size
            margin = 95;

            //Create a UIGridCell for each position in the grid
            for (int h = 0; h < this.height; h++)
            {
                for (int w = 0; w < this.width; w++)
                {
                    this.grid[h, w]         = new UIGridCell(GameBoard.game, this, w, h, (w * 63) + margin, (h * 63) + margin, 63, 63);
                    this.grid[h, w].layer   = 99;
                    this.grid[h, w].visible = true;
                }
            }

            //Create a UIUnit object for each unit in the data grid.  Save the UI object reference in the LiveUnit.  The UIUnit can be accessed through the data grid
            for (int h = 0; h < this.height; h++)
            {
                for (int w = 0; w < this.width; w++)
                {
                    LiveUnit cur = dataGrid.Get(w, h);
                    if (cur != null)
                    {
                        cur.sprite             = new UIUnits.UIUnit(GameBoard.game, cur, w, h, (w * 63) + 6 + margin, (h * 63) - 21 + margin, 51, 76);
                        cur.sprite.layer       = 98;
                        cur.sprite.visible     = true;
                        cur.sprite.mouseEvents = false;
                    }
                }
            }
        }
Beispiel #8
0
        public UnitManager()
        {
            this.dataGrid       = Grid.mainGrid;
            this.activeUnit     = null;
            this.activeAbility  = null;
            this.defaultAdvance = true;
            this.skillNum       = 0;

            //Initialize all the state variables
            this.displayingMovement = false;
            this.moveTargetSelected = false;
            this.readyMove          = false;
            this.attacking          = false;
            this.attack             = false;
            this.healing            = false;
            this.heal                   = false;
            this.teleporting            = false;
            this.teleportTargetSelected = false;
            this.teleport               = false;
            this.teleportTargetX        = -1;
            this.teleportTargetY        = -1;
        }
Beispiel #9
0
        public void MoveDetection()
        {
            //Get the Active Unit's loaction
            int aux = this.activeUnit.sprite.xInd;
            int auy = this.activeUnit.sprite.yInd;

            //Display possible movement
            if (this.displayingMovement == false)
            {
                //Set the possible movement region to possible movement
                this.UIGrid.SetRegion(UIGridCell.CellState.MovePossible, aux, auy, this.activeUnit.speed);
                //Set the cell under the active unit to active movement
                this.UIGrid.Set(UIGridCell.CellState.MoveActive, aux, auy);

                //Set the central grid cell to fixed
                this.UIGrid.grid[auy, aux].fixedState = true;

                this.displayingMovement = true;

                //If movement is already being displayed, check for a click within the movement radius
            }
            else
            {
                //If an inactive location was selected
                if (this.moveTargetSelected)
                {
                    //Make sure that this location is valid
                    //If this location contains another unit, set that unit to the active unit instead of running default code
                    if (this.UIGrid.dataGrid.Get(this.moveTargetX, this.moveTargetY) != null)
                    {
                        //Remove the fixed state from the current grid cell
                        this.UIGrid.grid[auy, aux].fixedState = false;
                        //Set the new active unit

                        if (!this.UIGrid.dataGrid.Get(this.moveTargetX, this.moveTargetY).ContainsBuffType(BuffType.IsUnselectable))
                        {
                            this.activeUnit = this.UIGrid.dataGrid.Get(this.moveTargetX, this.moveTargetY);
                        }
                        else
                        {
                            this.activeUnit = null;
                        }
                        //Clear the UIGrid of all active states
                        this.UIGrid.Clear();
                        //Set displayingMovement to false
                        this.displayingMovement = false;
                        //Set moveTargetSelected to false
                        this.moveTargetSelected = false;

                        //Else, this is a valid move location
                    }
                    else
                    {
                        //Set the grid cell to MoveActive, and set it's state to fixed
                        this.UIGrid.grid[this.moveTargetY, this.moveTargetX].cellState  = UIGridCell.CellState.MoveActive;
                        this.UIGrid.grid[this.moveTargetY, this.moveTargetX].fixedState = true;

                        /*
                         *  DRAW THE SHORTEST PATH FROM THE UNIT POSITION TO THE SELECTED POSITION
                         */

                        //If this was the second click at this location
                        if (this.readyMove)
                        {
                            //Remove the fixed qualification from the active unit's current cell
                            this.UIGrid.grid[auy, aux].fixedState = false;
                            //Remove the fixed qualification from the target cell
                            this.UIGrid.grid[this.moveTargetY, this.moveTargetX].fixedState = false;
                            //Move the unit and de-increment it's MovesLeft variable
                            this.UIGrid.Move(aux, auy, this.moveTargetX, this.moveTargetY);
                            this.activeUnit.sprite.MoveSubUI();
                            this.activeUnit.MovesLeft -= 1;
                            this.displayingMovement    = false;
                            this.moveTargetSelected    = false;
                            this.readyMove             = false;
                            //Clear the grid, allowing other draw code to take over
                            this.UIGrid.Clear();
                            //Show that this unit has already moved
                            this.activeUnit.hasMoved = true;
                        }
                    }
                }
            }
        }
Beispiel #10
0
        //A cell was clicked at this index, process that data and set relevant loop variables
        //The first variable shows what state the cell was in when it was clicked
        public void CellClick(UIGridCell.CellState state, int xInd, int yInd)
        {
            switch (state)
            {
            //If the clicked grid cell was Inactive
            case UIGridCell.CellState.Possible:
                //If active unit isn't null
                if (activeUnit != null)
                {
                    //If the target location is not the currently active unit, and it contains a unit
                    if ((xInd != this.activeUnit.sprite.xInd || yInd != this.activeUnit.sprite.yInd) && this.dataGrid.Get(xInd, yInd) != null)
                    {
                        //Remove the fixed qualifiaction from the current unit's cell
                        this.UIGrid.grid[this.activeUnit.sprite.yInd, this.activeUnit.sprite.xInd].fixedState = false;

                        //Check if the unit can be selected

                        if (!this.UIGrid.dataGrid.Get(xInd, yInd).ContainsBuffType(BuffType.IsUnselectable))
                        {
                            //If it can be, set the new active unit
                            this.activeUnit = this.UIGrid.dataGrid.Get(xInd, yInd);
                        }
                        else
                        {
                            this.activeUnit = null;
                        }
                        //Clear the UIGrid of all active states
                        this.UIGrid.Clear();
                        //Set attacking to false
                        this.attacking = false;
                        //Set displayingMovement to false
                        this.displayingMovement = false;
                        //Set moveTargetSelected to false
                        this.moveTargetSelected = false;
                    }
                }
                //If the target location contains no units
                if (this.dataGrid.Get(xInd, yInd) == null)
                {
                    //Remove the fixed qualification from the current unit's cell
                    if (this.activeUnit != null)
                    {
                        this.UIGrid.grid[this.activeUnit.sprite.yInd, this.activeUnit.sprite.xInd].fixedState = false;
                    }
                    //Set activeUnit to null
                    this.activeUnit = null;
                    //Clear the grid
                    this.UIGrid.Clear();
                    //Reset state variables
                    this.attacking          = false;
                    this.displayingMovement = false;
                    this.moveTargetSelected = false;
                    //If the target location contains a unit
                }
                else
                {
                    //Set the new active unit


                    if (!this.UIGrid.dataGrid.Get(xInd, yInd).ContainsBuffType(BuffType.IsUnselectable))
                    {
                        this.activeUnit = this.dataGrid.Get(xInd, yInd);
                    }
                }
                break;

            //If the clicked grid cell was MoveActive
            case UIGridCell.CellState.MoveActive:
                //If the target movement location has not yet been selected, set the clicked cell to active
                if (this.moveTargetSelected == false)
                {
                    this.moveTargetSelected = true;
                    this.moveTargetX        = xInd;
                    this.moveTargetY        = yInd;

                    //Else, moveTargetSelected is true.  Make sure the clicked location is the same cell.  If it is not, move the target cell
                }
                else if (xInd != this.moveTargetX || yInd != this.moveTargetY)
                {
                    this.UIGrid.grid[this.moveTargetY, this.moveTargetX].cellState  = UIGridCell.CellState.MovePossible;
                    this.UIGrid.grid[this.moveTargetY, this.moveTargetX].fixedState = false;
                    this.moveTargetSelected = true;
                    this.moveTargetX        = xInd;
                    this.moveTargetY        = yInd;

                    //Else, this is the second click on the target cell.  Set readyMove to true
                }
                else
                {
                    this.readyMove = true;
                }
                break;

            //If the clicked grid cell was AttackActive
            case UIGridCell.CellState.AttackActive:
                this.attack = true;
                break;

            //If the clicked grid cell was HealActive
            case UIGridCell.CellState.HealActive:
                this.heal = true;
                break;

            //If the clicked grid cell was TeleportActive
            case UIGridCell.CellState.TeleportActive:
                if (this.teleportTargetSelected == false)
                {
                    this.teleportTargetX = xInd;
                    this.teleportTargetY = yInd;

                    this.teleportTargetSelected = true;

                    //Make sure the second location is not the same cell
                }
                else if (xInd != this.teleportTargetX || yInd != this.teleportTargetY)
                {
                    this.teleport = true;
                }
                break;
            }
        }