示例#1
0
        public void Update(GameTime gameTime, Cursor cursor, List<FloorObject> floorObjectList, FloorObject table, Assistant assistant, Corpse corpse, List<MiniProgressBar> bars,MenuAction dissect,MenuAction study)
        {
            if (floorObjectList.Contains(table) && assistant.digging == false && corpse.visible == false && assistant.outside == false && assistant.corpseCarrying == false)
            {
                doable = true;
            }

            else
            {
                doable = false;
            }

            // clicking on build icon

            if (cursor.position.X >= iposition.X && cursor.position.X < (iposition.X + iwidth) && cursor.position.Y >= iposition.Y && cursor.position.Y < (iposition.Y + iheight))
            {
                high = true;

                if (cursor.mouseState.LeftButton == ButtonState.Pressed | cursor.mouseState.RightButton == ButtonState.Pressed)
                {
                    if (cursor.click == false)
                    {
                        if (doable == true)
                        {
                            assistant.DigUpCorpse(corpse,dissect,study);
                            clickOn = true;
                        }

                    }

                    cursor.click = true;
                }
            }

            else
            {
                high = false;
            }

            if (clickOn == true)
            {
                clickCount += gameTime.ElapsedGameTime.Milliseconds;

                if (clickCount > 100)
                {
                    clickCount = 0;
                    clickOn = false;
                }
            }
        }
