Exemple #1
0
        // build this object
        public void Update(GameTime gametime,Cursor cursor,Scientist scientist, Assistant assistant, List<MiniProgressBar> bars, Build build, List<FloorObject> floorObjectList, ReachableArea reachable, NumericalCounter money)
        {
            // check for mouseover/click on machine

            mouseOver = false;

            if (cursor.position.X >= (position.X - offset.X) && cursor.position.X <= (position.X - offset.X + ((rect.Width * scale) / frames))
                    && cursor.position.Y >= position.Y - offset.Y && cursor.position.Y <= (position.Y - offset.Y + (rect.Height * scale))
                        && cursor.corpseMouseover == false && menu == false && menuActions.Count > 0 && build.menu == false)
            {
                    // 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.click = true;
                        }
                    }

                    if (menu == false && mouseOver == false && cursor.mouseOver == false)
                    {
                        cursor.menuObject = this;
                        mouseOver = true; // add object mouseover text if no menu
                        cursor.mouseOver = true;
                    }

            }

            // check for mouseover/click on build menu icon

            iconMouseover = false;
            badIconMouseover = false;

            if (onBuildList == true)
            {
                if (cursor.position.X >= iconPosition.X && cursor.position.X <= iconPosition.X + iconTex.Width
                       && cursor.position.Y >= iconPosition.Y && cursor.position.Y <= iconPosition.Y + iconTex.Height && cursor.buildIconMouseover == false)
                {

                    iconMouseover = true;
                    cursor.buildIconMouseover = true;
                    cursor.menuObject = this;

                    // build object is clicked

                    if (cursor.mouseState.LeftButton == ButtonState.Pressed | cursor.mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (cursor.click == false)
                        {
                            if (money.value >= this.cost)
                            {
                                money.value -= this.cost;
                                build.BuildThis(floorObjectList, this, reachable);
                                cursor.click = true;
                            }

                            else
                            {
                                iconMouseover = false;
                                badIconMouseover = true;
                            }
                        }
                    }

                }
            }

            // animation
            timer += gametime.ElapsedGameTime.Milliseconds;

            if (on == true)
            {
                currentAnim = 1;
            }
            else
            {
                currentAnim = 0;
            }

            if (timer >= frate)
            {
                timer = 0;

                if (currentFrame++ == frames - 1)
                {
                    currentFrame = 0;
                }

                rect.X = currentFrame * width;
                rect.Y = currentAnim * height;
            }

            // 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
            }

            // menu update

            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;

                        if (cursor.mouseState.LeftButton == ButtonState.Pressed | cursor.mouseState.RightButton == ButtonState.Pressed)
                        {
                            if (cursor.click == false)
                            {
                                    if (action.scientist == true)
                                    {
                                        if (scientist.walking == true)
                                        {
                                            scientist.walking = false;
                                            scientist.floorObject = null;
                                            scientist.action = null;
                                        }

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

                                        scientist.action = menuHighlightAction;
                                        scientist.floorObject = this;
                                    }

                                    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;
                                        }

                                        assistant.action = menuHighlightAction;
                                        assistant.floorObject = this;
                                    }

                                    // both using same machine?
                                    if (action.assistant == true && action.scientist == true)
                                    {
                                        assistant.twoWork = true;
                                    }

                                menu = false;

                            }

                            cursor.click = true;
                        }
                    }

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

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

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

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

                }
            }
        }
Exemple #2
0
 public void Animate(Scientist scientist, Assistant assistant)
 {
     assistant.Animate(this);
     scientist.Animate(this);
 }
