public DecisionPopupChoice(string text, InternalActionEnum? internalAction, ActionType? gameAction,object[] arguments)
 {
     this.Text = text;
     this.InternalAction = internalAction;
     this.ActionType = gameAction;
     this.Args = arguments;
 }
Example #2
0
        /// <summary>
        /// Creats a Main Menu Button
        /// </summary>
        /// <param name="text">The text to show</param>
        /// <param name="content">The content manager</param>
        /// <param name="action">The action to perform when clicked</param>
        /// <param name="args">Arguments to pass when clicked</param>
        /// <param name="drawArea">The rectangle to draw in</param>
        public SystemButton(string text, ContentManager content,InternalActionEnum action,Object[] args, Rectangle drawArea)
        {
            this.displayText = text;
            this.action = action;
            this.args = args;
            //determine where we're drawing
            SpriteFont font = content.Load<SpriteFont>(@"Fonts/ButtonTextFont");

            this.drawRect = drawArea;
        }
Example #3
0
        /// <summary>
        /// Creats a Main Menu Button
        /// </summary>
        /// <param name="text">The text to show</param>
        /// <param name="content">The content manager</param>
        /// <param name="action">The action to perform when clicked</param>
        /// <param name="args">Arguments to pass when clicked</param>
        /// <param name="centerX">The CENTRE of the button</param>
        /// <param name="centreY">The CENTRE of the button</param>
        public AutoSizeButton(string text, ContentManager content,InternalActionEnum action,Object[] args, int centerX, int centreY)
        {
            this.displayText = text;
            this.action = action;
            this.args = args;
            //determine where we're drawing
            SpriteFont font = content.Load<SpriteFont>(@"Fonts/ButtonTextFont");
            Vector2 fontVector = font.MeasureString(text);

            //since this is the centre, we need to build the rectangle around it

            this.drawRect = new Rectangle((int)(centerX - fontVector.X/2),(int)(centreY - fontVector.Y/2),(int)fontVector.X,(int)fontVector.Y);
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            Point point = new Point(x, y);

            item = null;
            actionType = null;
            args = null;
            coord = null;
            destroy = false;
            internalActionType = null;

            if (!Visible)
            {
                return false;
            }

            //Did the user click on one of the choices?
            foreach (var decision in decisions)
            {
                if (decision.Rect.Contains(point))
                {
                    //Send the details pertaing to this decision
                    actionType = decision.ActionType;
                    internalActionType = decision.InternalAction;
                    args = decision.Args;
                    destroy = true; //User has made a choice, so close it

                    return true;
                }
            }

            //Not handled. But if it's modal, we expect it to catch all handling
            if (IsModal())
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            Point point = new Point(x, y);

            item = null;
            args = null;
            coord = null;
            destroy = false;
            actionType = null;
            internalActionType = null;

            if (!visible)
            {
                return false; //don't do anything
            }

            //If we pressed a stance button, just change it
            if (this.defensiveStatusRect.Contains(point))
            {
                //Swap stance to defensive
                attacker.CombatStance = DRObjects.ActorHandling.ActorStance.DEFENSIVE;
                return true;
            }
            else if (this.aggressiveStatusRect.Contains(point))
            {
                //Aggressive
                attacker.CombatStance = DRObjects.ActorHandling.ActorStance.AGGRESSIVE;
                return true;
            }
            else if (this.normalStatusRect.Contains(point))
            {
                //Normal
                attacker.CombatStance = DRObjects.ActorHandling.ActorStance.NEUTRAL;
                return true;
            }

            //Where did the user click?
            if (attackButtonRectangle.Contains(point))
            {
                //Then attack
                actionType = ActionType.ATTACK;
                List<object> argumentList = new List<object>();
                argumentList.Add(this.attacker);
                argumentList.Add(this.TargetActor);
                argumentList.Add(currentAttackLocation);

                args = argumentList.ToArray();

                return true;
            }

            //Did they click on something? Change the target
            if (headRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.HEAD;
                return true;
            }

            if (leftArmRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.LEFT_ARM;
                return true;
            }

            if (chestRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.CHEST;
                return true;

            }

            if (rightArmRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.RIGHT_ARM;
                return true;
            }

            if (legRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.LEGS;
                return true;
            }

            if (closeRect.Contains(point))
            {
                //Then close it
                destroy = true;

                return true;
            }

            //Did we click on a special attack?
            for(int i=0; i < saRects.Length; i++)
            {
                var rectangle = saRects[i];
                if (rectangle.Contains(x,y))
                {
                    //Valid special attack?
                    if (attacker.SpecialAttacks[i] != null && attacker.SpecialAttacks[i].TimeOutLeft == 0)
                    {
                        //Then attack
                        actionType = ActionType.ATTACK;
                        List<object> argumentList = new List<object>();
                        argumentList.Add(this.attacker);
                        argumentList.Add(this.TargetActor);
                        argumentList.Add(AttackLocation.CHEST);
                        argumentList.Add(attacker.SpecialAttacks[i]);

                        args = argumentList.ToArray();

                        return true;

                        //Attack!
                    }
                }
            }

            return visible; //If it's visible - block it. Otherwise do nothing
        }
        bool IGameInterfaceComponent.HandleClick(int x, int y, MouseActionEnum mouse, out DRObjects.Enums.ActionType? actionType,out InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            //This component will 'absorb' the click, but do nothing whatsoever.
            actionType = null;
            args = null;
            coord = null;
            destroy = false;
            internalActionType = null;
            itm = null;

            return true;
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            //This does nothing

            item = null;
            args = null;
            coord = null;
            destroy = false;
            actionType = null;
            internalActionType = null;

            return visible; //If it's visible - block it. Otherwise do nothing
        }
        public bool HandleClick(int x, int y, MouseActionEnum mouseAction, out ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out MapCoordinate coord, out bool destroy)
        {
            itm = null;
            internalActionType = null;

            //We only handle left clicks properly
            if (mouseAction.Equals(MouseActionEnum.LEFT_CLICK))
            {
                //check whether x and y was within a context menu item
                foreach (ContextMenuItem item in this.contextMenuItems)
                {
                    if (item.Rect.Contains(new Point(x, y)))
                    {
                        actionType = item.Action;
                        args = item.Args;
                        coord = this.coordinate;

                        //destroy the component
                        destroy = true;

                        return true;
                    }

                }
                args = null;
                actionType = null;
                coord = null;
                destroy = false;

                return false;
            }
            else
            {
                actionType = null;
                args = null;
                coord = null;
                //destroy it
                destroy = true;

                return false;
            }
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType,out InternalActionEnum? internalActionType, out object[] args,out MapItem itm, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            if (!visible)
            {
                itm = null;
                actionType = null;
                destroy = false;
                coord = null;
                args = null;
                internalActionType = null;
                return false;
            }

            //Check if we're in the middle of an animation cycle
            if (this.bigSizeSwitch == 0 || this.bigSizeSwitch == BIGSIZE)
            {
                //toggle big mode
                this.bigMode = !this.bigMode;

                if (this.bigMode)
                {
                    //Expand rectangle by 200 pixels - gradually

                    this.bigSizeSwitch = 0;

                    //  this.rect.Y -= 200;
                    // this.rect.Height += 200;
                }
                else
                {
                    this.bigSizeSwitch = 200;

                    // this.rect.Y += 200;
                    // this.rect.Height -= 200;
                }
            }

            actionType = null;
            destroy = false;
            coord = null;
            args = null;
            internalActionType = null;
            itm = null;
            return true;
        }
 public InterfaceToggleFeedback(InternalActionEnum action,bool open,object argument)
 {
     this.InterfaceComponent = action;
     this.Argument = argument;
     this.Open = open;
 }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            Point point = new Point(x, y);

            item = null;
            actionType = null;
            args = null;
            coord = null;
            destroy = false;
            internalActionType = null;

            if (!Visible)
            {
                return false;
            }

            if (mouseAction != Objects.Enums.MouseActionEnum.LEFT_CLICK)
            {
                return true;
            }

            //Did the user click on one of the choices?
            foreach (var decision in this.currentEvent.Choices)
            {
                if (decision.Rect.Contains(point))
                {
                    //Decision has been made
                    choicesMade.Add(decision.ChoiceName);

                    //Do we have a next choice?
                    if (decision.NextChoice != null)
                    {
                        //Change the current choice
                        this.currentEvent = decision.NextChoice;
                        this.PerformDrag(0, 0); //force recreation
                    }
                    else
                    {
                        //terminate! Send back that its a multidecision, and the event name and the choices made
                        internalActionType = InternalActionEnum.MULTIDECISION;
                        args = new object[] { this.currentEvent.EventName, this.choicesMade };
                        destroy = true;
                    }
                }
            }

            //Not handled. But if it's modal, we expect it to catch all handling
            if (IsModal())
            {
                return true;
            }
            else
            {
                return false;
            }
        }