示例#2
0
        public void Update(List<FloorObject> floorObjectList, List<MiniProgressBar> progBars,Scientist scientist, Assistant assistant, Build build, Graveyard graveyard,FloorObject table, Corpse corpse, NumericalCounter money,
                            Path path, List<Vector2> drawPath,Grid grid, Resurrect resurrect, NumericalCounter humanity, NumericalCounter longevity, NumericalCounter research, Random random)
        {
            MouseState mouseState = Mouse.GetState();

            // Put the cursor where the mouse is constantly

            position.X = mouseState.X;
            position.Y = mouseState.Y;

            mouseOver = false;

            // check if over a progress bar, show values if so

            barMouseover = false;

            foreach (MiniProgressBar bar in progBars)
            {

                // if menu is off, check if over an object, open menu if clicked

                if (menu == false)
                {
                    // objects
                    if (position.X >= bar.position.X && position.X <= (bar.position.X + bar.width)
                            && position.Y >= bar.position.Y && position.Y <= (bar.position.Y + bar.height))
                    {

                        barMouseover = true; // add object mouseover text
                        menuProgBar = bar;

                    }

                }
            }

            // check for clicking on/mouseover build icons

            buildIconMouseover = false;

            foreach (FloorObject curitem in build.buildList)
            {
                if (position.X >= curitem.iconPosition.X && position.X <= curitem.iconPosition.X + 60
                && position.Y >= curitem.iconPosition.Y && position.Y <= curitem.iconPosition.Y + 60)
                {
                    if (curitem.onBuildList == true && build.buildList.IndexOf(curitem) < (build.scrollPos + build.buildScreenLength) && build.buildList.IndexOf(curitem) >= build.scrollPos)
                    {
                        // tooltip + highlighting on
                        buildIconMouseover = true;
                        menuObject = curitem;

                        // build!
                        if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                        {
                            if (click == false)
                            {
                                if (money.value >= curitem.cost)
                                {
                                    remove = curitem;
                                    floorObjectList.Add(curitem);
                                    build.menu = false;
                                }
                            }

                        }

                        click = true;

                    }
                }

            }

            // remove anything that has been built from build list
            if (remove != null)
            {
                build.Remove(remove,money);
                remove = null;
            }
            // check for clicking on objects

                // if menu is off, check if over an object, open menu if clicked & check for clicking on graveyard + tooltip

                if (menu == false && graveMenu == false && corpseMenu == false)
                {
                    foreach (FloorObject floorObject in floorObjectList)
                    {

                        // objects
                        if (position.X >= (floorObject.position.X - floorObject.offset.X) && position.X <= (floorObject.position.X - floorObject.offset.X + ((floorObject.objectTex.Width*floorObject.scale) / floorObject.frames))
                                && position.Y >= floorObject.position.Y - floorObject.offset.Y && position.Y <= (floorObject.position.Y - floorObject.offset.Y + (floorObject.objectTex.Height*floorObject.scale)))
                        {
                            if (floorObject.menuActions.Count > 0)
                            {
                                mouseOver = true; // add object mouseover text
                                menuObject = floorObject;

                                // turn on menu when object is clicked

                                if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                                {
                                    if (click == false)
                                    {

                                        menu = true;

                                    }

                                }

                                click = true;
                            }
                        }

                    }

                    graveMouseOver = false;

                    // graveyard
                    if (position.X >= graveyard.tlcorner.X && position.X <= graveyard.brcorner.X
                            && position.Y >= graveyard.tlcorner.Y && position.Y <= graveyard.brcorner.Y)
                    {

                        graveMouseOver = true; // add object mouseover text

                        // turn on menu when object is clicked

                        if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                        {
                            if (click == false)
                            {
                                graveMenu = true;
                                graveMouseOver = false;
                            }

                        }

                        click = true;
                    }

                    corpseMouseover = false;

                    // corpse
                    if (position.X >= corpse.position.X && position.X <= corpse.position.X + corpse.width
                            && position.Y >= corpse.position.Y && position.Y <= corpse.position.Y + corpse.height && corpse.visible == true)
                    {

                        corpseMouseover = true; // add object mouseover text

                        // turn on menu when object is clicked

                        if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                        {
                            if (click == false)
                            {
                                corpseMenu = true;
                                corpseMouseover = false;
                            }

                        }

                        click = true;
                    }

                }

                // allow clicking on actions, turn off menu when anything else is clicked (if on)

                if (menu == true)
                {

                    if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (click == false)
                        {
                            if (menu == true)
                            {
                                menu = false;

                                if (menuMouseover == true)
                                {
                                    if (menuHighlightAction.scientist == true)
                                    {
                                        scientist.action = menuHighlightAction;
                                        scientist.floorObject = menuObject;
                                    }

                                    else
                                    {
                                        assistant.action = menuHighlightAction;
                                        assistant.floorObject = menuObject;
                                    }
                                }
                            }

                        }

                        click = true;
                    }

                }

                if (graveMenu == true)
                {

                    if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (click == false)
                        {

                                graveMenu = false;

                                if (menuMouseover == true)
                                {
                                    if (floorObjectList.Contains(table))
                                    {
                                        assistant.DigUpCorpse(corpse);
                                    }
                                }

                        }

                        click = true;
                    }

                }

                if (corpseMenu == true)
                {

                    if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (click == false)
                        {

                                corpseMenu = false;

                                if (menuMouseover == true)
                                {
                                        scientist.action = menuHighlightAction;
                                        scientist.corpseWork = true;
                                        //scientist.floorObject = menuObject;
                                }

                        }

                        click = true;
                    }

                }

                // clicking on animate icon

                if (position.X >= resurrect.position.X && position.X < (resurrect.position.X + resurrect.tex.Width) && position.Y >= resurrect.position.Y && position.Y < (resurrect.position.Y + resurrect.tex.Height))
                {
                    if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (click == false && resurrect.doable == true)
                        {
                            resurrect.Animate(corpse, humanity, longevity, research, random);
                        }

                        click = true;

                    }

                }

              // clicking on build icon

            if (position.X >= build.position.X && position.X < (build.position.X + build.tex.Width) && position.Y >= build.position.Y && position.Y < (build.position.Y + build.tex.Height))
            {
                if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                {
                    if (click == false)
                    {
                        build.menu = true;
                        build.scrollPos = 0;
                    }

                    click = true;

                }

            }

            else
            {
                if ((mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed) && position.Y < build.buildPos.Y)
                {
                    if (click == false)
                    {
                        build.menu = false;
                    }

                    click = true;

                }

            }

            // Scrolling build menu....

            // Right
            if (position.X >= build.rightArrowPos.X - build.arrow.Width && position.X <= build.rightArrowPos.X
                                    && position.Y >= build.rightArrowPos.Y && position.Y <= build.rightArrowPos.Y + build.arrow.Height)
            {
                if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                {
                    if (click == false)
                    {

                        build.ScrollRight();
                    }

                    click = true;

                }

            }

            // Left
            if (position.X >= build.leftArrowPos.X && position.X <= build.leftArrowPos.X + build.arrow.Width
                                    && position.Y >= build.leftArrowPos.Y - build.arrow.Height && position.Y <= build.leftArrowPos.Y)
            {
                if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                {
                    if (click == false)
                    {
                        build.ScrollLeft();
                    }

                    click = true;

                }

            }

            // turn off click flag when no longer clicking

            if (mouseState.LeftButton == ButtonState.Released && mouseState.RightButton == ButtonState.Released)
            {
                click = false;
            }

            text = position.ToString();
        }