Exemple #3
0
        public void Update(Corpse corpse,NumericalCounter lifeForce, NumericalCounter humanity, NumericalCounter longevity, FloorObject conductor,
                                GameTime gameTime, Cursor cursor,Scientist scientist, Assistant assistant)
        {
            // check if resurrection is possible

            if (conductor.on == true && corpse.visible == true && corpse.alive == false)
            {
                doable = true;
            }

            else
            {
                doable = false;
            }

            MouseState mouseState = Mouse.GetState();

            // clicking on animate icon

            if (cursor.position.X >= position.X && cursor.position.X < (position.X + tex.Width) && cursor.position.Y >= position.Y && cursor.position.Y < (position.Y + tex.Height))
            {
                if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                {
                    if (cursor.click == false && doable == true)
                    {
                        Animate(scientist, assistant);
                        clickOn = true;
                    }

                    cursor.click = true;
                }
            }

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

                if (clickCount > 100)
                {
                    clickCount = 0;
                    clickOn = false;
                }
            }
        }
Exemple #4
0
        // === load things... ==============
        protected override void LoadContent()
        {
            //========== GRAPHICS ==============================================

            // set viewport to size of screen, dependant on fullscreen/windowed
            if (graphics.IsFullScreen == true)
            {
                GraphicsDevice.Viewport = new Viewport(0, 0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width,
                                                GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
            }
            else
            {
                GraphicsDevice.Viewport = new Viewport(0, 0, Screen.PrimaryScreen.WorkingArea.Width - borderSpace,
                                                                Screen.PrimaryScreen.WorkingArea.Height - SystemInformation.CaptionHeight - borderSpace);
            }

            // find maximum size of render field with 16:9 aspect ratio when full screen

            width = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            height = (int)(width / aspectRatio);

            if (height > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height)
            {
                height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                width = (int)(height * aspectRatio);
            }

            xScale = (float)((double)width / (double)targetWidth);
            yScale = (float)((double)height / (double)targetHeight);

            xOffset = (int)((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - width) / 2.0);
            yOffset = (int)((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - height) / 2.0);

            // find maximum size of render field with 16:9 aspect ratio when windowed

            wheight = Screen.PrimaryScreen.WorkingArea.Height - SystemInformation.CaptionHeight - borderSpace;
            wwidth = (int)(wheight * aspectRatio);

            if (wwidth > Screen.PrimaryScreen.WorkingArea.Width - borderSpace)
            {
                wwidth = Screen.PrimaryScreen.WorkingArea.Width - borderSpace;
                wheight = (int)(wwidth / aspectRatio);
            }

            wxScale = (float)((double)wwidth / (double)targetWidth);
            wyScale = (float)((double)wheight / (double)targetHeight);

            wxOffset = (int)((Screen.PrimaryScreen.WorkingArea.Width - borderSpace - wwidth) / 2.0);
            wyOffset = (int)((Screen.PrimaryScreen.WorkingArea.Height - SystemInformation.CaptionHeight - borderSpace - wheight) / 2.0);

            // set viewport to this maximum render size, dependent on fullscreen/windowed
            if (graphics.IsFullScreen == true)
            {
                GraphicsDevice.Viewport = new Viewport(xOffset, yOffset, width, height);
            }

            if (graphics.IsFullScreen == false)
            {
                GraphicsDevice.Viewport = new Viewport(wxOffset, wyOffset, wwidth, wheight);

                var form = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle);
                form.Location = new System.Drawing.Point(0, 0);
            }

            // spritebatch

            spriteBatch = new SpriteBatch(GraphicsDevice);

            // ========= GAME OBJECTS ================================================

            // fonts

            cursorFont = Content.Load<SpriteFont>("font");
            counterFont = Content.Load<SpriteFont>("font2");

            // grid

            grid = new Grid(3600, 1750, 450, 20, 20, new Vector2(-850, 1070), true);
            reachable = new ReachableArea(grid, floorObjectList);

            // counters
            research = new NumericalCounter("Research", new Vector2(25, 15), 0, 100, 0, 0, counterFont, Color.Green, Color.Green, Content.Load<Texture2D>("counter_box"));
            madness = new NumericalCounter("Madness", new Vector2(25, 85), 0, 0, 0, 0, counterFont, Color.Red, Color.Green, Content.Load<Texture2D>("counter_box"));
            money = new NumericalCounter("Money", new Vector2(25, 155), 0, 500, 0, 60, counterFont, Color.Orange, Color.Yellow, Content.Load<Texture2D>("counter_box"), true);
            papers = new NumericalCounter("Papers Published", new Vector2(10, 300), 0, 0, 0, 0, cursorFont, Color.Black, Color.Black);
            lifeForce = new NumericalCounter("Life Force", new Vector2(10, 320), 100, 100, 0, 0, cursorFont, Color.Black, Color.Black);
            longevity = new NumericalCounter("Longevity", new Vector2(10, 340), 100, 30, 0, 0, cursorFont, Color.Black, Color.Black);
            humanity = new NumericalCounter("Humanity", new Vector2(10, 360), 100, 30, 0, 0, cursorFont, Color.Black, Color.Black);

            counters = new List<NumericalCounter>{research,madness,money,papers,lifeForce,longevity,humanity};

            build = new Build(new Vector2(5, 900), Content.Load<Texture2D>("build_icon_standard"), Content.Load<Texture2D>("build_icon_highlight"), Content.Load<Texture2D>("build_icon_pressed"), Content.Load<Texture2D>("invarrow"), Content.Load<Texture2D>("highinvarrow"), GraphicsDevice);

            //=====================================================

            // load menu actions from XML
            System.IO.Stream stream = TitleContainer.OpenStream("XMLActions.xml");

            XDocument doc = XDocument.Load(stream);

            menuActions = (from action in doc.Descendants("menuAction")
                           select new MenuAction(
                                                           action.Element("name").Value,
                                                           Convert.ToBoolean(action.Element("scientist").Value),
                                                           Convert.ToBoolean(action.Element("assistant").Value),
                                                           Convert.ToInt32(action.Element("time").Value),
                                                           (float)Convert.ToDouble(action.Element("reasearchUp").Value),
                                                           (float)Convert.ToDouble(action.Element("madnessUp").Value),
                                                           (float)Convert.ToDouble(action.Element("moneyChange").Value),
                                                           (float)Convert.ToDouble(action.Element("lifeForceUp").Value),
                                                           (float)Convert.ToDouble(action.Element("longevityUp").Value),
                                                           (float)Convert.ToDouble(action.Element("humanityUp").Value),
                                                           Convert.ToBoolean(action.Element("remain").Value),
                                                           Convert.ToBoolean(action.Element("turnOn").Value),
                                                           Convert.ToBoolean(action.Element("turnOff").Value),
                                                           new List<NumericalCounter> { research },
                                                           (float)Convert.ToDouble(action.Element("reasearchUpMultiplier").Value),
                                                           (float)Convert.ToDouble(action.Element("madnessUpMultiplier").Value),
                                                           (float)Convert.ToDouble(action.Element("moneyChangeMultiplier").Value),
                                                           (float)Convert.ToDouble(action.Element("lifeForceUpMultiplier").Value),
                                                           (float)Convert.ToDouble(action.Element("longevityUpMultiplier").Value),
                                                           (float)Convert.ToDouble(action.Element("humanityUpMultiplier").Value)
                                                           )).ToList();

            // dependant actions

            studyLiveCorpse = menuActions[6];
            writePaper = menuActions[9];

            // independent actions
            studyCorpse = menuActions[2];
            dissectCorpse = menuActions[3];
            clearCorpse = menuActions[4];
            talk = menuActions[7];

            // load in multiplying counters

            List<Tuple<string, string, string, string>> multipliers = new List<Tuple<string, string, string, string>>();

            multipliers = (from floorObject in doc.Descendants("menuAction")
                           select new Tuple<string, string, string, string>(
                            floorObject.Element("name").Value,
                            floorObject.Element("multiplyingCounter").Value,
                            floorObject.Element("multiplyingCounter2").Value,
                            floorObject.Element("multiplyingCounter3").Value)
                               ).ToList();

            foreach (MenuAction action in menuActions)
            {
                foreach (Tuple<string, string, string, string> tuple in multipliers)
                {
                    if (tuple.Item1 == action.name)
                    {
                        foreach (NumericalCounter counter in counters)
                        {
                            foreach (string name in new List<string> { tuple.Item2, tuple.Item3, tuple.Item4 })
                            {
                                if (counter.name == name)
                                {
                                    action.dependent.Add(counter);
                                }
                            }
                        }
                    }
                }
            }

            // load floor objects from XML
            System.IO.Stream stream2 = TitleContainer.OpenStream("XMLFloorObjects.xml");

            XDocument doc2 = XDocument.Load(stream2);

            build.buildList = (from floorObject in doc2.Descendants("FloorObject") select new FloorObject(Content.Load<Texture2D>(
                                    Convert.ToString(floorObject.Element("texture").Value)),
                                    Content.Load<Texture2D>(Convert.ToString(floorObject.Element("icon").Value)),
                                    Convert.ToInt32(floorObject.Element("frameNumber").Value),
                                    Convert.ToInt32(floorObject.Element("animNumber").Value),
                                    new Vector2(Convert.ToInt32(floorObject.Element("gridPositionX").Value),Convert.ToInt32(floorObject.Element("gridPositionY").Value)), grid,
                                    floorObject.Element("name").Value,
                                    Convert.ToInt32(floorObject.Element("cost").Value),
                                    new List<MenuAction>{}, GraphicsDevice,
                                    new Vector2(Convert.ToInt32(floorObject.Element("footprintX").Value),Convert.ToInt32(floorObject.Element("footprintY").Value)),
                                    Convert.ToBoolean(floorObject.Element("prebuilt").Value))
                                    ).ToList();

            // load in menu actions

            List<Tuple<string,string,string,string>> actions = new List<Tuple<string,string,string,string>>();

            actions = (from floorObject in doc2.Descendants("FloorObject")
                           select new Tuple<string,string,string,string>(
                            floorObject.Element("name").Value,
                            floorObject.Element("menuAction").Value,
                            floorObject.Element("menuAction2").Value,
                            floorObject.Element("menuAction3").Value)
                               ).ToList();

            foreach (FloorObject machine in build.buildList)
            {
                foreach (Tuple<string,string,string,string> tuple in actions)
                {
                    if (tuple.Item1 == machine.name)
                    {
                        foreach (MenuAction action in menuActions)
                        {
                            foreach (string name in new List<string>{tuple.Item2,tuple.Item3,tuple.Item4})
                            {
                                if (action.name == name)
                                {
                                    machine.menuActions.Add(action);
                                }
                            }
                        }
                    }
                }
            }

            // build any prebuilt objects

            foreach (FloorObject machine in build.buildList)
            {
                if (machine.prebuilt == true)
                {
                    build.BuildThis(floorObjectList, machine, reachable);
                }
            }

            build.removeUpdate(money);

            // objects

            table = build.buildList[0];
            lightningAbsorber = build.buildList[1];

            resurrect = new Resurrect(new Vector2(1750, 900), Content.Load<Texture2D>("raise_icon_standard"), Content.Load<Texture2D>("raise_icon_highlight"), Content.Load<Texture2D>("raise_icon_pressed"), GraphicsDevice, table);

            //===================================================

            // background stuff

            room = new NonInteractive(Vector2.Zero, 0.6f, Content.Load<Texture2D>("room"));
            door = new NonInteractive(new Vector2(380, 200), 0.59f, Content.Load<Texture2D>("door"),2);
            graveyard = new Graveyard(new Vector2(1140,200), 0.8f, new Vector2(10,760),Content.Load<Texture2D>("back"), Content.Load<Texture2D>("dig_icon_standard"), Content.Load<Texture2D>("dig_icon_highlight"), Content.Load<Texture2D>("dig_icon_pressed"), GraphicsDevice, 0.5f);
            digger = new NonInteractive(new Vector2(1200, 300), 0.79f, Content.Load<Texture2D>("digger"), 1, 10);
            Switch = new NonInteractive(new Vector2(860,400), 0.58f, Content.Load<Texture2D>("switch"), 2, 1);

            // cursor

            cursor = new Cursor(Content.Load<Texture2D>("cursor"),GraphicsDevice);

            // characters

            Simon = new Scientist(Content.Load<Texture2D>("tmpprof"), new Vector2(10,1),grid,reachable,table);
            Jeremy = new Assistant(Content.Load<Texture2D>("tmpass"), new Vector2(8, 1), grid,reachable,table);

            // the corpse!

            corpse = new Corpse(new Vector2(725, 540),Content.Load<Texture2D>("corpse"), new List<MenuAction> { studyCorpse, dissectCorpse }, new List<MenuAction> { talk,studyLiveCorpse }, new List<MenuAction> { clearCorpse },GraphicsDevice);

            // update reachable area to account for these

            reachable.Update(floorObjectList);

            // test items...

            blob = new positionTextBlob(Content.Load<Texture2D>("gball"), new Vector2(1, 1));

            knob = new Knob(new Vector2(300, 300), 0.2f, Content.Load<Texture2D>("knob"));

            // test saving...
        }