示例#3
0
        public void Update(GameTime gameTime, Cursor cursor, List<FloorObject> floorObjectList, FloorObject table, Assistant assistant, Corpse corpse, List<MiniProgressBar> bars)
        {
            // check for mouseover and click

            if (menu == false)
            {

                cursor.graveMouseOver = false;

                // graveyard
                if (cursor.position.X >= tlcorner.X && cursor.position.X <= brcorner.X
                        && cursor.position.Y >= tlcorner.Y && cursor.position.Y <= brcorner.Y)
                {

                    cursor.graveMouseOver = true; // add object mouseover text

                    // turn on menu when object is clicked

                    if (cursor.mouseState.LeftButton == ButtonState.Pressed | cursor.mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (cursor.click == false)
                        {
                            menu = true;
                            menuStart = true;
                            menuPosition = cursor.position;
                            cursor.graveMouseOver = false;
                        }

                        cursor.click = true;

                    }
                }
            }

            if (menu == true)
            {

                if (cursor.mouseState.LeftButton == ButtonState.Pressed | cursor.mouseState.RightButton == ButtonState.Pressed)
                {
                    if (cursor.click == false)
                    {

                        menu = false;

                        if (menuMouseover == true)
                        {
                            if (floorObjectList.Contains(table))
                            {
                                assistant.DigUpCorpse(corpse);
                            }
                        }

                    }

                    cursor.click = true;
                }

            }

            // set menu dimensions, make list of names and colours for each object

            if (menu == true && menuStart == true)
            {

                // find longest string in menu

                int boxWidth = 0;
                actions = new List<Tuple<string, Color, Color, Color>> { };

                foreach (MenuAction action in menuActions)
                {
                    // add
                    actions.Add(new Tuple<string, Color, Color, Color>(action.name, Color.White, Color.Gray, Color.DarkGray));

                    if (action.name.Length > boxWidth)
                    {
                        boxWidth = action.name.Length; // set box width for below

                    }
                }

                // boxes and outlines

                menuRectangle.Width = boxWidth * 12 + 10;  // set width to widest text from above
                menuRectangle.Height = 30;                  // menu item height spread
            }

            if (menu == true)
            {

                menuMouseover = false;
                Vector2 menuItemPosition = menuPosition;

                foreach (MenuAction action in menuActions)
                {

                    // IF MOUSE-OVERED change colours, set to highlighted item

                    if (cursor.position.X >= menuItemPosition.X && cursor.position.X < (menuItemPosition.X + menuRectangle.Width) && cursor.position.Y >= menuItemPosition.Y && cursor.position.Y < (menuItemPosition.Y + menuRectangle.Height))
                    {
                        textColour = Color.Black;
                        boxColour = Color.LightGray;
                        lineColour = Color.LimeGreen;

                        menuHighlightAction = action;
                        menuMouseover = true;
                    }

                    else
                    {
                        textColour = Color.White;
                        boxColour = Color.Gray;
                        lineColour = Color.DarkGray;
                    }

                    int index = menuActions.IndexOf(action);
                    actions[index] = new Tuple<string, Color, Color, Color>(actions[index].Item1, textColour, boxColour, lineColour);

                    if (cursor.mouseState.LeftButton == ButtonState.Pressed | cursor.mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (cursor.click == false)
                        {
                            menu = false;

                            if (menuMouseover == true)
                            {

                                if (action.assistant == true && assistant.outside == false && assistant.corpseCarrying == false)
                                {
                                    if (assistant.walking == true)
                                    {
                                        assistant.walking = false;
                                        assistant.floorObject = null;
                                        assistant.action = null;
                                    }

                                    else if (assistant.doing == true)
                                    {
                                        assistant.doing = false;
                                        assistant.digging = false;
                                        assistant.floorObject = null;
                                        bars.Remove(assistant.progBar);
                                        assistant.action = null;
                                        assistant.animStart = true;
                                    }

                                }

                            }

                        }

                        cursor.click = true;
                    }

                    menuItemPosition = menuItemPosition + new Vector2(0, menuRectangle.Height);

                }
            }
        }