Exemple #5
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();
        }
Exemple #6
0
        public void Update(GameTime gameTime, MenuAction dissect, MenuAction study,NumericalCounter longevity, NumericalCounter humanity, NumericalCounter lifeforce, Scientist scientist, Assistant assistant,
                                MenuAction talk, Cursor cursor,List<MiniProgressBar> bars, MenuAction clearCorpse)
        {
            cursor.corpseMouseover = false;

            if (flyTimer >= flyTime && alive == false)
            {
                flyTimer = 0;
                flies.AddFlies(1);
            }

            flyTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (flyTimer >= flyLossTime && visible == false)
            {
                if (flies.flies.Count > 0)
                {
                    flyTimer = 0;
                    flies.RemoveFlies(1);
                }
            }

            if (this.visible == true)
            {

                // update cut up-ness
                if (dead == false)
                {
                    cut = dissect.count * 3 + study.count;
                }

                if (cut > 3)
                {
                    cut = 3;
                }

                // check for mouseover & click

                if (cursor.position.X >= position.X && cursor.position.X <= position.X + fwidth*scale
                           && cursor.position.Y >= position.Y  && cursor.position.Y <= position.Y + height  && visible == true && corpseMenu == false)
                {

                    cursor.corpseMouseover = 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)
                        {
                            corpseMenu = true;
                            menuOpen = true;
                            cursor.corpseMouseover = false;
                        }

                        cursor.click = true;
                    }
                }

                // rotting timer and count and flies

                timer += gameTime.ElapsedGameTime.Milliseconds;
                rotTimer += gameTime.ElapsedGameTime.Milliseconds;
                colorTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (rotTimer >= rotTime * 1000.0 && alive == false && dead == false)
                {
                    rotTimer = 0;

                    if (rot.value > 1)
                    {
                        rot.value -= 1;
                        flyTime -= 1500;
                    }

                    else
                    {
                        Die();
                        corpseColor = Microsoft.Xna.Framework.Color.Brown;
                        rot.value = 3;
                    }
                }

                if (colorTimer >= colorTime)
                {
                    colorTimer = 0;
                    if (corpseColor.R > 90)
                    {
                        this.corpseColor.R -= 1;
                    }
                    if (corpseColor.B > 0)
                    {
                        this.corpseColor.B -= 1;
                    }
                    if (corpseColor.G > 60)
                    {
                        this.corpseColor.G -= 1;
                    }
                }

                // live corpse dead count && anim change

                if (alive == true)
                {
                    longevity.valueChange = -0.01f;

                    if (longevity.value == 0)
                    {
                        Die();
                    }

                    if (scientist.action == talk && scientist.doing == true)
                    {

                        talking = true;
                        anim = 2;
                        frames = nframes[2];
                    }
                    else
                    {
                        talking = false;
                        anim = 1;
                        frames = nframes[1];
                    }

                }

                else if (dead == false)
                {
                    longevity.valueChange = 0;

                    anim = 0;
                    frames = nframes[0];
                }

                // kill if dissected

                if (dissect.done == true)
                {
                    Die();
                }

                // kill if studies 3 times

                if (study.count >= 3)
                {
                    Die();
                }

                // update anim

                if (timer >= frate)
                {
                    timer = 0;

                    if (currentFrame++ == frames - 1)
                    {
                        currentFrame = 0;
                    }

                    rect.Y = cut * height + currentFrame; // * fwidth
                }

                // menu setup

                if (corpseMenu == true && menuOpen == true)
                {
                    menuPosition = cursor.position;
                    menuOpen = false;

                    // find longest string in menu

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

                    if (alive == false && dead == false)
                    {
                        menuActions = workMenuActions;

                        foreach (MenuAction action in workMenuActions)
                        {
                            // 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

                            }
                        }
                    }

                    if (alive == true)
                    {
                        menuActions = aliveMenuActions;

                        foreach (MenuAction action in aliveMenuActions)
                        {
                            // 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

                            }
                        }
                    }

                    if (dead == true)
                    {
                        menuActions = deadMenuActions;

                        foreach (MenuAction action in deadMenuActions)
                        {
                            // 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
                }

                // menu update

                if (corpseMenu == 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;

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

                                        if (action.scientist == true)
                                        {
                                            if (scientist.walking == true)
                                            {
                                                scientist.walking = false;
                                                scientist.floorObject = null;
                                                scientist.action = null;
                                            }

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

                                            scientist.action = menuHighlightAction;
                                            scientist.corpseWork = true;
                                        }

                                        if (action.assistant == true)
                                        {
                                            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;
                                            }

                                            assistant.action = menuHighlightAction;
                                            assistant.corpseWork = true;

                                        }

                                    }

                                cursor.click = true;
                            }
                        }

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

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

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

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

                    }
                }
            }

            // check for cleared up dead corpse, reset corpse if so.

            if (clearCorpse.count > 0)
            {
                clearCorpse.count = 0;
                visible = false;
                dead = false;
                corpseColor = Color.White;
                rot.value = 3;
            }

            // update the rot counter
            rot.Update(gameTime);

            // update fly swarm

            flies.Update();
        }
Exemple #7
0
        public void Render(SpriteBatch sbatch,Cursor cursor,SpriteFont font,NumericalCounter money, List<FloorObject> floorObjectList, ReachableArea reachable, Scientist scientist, Assistant assistant)
        {
            // draw icon - highlighted

            if (cursor.position.X >= position.X && cursor.position.X < (position.X + width)
                && cursor.position.Y >= position.Y && cursor.position.Y < (position.Y + height)
                && clickOn == false)
            {
                sbatch.Draw(hTex, position, rect, Microsoft.Xna.Framework.Color.White, 0, Vector2.Zero,scale, SpriteEffects.None, layer);
            }

            // draw icon - clicked
            else if (clickOn == true)
            {
                sbatch.Draw(cTex, position, rect, Microsoft.Xna.Framework.Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, layer);
            }

            // draw icon - unhighlighted
            else
            {
                sbatch.Draw(tex, position, rect, Microsoft.Xna.Framework.Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, layer);
            }

            // menu
            if (menu == true)
            {
                // arrows
                if (buildList.Count > buildScreenLength)
                {
                    full = true;

                    if (scrollPos == (buildList.Count - buildScreenLength))
                    {
                        if (cursor.position.X >= leftArrowPos.X && cursor.position.X <= leftArrowPos.X + arrow.Width
                                    && cursor.position.Y >= leftArrowPos.Y - arrow.Height && cursor.position.Y <= leftArrowPos.Y)
                        {

                            sbatch.Draw(highArrow, leftArrowPos, null, Color.White, -(float)Math.PI / 2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }

                        else
                        {
                            sbatch.Draw(arrow, leftArrowPos, null, Color.White, -(float)Math.PI / 2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }
                    }

                    if (scrollPos == 0)
                    {

                        if (cursor.position.X >= rightArrowPos.X - arrow.Width && cursor.position.X <= rightArrowPos.X
                                    && cursor.position.Y >= rightArrowPos.Y && cursor.position.Y <= rightArrowPos.Y + arrow.Height)
                        {
                            sbatch.Draw(highArrow, rightArrowPos, null, Color.White, (float)Math.PI/2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }

                        else
                        {
                            sbatch.Draw(arrow, rightArrowPos, null, Color.White, (float)Math.PI / 2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }
                    }

                    if (scrollPos < (buildList.Count - buildScreenLength) && scrollPos > 0)
                    {
                        if (cursor.position.X >= leftArrowPos.X && cursor.position.X <= leftArrowPos.X + arrow.Width
                                    && cursor.position.Y >= leftArrowPos.Y - arrow.Height && cursor.position.Y <= leftArrowPos.Y)
                        {

                            sbatch.Draw(highArrow, leftArrowPos, null, Color.White, -(float)Math.PI / 2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }

                        else
                        {
                            sbatch.Draw(arrow, leftArrowPos, null, Color.White, -(float)Math.PI / 2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }

                        if (cursor.position.X >= rightArrowPos.X - arrow.Width && cursor.position.X <= rightArrowPos.X
                                    && cursor.position.Y >= rightArrowPos.Y && cursor.position.Y <= rightArrowPos.Y + arrow.Height)
                        {
                            sbatch.Draw(highArrow, rightArrowPos, null, Color.White, (float)Math.PI / 2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }

                        else
                        {
                            sbatch.Draw(arrow, rightArrowPos, null, Color.White, (float)Math.PI / 2.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.1f);
                        }
                    }

                }

                else
                {
                    full = false;
                }

                // render background

                sbatch.Draw(dummyTexture, buildPos, buildRectangle, boxColour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0.17f);

                // render items

                for (int x = scrollPos; x < (scrollPos + buildScreenLength) && x < buildList.Count; x++)
                {
                    FloorObject curitem = buildList[x];

                    curitem.IconRender(sbatch,this);
                }

            }
        }
Exemple #8
0
        public void Render(SpriteBatch sbatch,Cursor cursor,SpriteFont font,NumericalCounter money, List<FloorObject> floorObjectList, ReachableArea reachable, Scientist scientist, Assistant assistant)
        {
            // draw icon - highlighted

            if (cursor.position.X >= position.X && cursor.position.X < (position.X + width)
                && cursor.position.Y >= position.Y && cursor.position.Y < (position.Y + height)
                && clickOn == false)
            {
                sbatch.Draw(hTex, position, rect, Microsoft.Xna.Framework.Color.White, 0, Vector2.Zero,scale, SpriteEffects.None, layer);
            }

            // draw icon - clicked
            else if (clickOn == true)
            {
                sbatch.Draw(cTex, position, rect, Microsoft.Xna.Framework.Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, layer);
            }

            // draw icon - unhighlighted
            else
            {
                sbatch.Draw(tex, position, rect, Microsoft.Xna.Framework.Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, layer);
            }

            // menu
            if (menu == true)
            {

                // find longest string in menu

                int boxWidth = 0;

                if (menu == true)
                {
                    foreach (FloorObject machine in buildList)
                    {

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

                        }
                    }
                }

                // draw boxes and outlines for each item, check if highlighted, clicked

                menuRectangle.Width  = boxWidth * 12 + 10;  // set width to widest text from above
                menuRectangle.Height = 30;                  // menu item height spread
                Vector2 menuItemPosition = menuPosition - new Vector2(0, menuRectangle.Height);    // position of each text menu item

                menuMouseover = false;

                MouseState mouseState = Mouse.GetState();

                FloorObject remove = null; // built items to remove from build list

                foreach (FloorObject machine in buildList)
                {
                    // declare colours
                    Color textColour;
                    Color boxColour;
                    Color lineColour;

                    // 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;

                        menuHighlightObject = machine;
                        menuMouseover = true;

                        // build item if clicked

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

                                if (money.value >= menuHighlightObject.cost)
                                {
                                    remove = menuHighlightObject;
                                }
                            }

                            cursor.click = true;

                        }

                    }

                    // IF NOT MOUSE-OVERED
                    else
                    {
                        // set colours to standard
                        textColour = Color.White;
                        boxColour = Color.Gray;
                        lineColour = Color.DarkGray;

                    }

                    // text

                    sbatch.DrawString(font, machine.name + ": $" + machine.cost.ToString(), menuItemPosition + new Vector2(5,0), textColour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0.13f);

                    // text rectangle
                    sbatch.Draw(dummyTexture, menuItemPosition , menuRectangle, boxColour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0.17f);

                    // top line
                    Tuple<Vector2, Vector2> line = new Tuple<Vector2, Vector2>(menuItemPosition, (menuItemPosition + new Vector2(menuRectangle.Width, 0)));

                    float angle = (float)Math.Atan2(line.Item2.Y - line.Item1.Y, line.Item2.X - line.Item1.X);
                    float length = Vector2.Distance(line.Item1, line.Item2);

                    sbatch.Draw(dummyTexture, line.Item1 + new Vector2(0, 0), null, lineColour, angle, Vector2.Zero, new Vector2(length, 3.0f), SpriteEffects.None, 0.15f);

                    // right line
                    Tuple<Vector2, Vector2> line2 = new Tuple<Vector2, Vector2>((menuItemPosition + new Vector2(menuRectangle.Width, menuRectangle.Height)), (menuItemPosition + new Vector2(menuRectangle.Width, 0)));

                    float angle2 = (float)Math.Atan2(line2.Item2.Y - line2.Item1.Y, line2.Item2.X - line2.Item1.X);
                    float length2 = Vector2.Distance(line2.Item1, line2.Item2);

                    sbatch.Draw(dummyTexture, line2.Item1 + new Vector2(0, 0), null, lineColour, angle2, Vector2.Zero, new Vector2(length2, 3.0f), SpriteEffects.None, 0.15f);

                    // left line
                    Tuple<Vector2, Vector2> line3 = new Tuple<Vector2, Vector2>(menuItemPosition, (menuItemPosition + new Vector2(0, menuRectangle.Height)));

                    float angle3 = (float)Math.Atan2(line3.Item2.Y - line3.Item1.Y, line3.Item2.X - line3.Item1.X);
                    float length3 = Vector2.Distance(line3.Item1, line3.Item2);

                    sbatch.Draw(dummyTexture, line3.Item1 + new Vector2(0, 0), null, lineColour, angle3, Vector2.Zero, new Vector2(length3, 3.0f), SpriteEffects.None, 0.15f);

                    // bottom line
                    Tuple<Vector2, Vector2> line4 = new Tuple<Vector2, Vector2>((menuItemPosition + new Vector2(menuRectangle.Width, menuRectangle.Height)), (menuItemPosition + new Vector2(0, menuRectangle.Height)));

                    float angle4 = (float)Math.Atan2(line4.Item2.Y - line4.Item1.Y, line4.Item2.X - line4.Item1.X);
                    float length4 = Vector2.Distance(line4.Item1, line4.Item2);

                    sbatch.Draw(dummyTexture, line4.Item1 + new Vector2(0, 0), null, lineColour, angle4, Vector2.Zero, new Vector2(length4, 3.0f), SpriteEffects.None, 0.15f);

                    // set to height of next text item
                    menuItemPosition -= new Vector2(0, menuRectangle.Height);

                }

                // remove anything that has been built from build list, build, update its position
                if (remove != null)
                {
                    floorObjectList.Add(remove);        // add to floor objects (build)
                    Remove(remove, money);              // remove from build list
                    reachable.Update(floorObjectList);  // update reachable squares of grid, update character's paths
                    scientist.path.Update(reachable);   // update path from updated reachable
                    assistant.path.Update(reachable);   // update path from updated reachable
                    remove = null;
                }

                // set to close menu if clicking is done outside...
                if (menuMouseover == false)
                {
                    if (mouseState.LeftButton == ButtonState.Pressed | mouseState.RightButton == ButtonState.Pressed)
                    {
                        if (cursor.click == false)
                        {
                            menu = false;
                        }

                        cursor.click = true;
                    }
                }

            }
        }